[gnome-panel] panel-applets-manager: add get_standalone_menu



commit 22809aa94b0771581dacadbfd180a6c90a2a2b94
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Sep 17 15:13:20 2018 +0300

    panel-applets-manager: add get_standalone_menu

 .../libpanel-applet-private/gp-applet-manager.c    | 45 ++++++++++++++++++++++
 .../panel-applets-manager-dbus.c                   |  7 ++++
 gnome-panel/panel-applets-manager.c                | 21 ++++++++++
 gnome-panel/panel-applets-manager.h                |  4 ++
 4 files changed, 77 insertions(+)
---
diff --git a/gnome-panel/libpanel-applet-private/gp-applet-manager.c 
b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
index ab7578086..bc7e68b46 100644
--- a/gnome-panel/libpanel-applet-private/gp-applet-manager.c
+++ b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
@@ -24,6 +24,7 @@
 #include "libgnome-panel/gp-applet-info-private.h"
 #include "libgnome-panel/gp-initial-setup-dialog-private.h"
 #include "libgnome-panel/gp-module-private.h"
+#include "panel-lockdown.h"
 
 struct _GpAppletManager
 {
@@ -409,6 +410,49 @@ gp_applet_manager_open_initial_setup_dialog (PanelAppletsManager    *manager,
   return TRUE;
 }
 
+static GtkWidget *
+gp_applet_manager_get_standalone_menu (PanelAppletsManager *manager)
+{
+  GpAppletManager *applet_manager;
+  GSettings *general_settings;
+  gboolean enable_tooltips;
+  gboolean locked_down;
+  guint menu_icon_size;
+  GList *modules;
+  GList *l;
+  GtkWidget *menu;
+
+  applet_manager = GP_APPLET_MANAGER (manager);
+
+  general_settings = g_settings_new ("org.gnome.gnome-panel.general");
+
+  enable_tooltips = g_settings_get_boolean (general_settings, "enable-tooltips");
+  locked_down = panel_lockdown_get_panels_locked_down_s ();
+  menu_icon_size = g_settings_get_enum (general_settings, "menu-icon-size");
+
+  g_object_unref (general_settings);
+
+  modules = g_hash_table_get_values (applet_manager->modules);
+  menu = NULL;
+
+  for (l = modules; l != NULL; l = l->next)
+    {
+      GpModule *module;
+
+      module = GP_MODULE (l->data);
+
+      menu = gp_module_get_standalone_menu (module, enable_tooltips,
+                                            locked_down, menu_icon_size);
+
+      if (menu != NULL)
+        break;
+    }
+
+  g_list_free (modules);
+
+  return menu;
+}
+
 static void
 gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
 {
@@ -428,6 +472,7 @@ gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
   applets_manager_class->get_applet_widget = gp_applet_manager_get_applet_widget;
   applets_manager_class->get_new_iid = gp_applet_manager_get_new_iid;
   applets_manager_class->open_initial_setup_dialog = gp_applet_manager_open_initial_setup_dialog;
+  applets_manager_class->get_standalone_menu = gp_applet_manager_get_standalone_menu;
 }
 
 static void
diff --git a/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c 
b/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
index 55c8b12c6..3e1117809 100644
--- a/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
+++ b/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
@@ -554,6 +554,12 @@ panel_applets_manager_dbus_open_initial_setup_dialog (PanelAppletsManager    *ma
   return FALSE;
 }
 
+static GtkWidget *
+panel_applets_manager_dbus_get_standalone_menu (PanelAppletsManager *manager)
+{
+  return NULL;
+}
+
 static void
 panel_applets_manager_dbus_finalize (GObject *object)
 {
@@ -601,4 +607,5 @@ panel_applets_manager_dbus_class_init (PanelAppletsManagerDBusClass *class)
        manager_class->get_applet_widget = panel_applets_manager_dbus_get_applet_widget;
        manager_class->get_new_iid = panel_applets_manager_dbus_get_new_iid;
        manager_class->open_initial_setup_dialog = panel_applets_manager_dbus_open_initial_setup_dialog;
+       manager_class->get_standalone_menu = panel_applets_manager_dbus_get_standalone_menu;
 }
diff --git a/gnome-panel/panel-applets-manager.c b/gnome-panel/panel-applets-manager.c
index 1ce6da96a..83b9463f5 100644
--- a/gnome-panel/panel-applets-manager.c
+++ b/gnome-panel/panel-applets-manager.c
@@ -237,3 +237,24 @@ panel_applets_manager_open_initial_setup_dialog (const gchar            *iid,
 
        return ret;
 }
+
+GtkWidget *
+panel_applets_manager_get_standalone_menu (void)
+{
+       GSList *l;
+       PanelAppletsManager *manager;
+       GtkWidget *menu;
+
+       _panel_applets_managers_ensure_loaded ();
+
+       for (l = panel_applets_managers; l != NULL; l = l->next) {
+               manager = PANEL_APPLETS_MANAGER (l->data);
+
+               menu = PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_standalone_menu (manager);
+
+               if (menu != NULL)
+                       return menu;
+       }
+
+       return NULL;
+}
diff --git a/gnome-panel/panel-applets-manager.h b/gnome-panel/panel-applets-manager.h
index bfebcc023..8f3a75c5d 100644
--- a/gnome-panel/panel-applets-manager.h
+++ b/gnome-panel/panel-applets-manager.h
@@ -71,6 +71,8 @@ struct _PanelAppletsManagerClass {
                                                         GpInitialSetupCallback       callback,
                                                         gpointer                     user_data,
                                                         GDestroyNotify               free_func);
+
+       GtkWidget        * (*get_standalone_menu)   (PanelAppletsManager         *manager);
 };
 
 struct _PanelAppletsManager {
@@ -100,6 +102,8 @@ gboolean          panel_applets_manager_open_initial_setup_dialog   (const gchar
                                                                      gpointer                user_data,
                                                                      GDestroyNotify          free_func);
 
+GtkWidget        *panel_applets_manager_get_standalone_menu         (void);
+
 G_END_DECLS
 
 #endif /* __PANEL_APPLETS_MANAGER_H__ */


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