Commit 949652b0 authored by Kai Willadsen's avatar Kai Willadsen

sourceview: Support toggling whitespace drawing from statusbar (#119)

parent 8c7d5e0c
......@@ -239,6 +239,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
# Set up property actions for statusbar toggles
sourceview_prop_actions = [
'draw-spaces-bool',
'highlight-current-line-local',
'show-line-numbers',
'wrap-mode-bool',
......
......@@ -5,6 +5,10 @@
<attribute name="label">Display line numbers</attribute>
<attribute name="action">show-line-numbers</attribute>
</item>
<item>
<attribute name="label">Show whitespace</attribute>
<attribute name="action">draw-spaces-bool</attribute>
</item>
<item>
<attribute name="label">Highlight current line</attribute>
<attribute name="action">highlight-current-line-local</attribute>
......
......@@ -132,6 +132,15 @@ class MeldSourceView(GtkSource.View):
),
)
draw_spaces_bool = GObject.Property(
type=bool, default=False,
nick="Draw spaces (Boolean version)",
blurb=(
"Mirror of the draw-spaces GtkSourceView property, "
"reduced to a single Boolean for UI ease-of-use."
),
)
replaced_entries = (
# We replace the default GtkSourceView undo mechanism
(Gdk.KEY_z, Gdk.ModifierType.CONTROL_MASK),
......@@ -260,6 +269,21 @@ class MeldSourceView(GtkSource.View):
)
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,
)
self.draw_spaces_bool = draw_spaces_to_bool(
None, self.props.draw_spaces)
self.on_setting_changed(meldsettings, 'font')
self.on_setting_changed(meldsettings, 'style-scheme')
return GtkSource.View.do_realize(self)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment