[meld] meldwindow: Move toolbar and statusbar visibility handling to GSettings



commit e45375f96153e46d396e25b19afb723d08cd8ebe
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Wed Nov 27 06:22:42 2013 +1000

    meldwindow: Move toolbar and statusbar visibility handling to GSettings

 data/org.gnome.meld.gschema.xml |   13 +++++++++++++
 meld/meldwindow.py              |   34 +++++++++++++---------------------
 meld/preferences.py             |    5 -----
 3 files changed, 26 insertions(+), 26 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index 38cf1ab..44575a6 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -9,6 +9,19 @@
   </flags>
 
   <schema id="org.gnome.meld" path="/org/gnome/meld/">
+      <!-- Application settings -->
+      <key name="toolbar-visible" type="b">
+          <default>true</default>
+          <summary>Show toolbar</summary>
+          <description>If true, the window toolbar is visible.</description>
+      </key>
+      <key name="statusbar-visible" type="b">
+          <default>true</default>
+          <summary>Show statusbar</summary>
+          <description>If true, the window statusbar is visible.</description>
+      </key>
+
+
       <!-- Settings corresponding directly to GtkSourceView properties -->
       <key name="indent-width" type="i">
           <default>8</default>
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index d411e95..ef53bc8 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -27,7 +27,6 @@ from . import dirdiff
 from . import filediff
 from . import filemerge
 from . import melddoc
-from . import misc
 from . import newdifftab
 from . import recent
 from . import task
@@ -38,7 +37,7 @@ from .ui import notebooklabel
 from .util.compat import string_types
 from .meldapp import app
 
-from meld.settings import interface_settings
+from meld.settings import interface_settings, settings
 
 
 class MeldWindow(gnomeglade.Component):
@@ -133,10 +132,10 @@ class MeldWindow(gnomeglade.Component):
                 self.on_action_fullscreen_toggled, False),
             ("ToolbarVisible", None, _("_Toolbar"), None,
                 _("Show or hide the toolbar"),
-                self.on_menu_toolbar_toggled, app.prefs.toolbar_visible),
+                None, True),
             ("StatusbarVisible", None, _("_Statusbar"), None,
                 _("Show or hide the statusbar"),
-                self.on_menu_statusbar_toggled, app.prefs.statusbar_visible)
+                None, True),
         )
         ui_file = gnomeglade.ui_file("meldapp-ui.xml")
         self.actiongroup = Gtk.ActionGroup('MainActions')
@@ -167,6 +166,16 @@ class MeldWindow(gnomeglade.Component):
         self.menubar = self.ui.get_widget('/Menubar')
         self.toolbar = self.ui.get_widget('/Toolbar')
 
+        settings.bind('toolbar-visible',
+                      self.actiongroup.get_action('ToolbarVisible'), 'active',
+                      Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('statusbar-visible',
+                      self.actiongroup.get_action('StatusbarVisible'), 'active',
+                      Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('toolbar-visible', self.toolbar, 'visible',
+                      Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('statusbar-visible', self.statusbar, 'visible',
+                      Gio.SettingsBindFlags.DEFAULT)
         interface_settings.bind('toolbar-style', self.toolbar, 'toolbar-style',
                                 Gio.SettingsBindFlags.DEFAULT)
 
@@ -193,9 +202,6 @@ class MeldWindow(gnomeglade.Component):
         self.widget.drag_dest_add_uri_targets()
         self.widget.connect("drag_data_received",
                             self.on_widget_drag_data_received)
-        self.toolbar.props.visible = app.prefs.toolbar_visible
-        self.statusbar.props.visible = app.prefs.statusbar_visible
-        app.prefs.notify_add(self.on_preference_changed)
         self.idle_hooked = 0
         self.scheduler = task.LifoScheduler()
         self.scheduler.connect("runnable", self.on_scheduler_runnable)
@@ -276,14 +282,6 @@ class MeldWindow(gnomeglade.Component):
             self.actiongroup.get_action("Stop").set_sensitive(True)
             self.idle_hooked = GObject.idle_add(self.on_idle)
 
-    def on_preference_changed(self, key, value):
-        if key == "toolbar_style":
-            self.toolbar.set_style(app.prefs.get_toolbar_style())
-        elif key == "statusbar_visible":
-            self.statusbar.props.visible = app.prefs.statusbar_visible
-        elif key == "toolbar_visible":
-            self.toolbar.props.visible = app.prefs.toolbar_visible
-
     def on_delete_event(self, *extra):
         # Delete pages from right-to-left.  This ensures that if a version
         # control page is open in the far left page, it will be closed last.
@@ -489,12 +487,6 @@ class MeldWindow(gnomeglade.Component):
         elif is_full:
             self.widget.unfullscreen()
 
-    def on_menu_toolbar_toggled(self, widget):
-        app.prefs.toolbar_visible = widget.get_active()
-
-    def on_menu_statusbar_toggled(self, widget):
-        app.prefs.statusbar_visible = widget.get_active()
-
     def on_menu_edit_down_activate(self, *args):
         self.current_doc().next_diff(Gdk.ScrollDirection.DOWN)
 
diff --git a/meld/preferences.py b/meld/preferences.py
index 28ed3d0..14e6436 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -277,11 +277,6 @@ class MeldPreferences(prefs.Preferences):
         "text_codecs": prefs.Value(prefs.STRING, "utf8 latin1"),
         "vc_console_visible": prefs.Value(prefs.BOOL, 0),
         "ignore_blank_lines" : prefs.Value(prefs.BOOL, False),
-        "toolbar_visible" : prefs.Value(prefs.BOOL, True),
-        "statusbar_visible" : prefs.Value(prefs.BOOL, True),
-        # Currently, we're using a quite simple format to store the columns:
-        # each line contains a column name followed by a 1 or a 0
-        # depending on whether the column is visible or not.
         "vc_left_is_local": prefs.Value(prefs.BOOL, False),
     }
 


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