[meld] Add a toggle for unlocking scrolling in file diff (closes bgo#348119)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Add a toggle for unlocking scrolling in file diff (closes bgo#348119)
- Date: Mon, 24 Jan 2011 21:07:58 +0000 (UTC)
commit c385b762fbe8521bfcaf878c42d834fb64533bef
Author: Kai Willadsen <kai willadsen gmail com>
Date: Wed Jan 19 06:51:59 2011 +1000
Add a toggle for unlocking scrolling in file diff (closes bgo#348119)
While it's expected that the normal mode of operation in Meld is to
have panes' scrolling locked, it is sometimes useful to be able to
unlock scrolling to compare two different sections of files.
This commit adds a "Lock scrolling" option to the View menu of file
comparisons, and adds a toggleable lock button to the upper-right
corner of comparison tabs.
The locked and unlocked icons are taken from the GNOME Colors
project, licensed under GPL v2.
data/icons/COPYING | 6 +++++-
data/icons/meld-locked.png | Bin 0 -> 709 bytes
data/icons/meld-unlocked.png | Bin 0 -> 640 bytes
data/ui/filediff-ui.xml | 5 +++++
data/ui/filediff.ui | 23 ++++++++++++++++++++++-
data/ui/meldapp-ui.xml | 2 ++
meld/filediff.py | 25 +++++++++++++++++++++++--
7 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/data/icons/COPYING b/data/icons/COPYING
index 52b9052..4f19cd2 100644
--- a/data/icons/COPYING
+++ b/data/icons/COPYING
@@ -4,4 +4,8 @@ separately.
emblem-meld-newer-file.png is taken from the gnome-icon-theme project at
gnome/8x8/emblems/emblem-new.png and is licensed under the terms of the
-Creative Commons BY-SA 3.0 license. See COPYING_CCBYSA3 for details.
\ No newline at end of file
+Creative Commons BY-SA 3.0 license. See COPYING_CCBYSA3 for details.
+
+meld-locked.png and meld-unlocked.png are taken from the gnome-colors project
+at gnome-colors/gnome-colors-common/16x16/status/locked.png and unlocked.png,
+and are licensed under the GPL v2.
diff --git a/data/icons/meld-locked.png b/data/icons/meld-locked.png
new file mode 100644
index 0000000..d08fb33
Binary files /dev/null and b/data/icons/meld-locked.png differ
diff --git a/data/icons/meld-unlocked.png b/data/icons/meld-unlocked.png
new file mode 100644
index 0000000..5547c00
Binary files /dev/null and b/data/icons/meld-unlocked.png differ
diff --git a/data/ui/filediff-ui.xml b/data/ui/filediff-ui.xml
index 873f42a..d6c7b79 100644
--- a/data/ui/filediff-ui.xml
+++ b/data/ui/filediff-ui.xml
@@ -34,6 +34,11 @@
<menuitem action="MergeAll"/>
</placeholder>
</menu>
+ <menu action="ViewMenu">
+ <placeholder name="ViewUtilityPlaceholder">
+ <menuitem action="LockScrolling"/>
+ </placeholder>
+ </menu>
</menubar>
<popup name="Popup">
diff --git a/data/ui/filediff.ui b/data/ui/filediff.ui
index 815f032..f39d6fa 100644
--- a/data/ui/filediff.ui
+++ b/data/ui/filediff.ui
@@ -215,6 +215,27 @@
<property name="right_attach">7</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="x_options">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="lock_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="relief">none</property>
+ <signal handler="on_lock_button_toggled" name="toggled"/>
+ <child>
+ <object class="GtkImage" id="lock_button_image">
+ <property name="visible">True</property>
+ <property name="icon-name">meld-locked</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">6</property>
+ <property name="right_attach">7</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -249,7 +270,7 @@
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="x_options">0</property>
</packing>
</child>
<child>
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index 95bdf52..c1be2e7 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -37,6 +37,8 @@
<menuitem action="StatusbarVisible" />
<menuitem action="Fullscreen" />
<separator/>
+ <placeholder name="ViewUtilityPlaceholder" />
+ <separator/>
<placeholder name="ViewPlaceholder" />
<menu action="FileStatus" />
<menu action="VcStatus" />
diff --git a/meld/filediff.py b/meld/filediff.py
index bd2e6ec..778c35b 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -213,6 +213,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self._connect_buffer_handlers()
self._sync_vscroll_lock = False
self._sync_hscroll_lock = False
+ self._scroll_lock = False
self.linediffer = self.differ()
self.linediffer.ignore_blanks = self.prefs.ignore_blank_lines
self.in_nested_action = False
@@ -265,10 +266,17 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
("MergeAll", None, _("Merge all non-conflicting"), None, _("Merge all non-conflicting changes from left and right panes"), lambda x: self.merge_all_non_conflicting_changes()),
)
+ toggle_actions = (
+ ("LockScrolling", None, _("Lock scrolling"), None,
+ _("Lock scrolling of all panes"),
+ self.on_action_lock_scrolling_toggled, True),
+ )
+
self.ui_file = paths.ui_dir("filediff-ui.xml")
self.actiongroup = gtk.ActionGroup('FilediffPopupActions')
self.actiongroup.set_translation_domain("meld")
self.actiongroup.add_actions(actions)
+ self.actiongroup.add_toggle_actions(toggle_actions)
self.set_num_panes(num_panes)
gobject.idle_add( lambda *args: self.load_font()) # hack around Bug 316730
gnomeglade.connect_signal_handlers(self)
@@ -1242,11 +1250,24 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.diffmap0.queue_draw()
self.diffmap1.queue_draw()
+ def on_action_lock_scrolling_toggled(self, action):
+ self.toggle_scroll_lock(action.get_active())
+
+ def on_lock_button_toggled(self, button):
+ self.toggle_scroll_lock(not button.get_active())
+
+ def toggle_scroll_lock(self, locked):
+ icon_name = "meld-locked" if locked else "meld-unlocked"
+ self.lock_button_image.props.icon_name = icon_name
+ self.lock_button.set_active(not locked)
+ self.actiongroup.get_action("LockScrolling").set_active(locked)
+ self._scroll_lock = not locked
+
#
# scrollbars
#
def _sync_hscroll(self, adjustment):
- if self._sync_hscroll_lock:
+ if self._sync_hscroll_lock or self._scroll_lock:
return
self._sync_hscroll_lock = True
@@ -1262,7 +1283,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if self._sync_vscroll_lock:
return
- if (self.keymask & MASK_SHIFT) == 0:
+ if not self._scroll_lock and (self.keymask & MASK_SHIFT) == 0:
self._sync_vscroll_lock = True
syncpoint = 0.5
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]