]> git.lyx.org Git - features.git/commitdiff
Inset configurability: separate charstyle and custom insets
authorMartin Vermeer <martin.vermeer@hut.fi>
Fri, 24 Aug 2007 12:45:40 +0000 (12:45 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Fri, 24 Aug 2007 12:45:40 +0000 (12:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19769 a592a061-630c-0410-9148-cb99ea01b6c8

lib/layouts/stdcustom.inc [new file with mode: 0644]
lib/ui/stdmenus.inc
src/MenuBackend.cpp
src/MenuBackend.h
src/TextClass.cpp

diff --git a/lib/layouts/stdcustom.inc b/lib/layouts/stdcustom.inc
new file mode 100644 (file)
index 0000000..17e542d
--- /dev/null
@@ -0,0 +1,19 @@
+# Textclass definition file for LaTeX.
+# Author : Martin vermeer <amrtin.vermeer@tkk.fi>
+# Custom Inset layouts definition
+
+Format 5
+
+InsetLayout Custom:Endnote
+   LyXType     custom
+   LatexName   endnote
+   LatexType   command
+   Font
+     Size      Small
+   EndFont
+   LabelString foot
+   Preamble
+     \usepackage{endnote}
+   EndPreamble
+End
+
index 0fadc286c85e607321fc2c96c848e2282404a0c3..466dd642d0232e6d815a5418fde5306e5660401e 100644 (file)
@@ -295,6 +295,7 @@ Menuset
                Submenu "Float|a" "insert_float"
                Submenu "Note|N" "insert_note"
                Submenu "Branch|B" "insert_branches"
+               Submenu "Custom insets" "insert_custom"
                Submenu "File|e" "insert_file"
                Item "Box" "box-insert Frameless"
                Separator
@@ -404,6 +405,10 @@ Menuset
                Branches
        End
 
+       Menu "insert_custom"
+               Custom
+       End
+
 #
 # DOCUMENT MENU
 #
index 0180e42271ec6bad779be2e6bef346effdad627a..c81ce2759495fdfcf38862efdc71fe65ae37e267 100644 (file)
@@ -218,6 +218,7 @@ Menu & Menu::read(Lexer & lex)
                md_documents,
                md_bookmarks,
                md_charstyles,
+               md_custom,
                md_endmenu,
                md_exportformats,
                md_importformats,
@@ -240,6 +241,7 @@ Menu & Menu::read(Lexer & lex)
                { "bookmarks", md_bookmarks },
                { "branches", md_branches },
                { "charstyles", md_charstyles },
+               { "custom", md_custom },
                { "documents", md_documents },
                { "end", md_endmenu },
                { "exportformats", md_exportformats },
@@ -294,6 +296,10 @@ Menu & Menu::read(Lexer & lex)
                        add(MenuItem(MenuItem::CharStyles));
                        break;
 
+               case md_custom:
+                       add(MenuItem(MenuItem::Custom));
+                       break;
+
                case md_documents:
                        add(MenuItem(MenuItem::Documents));
                        break;
@@ -613,7 +619,7 @@ void expandFloatInsert(Menu & tomenu, Buffer const * buf)
 }
 
 
-void expandCharStyleInsert(Menu & tomenu, Buffer const * buf)
+void expandCharStyleInsert(Menu & tomenu, Buffer const * buf, std::string s)
 {
        if (!buf) {
                tomenu.add(MenuItem(MenuItem::Command,
@@ -627,8 +633,9 @@ void expandCharStyleInsert(Menu & tomenu, Buffer const * buf)
        CharStyles::iterator end = charstyles.end();
        for (; cit != end; ++cit) {
                docstring const label = from_utf8(cit->name);
-               tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, label,
-                                   FuncRequest(LFUN_CHARSTYLE_INSERT,
+               if (cit->lyxtype == s)
+                       tomenu.addWithStatusCheck(MenuItem(MenuItem::Command, 
+                               label, FuncRequest(LFUN_CHARSTYLE_INSERT,
                                                label)));
        }
 }
@@ -877,7 +884,11 @@ void MenuBackend::expand(Menu const & frommenu, Menu & tomenu,
                        break;
 
                case MenuItem::CharStyles:
-                       expandCharStyleInsert(tomenu, buf);
+                       expandCharStyleInsert(tomenu, buf, "charstyle");
+                       break;
+
+               case MenuItem::Custom:
+                       expandCharStyleInsert(tomenu, buf, "custom");
                        break;
 
                case MenuItem::FloatListInsert:
index 07c115a2727d052cc42e978e9a084d38c3634c89..815f2669a82f5572252ada599684c9f3619720f7 100644 (file)
@@ -63,6 +63,9 @@ public:
                /** This is the list of elements available
                 * for insertion into document. */
                CharStyles,
+               /** This is the list of user-configurable
+               insets to insert into document */
+               Custom,
                /** This is the list of floats that we can
                    insert a list for. */
                FloatListInsert,
index 707819d7e28f66fcf44ee809465743b10f845b47..4cd7599116e0fed62fb23f703a3e460fc8a06a8d 100644 (file)
@@ -698,7 +698,7 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                insetlayoutlist_[name] = il;
 
                // test name for CS:
-               if (il.lyxtype == "charstyle") {
+               if (il.lyxtype == "charstyle" || il.lyxtype == "custom") {
                        charstyles().push_back(il);
                }
        }