[meld/ui-next] filediff: Move the copy actions into a popover



commit caff52872e1220cd472c63846804ca541923669e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Mar 2 11:02:07 2019 +1000

    filediff: Move the copy actions into a popover
    
    These are less in common use, they take up a *lot* of visual space, and
    they're already available via both shortcuts and action gutter
    interaction.

 meld/filediff.py                    |  11 ++++
 meld/resources/ui/filediff-menus.ui |  24 +++++++++
 meld/resources/ui/filediff.ui       | 100 ++++++++++--------------------------
 3 files changed, 62 insertions(+), 73 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index cb610f0a..3f5e22cf 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -125,6 +125,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
     actiongutter1 = Template.Child()
     actiongutter2 = Template.Child()
     actiongutter3 = Template.Child()
+    copy_action_button = Template.Child()
     dummy_toolbar_actiongutter0 = Template.Child()
     dummy_toolbar_actiongutter1 = Template.Child()
     dummy_toolbar_actiongutter2 = Template.Child()
@@ -415,6 +416,16 @@ class FileDiff(Gtk.VBox, MeldDoc):
 
         self.connect("notify::ignore-blank-lines", self.refresh_comparison)
 
+    def do_realize(self):
+        Gtk.VBox().do_realize(self)
+
+        builder = Gtk.Builder.new_from_resource(
+            '/org/gnome/meld/ui/filediff-menus.ui')
+        filter_menu = builder.get_object('file-copy-actions-menu')
+
+        self.copy_action_button.set_popover(
+            Gtk.Popover.new_from_model(self.copy_action_button, filter_menu))
+
     def get_keymask(self):
         return self._keymask
 
diff --git a/meld/resources/ui/filediff-menus.ui b/meld/resources/ui/filediff-menus.ui
new file mode 100644
index 00000000..768149cf
--- /dev/null
+++ b/meld/resources/ui/filediff-menus.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <menu id="file-copy-actions-menu">
+    <section>
+      <attribute name="id">status-section</attribute>
+      <item>
+        <attribute name="label">Copy change above the left chunk</attribute>
+        <attribute name="action">view.file-copy-left-up</attribute>
+      </item>
+      <item>
+        <attribute name="label">Copy change below the left chunk</attribute>
+        <attribute name="action">view.file-copy-left-down</attribute>
+      </item>
+      <item>
+        <attribute name="label">Copy change above the right chunk</attribute>
+        <attribute name="action">view.file-copy-right-up</attribute>
+      </item>
+      <item>
+        <attribute name="label">Copy change below the right chunk</attribute>
+        <attribute name="action">view.file-copy-right-down</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/meld/resources/ui/filediff.ui b/meld/resources/ui/filediff.ui
index 72bf3a91..34361cb3 100644
--- a/meld/resources/ui/filediff.ui
+++ b/meld/resources/ui/filediff.ui
@@ -151,86 +151,19 @@
           </packing>
         </child>
         <child>
-          <object class="GtkButton">
-            <property name="visible">True</property>
-            <property name="action-name">view.file-copy-left-up</property>
-            <property name="use-action-appearance">False</property>
-            <property name="tooltip-text">Copy change above the left chunk</property>
+          <object class="GtkMenuButton" id="copy_action_button">
+            <property name="visible">true</property>
             <property name="focus_on_click">False</property>
+            <property name="tooltip-text">Copy chunks</property>
+            <property name="use_popover">True</property>
             <style>
               <class name="image-button"/>
             </style>
             <child>
               <object class="GtkImage">
                 <property name="visible">True</property>
-                <property name="icon-name">view-list-symbolic</property>
-                <property name="icon-size">1</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="pack-type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton">
-            <property name="visible">True</property>
-            <property name="action-name">view.file-copy-left-down</property>
-            <property name="use-action-appearance">False</property>
-            <property name="tooltip-text">Copy change below the left chunk</property>
-            <property name="focus_on_click">False</property>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="icon-name">view-list-symbolic</property>
-                <property name="icon-size">1</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="pack-type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton">
-            <property name="visible">True</property>
-            <property name="action-name">view.file-copy-right-up</property>
-            <property name="use-action-appearance">False</property>
-            <property name="tooltip-text">Copy change above the right chunk</property>
-            <property name="focus_on_click">False</property>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="icon-name">view-list-symbolic</property>
-                <property name="icon-size">1</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="pack-type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton">
-            <property name="visible">True</property>
-            <property name="action-name">view.file-copy-right-down</property>
-            <property name="use-action-appearance">False</property>
-            <property name="tooltip-text">Copy change below the right chunk</property>
-            <property name="focus_on_click">False</property>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="icon-name">view-list-symbolic</property>
-                <property name="icon-size">1</property>
+                <property name="icon-name">edit-copy-symbolic</property>
+                <property name="visible">true</property>
               </object>
             </child>
           </object>
@@ -983,4 +916,25 @@
       </packing>
     </child>
   </template>
+  <menu id="file-copy-actions-menu">
+    <section>
+      <attribute name="id">status-section</attribute>
+      <item>
+        <attribute name="label">Copy change above the left chunk</attribute>
+        <attribute name="action">view.file-copy-left-up</attribute>
+      </item>
+      <item>
+        <attribute name="label">Copy change below the left chunk</attribute>
+        <attribute name="action">view.file-copy-left-down</attribute>
+      </item>
+      <item>
+        <attribute name="label">Copy change above the right chunk</attribute>
+        <attribute name="action">view.file-copy-right-up</attribute>
+      </item>
+      <item>
+        <attribute name="label">Copy change below the right chunk</attribute>
+        <attribute name="action">view.file-copy-right-down</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>


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