Re-show original Profile button upon unrealize.
authorSalvatore Iovene <salvatore@iovene.com>
Mon, 11 Jan 2010 18:12:48 +0000 (20:12 +0200)
committerSalvatore Iovene <salvatore@iovene.com>
Mon, 11 Jan 2010 18:12:48 +0000 (20:12 +0200)
modules/tweakr-profile-status-menu-widget.c

index ade651e..cd517fa 100644 (file)
@@ -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);
 }