[gnome-boxes/refactor-thumbs: 4/5] list-view-row: Add popover menu to advertize row options




commit 1a8b6c852ec04ee7ff198cd4241e054ca8ee2c6d
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jan 4 12:14:13 2022 +0100

    list-view-row: Add popover menu to advertize row options
    
    It is unclear to users that they can get options with right-click.
    So adding an explicit row menu helps.

 data/ui/list-view-row.ui | 20 +++++++++++++++++++-
 src/list-view-row.vala   | 12 ++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/list-view-row.ui b/data/ui/list-view-row.ui
index 01776927..7bcc2452 100644
--- a/data/ui/list-view-row.ui
+++ b/data/ui/list-view-row.ui
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.9 -->
   <template class="BoxesListViewRow" parent="HdyActionRow">
     <property name="visible">True</property>
     <property name="margin">8</property>
@@ -15,5 +14,24 @@
         <property name="height-request">45</property>
       </object>
     </child>
+
+    <child>
+      <object class="GtkButton" id="menu_button">
+        <property name="visible">True</property>
+        <property name="halign">end</property>
+        <property name="valign">center</property>
+        <signal name="clicked" handler="pop_menu"/>
+        <style>
+          <class name="flat"/>
+        </style>
+
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">view-more-symbolic</property>
+          </object>
+        </child>
+      </object>
+    </child>
   </template>
 </interface>
diff --git a/src/list-view-row.vala b/src/list-view-row.vala
index f182b5b3..4f97d053 100644
--- a/src/list-view-row.vala
+++ b/src/list-view-row.vala
@@ -10,6 +10,9 @@
 
     [GtkChild]
     public unowned Boxes.Thumbnail thumbnail;
+    [GtkChild]
+    public unowned Gtk.Button menu_button;
+    private Boxes.ActionsPopover context_popover;
 
     public ListViewRow (CollectionItem item) {
         this.item = item;
@@ -27,6 +30,8 @@ public ListViewRow (CollectionItem item) {
 
         // This is a hack to align the "title" next to the "thumbnail".
         activatable_widget.get_parent ().hexpand = false;
+
+        context_popover = new Boxes.ActionsPopover (machine.window);
     }
 
     private void update_thumbnail () {
@@ -54,4 +59,11 @@ private void update_status () {
 
         subtitle = _("Powered Off");
     }
+
+    [GtkCallback]
+    public void pop_menu () {
+        context_popover.update_for_item (item);
+        context_popover.relative_to = menu_button;
+        context_popover.show ();
+    }
 }


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