From 08d36bb3c715d57694d1bb447e09264620c6145c Mon Sep 17 00:00:00 2001 From: Salvatore Iovene Date: Mon, 11 Jan 2010 20:12:48 +0200 Subject: [PATCH] Re-show original Profile button upon unrealize. --- modules/tweakr-profile-status-menu-widget.c | 45 ++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/modules/tweakr-profile-status-menu-widget.c b/modules/tweakr-profile-status-menu-widget.c index ade651e..cd517fa 100644 --- a/modules/tweakr-profile-status-menu-widget.c +++ b/modules/tweakr-profile-status-menu-widget.c @@ -173,6 +173,17 @@ _button_clicked (HildonButton *b, TweakrProfileStatusPlugin *plugin) } static void +_reshow_profile_button_real (GtkWidget *widget, + TweakrProfileStatusPlugin *plugin) +{ + if (g_strcmp0 (G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (widget)), + "ProfilesStatusMenuItem") == 0) + { + gtk_widget_show (widget); + } +} + +static void _hide_profile_button_real (GtkWidget *widget, TweakrProfileStatusPlugin *plugin) { @@ -183,8 +194,8 @@ _hide_profile_button_real (GtkWidget *widget, } } -static void -_hide_profile_button (TweakrProfileStatusPlugin *plugin, gpointer data) +static GtkWidget * +_find_hds_container (TweakrProfileStatusPlugin *plugin) { GtkWidget *parent; const gchar *class_name; @@ -198,8 +209,30 @@ _hide_profile_button (TweakrProfileStatusPlugin *plugin, gpointer data) class_name = G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (G_OBJECT (parent))); } - if (parent != NULL) - gtk_container_foreach (GTK_CONTAINER (parent), + + return parent; +} + +static void +_reshow_profile_button (TweakrProfileStatusPlugin *plugin, gpointer data) +{ + GtkWidget *container; + + container = _find_hds_container (plugin); + if (container != NULL) + gtk_container_foreach (GTK_CONTAINER (container), + (GtkCallback) _reshow_profile_button_real, + plugin); +} + +static void +_hide_profile_button (TweakrProfileStatusPlugin *plugin, gpointer data) +{ + GtkWidget *container; + + container = _find_hds_container (plugin); + if (container != NULL) + gtk_container_foreach (GTK_CONTAINER (container), (GtkCallback) _hide_profile_button_real, plugin); } @@ -240,6 +273,10 @@ _create_main_button (TweakrProfileStatusPlugin *plugin) g_signal_connect (plugin, "realize", G_CALLBACK (_hide_profile_button), NULL); + g_signal_connect (plugin, "unrealize", + G_CALLBACK (_reshow_profile_button), NULL); + + gtk_widget_show_all (plugin->priv->button); } -- 1.7.9.5