[fractal] add_room_menu: Use menu model



commit 784b45c537d6f3bc289aaf2c11feffc741d6e8c1
Author: Christopher Davis <brainblasted disroot org>
Date:   Sat Oct 31 14:39:23 2020 -0700

    add_room_menu: Use menu model
    
    Instead of manually building the menu,
    we can use a menu model. In GTK4 ModelButton
    is private, so menu models are the way
    to create proper menus for popovers.

 fractal-gtk/res/ui/add_room_menu.ui | 109 ++++++++----------------------------
 fractal-gtk/res/ui/main_window.ui   |   2 +-
 2 files changed, 23 insertions(+), 88 deletions(-)
---
diff --git a/fractal-gtk/res/ui/add_room_menu.ui b/fractal-gtk/res/ui/add_room_menu.ui
index edcb92b0..8453efcf 100644
--- a/fractal-gtk/res/ui/add_room_menu.ui
+++ b/fractal-gtk/res/ui/add_room_menu.ui
@@ -2,91 +2,26 @@
 <!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.20"/>
-  <object class="GtkPopoverMenu" id="add_room_popover">
-    <property name="can_focus">False</property>
-    <child>
-      <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="margin_top">6</property>
-        <property name="margin_bottom">6</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GtkModelButton" id="directory_menu">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="action_name">app.directory</property>
-            <property name="text" translatable="yes">Room Directory</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkModelButton" id="join_room_menu">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="action_name">app.join_room</property>
-            <property name="text" translatable="yes">Join Room</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkSeparator">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="margin_top">3</property>
-            <property name="margin_bottom">3</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkModelButton" id="new_room_menu">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="action_name">app.new_room</property>
-            <property name="text" translatable="yes">New Room</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">3</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkModelButton" id="start_chat_menu">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="action_name">app.start_chat</property>
-            <property name="text" translatable="yes">New Direct Chat</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">4</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="submenu">main</property>
-        <property name="position">1</property>
-      </packing>
-    </child>
-  </object>
+  <menu id="add_room_menu_model">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Room Directory</attribute>
+        <attribute name="action">app.directory</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Join Room</attribute>
+        <attribute name="action">app.join_room</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">New Room</attribute>
+        <attribute name="action">app.new_room</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">New Direct Chat</attribute>
+        <attribute name="action">app.start_chat</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>
diff --git a/fractal-gtk/res/ui/main_window.ui b/fractal-gtk/res/ui/main_window.ui
index d0a6624c..3ced6bb6 100644
--- a/fractal-gtk/res/ui/main_window.ui
+++ b/fractal-gtk/res/ui/main_window.ui
@@ -67,7 +67,7 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
-                                <property name="popover">add_room_popover</property>
+                                <property name="menu_model">add_room_menu_model</property>
                                 <child>
                                   <object class="GtkImage">
                                     <property name="visible">True</property>


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