[meld/ui-next] Move pane switching to GActions



commit dcd4110171de2ca91a9502152ef1633be73eba9f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Thu Feb 28 07:18:27 2019 +1000

    Move pane switching to GActions
    
    This does remove it from the menu, which doesn't help discoverability...
    but on the other hand, no one is going to the menu to switch panes.

 data/ui/filediff-ui.xml            |  6 ---
 data/ui/meldapp-ui.xml             |  3 --
 meld/accelerators.py               |  2 +
 meld/filediff.py                   | 10 ++---
 meld/meldwindow.py                 |  4 --
 meld/resources/gtk/help-overlay.ui | 77 +++++++++++++++++++++-----------------
 meld/resources/ui/filediff.ui      | 16 --------
 7 files changed, 48 insertions(+), 70 deletions(-)
---
diff --git a/data/ui/filediff-ui.xml b/data/ui/filediff-ui.xml
index 2eb7d80c..02d015d5 100644
--- a/data/ui/filediff-ui.xml
+++ b/data/ui/filediff-ui.xml
@@ -21,12 +21,6 @@
         <menuitem action="MergeAll"/>
       </placeholder>
     </menu>
-    <menu action="ViewMenu">
-      <placeholder name="ViewPlaceholder">
-        <menuitem action="PrevPane" />
-        <menuitem action="NextPane" />
-      </placeholder>
-    </menu>
   </menubar>
 
   <popup name="Popup">
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index d664eff2..34f0711d 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -15,9 +15,6 @@
     <menu action="ChangesMenu">
       <placeholder name="ChangesActions" />
     </menu>
-    <menu action="ViewMenu">
-      <placeholder name="ViewPlaceholder" />
-    </menu>
   </menubar>
 
   <popup name="Popup">
diff --git a/meld/accelerators.py b/meld/accelerators.py
index 62c01e21..0e5d9908 100644
--- a/meld/accelerators.py
+++ b/meld/accelerators.py
@@ -9,7 +9,9 @@ def register_accels(app: Gtk.Application):
         ('view.folder-copy-right', '<Alt>Right'),
         ('view.folder-delete', 'Delete'),
         ("view.next-change", ("<Alt>Down", "<Alt>KP_Down", "<Primary>D")),
+        ('view.next-pane', '<Alt>Page_Down'),
         ("view.previous-change", ("<Alt>Up", "<Alt>KP_Up", "<Primary>E")),
+        ('view.previous-pane', '<Alt>Page_Up'),
         ('view.redo', '<Primary><Shift>Z'),
         ("view.refresh", ("<control>R", "F5")),
         ('view.save', '<Primary>S'),
diff --git a/meld/filediff.py b/meld/filediff.py
index cc19d91b..be32d75f 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -293,8 +293,10 @@ class FileDiff(Gtk.VBox, MeldDoc):
             ('clear-sync-point', self.clear_sync_points),
             ('format-as-patch', self.action_format_as_patch),
             ('next-change', self.action_next_change),
+            ('next-pane', self.action_next_pane),
             ('open-external', self.action_open_external),
             ('previous-change', self.action_previous_change),
+            ('previous-pane', self.action_prev_pane),
             ('redo', self.action_redo),
             ('refresh', self.action_refresh),
             ('revert', self.action_revert),
@@ -591,10 +593,8 @@ class FileDiff(Gtk.VBox, MeldDoc):
         self.actiongroup.get_action("CopyRightUp").set_sensitive(copy_right)
         self.actiongroup.get_action("CopyRightDown").set_sensitive(copy_right)
 
-        prev_pane = pane > 0
-        next_pane = pane < self.num_panes - 1
-        self.actiongroup.get_action("PrevPane").set_sensitive(prev_pane)
-        self.actiongroup.get_action("NextPane").set_sensitive(next_pane)
+        self.set_action_enabled('previous-pane', pane > 0)
+        self.set_action_enabled('next-pane', pane < self.num_panes - 1)
         # FIXME: don't queue_draw() on everything... just on what changed
         self.queue_draw()
 
@@ -912,13 +912,11 @@ class FileDiff(Gtk.VBox, MeldDoc):
         new_line = self._corresponding_chunk_line(chunk, line, pane, new_pane)
         self.move_cursor(new_pane, new_line)
 
-    @Template.Callback()
     def action_prev_pane(self, *args):
         pane = self._get_focused_pane()
         new_pane = (pane - 1) % self.num_panes
         self.move_cursor_pane(pane, new_pane)
 
-    @Template.Callback()
     def action_next_pane(self, *args):
         pane = self._get_focused_pane()
         new_pane = (pane + 1) % self.num_panes
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 4c23a364..fdc1f735 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -87,10 +87,6 @@ class MeldWindow(Gtk.ApplicationWindow):
                 self.on_menu_go_to_line_activate),
 
             ("ChangesMenu", None, _("_Changes")),
-
-            ("ViewMenu", None, _("_View")),
-            ("FileStatus", None, _("File Status")),
-            ("VcStatus", None, _("Version Status")),
         )
         self.actiongroup = Gtk.ActionGroup(name='MainActions')
         self.actiongroup.set_translation_domain("meld")
diff --git a/meld/resources/gtk/help-overlay.ui b/meld/resources/gtk/help-overlay.ui
index 24175269..2fa886b0 100644
--- a/meld/resources/gtk/help-overlay.ui
+++ b/meld/resources/gtk/help-overlay.ui
@@ -60,40 +60,40 @@
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
             <property name="view">tab</property>
-            <property name="title" translatable="yes" context="shortcut window">Tabs</property>
-            <child>
-              <object class="GtkShortcutsShortcut">
-                <property name="visible">True</property>
-                <property name="accelerator">&lt;primary&gt;&lt;alt&gt;Page_Up</property>
-                <property name="title" translatable="yes" context="shortcut window">Go to previous 
tab</property>
-              </object>
-            </child>
+            <property name="title" translatable="yes" context="shortcut window">Panes</property>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
-                <property name="accelerator">&lt;primary&gt;&lt;alt&gt;Page_Down</property>
-                <property name="title" translatable="yes" context="shortcut window">Go to next tab</property>
+                <property name="accelerator">&lt;alt&gt;Page_Up</property>
+                <property name="title" translatable="yes" context="shortcut window">Previous comparison 
pane</property>
               </object>
             </child>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
-                <property name="accelerator">&lt;alt&gt;0...9</property>
-                <property name="title" translatable="yes" context="shortcut window">Switch to tab</property>
+                <property name="accelerator">&lt;alt&gt;Page_Down</property>
+                <property name="title" translatable="yes" context="shortcut window">Next comparison 
pane</property>
               </object>
             </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkShortcutsGroup">
+            <property name="visible">True</property>
+            <property name="view">tab</property>
+            <property name="title" translatable="yes" context="shortcut window">Changes</property>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
-                <property name="accelerator">&lt;shift&gt;&lt;primary&gt;&lt;alt&gt;Page_Up</property>
-                <property name="title" translatable="yes" context="shortcut window">Move tab left</property>
+                <property name="accelerator">&lt;alt&gt;Up</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to previous 
change</property>
               </object>
             </child>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
-                <property name="accelerator">&lt;shift&gt;&lt;primary&gt;&lt;alt&gt;Page_Down</property>
-                <property name="title" translatable="yes" context="shortcut window">Move tab right</property>
+                <property name="accelerator">&lt;alt&gt;Down</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to next 
change</property>
               </object>
             </child>
           </object>
@@ -102,19 +102,40 @@
           <object class="GtkShortcutsGroup">
             <property name="visible">True</property>
             <property name="view">tab</property>
-            <property name="title" translatable="yes" context="shortcut window">Changes</property>
+            <property name="title" translatable="yes" context="shortcut window">Tabs</property>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
-                <property name="accelerator">&lt;alt&gt;Up</property>
-                <property name="title" translatable="yes" context="shortcut window">Go to previous 
change</property>
+                <property name="accelerator">&lt;primary&gt;&lt;alt&gt;Page_Up</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to previous 
tab</property>
               </object>
             </child>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
-                <property name="accelerator">&lt;alt&gt;Down</property>
-                <property name="title" translatable="yes" context="shortcut window">Go to next 
change</property>
+                <property name="accelerator">&lt;primary&gt;&lt;alt&gt;Page_Down</property>
+                <property name="title" translatable="yes" context="shortcut window">Go to next tab</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="accelerator">&lt;alt&gt;0...9</property>
+                <property name="title" translatable="yes" context="shortcut window">Switch to tab</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="accelerator">&lt;shift&gt;&lt;primary&gt;&lt;alt&gt;Page_Up</property>
+                <property name="title" translatable="yes" context="shortcut window">Move tab left</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="accelerator">&lt;shift&gt;&lt;primary&gt;&lt;alt&gt;Page_Down</property>
+                <property name="title" translatable="yes" context="shortcut window">Move tab right</property>
               </object>
             </child>
           </object>
@@ -292,20 +313,6 @@
                 <property name="title" translatable="yes" context="shortcut window">Delete change</property>
               </object>
             </child>
-            <child>
-              <object class="GtkShortcutsShortcut">
-                <property name="visible">True</property>
-                <property name="accelerator">&lt;alt&gt;Page_Up</property>
-                <property name="title" translatable="yes" context="shortcut window">Previous comparison 
pane</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkShortcutsShortcut">
-                <property name="visible">True</property>
-                <property name="accelerator">&lt;alt&gt;Page_Down</property>
-                <property name="title" translatable="yes" context="shortcut window">Next comparison 
pane</property>
-              </object>
-            </child>
           </object>
         </child>
         <child>
diff --git a/meld/resources/ui/filediff.ui b/meld/resources/ui/filediff.ui
index 86fc9026..1a64814c 100644
--- a/meld/resources/ui/filediff.ui
+++ b/meld/resources/ui/filediff.ui
@@ -845,21 +845,5 @@
         <signal name="activate" handler="merge_all_non_conflicting_changes" swapped="no"/>
       </object>
     </child>
-    <child>
-      <object class="GtkAction" id="PrevPane">
-        <property name="label" translatable="yes">Previous Pane</property>
-        <property name="tooltip" translatable="yes">Move keyboard focus to the previous document in this 
comparison</property>
-        <signal name="activate" handler="action_prev_pane" swapped="no"/>
-      </object>
-      <accelerator key="Page_Up" modifiers="GDK_MOD1_MASK"/>
-    </child>
-    <child>
-      <object class="GtkAction" id="NextPane">
-        <property name="label" translatable="yes">Next Pane</property>
-        <property name="tooltip" translatable="yes">Move keyboard focus to the next document in this 
comparison</property>
-        <signal name="activate" handler="action_next_pane" swapped="no"/>
-      </object>
-      <accelerator key="Page_Down" modifiers="GDK_MOD1_MASK"/>
-    </child>
   </object>
 </interface>


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