[meld] filediff: First pass at UI-ifying Filediff actions



commit 894fd3c8b84321f03b1350a8bae0de3c78b779e0
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Nov 30 07:45:33 2014 +1000

    filediff: First pass at UI-ifying Filediff actions

 data/ui/filediff.ui |  171 +++++++++++++++++++++++++++++++++++++++++++++++++++
 meld/filediff.py    |   77 +----------------------
 2 files changed, 174 insertions(+), 74 deletions(-)
---
diff --git a/data/ui/filediff.ui b/data/ui/filediff.ui
index 1fb7429..02e9610 100644
--- a/data/ui/filediff.ui
+++ b/data/ui/filediff.ui
@@ -2,6 +2,177 @@
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <!-- interface-requires meld.ui.gladesupport 0.0 -->
+  <object class="GtkActionGroup" id="FilediffActions">
+    <child>
+      <object class="GtkAction" id="MakePatch">
+        <property name="label" translatable="yes">Format as Patch...</property>
+        <property name="tooltip" translatable="yes">Create a patch using differences between files</property>
+        <signal name="activate" handler="make_patch" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="SaveAll">
+        <property name="label" translatable="yes">Save A_ll</property>
+        <property name="tooltip" translatable="yes">Save all files in the current comparison</property>
+        <signal name="activate" handler="on_save_all_activate" swapped="no"/>
+      </object>
+      <accelerator key="L" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="Revert">
+        <property name="tooltip" translatable="yes">Revert files to their saved versions</property>
+        <property name="stock_id">gtk-revert-to-saved</property>
+        <signal name="activate" handler="on_revert_activate" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="SplitAdd">
+        <property name="label" translatable="yes">Add Synchronization Point</property>
+        <property name="tooltip" translatable="yes">Add a manual point for synchronization of changes 
between files</property>
+        <signal name="activate" handler="add_sync_point" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="SplitClear">
+        <property name="label" translatable="yes">Clear Synchronization Points</property>
+        <property name="tooltip" translatable="yes">Clear manual change sychronization points</property>
+        <signal name="activate" handler="clear_sync_points" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="PrevConflict">
+        <property name="label" translatable="yes">Previous Conflict</property>
+        <property name="tooltip" translatable="yes">Go to the previous conflict</property>
+        <signal name="activate" handler="on_next_conflict(Gdk.ScrollDirection.UP)" swapped="no"/>
+      </object>
+      <accelerator key="I" modifiers="GDK_CONTROL_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="NextConflict">
+        <property name="label" translatable="yes">Next Conflict</property>
+        <property name="tooltip" translatable="yes">Go to the next conflict</property>
+        <signal name="activate" handler="on_next_conflict(Gdk.ScrollDirection.DOWN)" swapped="no"/>
+      </object>
+      <accelerator key="K" modifiers="GDK_CONTROL_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="PushLeft">
+        <property name="label" translatable="yes">Push to Left</property>
+        <property name="tooltip" translatable="yes">Push current change to the left</property>
+        <property name="stock_id">gtk-go-back</property>
+        <signal name="activate" handler="push_change(-1)" swapped="no"/>
+      </object>
+      <accelerator key="Left" modifiers="GDK_MOD1_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="PushRight">
+        <property name="label" translatable="yes">Push to Right</property>
+        <property name="tooltip" translatable="yes">Push current change to the right</property>
+        <property name="stock_id">gtk-go-forward</property>
+        <signal name="activate" handler="push_change(1)" swapped="no"/>
+      </object>
+      <accelerator key="Right" modifiers=""/>
+    </child>
+    <!-- FIXME: using LAST and FIRST is terrible and unreliable icon abuse -->
+    <child>
+      <object class="GtkAction" id="PullLeft">
+        <property name="label" translatable="yes">Pull from Left</property>
+        <property name="tooltip" translatable="yes">Pull change from the left</property>
+        <property name="stock_id">gtk-goto-last</property>
+        <signal name="activate" handler="pull_change(-1)" swapped="no"/>
+      </object>
+      <accelerator key="Right" modifiers="GDK_MOD1_MASK | GDK_SHIFT_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="PullRight">
+        <property name="label" translatable="yes">Pull from Right</property>
+        <property name="tooltip" translatable="yes">Pull change from the right</property>
+        <property name="stock_id">gtk-goto-first</property>
+        <signal name="activate" handler="pull_change(1)" swapped="no"/>
+      </object>
+      <accelerator key="Left" modifiers="GDK_MOD1_MASK | GDK_SHIFT_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="CopyLeftUp">
+        <property name="label" translatable="yes">Copy Above Left</property>
+        <property name="tooltip" translatable="yes">Copy change above the left chunk</property>
+        <signal name="activate" handler="copy_change(-1, -1)" swapped="no"/>
+      </object>
+      <accelerator key="bracketleft" modifiers="GDK_MOD1_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="CopyLeftDown">
+        <property name="label" translatable="yes">Copy Below Left</property>
+        <property name="tooltip" translatable="yes">Copy change below the left chunk</property>
+        <signal name="activate" handler="self.copy_change(-1, 1)" swapped="no"/>
+      </object>
+      <accelerator key="semicolon" modifiers="GDK_MOD1_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="CopyRightUp">
+        <property name="label" translatable="yes">Copy Above Right</property>
+        <property name="tooltip" translatable="yes">Copy change above the right chunk</property>
+        <signal name="activate" handler="copy_change(1, -1)" swapped="no"/>
+      </object>
+      <accelerator key="bracketright" modifiers="GDK_MOD1_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="CopyRightDown">
+        <property name="label" translatable="yes">Copy Below Right</property>
+        <property name="tooltip" translatable="yes">Copy change below the right chunk</property>
+        <signal name="activate" handler="copy_change(1, 1)" swapped="no"/>
+      </object>
+      <accelerator key="quoteright" modifiers="GDK_MOD1_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="Delete">
+        <property name="label" translatable="yes">Delete</property>
+        <property name="tooltip" translatable="yes">Delete change</property>
+        <property name="stock_id">gtk-delete</property>
+        <signal name="activate" handler="delete_change" swapped="no"/>
+      </object>
+      <accelerator key="Delete" modifiers="GDK_MOD1_MASK"/>
+    </child>
+    <child>
+      <object class="GtkAction" id="MergeFromLeft">
+        <property name="label" translatable="yes">Merge All from Left</property>
+        <property name="tooltip" translatable="yes">Merge all non-conflicting changes from the 
left</property>
+        <signal name="activate" handler="pull_all_non_conflicting_changes(-1)" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="MergeFromRight">
+        <property name="label" translatable="yes">Merge All from Right</property>
+        <property name="tooltip" translatable="yes">Merge all non-conflicting changes from the 
right</property>
+        <signal name="activate" handler="pull_all_non_conflicting_changes(1)" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="MergeAll">
+        <property name="label" translatable="yes">Merge All</property>
+        <property name="tooltip" translatable="yes">Merge all non-conflicting changes from left and right 
panes</property>
+        <signal name="activate" handler="merge_all_non_conflicting_changes" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="CycleDocuments">
+        <property name="label" translatable="yes">Cycle Through Documents</property>
+        <property name="tooltip" translatable="yes">Move keyboard focus to the next document in this 
comparison</property>
+        <signal name="activate" handler="action_cycle_documents" swapped="no"/>
+      </object>
+      <accelerator key="Escape" modifiers="GDK_CONTROL_MASK"/>
+    </child>
+<!-- 
+    <child>
+      <object class="GtkAction" id="NONE">
+        <property name="label" translatable="yes">NONE</property>
+        <property name="tooltip" translatable="yes">NONE</property>
+        <signal name="activate" handler="NONE" swapped="no"/>
+      </object>
+      <accelerator key="NONE" modifiers="NONE"/>
+    </child>
+ -->
+  </object>
   <object class="GtkMessageDialog" id="check_save_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
diff --git a/meld/filediff.py b/meld/filediff.py
index 0233d5a..61dd4e7 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -174,7 +174,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         """Start up an filediff with num_panes empty contents.
         """
         melddoc.MeldDoc.__init__(self)
-        gnomeglade.Component.__init__(self, "filediff.ui", "filediff")
+        gnomeglade.Component.__init__(
+            self, "filediff.ui", "filediff", ["FilediffActions"])
         bind_settings(self)
 
         widget_lists = [
@@ -239,77 +240,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             buf.connect("notify::has-selection",
                         self.update_text_actions_sensitivity)
 
-        actions = (
-            ("MakePatch", None, _("Format as Patch..."), None,
-                _("Create a patch using differences between files"),
-                self.make_patch),
-            ("SaveAll", None, _("Save A_ll"), "<Ctrl><Shift>L",
-                _("Save all files in the current comparison"),
-                self.on_save_all_activate),
-            ("Revert", Gtk.STOCK_REVERT_TO_SAVED, None, None,
-                _("Revert files to their saved versions"),
-                self.on_revert_activate),
-            ("SplitAdd", None, _("Add Synchronization Point"), None,
-                _("Add a manual point for synchronization of changes between "
-                  "files"),
-                self.add_sync_point),
-            ("SplitClear", None, _("Clear Synchronization Points"), None,
-                _("Clear manual change sychronization points"),
-                self.clear_sync_points),
-            ("PrevConflict", None, _("Previous Conflict"), "<Ctrl>I",
-                _("Go to the previous conflict"),
-                lambda x: self.on_next_conflict(Gdk.ScrollDirection.UP)),
-            ("NextConflict", None, _("Next Conflict"), "<Ctrl>K",
-                _("Go to the next conflict"),
-                lambda x: self.on_next_conflict(Gdk.ScrollDirection.DOWN)),
-            ("PushLeft", Gtk.STOCK_GO_BACK, _("Push to Left"), "<Alt>Left",
-                _("Push current change to the left"),
-                lambda x: self.push_change(-1)),
-            ("PushRight", Gtk.STOCK_GO_FORWARD,
-                _("Push to Right"), "<Alt>Right",
-                _("Push current change to the right"),
-                lambda x: self.push_change(1)),
-            # FIXME: using LAST and FIRST is terrible and unreliable icon abuse
-            ("PullLeft", Gtk.STOCK_GOTO_LAST,
-                _("Pull from Left"), "<Alt><Shift>Right",
-                _("Pull change from the left"),
-                lambda x: self.pull_change(-1)),
-            ("PullRight", Gtk.STOCK_GOTO_FIRST,
-                _("Pull from Right"), "<Alt><Shift>Left",
-                _("Pull change from the right"),
-                lambda x: self.pull_change(1)),
-            ("CopyLeftUp", None, _("Copy Above Left"), "<Alt>bracketleft",
-                _("Copy change above the left chunk"),
-                lambda x: self.copy_change(-1, -1)),
-            ("CopyLeftDown", None, _("Copy Below Left"), "<Alt>semicolon",
-                _("Copy change below the left chunk"),
-                lambda x: self.copy_change(-1, 1)),
-            ("CopyRightUp", None, _("Copy Above Right"), "<Alt>bracketright",
-                _("Copy change above the right chunk"),
-                lambda x: self.copy_change(1, -1)),
-            ("CopyRightDown", None, _("Copy Below Right"), "<Alt>quoteright",
-                _("Copy change below the right chunk"),
-                lambda x: self.copy_change(1, 1)),
-            ("Delete", Gtk.STOCK_DELETE, _("Delete"), "<Alt>Delete",
-                _("Delete change"),
-                self.delete_change),
-            ("MergeFromLeft", None, _("Merge All from Left"), None,
-                _("Merge all non-conflicting changes from the left"),
-                lambda x: self.pull_all_non_conflicting_changes(-1)),
-            ("MergeFromRight", None, _("Merge All from Right"), None,
-                _("Merge all non-conflicting changes from the right"),
-                lambda x: self.pull_all_non_conflicting_changes(1)),
-            ("MergeAll", None, _("Merge All"), None,
-                _("Merge all non-conflicting changes from left and right "
-                  "panes"),
-                lambda x: self.merge_all_non_conflicting_changes()),
-            ("CycleDocuments", None,
-                _("Cycle Through Documents"), "<control>Escape",
-                _("Move keyboard focus to the next document in this "
-                  "comparison"),
-                self.action_cycle_documents),
-        )
-
         toggle_actions = (
             ("LockScrolling", None, _("Lock Scrolling"), None,
              _("Lock scrolling of all panes"),
@@ -317,9 +247,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         )
 
         self.ui_file = gnomeglade.ui_file("filediff-ui.xml")
-        self.actiongroup = Gtk.ActionGroup(name="FilediffPopupActions")
+        self.actiongroup = self.FilediffActions
         self.actiongroup.set_translation_domain("meld")
-        self.actiongroup.add_actions(actions)
         self.actiongroup.add_toggle_actions(toggle_actions)
 
         self.findbar = findbar.FindBar(self.grid)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]