[Xfce4-commits] <midori:master> Hide Extensions panel if no extensions are available at all.

Christian Dywan noreply at xfce.org
Fri Oct 30 22:46:05 CET 2009


Updating branch refs/heads/master
         to ec9ea0233e7e34233dd0fae1ba81e45b9095e79f (commit)
       from a712d0ea7a27176e90def2a290a8c526b3af8d65 (commit)

commit ec9ea0233e7e34233dd0fae1ba81e45b9095e79f
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Oct 30 21:43:42 2009 +0100

    Hide Extensions panel if no extensions are available at all.

 midori/main.c              |    3 ++-
 midori/midori-panel.c      |   20 ++++++++++++++++----
 panels/midori-extensions.c |    6 +++++-
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index ac0cece..1e5be1e 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -966,8 +966,9 @@ midori_app_add_browser_cb (MidoriApp*     app,
     midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
 
     /* Extensions */
-    addon = g_object_new (MIDORI_TYPE_EXTENSIONS, "app", app, NULL);
+    addon = g_object_new (MIDORI_TYPE_EXTENSIONS, NULL);
     gtk_widget_show (addon);
+    g_object_set (addon, "app", app, NULL);
     midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
 
     g_object_unref (panel);
diff --git a/midori/midori-panel.c b/midori/midori-panel.c
index 4d92403..d94fd0c 100644
--- a/midori/midori-panel.c
+++ b/midori/midori-panel.c
@@ -633,10 +633,12 @@ midori_panel_construct_menu_item (MidoriPanel*    panel,
 
     stock_id = midori_viewable_get_stock_id (viewable);
     menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
-    gtk_widget_show (menuitem);
     g_object_set_data (G_OBJECT (menuitem), "page", viewable);
     g_signal_connect (menuitem, "activate",
                       G_CALLBACK (midori_panel_menu_item_activate_cb), panel);
+
+    if (GTK_WIDGET_VISIBLE (viewable))
+        gtk_widget_show (menuitem);
     return menuitem;
 }
 
@@ -747,6 +749,8 @@ midori_panel_options_clicked_cb (GtkToolItem* toolitem,
  * Since 0.1.3 destroying the @viewable implicitly removes
  * the page including the menu and eventual toolbar.
  *
+ * Since 0.2.1 a hidden @viewable will not be shown in the panel.
+ *
  * In the case of an error, -1 is returned.
  *
  * Return value: the index of the new page, or -1
@@ -759,9 +763,7 @@ midori_panel_append_page (MidoriPanel*    panel,
     GObjectClass* gobject_class;
     GtkWidget* widget;
     GtkWidget* toolbar;
-    #if !HAVE_HILDON
     GtkToolItem* toolitem;
-    #endif
     const gchar* label;
     guint n;
 
@@ -809,10 +811,16 @@ midori_panel_append_page (MidoriPanel*    panel,
     label = midori_viewable_get_label (viewable);
 
     g_object_set_data (G_OBJECT (viewable), "parent", scrolled);
-    midori_panel_construct_tool_item (panel, viewable);
+    toolitem = midori_panel_construct_tool_item (panel, viewable);
     g_signal_connect (viewable, "destroy",
                       G_CALLBACK (midori_panel_viewable_destroy_cb), panel);
 
+    if (!GTK_WIDGET_VISIBLE (viewable))
+    {
+        gtk_widget_hide (scrolled);
+        gtk_widget_hide (GTK_WIDGET (toolitem));
+    }
+
     return n;
 }
 
@@ -941,6 +949,8 @@ midori_panel_page_num (MidoriPanel* panel,
  * silently ignore the attempt to switch the page.
  *
  * Since 0.1.8 the "page" property is notifying changes.
+ *
+ * Since 0.2.1 switching to hidden pages fails silently.
  **/
 void
 midori_panel_set_current_page (MidoriPanel* panel,
@@ -954,6 +964,8 @@ midori_panel_set_current_page (MidoriPanel* panel,
     {
         const gchar* label;
 
+        if (!GTK_WIDGET_VISIBLE (viewable))
+            return;
         gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->toolbook), n);
         gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->notebook), n);
         label = midori_viewable_get_label (MIDORI_VIEWABLE (viewable));
diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c
index 5bbaa9a..b08db86 100644
--- a/panels/midori-extensions.c
+++ b/panels/midori-extensions.c
@@ -73,7 +73,7 @@ midori_extensions_class_init (MidoriExtensionsClass* class)
     gobject_class->get_property = midori_extensions_get_property;
     gobject_class->finalize = midori_extensions_finalize;
 
-    flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
+    flags = G_PARAM_READWRITE;
 
     g_object_class_install_property (gobject_class,
                                      PROP_APP,
@@ -183,6 +183,10 @@ midori_extensions_set_property (GObject*      object,
         i = 0;
         while ((extension = katze_array_get_nth_item (array, i++)))
             midori_extensions_add_item_cb (array, extension, extensions);
+
+        /* Hide if there are no extensions at all */
+        if (!katze_array_get_nth_item (array, 0))
+            gtk_widget_hide (GTK_WIDGET (object));
     }
         break;
     default:



More information about the Xfce4-commits mailing list