[meld] filediff: Move draw-spaces handling into GSettings
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filediff: Move draw-spaces handling into GSettings
- Date: Fri, 6 Dec 2013 23:25:41 +0000 (UTC)
commit d4eb080678409ddf0f0d82b98e8525288e16531e
Author: Kai Willadsen <kai willadsen gmail com>
Date: Wed Nov 27 06:43:55 2013 +1000
filediff: Move draw-spaces handling into GSettings
data/org.gnome.meld.gschema.xml | 9 +++++----
meld/filediff.py | 8 +++-----
meld/preferences.py | 10 ++++++----
meld/util/sourceviewer.py | 4 ----
4 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index 44575a6..53b8136 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -6,6 +6,9 @@
<value nick="tab" value="2"/>
<value nick="newline" value="4"/>
<value nick="nbsp" value="8"/>
+ <value nick="leading" value="16"/>
+ <value nick="text" value="32"/>
+ <value nick="trailing" value="64"/>
</flags>
<schema id="org.gnome.meld" path="/org/gnome/meld/">
@@ -43,10 +46,8 @@
<summary>Highlight syntax</summary>
<description>Whether to highlight syntax in comparisons. Because of Meld's own color highlighting,
this is off by default.</description>
</key>
-
-
- <key name="show-whitespace" flags='org.gnome.meld.spacesflags'>
- <default>["space", "tab"]</default>
+ <key name="draw-spaces" flags='org.gnome.meld.spacesflags'>
+ <default>[]</default>
<summary>Displayed whitespace</summary>
<description>Selector for individual whitespace character types to be shown. Possible values are
'space', 'tab', 'newline' and 'nbsp'.</description>
</key>
diff --git a/meld/filediff.py b/meld/filediff.py
index 8e46428..50d3ffa 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -183,7 +183,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
buf.connect('end_user_action', self.on_textbuffer_end_user_action)
v.set_buffer(buf)
v.set_wrap_mode(self.prefs.edit_wrap_lines)
- v.set_draw_spaces(self.prefs.show_whitespace)
buf.data.connect('file-changed', self.notify_file_changed)
self._keymask = 0
self.load_font()
@@ -356,6 +355,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
Gio.SettingsBindFlags.DEFAULT)
settings.bind('show-line-numbers', view, 'show-line-numbers',
Gio.SettingsBindFlags.DEFAULT)
+ settings.bind('draw-spaces', view, 'draw-spaces',
+ Gio.SettingsBindFlags.DEFAULT)
for buf in self.textbuffer:
settings.bind('highlight-syntax', buf, 'highlight-syntax',
Gio.SettingsBindFlags.DEFAULT)
@@ -830,10 +831,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.load_font()
def on_preference_changed(self, key, value):
- if key == "show_whitespace":
- for v in self.textview:
- v.set_draw_spaces(value)
- elif key == "edit_wrap_lines":
+ if key == "edit_wrap_lines":
for t in self.textview:
t.set_wrap_mode(self.prefs.edit_wrap_lines)
# FIXME: On changing wrap mode, we get one redraw using cached
diff --git a/meld/preferences.py b/meld/preferences.py
index 14e6436..536dc6f 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -22,6 +22,7 @@ from gi.repository import Gio
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gtk
+from gi.repository import GtkSource
from . import filters
from .ui import gnomeglade
@@ -200,8 +201,9 @@ class PreferencesDialog(gnomeglade.Component):
'use-system-font', self.fontpicker, 'sensitive',
Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)
+ # TODO: Fix once bind_with_mapping is available
self.checkbutton_show_whitespace.set_active(
- self.prefs.show_whitespace)
+ bool(settings.get_flags('draw-spaces')))
# TODO: This doesn't restore the state of character wrapping when word
# wrapping is disabled, but this is hard with our existing gconf keys
if self.prefs.edit_wrap_lines != Gtk.WrapMode.NONE:
@@ -250,8 +252,9 @@ class PreferencesDialog(gnomeglade.Component):
else:
self.prefs.edit_wrap_lines = 1
- def on_checkbutton_show_whitespace_toggled(self, check):
- self.prefs.show_whitespace = check.get_active()
+ def on_checkbutton_show_whitespace_toggled(self, widget):
+ 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()
@@ -272,7 +275,6 @@ class MeldPreferences(prefs.Preferences):
defaults = {
"window_size_x": prefs.Value(prefs.INT, 600),
"window_size_y": prefs.Value(prefs.INT, 600),
- "show_whitespace": prefs.Value(prefs.BOOL, False),
"edit_wrap_lines" : prefs.Value(prefs.INT, 0),
"text_codecs": prefs.Value(prefs.STRING, "utf8 latin1"),
"vc_console_visible": prefs.Value(prefs.BOOL, 0),
diff --git a/meld/util/sourceviewer.py b/meld/util/sourceviewer.py
index eb04083..0a586b3 100644
--- a/meld/util/sourceviewer.py
+++ b/meld/util/sourceviewer.py
@@ -72,7 +72,3 @@ class MeldSourceView(GtkSource.View):
def get_line_num_for_y(self, y):
return self.get_line_at_y(y)[0].get_line()
-
- def set_draw_spaces(self, draw):
- spaces_flag = GtkSource.DrawSpacesFlags.ALL if draw else 0
- super(MeldSourceView, self).set_draw_spaces(spaces_flag)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]