diff options
-rw-r--r-- | libmate-panel-applet/mate-panel-applet.c | 7 | ||||
-rw-r--r-- | mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c | 29 | ||||
-rw-r--r-- | mate-panel/panel-applets-manager.c | 20 | ||||
-rw-r--r-- | mate-panel/panel-applets-manager.h | 7 |
4 files changed, 63 insertions, 0 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index c2e0e476..bf7a1f35 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -2454,3 +2454,10 @@ mate_panel_applet_get_object_path (MatePanelApplet *applet) { return applet->priv->object_path; } + +G_MODULE_EXPORT GtkWidget * +mate_panel_applet_get_applet_widget (const gchar *factory_id, + guint uid) +{ + return mate_panel_applet_factory_get_applet_widget (factory_id, uid); +} diff --git a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c index 695f66fb..43263dae 100644 --- a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c +++ b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c @@ -46,6 +46,8 @@ struct _MatePanelAppletsManagerDBusPrivate }; typedef gint (* ActivateAppletFunc) (void); +typedef GtkWidget * (* GetAppletWidgetFunc) (const gchar *factory_id, + guint uid); typedef struct _MatePanelAppletFactoryInfo { gchar *id; @@ -53,6 +55,7 @@ typedef struct _MatePanelAppletFactoryInfo { gboolean in_process; GModule *module; ActivateAppletFunc activate_applet; + GetAppletWidgetFunc get_applet_widget; guint n_applets; gchar *srcdir; @@ -395,6 +398,7 @@ mate_panel_applets_manager_dbus_factory_activate (MatePanelAppletsManager *manag { MatePanelAppletFactoryInfo *info; ActivateAppletFunc activate_applet; + GetAppletWidgetFunc get_applet_widget; info = get_applet_factory_info (manager, iid); if (!info) @@ -434,6 +438,15 @@ mate_panel_applets_manager_dbus_factory_activate (MatePanelAppletsManager *manag return FALSE; } + if (!g_module_symbol (info->module, "mate_panel_applet_get_applet_widget", (gpointer *) &get_applet_widget)) { + /* FIXME: use a GError? */ + g_warning ("Failed to load applet %s: %s", iid, g_module_error ()); + g_module_close (info->module); + info->module = NULL; + + return FALSE; + } + /* Activate the applet */ if (activate_applet () != 0) { /* FIXME: use a GError? */ @@ -444,6 +457,7 @@ mate_panel_applets_manager_dbus_factory_activate (MatePanelAppletsManager *manag return FALSE; } info->activate_applet = activate_applet; + info->get_applet_widget = get_applet_widget; info->n_applets = 1; @@ -550,6 +564,20 @@ mate_panel_applets_manager_dbus_load_applet (MatePanelAppletsManager *ma return mate_panel_applet_frame_dbus_load (iid, frame_act); } +static GtkWidget * +mate_panel_applets_manager_dbus_get_applet_widget (MatePanelAppletsManager *manager, + const gchar *iid, + guint uid) +{ + MatePanelAppletFactoryInfo *info; + + info = get_applet_factory_info (manager, iid); + if (!info) + return NULL; + + return info->get_applet_widget (info->id, uid); +} + static void mate_panel_applets_manager_dbus_finalize (GObject *object) { @@ -598,6 +626,7 @@ mate_panel_applets_manager_dbus_class_init (MatePanelAppletsManagerDBusClass *cl manager_class->get_applet_info = mate_panel_applets_manager_dbus_get_applet_info; manager_class->get_applet_info_from_old_id = mate_panel_applets_manager_dbus_get_applet_info_from_old_id; manager_class->load_applet = mate_panel_applets_manager_dbus_load_applet; + manager_class->get_applet_widget = mate_panel_applets_manager_dbus_get_applet_widget; g_type_class_add_private (class, sizeof (MatePanelAppletsManagerDBusPrivate)); } diff --git a/mate-panel/panel-applets-manager.c b/mate-panel/panel-applets-manager.c index 9568327e..23b43f0c 100644 --- a/mate-panel/panel-applets-manager.c +++ b/mate-panel/panel-applets-manager.c @@ -199,3 +199,23 @@ mate_panel_applets_manager_load_applet (const gchar *iid, return FALSE; } + +GtkWidget * +mate_panel_applets_manager_get_applet_widget (const gchar *iid, + guint uid) +{ + GSList *l; + + _mate_panel_applets_managers_ensure_loaded (); + + for (l = mate_panel_applets_managers; l != NULL; l = l->next) { + MatePanelAppletsManager *manager = MATE_PANEL_APPLETS_MANAGER (l->data); + + if (!MATE_PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applet_info (manager, iid)) + continue; + + return MATE_PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applet_widget (manager, iid, uid); + } + + return NULL; +} diff --git a/mate-panel/panel-applets-manager.h b/mate-panel/panel-applets-manager.h index 5ea82bf8..d2c5e2e8 100644 --- a/mate-panel/panel-applets-manager.h +++ b/mate-panel/panel-applets-manager.h @@ -68,6 +68,10 @@ struct _MatePanelAppletsManagerClass { gboolean (*load_applet) (MatePanelAppletsManager *manager, const gchar *iid, MatePanelAppletFrameActivating *frame_act); + + GtkWidget * (*get_applet_widget) (MatePanelAppletsManager *manager, + const gchar *iid, + guint uid); }; struct _MatePanelAppletsManager { @@ -87,6 +91,9 @@ MatePanelAppletInfo *mate_panel_applets_manager_get_applet_info_from_old_id (co gboolean mate_panel_applets_manager_load_applet (const gchar *iid, MatePanelAppletFrameActivating *frame_act); +GtkWidget *mate_panel_applets_manager_get_applet_widget (const gchar *iid, + guint uid); + #ifdef __cplusplus } #endif |