[meld/pathlabel] vcview: Move toolbar to actionbar and rearrange action buttons



commit 72d927ae8ed84d818161169fbc94c2ddc0e78603
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Aug 22 09:27:32 2021 +1000

    vcview: Move toolbar to actionbar and rearrange action buttons
    
    This is the first pass at a significant change to bring the version
    control UI into step with the folder and file comparison interfaces.

 meld/resources/ui/vcview.ui | 221 +++++++++++++++++++++++++-------------------
 meld/vcview.py              |  13 +--
 2 files changed, 134 insertions(+), 100 deletions(-)
---
diff --git a/meld/resources/ui/vcview.ui b/meld/resources/ui/vcview.ui
index e1b67ceb..96ceff49 100644
--- a/meld/resources/ui/vcview.ui
+++ b/meld/resources/ui/vcview.ui
@@ -6,167 +6,200 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <child>
-      <object class="GtkToolbar" id="file_toolbar">
+      <object class="GtkActionBar" id="file_toolbar">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="show_arrow">False</property>
-        <property name="icon_size">1</property>
-        <style>
-          <class name="meld-notebook-toolbar"/>
-        </style>
         <child>
-          <object class="GtkToolItem" id="fileentry_toolitem0">
+          <object class="MeldFileButton" id="file_open_button0">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="margin-start">4</property>
-            <property name="margin-end">12</property>
-            <child>
-              <object class="GtkFileChooserButton" id="fileentry">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="action">select-folder</property>
-                <signal name="file-set" handler="on_fileentry_file_set" swapped="no"/>
-              </object>
-            </child>
+            <property name="pane">0</property>
+            <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
+            <property name="local-only">True</property>
+            <property name="dialog_label">Select Folder</property>
+            <property name="tooltip_text" translatable="yes">Open version controlled folder in this 
pane</property>
+            <signal name="file-selected" handler="on_file_selected" swapped="no"/>
           </object>
-          <packing>
-            <property name="expand">False</property>
-          </packing>
         </child>
         <child>
-          <object class="GtkToolItem" id="fileentry_toolitem1">
+          <object class="GtkButton">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="margin-end">4</property>
+            <property name="action_name">view.vc-commit</property>
+            <property name="tooltip_text" translatable="yes">Commit changes to version control</property>
             <child>
-              <object class="GtkComboBox" id="combobox_vcs">
+              <object class="GtkLabel">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="model">liststore_vcs</property>
-                <property name="popup_fixed_width">False</property>
-                <signal name="changed" handler="on_vc_change" swapped="no"/>
-                <child>
-                  <object class="GtkCellRendererText">
-                    <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
-                    <property name="width-chars">12</property>
-                    <property name="max-width-chars">30</property>
-                  </object>
-                  <attributes>
-                    <attribute name="text">0</attribute>
-                    <attribute name="sensitive">2</attribute>
-                  </attributes>
-                </child>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkToolItem">
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkModelButton">
-                <property name="visible">True</property>
-                <property name="action_name">view.vc-commit</property>
-                <property name="text" translatable="yes">Commit…</property>
-                <property name="tooltip_text" translatable="yes">Commit changes to version control</property>
+                <property name="label" translatable="yes">Commit…</property>
               </object>
             </child>
           </object>
         </child>
         <child>
-          <object class="GtkToolItem">
+          <object class="GtkBox">
             <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="homogeneous">True</property>
+            <style>
+              <class name="linked"/>
+            </style>
             <child>
-              <object class="GtkModelButton">
+              <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="action_name">view.vc-update</property>
-                <property name="text" translatable="yes">Pull</property>
                 <property name="tooltip_text" translatable="yes">Pull remote changes to the local 
repository</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">vc-pull-symbolic</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
               </object>
             </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkToolItem">
-            <property name="visible">True</property>
             <child>
-              <object class="GtkModelButton">
+              <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="action_name">view.vc-push</property>
-                <property name="text" translatable="yes">Push</property>
                 <property name="tooltip_text" translatable="yes">Push local changes to remote</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">vc-push-symbolic</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>
         </child>
         <child>
-          <object class="GtkToolItem">
+          <object class="GtkBox">
             <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="homogeneous">True</property>
+            <style>
+              <class name="linked"/>
+            </style>
             <child>
-              <object class="GtkModelButton">
+              <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="action_name">view.vc-add</property>
-                <property name="text" translatable="yes">Add</property>
                 <property name="tooltip_text" translatable="yes">Add to version control</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">list-add-symbolic</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
               </object>
             </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkToolItem">
-            <property name="visible">True</property>
             <child>
-              <object class="GtkModelButton">
+              <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="action_name">view.vc-remove</property>
-                <property name="text" translatable="yes">Remove</property>
                 <property name="tooltip_text" translatable="yes">Remove from version control</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">list-remove-symbolic</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
               </object>
             </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkToolItem">
-            <property name="visible">True</property>
             <child>
-              <object class="GtkModelButton">
+              <object class="GtkButton">
                 <property name="visible">True</property>
-                <property name="action_name">view.vc-resolve</property>
-                <property name="text" translatable="yes">Mark as Resolved</property>
-                <property name="tooltip_text" translatable="yes">Mark as resolved in version 
control</property>
+                <property name="action_name">view.vc-revert</property>
+                <property name="tooltip_text" translatable="yes">Revert working copy to original 
state</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">document-revert-symbolic</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton">
+                <property name="visible">True</property>
+                <property name="action_name">view.vc-delete-locally</property>
+                <property name="tooltip_text" translatable="yes">Delete from working copy</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">edit-delete-symbolic</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>
         </child>
         <child>
-          <object class="GtkToolItem">
+          <object class="GtkButton">
             <property name="visible">True</property>
+            <property name="action_name">view.vc-resolve</property>
+            <property name="tooltip_text" translatable="yes">Mark as resolved in version control</property>
             <child>
-              <object class="GtkModelButton">
+              <object class="GtkLabel">
                 <property name="visible">True</property>
-                <property name="action_name">view.vc-revert</property>
-                <property name="text" translatable="yes">Revert</property>
-                <property name="tooltip_text" translatable="yes">Revert working copy to original 
state</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Resolve Conflict</property>
               </object>
             </child>
           </object>
         </child>
-        <child>
-          <object class="GtkToolItem">
+        <child type="center">
+          <object class="GtkBox">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin-start">6</property>
+            <property name="margin-end">6</property>
+            <property name="orientation">horizontal</property>
             <child>
-              <object class="GtkModelButton">
+              <object class="PathLabel" id="filelabel">
                 <property name="visible">True</property>
-                <property name="action_name">view.vc-delete-locally</property>
-                <property name="text" translatable="yes">Delete</property>
-                <property name="tooltip_text" translatable="yes">Delete from working copy</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">File 1</property>
+                <property name="icon-name">text-x-generic-symbolic</property>
+                <style>
+                  <class name="flat"/>
+                </style>
               </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="combobox_vcs">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="model">liststore_vcs</property>
+                <property name="popup_fixed_width">False</property>
+                <signal name="changed" handler="on_vc_change" swapped="no"/>
+                <child>
+                  <object class="GtkCellRendererText">
+                    <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
+                    <property name="width-chars">12</property>
+                    <property name="max-width-chars">30</property>
+                  </object>
+                  <attributes>
+                    <attribute name="text">0</attribute>
+                    <attribute name="sensitive">2</attribute>
+                  </attributes>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
             </child>
           </object>
         </child>
+        <style>
+          <class name="meld-actionbar"/>
+        </style>
       </object>
       <packing>
         <property name="expand">False</property>
diff --git a/meld/vcview.py b/meld/vcview.py
index d6978ed6..2a107034 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -158,7 +158,7 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
     emblem_renderer = Gtk.Template.Child()
     extra_column = Gtk.Template.Child()
     extra_renderer = Gtk.Template.Child()
-    fileentry = Gtk.Template.Child()
+    filelabel = Gtk.Template.Child()
     liststore_vcs = Gtk.Template.Child()
     location_column = Gtk.Template.Child()
     location_renderer = Gtk.Template.Child()
@@ -374,7 +374,7 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
         self.location = location
         self.current_path = None
         self.model.clear()
-        self.fileentry.set_filename(location)
+        self.filelabel.props.gfile = Gio.File.new_for_path(location)
         it = self.model.add_entries(None, [location])
         self.treeview.grab_focus()
         self.treeview.get_selection().select_iter(it)
@@ -492,9 +492,10 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
 
     # TODO: This doesn't fire when the user selects a shortcut folder
     @Gtk.Template.Callback()
-    def on_fileentry_file_set(self, fileentry):
-        directory = fileentry.get_file()
-        path = directory.get_path()
+    def on_file_selected(
+            self, button: Gtk.Button, pane: int, file: Gio.File) -> None:
+
+        path = file.get_path()
         self.set_location(path)
 
     def on_delete_event(self):
@@ -917,7 +918,7 @@ class VcView(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
         self.next_diff(Gdk.ScrollDirection.DOWN)
 
     def action_refresh(self, *args):
-        self.on_fileentry_file_set(self.fileentry)
+        self.set_location(self.location)
 
     def action_find(self, *args):
         self.treeview.emit("start-interactive-search")


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