From 9b30676bf6d4d5cd748c75631192f0aa3e0a356d Mon Sep 17 00:00:00 2001 From: Lionel Le Folgoc Date: Mon, 21 Feb 2011 19:25:19 +0100 Subject: Add entry_{added,removed} signal handlers Without them, some applications such as network-manager-applet and transmission will not appear in the panel. --- panel-plugin/indicator.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/panel-plugin/indicator.c b/panel-plugin/indicator.c index b769297..1c66999 100644 --- a/panel-plugin/indicator.c +++ b/panel-plugin/indicator.c @@ -308,6 +308,50 @@ indicator_construct (XfcePanelPlugin *plugin) } +static void +entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) +{ + GtkWidget * menuitem = gtk_menu_item_new(); + GtkWidget * hbox = gtk_hbox_new(FALSE, 3); + + if (entry->image != NULL) + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->image), FALSE, FALSE, 0); + + if (entry->label != NULL) + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->label), FALSE, FALSE, 0); + + gtk_container_add(GTK_CONTAINER(menuitem), hbox); + gtk_widget_show(hbox); + + if (entry->menu != NULL) + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu)); + + gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem); + gtk_widget_show(menuitem); + + g_object_set_data(G_OBJECT(menuitem), "indicator-custom-entry-data", entry); +} + + +static void +entry_removed_cb (GtkWidget * widget, gpointer userdata) +{ + gpointer data = g_object_get_data(G_OBJECT(widget), "indicator-custom-entry-data"); + + if (data != userdata) + return; + + gtk_widget_destroy(widget); +} + + +static void +entry_removed (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) +{ + gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry); +} + + static gboolean load_module (const gchar * name, GtkWidget * menu) { @@ -323,6 +367,11 @@ load_module (const gchar * name, GtkWidget * menu) IndicatorObject * io = indicator_object_new_from_file(fullpath); g_free(fullpath); + g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, + G_CALLBACK(entry_added), menu); + g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, + G_CALLBACK(entry_removed), menu); + GList * entries = indicator_object_get_entries(io); GList * entry = NULL; -- 1.7.4.1