[gnome-panel] action-protocol: add support for menus built as applet



commit 9efa2bb010fc85d1e744008d5b274e5ce4bb4379
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Jan 11 18:46:43 2018 +0200

    action-protocol: add support for menus built as applet

 gnome-panel/applet.c                |   29 +++++++++++++++++++++++++++++
 gnome-panel/applet.h                |    2 ++
 gnome-panel/panel-action-protocol.c |    3 +++
 3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index 06c02d9..67ef19f 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -14,6 +14,7 @@
 #include <glib/gi18n.h>
 #include <gdk/gdkx.h>
 
+#include <libgnome-panel/gp-main-menu-private.h>
 #include <libpanel-util/panel-glib.h>
 #include <libpanel-util/panel-show.h>
 
@@ -889,6 +890,34 @@ panel_applet_get_by_type (PanelObjectType object_type, GdkScreen *screen)
        return NULL;
 }
 
+gboolean
+panel_applet_activate_main_menu (guint32 activate_time)
+{
+  GSList *l;
+
+  for (l = registered_applets; l != NULL; l = l->next)
+    {
+      AppletInfo *info;
+      GtkWidget *applet;
+
+      info = l->data;
+      if (info->type != PANEL_OBJECT_APPLET)
+        continue;
+
+      applet = gtk_bin_get_child (GTK_BIN (info->widget));
+      if (applet == NULL)
+        continue;
+
+      if (!g_type_is_a (G_TYPE_FROM_INSTANCE (applet), GP_TYPE_MAIN_MENU))
+        continue;
+
+      if (gp_main_menu_activate (GP_MAIN_MENU (applet), activate_time))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
 AppletInfo *
 panel_applet_register (GtkWidget       *applet,
                       PanelWidget     *panel,
diff --git a/gnome-panel/applet.h b/gnome-panel/applet.h
index beab5c7..878a9e8 100644
--- a/gnome-panel/applet.h
+++ b/gnome-panel/applet.h
@@ -57,6 +57,8 @@ const char *panel_applet_get_id_by_widget (GtkWidget       *widget);
 AppletInfo *panel_applet_get_by_id        (const char      *id);
 AppletInfo *panel_applet_get_by_type      (PanelObjectType  object_type, GdkScreen *screen);
 
+gboolean    panel_applet_activate_main_menu (guint32 activate_time);
+
 GSList     *panel_applet_list_applets (void);
 
 void        panel_applet_clean        (AppletInfo    *info);
diff --git a/gnome-panel/panel-action-protocol.c b/gnome-panel/panel-action-protocol.c
index e9b052b..2772f9c 100644
--- a/gnome-panel/panel-action-protocol.c
+++ b/gnome-panel/panel-action-protocol.c
@@ -51,6 +51,9 @@ panel_action_protocol_main_menu (GdkScreen *screen,
        GtkWidget   *menu;
        AppletInfo  *info;
 
+       if (panel_applet_activate_main_menu (activate_time))
+               return;
+
        info = panel_applet_get_by_type (PANEL_OBJECT_MENU_BAR, screen);
        if (info) {
                panel_menu_bar_popup_menu (PANEL_MENU_BAR (info->widget),


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