[meld] sourceview, preferences: Migrate to new GtkSourceView space-drawer API
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] sourceview, preferences: Migrate to new GtkSourceView space-drawer API
- Date: Wed, 14 Aug 2019 20:54:27 +0000 (UTC)
commit f57cdd66f076273b14aef13d25694906c5833418
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Jul 14 07:17:25 2019 +1000
sourceview, preferences: Migrate to new GtkSourceView space-drawer API
The old whitespace display API goes away in 4.0, so this is necessary.
There's no migration from the existing draw-spaces preference, but
honestly it's one tick box, so I can live with this.
data/org.gnome.meld.gschema.xml | 8 ++++----
meld/preferences.py | 10 +---------
meld/resources/ui/preferences.ui | 1 -
meld/sourceview.py | 17 +++--------------
4 files changed, 8 insertions(+), 28 deletions(-)
---
diff --git a/data/org.gnome.meld.gschema.xml b/data/org.gnome.meld.gschema.xml
index 094d7089..b91b69f1 100644
--- a/data/org.gnome.meld.gschema.xml
+++ b/data/org.gnome.meld.gschema.xml
@@ -86,10 +86,10 @@
<summary>Color scheme to use for syntax highlighting</summary>
<description>Used by GtkSourceView to determine colors for syntax highlighting</description>
</key>
- <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 name="enable-space-drawer" type='b'>
+ <default>false</default>
+ <summary>Draw whitespace</summary>
+ <description>If true, whitespace characters will be drawn in comparisons even if they are not in a
changed area.</description>
</key>
<key name="wrap-mode" enum='org.gnome.meld.wrapmode'>
<aliases>
diff --git a/meld/preferences.py b/meld/preferences.py
index 323ab43d..2f6aca55 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -301,6 +301,7 @@ class PreferencesDialog(Gtk.Dialog):
('highlight-current-line', self.checkbutton_highlight_current_line, 'active'), # noqa: E501
('show-line-numbers', self.checkbutton_show_line_numbers, 'active'), # noqa: E501
('highlight-syntax', self.checkbutton_use_syntax_highlighting, 'active'), # noqa: E501
+ ('enable-space-drawer', self.checkbutton_show_whitespace, 'active'), # noqa: E501
('use-system-editor', self.system_editor_checkbutton, 'active'),
('custom-editor-command', self.custom_edit_command_entry, 'text'),
('folder-shallow-comparison', self.checkbutton_shallow_compare, 'active'), # noqa: E501
@@ -333,10 +334,6 @@ class PreferencesDialog(Gtk.Dialog):
'active', self.checkbutton_wrap_word, 'sensitive',
GObject.BindingFlags.DEFAULT)
- # TODO: Fix once bind_with_mapping is available
- self.checkbutton_show_whitespace.set_active(
- bool(settings.get_flags('draw-spaces')))
-
wrap_mode = settings.get_enum('wrap-mode')
self.checkbutton_wrap_text.set_active(wrap_mode != Gtk.WrapMode.NONE)
self.checkbutton_wrap_word.set_active(wrap_mode == Gtk.WrapMode.WORD)
@@ -380,11 +377,6 @@ class PreferencesDialog(Gtk.Dialog):
wrap_mode = Gtk.WrapMode.CHAR
settings.set_enum('wrap-mode', wrap_mode)
- @Template.Callback()
- def on_checkbutton_show_whitespace_toggled(self, widget):
- value = GtkSource.DrawSpacesFlags.ALL if widget.get_active() else 0
- settings.set_flags('draw-spaces', value)
-
@Template.Callback()
def on_response(self, dialog, response_id):
self.destroy()
diff --git a/meld/resources/ui/preferences.ui b/meld/resources/ui/preferences.ui
index 9ba43d71..37dc3055 100644
--- a/meld/resources/ui/preferences.ui
+++ b/meld/resources/ui/preferences.ui
@@ -369,7 +369,6 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_checkbutton_show_whitespace_toggled"
swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/meld/sourceview.py b/meld/sourceview.py
index 54641d6a..7daf9d2e 100644
--- a/meld/sourceview.py
+++ b/meld/sourceview.py
@@ -112,7 +112,7 @@ class MeldSourceView(GtkSource.View, SourceViewHelperMixin):
('highlight-current-line', 'highlight-current-line-local'),
('indent-width', 'tab-width'),
('insert-spaces-instead-of-tabs', 'insert-spaces-instead-of-tabs'),
- ('draw-spaces', 'draw-spaces'),
+ ('enable-space-drawer', 'draw-spaces-bool'),
('wrap-mode', 'wrap-mode'),
('show-line-numbers', 'show-line-numbers'),
)
@@ -273,20 +273,10 @@ class MeldSourceView(GtkSource.View, SourceViewHelperMixin):
)
self.wrap_mode_bool = wrap_mode_to_bool(None, self.props.wrap_mode)
- def draw_spaces_from_bool(binding, from_value):
- return GtkSource.DrawSpacesFlags.ALL if from_value else 0
-
- def draw_spaces_to_bool(binding, from_value):
- return bool(from_value)
-
self.bind_property(
- 'draw-spaces-bool', self, 'draw-spaces',
- GObject.BindingFlags.BIDIRECTIONAL,
- draw_spaces_from_bool,
- draw_spaces_to_bool,
+ 'draw-spaces-bool', self.props.space_drawer, 'enable-matrix',
+ GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE,
)
- self.draw_spaces_bool = draw_spaces_to_bool(
- None, self.props.draw_spaces)
meld_settings = get_meld_settings()
@@ -406,7 +396,6 @@ class CommitMessageSourceView(GtkSource.View):
__gsettings_bindings__ = (
('indent-width', 'tab-width'),
('insert-spaces-instead-of-tabs', 'insert-spaces-instead-of-tabs'),
- ('draw-spaces', 'draw-spaces'),
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]