[gnome-characters/bilelmoussaoui/gtk4: 73/76] window: re-add the show primary menu shortcut




commit 080aedd1fbe193fbed02859808a71e64d168c9a2
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Fri Nov 26 08:25:33 2021 +0100

    window: re-add the show primary menu shortcut
    
    GtkMenuButton is no longer Actionable

 data/window.ui |  2 +-
 src/window.js  | 14 +++++---------
 2 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/data/window.ui b/data/window.ui
index 095ebd0..54bf4d1 100644
--- a/data/window.ui
+++ b/data/window.ui
@@ -38,7 +38,7 @@
                   </object>
                 </child>
                 <child type="end">
-                  <object class="GtkMenuButton">
+                  <object class="GtkMenuButton" id="primaryMenuButton">
                     <property name="menu-model">primary_menu</property>
                     <property name="icon-name">open-menu-symbolic</property>
                   </object>
diff --git a/src/window.js b/src/window.js
index 9153407..06c4205 100644
--- a/src/window.js
+++ b/src/window.js
@@ -37,7 +37,7 @@ var MainWindow = GObject.registerClass({
         'searchButton', 'search-bar', 'searchEntry', 'back-button',
         'container', 'sidebar', 'loadingSpinner',
         'leaflet', 'mainStack', 'windowTitle',
-        'charactersView', 'scrolledWindow',
+        'charactersView', 'scrolledWindow', 'primaryMenuButton',
     ],
     Properties: {
         'max-recent-characters': GObject.ParamSpec.uint(
@@ -85,11 +85,7 @@ var MainWindow = GObject.registerClass({
                     this._searchButton.active = !this._searchButton.active;
                 },
             },
-            {
-                name: 'show-primary-menu',
-                activate: this._togglePrimaryMenu,
-                state: new GLib.Variant('b', false),
-            },
+            { name: 'show-primary-menu', activate: this._showPrimaryMenu },
         ]);
 
         this._searchButton.bind_property('active',
@@ -143,9 +139,9 @@ var MainWindow = GObject.registerClass({
             this._sidebar.selectRowByName('smileys');
     }
 
-    _togglePrimaryMenu(action) {
-        let state = action.get_state().get_boolean();
-        action.set_state(GLib.Variant.new_boolean(!state));
+    _showPrimaryMenu() {
+        const popover = this._primaryMenuButton.get_popover();
+        popover.popup();
     }
 
     set searchActive(v) {


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