[gedit-latex] More LaTeX toolbar visibility options



commit ca9e742dfb5cdcbfc51deb00d3684bf056113450
Author: John Stowers <john stowers gmail com>
Date:   Thu Aug 18 00:45:50 2011 +1200

    More LaTeX toolbar visibility options
    
    User can select to have a combined, seperate (default,
    the old behaviour) or disabled toolbar. There is no
    UI exposed for selecting this yet. See gsettings

 ...org.gnome.gedit.plugins.latex.gschema.xml.in.in |   11 ++++-
 data/ui/configure.ui                               |   43 +++++--------------
 .../ui/{ui.builder => ui-toolbar-combined.builder} |    3 +-
 data/ui/ui-toolbar-disabled.builder                |   30 ++++++++++++++
 data/ui/{ui.builder => ui-toolbar-normal.builder}  |    0
 latex/base/windowactivatable.py                    |   21 +++++-----
 latex/latex/editor.py                              |    6 ---
 latex/preferences/dialog.py                        |   12 +-----
 8 files changed, 64 insertions(+), 62 deletions(-)
---
diff --git a/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in b/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in
index 633bb9b..2bce29d 100644
--- a/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in
+++ b/data/org.gnome.gedit.plugins.latex.gschema.xml.in.in
@@ -1,4 +1,9 @@
 <schemalist>
+  <enum id='org.gnome.gedit.plugins.latex.ToolbarMode'>
+    <value nick='normal' value='0'/>
+    <value nick='combined' value='1'/>
+    <value nick='disabled' value='2'/>
+  </enum>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gedit.plugins.latex" path="/org/gnome/gedit/plugins/latex/">
     <key name="maximum-bibtex-size" type="i">
       <default>500</default>
@@ -35,9 +40,9 @@
       <default>false</default>
       <_summary>Hide Box Warnings</_summary>
     </key>
-    <key name="show-latex-toolbar" type="b">
-      <default>true</default>
-      <_summary>Show LaTeX Toolbar</_summary>
+   <key name="toolbar-mode" enum="org.gnome.gedit.plugins.latex.ToolbarMode">
+      <default>'normal'</default>
+      <_summary>Show LaTeX Toolbar below (normal), combined with the main toolbar, or disabled</_summary>
     </key>
     <key name="expanded-symbol-groups" type="s">
       <default>'Greek,Operators,Arrows,Special'</default>
diff --git a/data/ui/configure.ui b/data/ui/configure.ui
index 60fcc5e..e7528e6 100644
--- a/data/ui/configure.ui
+++ b/data/ui/configure.ui
@@ -280,37 +280,6 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label12">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="label" translatable="yes">&lt;b&gt;LaTeX Toolbar&lt;/b&gt;</property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="right_attach">2</property>
-            <property name="top_attach">8</property>
-            <property name="bottom_attach">9</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="checkShowToolbar">
-            <property name="label" translatable="yes">Show LaTeX Toolbar when editing LaTeX files</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_action_appearance">False</property>
-            <property name="draw_indicator">True</property>
-            <signal name="toggled" handler="on_checkShowToolbar_toggled" swapped="no"/>
-          </object>
-          <packing>
-            <property name="right_attach">2</property>
-            <property name="top_attach">9</property>
-            <property name="bottom_attach">10</property>
-            <property name="x_options">GTK_FILL</property>
-          </packing>
-        </child>
-        <child>
           <object class="GtkLabel" id="label13">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -337,6 +306,18 @@
         <child>
           <placeholder/>
         </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
       </object>
       <packing>
         <property name="position">1</property>
diff --git a/data/ui/ui.builder b/data/ui/ui-toolbar-combined.builder
similarity index 98%
copy from data/ui/ui.builder
copy to data/ui/ui-toolbar-combined.builder
index 247a88f..8571a05 100644
--- a/data/ui/ui.builder
+++ b/data/ui/ui-toolbar-combined.builder
@@ -26,7 +26,8 @@
             </menu>
         </placeholder>
     </menubar>
-    <toolbar name="LaTeXToolbar">
+    <toolbar name="ToolBar">
+        <separator />
         <toolitem action="LaTeXFontFamilyAction">
             <menu action="LaTeXFontFamilyMenuAction">
                 <menuitem action="LaTeXBoldAction" />
diff --git a/data/ui/ui-toolbar-disabled.builder b/data/ui/ui-toolbar-disabled.builder
new file mode 100644
index 0000000..100caa7
--- /dev/null
+++ b/data/ui/ui-toolbar-disabled.builder
@@ -0,0 +1,30 @@
+<ui>
+    <menubar name="MenuBar">
+        <menu name="FileMenu" action="File">
+            <placeholder name="FileOps_1">
+                <menuitem action="LaTeXNewAction" />
+            </placeholder>
+            <placeholder name="FileOps_3">
+                <menuitem action="LaTeXSaveAsTemplateAction" />
+            </placeholder>
+        </menu>
+        <placeholder name="ExtraMenu_1">
+            <menu action="LaTeXMenuAction">
+                <menuitem action="LaTeXChooseMasterAction" />
+                <separator />
+                <menuitem action="LaTeXGraphicsAction" />
+                <menuitem action="LaTeXTableAction" />
+                <menuitem action="LaTeXListingAction" />
+                <menuitem action="LaTeXUseBibliographyAction" />
+                <separator />
+                <menuitem action="LaTeXCloseEnvironmentAction" />
+                <separator />
+                <menuitem action="LaTeXBuildImageAction" />
+            </menu>
+            <menu action="BibTeXMenuAction">
+                <menuitem action="BibTeXNewEntryAction" />
+            </menu>
+        </placeholder>
+    </menubar>
+</ui>
+
diff --git a/data/ui/ui.builder b/data/ui/ui-toolbar-normal.builder
similarity index 100%
rename from data/ui/ui.builder
rename to data/ui/ui-toolbar-normal.builder
diff --git a/latex/base/windowactivatable.py b/latex/base/windowactivatable.py
index 390d3cc..7fa5c32 100644
--- a/latex/base/windowactivatable.py
+++ b/latex/base/windowactivatable.py
@@ -214,21 +214,27 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
                 else:
                     self._action_extensions[extension] = [clazz.__name__]
 
+        toolbar_mode = self._preferences.get("toolbar-mode")
+
         # merge ui
         self._ui_manager.insert_action_group(self._action_group, -1)
-        self._ui_id = self._ui_manager.add_ui_from_file(Resources().get_ui_file("ui.builder"))
+        self._ui_id = self._ui_manager.add_ui_from_file(Resources().get_ui_file("ui-toolbar-%s.builder" % toolbar_mode))
 
-        # hook the toolbar
-        self._toolbar = self._ui_manager.get_widget("/LaTeXToolbar")
-        if self._toolbar:
+        if toolbar_mode == "normal":
+            self._toolbar = self._ui_manager.get_widget("/LaTeXToolbar")
             self._toolbar_name = "LaTeXToolbar"
             self._toolbar.set_style(Gtk.ToolbarStyle.BOTH_HORIZ)
             # FIXME: Adding a new toolbar to gedit is not really public API
             self._main_box = self.window.get_children()[0]
             self._main_box.pack_start(self._toolbar, False, True, 0)
             self._main_box.reorder_child(self._toolbar, 2)
-        else:
+        elif toolbar_mode == "combined":
+            self._toolbar = None
             self._toolbar_name = "ToolBar"
+        else:
+            self._toolbar = None
+            self._toolbar_name = ""
+            self._log.info("Toolbar disabled")    
 
     def _init_tab_decorators(self):
         """
@@ -413,11 +419,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
         self._log.debug("---------- ADJUST: %s" % (extension))
 
         latex_extensions = self._preferences.get("latex-extensions").split(",")
-        show_toolbar = self._preferences.get ("show-latex-toolbar")
-        if show_toolbar and extension in latex_extensions:
-            self.show_toolbar()
-        else:
-            self.hide_toolbar()
 
         #
         # adjust actions
diff --git a/latex/latex/editor.py b/latex/latex/editor.py
index 8a75e19..2ea72a5 100644
--- a/latex/latex/editor.py
+++ b/latex/latex/editor.py
@@ -109,12 +109,6 @@ class LaTeXEditor(Editor, IIssueHandler):
                 # FIXME: self._document contains the full model of child and master
                 # so we may not use it for regenerating the outline here
                 self.__parse()
-        elif key == "show-latex-toolbar":
-            show_toolbar = self._preferences.get("show-latex-toolbar")
-            if show_toolbar:
-                self._window_context._window_decorator.show_toolbar()
-            else:
-                self._window_context._window_decorator.hide_toolbar()
 
     def drag_drop_received(self, files):
         # see base.Editor.drag_drop_received
diff --git a/latex/preferences/dialog.py b/latex/preferences/dialog.py
index fa07c6e..4810f51 100644
--- a/latex/preferences/dialog.py
+++ b/latex/preferences/dialog.py
@@ -355,11 +355,6 @@ class PreferencesDialog(GladeInterface):
             check_hide_box = self.find_widget("checkHideBox")
             check_hide_box.set_active(self._preferences.get("hide-box-warnings"))
 
-
-            check_show_toolbar = self.find_widget("checkShowToolbar")
-            check_show_toolbar.set_active(self._preferences.get("show-latex-toolbar"))
-
-
             filechooser_tmp = self.find_widget("filechooserTemplates")
             filechooser_tmp.set_filename(self._preferences.TEMPLATE_DIR)
 
@@ -382,15 +377,10 @@ class PreferencesDialog(GladeInterface):
                                    "on_buttonConfigureTool_clicked" : self._on_configure_tool_clicked,
                                    "on_buttonDeleteTool_clicked" : self._on_delete_tool_clicked,
                                    "on_checkHideBox_toggled" : self._on_hide_box_toggled,
-                                   "on_filechooserTemplates_selection_changed" : self._on_templates_dir_changed,
-                                   "on_checkShowToolbar_toggled" : self._on_show_toolbar_toggled })
+                                   "on_filechooserTemplates_selection_changed" : self._on_templates_dir_changed})
 
         return self._dialog
 
-    def _on_show_toolbar_toggled(self, togglebutton):
-        value = togglebutton.get_active()
-        self._preferences.set("show-latex-toolbar", value)
-
     def _on_templates_dir_changed(self, filechooser):
         folder = filechooser.get_filename()
         if folder is None:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]