]> spindle.queued.net Git - midori/commitdiff
Hide the combobox arrow if the history unset or is empty
authorChristian Dywan <christian@twotoasts.de>
Thu, 28 Jan 2010 22:56:54 +0000 (23:56 +0100)
committerChristian Dywan <christian@twotoasts.de>
Fri, 29 Jan 2010 17:54:58 +0000 (18:54 +0100)
midori/midori-browser.c
midori/midori-locationaction.c

index ed8b2302911d36247db3432c70dbda487c3fe4d5..0e460619a30e704c8ba19bff0ca4716c3ae86ec6 100644 (file)
@@ -499,10 +499,7 @@ midori_view_notify_load_status_cb (GtkWidget*      widget,
     action = _action_by_name (browser, "Location");
 
     if (midori_view_get_load_status (view) == MIDORI_LOAD_COMMITTED)
-    {
-        if (browser->maximum_history_age)
-            midori_location_action_add_uri (MIDORI_LOCATION_ACTION (action), uri);
-    }
+        midori_location_action_add_uri (MIDORI_LOCATION_ACTION (action), uri);
 
     if (widget == midori_browser_get_current_tab (browser))
     {
@@ -5586,9 +5583,9 @@ midori_browser_history_clear_cb (KatzeArray*    history,
                                  MidoriBrowser* browser)
 {
     GtkAction* location_action = _action_by_name (browser, "Location");
-    midori_location_action_clear (MIDORI_LOCATION_ACTION (location_action));
     g_object_set (_action_by_name (browser, "RecentlyVisited"),
                   "array", NULL, NULL);
+    midori_location_action_clear (MIDORI_LOCATION_ACTION (location_action));
 }
 
 static void
index a3e5cd88361d64ebce729b26ffa5929d8298b9ad..6cf9f0a9575c99b66cbe4f5d47a94eb5bbe7caa8 100644 (file)
@@ -600,6 +600,32 @@ midori_location_action_finalize (GObject* object)
     G_OBJECT_CLASS (midori_location_action_parent_class)->finalize (object);
 }
 
+static void
+midori_location_action_toggle_arrow_cb (GtkWidget*            widget,
+                                        MidoriLocationAction* location_action)
+{
+    if (GTK_IS_BUTTON (widget))
+    {
+        gboolean show = location_action->history
+            && katze_array_get_nth_item (location_action->history, 0);
+        sokoke_widget_set_visible (widget, show);
+        gtk_widget_set_size_request (widget, show ? -1 : 1, show ? -1 : 1);
+    }
+}
+
+static void
+midori_location_action_toggle_arrow (MidoriLocationAction* location_action)
+{
+    GSList* proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
+    for (; proxies != NULL; proxies = g_slist_next (proxies))
+    if (GTK_IS_TOOL_ITEM (proxies->data))
+    {
+        GtkWidget* entry = midori_location_action_entry_for_proxy (proxies->data);
+        gtk_container_forall (GTK_CONTAINER (entry),
+            (GtkCallback)midori_location_action_toggle_arrow_cb, location_action);
+    }
+}
+
 static void
 midori_location_action_set_property (GObject*      object,
                                      guint         prop_id,
@@ -621,6 +647,8 @@ midori_location_action_set_property (GObject*      object,
     case PROP_HISTORY:
     {
         katze_assign (location_action->history, g_value_dup_object (value));
+
+        midori_location_action_toggle_arrow (location_action);
         break;
     }
     default:
@@ -1207,6 +1235,8 @@ midori_location_action_connect_proxy (GtkAction* action,
             renderer, midori_location_entry_render_text_cb, child, NULL);
 
         gtk_combo_box_set_active (GTK_COMBO_BOX (entry), -1);
+        gtk_container_forall (GTK_CONTAINER (entry),
+            (GtkCallback)midori_location_action_toggle_arrow_cb, action);
         g_signal_connect (entry, "changed",
             G_CALLBACK (midori_location_action_entry_changed_cb), action);
         g_signal_connect (entry, "popup",
@@ -1405,6 +1435,8 @@ midori_location_action_add_uri (MidoriLocationAction* location_action,
     g_return_if_fail (uri != NULL);
 
     katze_assign (location_action->uri, g_strdup (uri));
+
+    midori_location_action_toggle_arrow (location_action);
 }
 
 void
@@ -1583,5 +1615,5 @@ midori_location_action_clear (MidoriLocationAction* location_action)
 {
     g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
 
-    /* Nothing to do */
+    midori_location_action_toggle_arrow (location_action);
 }