[meld/ui-next] filediff: Move scroll lock to a GAction
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/ui-next] filediff: Move scroll lock to a GAction
- Date: Sat, 23 Mar 2019 02:00:41 +0000 (UTC)
commit e5a88006d44684ecff5d95857b70f8290294220e
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Feb 23 08:50:10 2019 +1000
filediff: Move scroll lock to a GAction
data/ui/filediff-ui.xml | 3 ---
meld/filediff.py | 29 ++++++++++++++++-------------
meld/resources/gtk/menus.ui | 4 ++++
meld/resources/ui/filediff.ui | 8 --------
4 files changed, 20 insertions(+), 24 deletions(-)
---
diff --git a/data/ui/filediff-ui.xml b/data/ui/filediff-ui.xml
index 52367c47..36e50a76 100644
--- a/data/ui/filediff-ui.xml
+++ b/data/ui/filediff-ui.xml
@@ -28,9 +28,6 @@
</placeholder>
</menu>
<menu action="ViewMenu">
- <placeholder name="ViewUtilityPlaceholder">
- <menuitem action="LockScrolling"/>
- </placeholder>
<placeholder name="ViewPlaceholder">
<menuitem action="PrevPane" />
<menuitem action="NextPane" />
diff --git a/meld/filediff.py b/meld/filediff.py
index 767bf3f3..c59e5a88 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -68,7 +68,8 @@ def with_scroll_lock(lock_attr):
def wrap(function):
@functools.wraps(function)
def wrap_function(locked, *args, **kwargs):
- if getattr(locked, lock_attr, False) or locked._scroll_lock:
+ force_locked = locked.props.lock_scrolling
+ if getattr(locked, lock_attr, False) or force_locked:
return
try:
@@ -202,6 +203,12 @@ class FileDiff(Gtk.VBox, MeldDoc):
default=ActionMode.Replace,
)
+ lock_scrolling = GObject.property(
+ type=bool,
+ nick='Lock scrolling of all panes',
+ default=False,
+ )
+
def __init__(self, num_panes):
super().__init__()
# FIXME:
@@ -249,7 +256,6 @@ class FileDiff(Gtk.VBox, MeldDoc):
self._connect_buffer_handlers()
self._sync_vscroll_lock = False
self._sync_hscroll_lock = False
- self._scroll_lock = False
self.linediffer = self.differ()
self.force_highlight = False
self.syncpoints = []
@@ -272,9 +278,14 @@ class FileDiff(Gtk.VBox, MeldDoc):
# Set up per-view action group for top-level menu insertion
self.view_action_group = Gio.SimpleActionGroup()
- action = Gio.PropertyAction.new(
- 'show-sourcemap', self, 'show-sourcemap')
- self.view_action_group.add_action(action)
+
+ property_actions = (
+ ('show-sourcemap', self, 'show-sourcemap'),
+ ('lock-scrolling', self, 'lock_scrolling'),
+ )
+ for action_name, obj, prop_name in property_actions:
+ action = Gio.PropertyAction.new(action_name, obj, prop_name)
+ self.view_action_group.add_action(action)
# Manually handle GAction additions
actions = (
@@ -1930,14 +1941,6 @@ class FileDiff(Gtk.VBox, MeldDoc):
for gutter in self.actiongutter:
gutter.queue_draw()
- @Template.Callback()
- def on_action_lock_scrolling_toggled(self, action):
- self.toggle_scroll_lock(action.get_active())
-
- def toggle_scroll_lock(self, locked):
- self.actiongroup.get_action("LockScrolling").set_active(locked)
- self._scroll_lock = not locked
-
@Template.Callback()
def on_readonly_button_toggled(self, button):
index = self.readonlytoggle.index(button)
diff --git a/meld/resources/gtk/menus.ui b/meld/resources/gtk/menus.ui
index 1b3483fd..c848a3b3 100644
--- a/meld/resources/gtk/menus.ui
+++ b/meld/resources/gtk/menus.ui
@@ -48,6 +48,10 @@
<attribute name="label" translatable="yes">Overview Map</attribute>
<attribute name="action">view.show-sourcemap</attribute>
</item>
+ <item>
+ <attribute name="label">Lock scrolling</attribute>
+ <attribute name="action">view.lock-scrolling</attribute>
+ </item>
</section>
</submenu>
</section>
diff --git a/meld/resources/ui/filediff.ui b/meld/resources/ui/filediff.ui
index 785314e2..4ae93bee 100644
--- a/meld/resources/ui/filediff.ui
+++ b/meld/resources/ui/filediff.ui
@@ -875,13 +875,5 @@
</object>
<accelerator key="Page_Down" modifiers="GDK_MOD1_MASK"/>
</child>
- <child>
- <object class="GtkToggleAction" id="LockScrolling">
- <property name="label" translatable="yes">Lock Scrolling</property>
- <property name="tooltip" translatable="yes">Lock scrolling of all panes</property>
- <property name="active">True</property>
- <signal name="toggled" handler="on_action_lock_scrolling_toggled" swapped="no"/>
- </object>
- </child>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]