[meld] preferences: Move ignore-blank-lines to GSettings



commit 701c9c49e4bf2aa644568dec0796d0779d0aac4f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Dec 3 06:11:09 2013 +1000

    preferences: Move ignore-blank-lines to GSettings

 data/org.gnome.meld.gschema.xml |    8 ++++++++
 data/ui/preferences.ui          |    1 -
 meld/dirdiff.py                 |   15 ++++++++++-----
 meld/filediff.py                |   17 ++++++++++++-----
 meld/preferences.py             |    6 +-----
 5 files changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index 7aca413..4a5f5ec 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -79,6 +79,14 @@
       </key>
 
 
+      <!-- File comparison settings -->
+      <key name="ignore-blank-lines" type="b">
+          <default>false</default>
+          <summary>Ignore blank lines when comparing files</summary>
+          <description>If true, blank lines will be trimmed when highlighting changes between 
files.</description>
+      </key>
+
+
       <!-- External helper properties -->
       <key name="use-system-editor" type="b">
           <default>true</default>
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index 5f5aa32..249c238 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -1193,7 +1193,6 @@
                         <property name="use_underline">True</property>
                         <property name="xalign">0.5</property>
                         <property name="draw_indicator">True</property>
-                        <signal name="toggled" handler="on_checkbutton_ignore_blank_lines_toggled" 
swapped="no"/>
                       </object>
                       <packing>
                         <property name="expand">False</property>
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index f239ceb..5382fa2 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -252,6 +252,12 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
 
     __gtype_name__ = "DirDiff"
 
+    ignore_blank_lines = GObject.property(
+        type=bool,
+        nick="Ignore blank lines",
+        blurb="Whether to ignore blank lines when comparing file contents",
+        default=False,
+    )
     ignore_symlinks = GObject.property(
         type=bool,
         nick="Ignore symbolic links",
@@ -420,10 +426,13 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                       Gio.SettingsBindFlags.DEFAULT)
         settings.bind('folder-status-filters', self, 'status-filters',
                       Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('ignore-blank-lines', self, 'ignore-blank-lines',
+                      Gio.SettingsBindFlags.DEFAULT)
 
         self.update_comparator()
         self.connect("notify::shallow-comparison", self.update_comparator)
         self.connect("notify::time-resolution", self.update_comparator)
+        self.connect("notify::ignore-blank-lines", self.update_comparator)
 
         self.state_filters = []
         for s in self.state_actions:
@@ -461,15 +470,11 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         for diffmap in self.diffmap:
             diffmap.queue_draw()
 
-    def on_preference_changed(self, key, value):
-        if key == "ignore_blank_lines":
-            self.update_comparator()
-
     def update_comparator(self, *args):
         comparison_args = {
             'shallow-comparison': self.props.shallow_comparison,
             'time-resolution': self.props.time_resolution,
-            'ignore_blank_lines': self.prefs.ignore_blank_lines,
+            'ignore_blank_lines': self.props.ignore_blank_lines,
         }
         self.file_compare = functools.partial(
             _files_same, comparison_args=comparison_args)
diff --git a/meld/filediff.py b/meld/filediff.py
index 5a2521c..7267b5b 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -140,6 +140,12 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
     __gtype_name__ = "FileDiff"
 
     highlight_current_line = GObject.property(type=bool, default=False)
+    ignore_blank_lines = GObject.property(
+        type=bool,
+        nick="Ignore blank lines",
+        blurb="Whether to ignore blank lines when comparing file contents",
+        default=False,
+    )
 
     differ = diffutil.Differ
 
@@ -209,7 +215,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         self._sync_hscroll_lock = False
         self._scroll_lock = False
         self.linediffer = self.differ()
-        self.linediffer.ignore_blanks = self.prefs.ignore_blank_lines
         self.force_highlight = False
         self.syncpoints = []
         self.in_nested_textview_gutter_expose = False
@@ -363,6 +368,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
 
         settings.bind('highlight-current-line', self, 'highlight-current-line',
                       Gio.SettingsBindFlags.DEFAULT)
+        settings.bind('ignore-blank-lines', self, 'ignore-blank-lines',
+                      Gio.SettingsBindFlags.DEFAULT)
+
+        self.connect("notify::ignore-blank-lines", self.refresh_comparison)
 
         meldsettings.connect('changed', self.on_setting_changed)
 
@@ -839,9 +848,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             # correct coordinates. Overly-aggressive textview lazy calculation?
             self.diffmap0.queue_draw()
             self.diffmap1.queue_draw()
-        elif key == "ignore_blank_lines":
-            self.linediffer.ignore_blanks = self.prefs.ignore_blank_lines
-            self.refresh_comparison()
 
     def on_key_press_event(self, object, event):
         keymap = Gdk.Keymap.get_default()
@@ -1188,6 +1194,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
     def _diff_files(self, refresh=False):
         yield _("[%s] Computing differences") % self.label_text
         texts = self.buffer_filtered[:self.num_panes]
+        self.linediffer.ignore_blanks = self.props.ignore_blank_lines
         step = self.linediffer.set_sequences_iter(texts)
         while next(step) is None:
             yield 1
@@ -1257,7 +1264,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         msgarea.connect("response", on_file_changed_response)
         msgarea.show_all()
 
-    def refresh_comparison(self):
+    def refresh_comparison(self, *args):
         """Refresh the view by clearing and redoing all comparisons"""
         self._disconnect_buffer_handlers()
         self.linediffer.clear()
diff --git a/meld/preferences.py b/meld/preferences.py
index 435a22c..5daa29d 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -186,6 +186,7 @@ class PreferencesDialog(gnomeglade.Component):
             ('vc-show-commit-margin', self.checkbutton_show_commit_margin, 'active'),
             ('vc-commit-margin', self.spinbutton_commit_margin, 'value'),
             ('vc-break-commit-message', self.checkbutton_break_commit_lines, 'active'),
+            ('ignore-blank-lines', self.checkbutton_ignore_blank_lines, 'active'),
             # Sensitivity bindings must come after value bindings, or the key
             # writability in gsettings overrides manual sensitivity setting.
             ('vc-show-commit-margin', self.spinbutton_commit_margin, 'sensitive'),
@@ -218,7 +219,6 @@ class PreferencesDialog(gnomeglade.Component):
         # text filters
         self.textfilter = FilterList("text-filters", filters.FilterEntry.REGEX)
         self.text_filters_tab.pack_start(self.textfilter.widget, True, True, 0)
-        self.checkbutton_ignore_blank_lines.set_active( self.prefs.ignore_blank_lines )
 
         columnlist = ColumnList("folder-columns")
         self.column_list_vbox.pack_start(columnlist.widget, True, True, 0)
@@ -254,9 +254,6 @@ class PreferencesDialog(gnomeglade.Component):
         value = GtkSource.DrawSpacesFlags.ALL if widget.get_active() else 0
         settings.set_flags('draw-spaces', value)
 
-    def on_checkbutton_ignore_blank_lines_toggled(self, check):
-        self.prefs.ignore_blank_lines = check.get_active()
-
     def on_combo_file_order_changed(self, combo):
         file_order = combo.get_model()[combo.get_active_iter()][0]
         self.prefs.vc_left_is_local = True if file_order else False
@@ -271,7 +268,6 @@ class MeldPreferences(prefs.Preferences):
         "window_size_y": prefs.Value(prefs.INT, 600),
         "edit_wrap_lines" : prefs.Value(prefs.INT, 0),
         "vc_console_visible": prefs.Value(prefs.BOOL, 0),
-        "ignore_blank_lines" : prefs.Value(prefs.BOOL, False),
         "vc_left_is_local": prefs.Value(prefs.BOOL, False),
     }
 


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