[gnome-boxes/move-snapshot-actions-to-row] preferences, snapshot-list-row: Add snapshot action buttons




commit a8fd83b320cc5733d1de5835e6f8747c56da3f4e
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jan 4 16:59:35 2022 +0100

    preferences, snapshot-list-row: Add snapshot action buttons
    
    Instead of the popover menu we can actually fit the buttons within
    the row. This is a better use of horizontal space.

 data/ui/preferences/snapshot-list-row.ui | 68 +++++++++++++++++++++-----------
 src/preferences/snapshot-list-row.vala   | 19 +++------
 2 files changed, 50 insertions(+), 37 deletions(-)
---
diff --git a/data/ui/preferences/snapshot-list-row.ui b/data/ui/preferences/snapshot-list-row.ui
index 0fec01fe..ac1b2e99 100644
--- a/data/ui/preferences/snapshot-list-row.ui
+++ b/data/ui/preferences/snapshot-list-row.ui
@@ -1,24 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <menu id="actions_menu">
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">Revert to this state</attribute>
-        <attribute name="action">snap.revert-to</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Rename</attribute>
-        <attribute name="action">snap.rename</attribute>
-      </item>
-    </section>
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">Delete</attribute>
-        <attribute name="action">snap.delete</attribute>
-      </item>
-    </section>
-  </menu>
-
   <template class="BoxesSnapshotListRow" parent="HdyActionRow">
     <property name="visible">True</property>
     <property name="activatable">False</property>
@@ -73,17 +54,56 @@
             </child>
 
             <child>
-              <object class="GtkMenuButton" id="more_button">
+              <object class="GtkBox" id="suffixes">
                 <property name="visible">true</property>
-                <property name="menu_model">actions_menu</property>
                 <property name="valign">center</property>
+                <property name="halign">end</property>
                 <style>
-                  <class name="flat" />
+                  <class name="linked"/>
                 </style>
+
                 <child>
-                  <object class="GtkImage">
+                  <object class="GtkButton">
+                    <property name="visible">true</property>
+                    <property name="tooltip-text" translatable="yes">Revert to snapshot</property>
+                    <signal name="clicked" handler="on_revert_button_clicked"/>
+
+                    <child>
+                      <object class="GtkImage">
+                        <property name="visible">true</property>
+                        <property name="icon-name">document-revert-symbolic</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkButton">
+                    <property name="visible">true</property>
+                    <property name="tooltip-text" translatable="yes">Rename snapshot</property>
+                    <signal name="clicked" handler="on_rename_button_clicked"/>
+
+                    <child>
+                      <object class="GtkImage">
+                        <property name="visible">true</property>
+                        <property name="icon-name">document-edit-symbolic</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+
+                <child>
+                  <object class="GtkButton">
                     <property name="visible">true</property>
-                    <property name="icon-name">view-more-symbolic</property>
+                    <property name="tooltip-text" translatable="yes">Delete snapshot</property>
+                    <signal name="clicked" handler="on_delete_button_clicked"/>
+
+                    <child>
+                      <object class="GtkImage">
+                        <property name="visible">true</property>
+                        <property name="icon-name">edit-delete-symbolic</property>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>
diff --git a/src/preferences/snapshot-list-row.vala b/src/preferences/snapshot-list-row.vala
index 639603df..7c0a28f8 100644
--- a/src/preferences/snapshot-list-row.vala
+++ b/src/preferences/snapshot-list-row.vala
@@ -24,12 +24,6 @@
     private Boxes.LibvirtMachine machine;
     private unowned Gtk.Container? parent_container = null;
 
-    private const GLib.ActionEntry[] action_entries = {
-        {"revert-to", revert_to_activated},
-        {"rename",    rename_activated},
-        {"delete",    delete_activated}
-    };
-
     construct {
         this.parent_set.connect (() => {
             var parent = get_parent () as Gtk.Container;
@@ -51,10 +45,6 @@ public SnapshotListRow (GVir.DomainSnapshot snapshot,
         } catch (GLib.Error e) {
             critical (e.message);
         }
-
-        var action_group = new GLib.SimpleActionGroup ();
-        action_group.add_action_entries (action_entries, this);
-        this.insert_action_group ("snap", action_group);
     }
 
     private void setup_labels (GVirConfig.DomainSnapshot config, string? name = null) {
@@ -84,7 +74,8 @@ private void on_save_name_button_clicked () {
     }
 
 
-    private void revert_to_activated (GLib.SimpleAction action, GLib.Variant? v) {
+    [GtkCallback]
+    private void on_revert_button_clicked () {
         var snapshot_name = this.snapshot.get_name ();
         var snapshot_state = GVirConfig.DomainSnapshotDomainState.NOSTATE;
 
@@ -121,7 +112,8 @@ private void revert_to_activated (GLib.SimpleAction action, GLib.Variant? v) {
     }
 
 
-    private void delete_activated (GLib.SimpleAction action, GLib.Variant? v) {
+    [GtkCallback]
+    private void on_delete_button_clicked () {
         string snapshot_identifier = snapshot.get_name ();
         try {
             var config = snapshot.get_config (0);
@@ -161,7 +153,8 @@ private void delete_activated (GLib.SimpleAction action, GLib.Variant? v) {
         deletion_requested (toast);
     }
 
-    private void rename_activated (GLib.SimpleAction action, GLib.Variant? v) {
+    [GtkCallback]
+    private void on_rename_button_clicked () {
         name_entry.text = name_label.get_text ();
         mode_stack.visible_child = edit_name_box;
         name_entry.grab_focus ();


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