]> spindle.queued.net Git - midori/commitdiff
Save paned actions as separate toolbar items
authorPeter Hatina <phatina@redhat.com>
Wed, 16 Nov 2011 22:54:27 +0000 (23:54 +0100)
committerChristian Dywan <christian@twotoasts.de>
Wed, 16 Nov 2011 23:03:52 +0000 (00:03 +0100)
midori/main.c
midori/midori-browser.c
midori/midori-panedaction.c
midori/midori-panedaction.h

index ccfe353237b59258314b9489148389bbd68332fc..69a3210693482849de498c891e4b8e9a0b9469c9 100644 (file)
@@ -617,6 +617,7 @@ settings_notify_cb (MidoriWebSettings* settings,
     /* Skip state related properties to avoid disk IO */
     if ((pspec && g_str_has_prefix (pspec->name, "last-window-"))
      || (pspec && g_str_has_prefix (pspec->name, "user-stylesheet-uri"))
+     || (pspec && g_str_equal (pspec->name, "search-width"))
      || (pspec && g_str_has_prefix (pspec->name, "last-panel-")))
         return;
 
index 4aa01d7da3b1250fa3463d6db053675ec62b5cac..4604c975c1a994fcefa268308ac1143918b937e5 100644 (file)
@@ -2709,8 +2709,19 @@ _midori_browser_save_toolbar_items (MidoriBrowser* browser)
         g_warn_if_fail (action != NULL);
         if (action)
         {
-            g_string_append (toolbar_items, gtk_action_get_name (action));
-            g_string_append (toolbar_items, ",");
+            const char* action_name = gtk_action_get_name (action);
+            if (g_str_equal (action_name, "LocationSearch"))
+            {
+                MidoriPanedAction* paned_action = MIDORI_PANED_ACTION (action);
+                g_string_append_printf (toolbar_items, "%s,%s,",
+                    midori_paned_action_get_child1_name (paned_action),
+                    midori_paned_action_get_child2_name (paned_action));
+            }
+            else
+            {
+                g_string_append (toolbar_items, action_name);
+                g_string_append (toolbar_items, ",");
+            }
         }
     }
     items = g_string_free (toolbar_items, FALSE);
@@ -2718,20 +2729,6 @@ _midori_browser_save_toolbar_items (MidoriBrowser* browser)
     g_free (items);
 }
 
-static void
-_midori_browser_save_search_item (MidoriBrowser* browser)
-{
-    MidoriPanedAction* paned_action = MIDORI_PANED_ACTION (_action_by_name (browser, "LocationSearch"));
-    GtkWidget* search = midori_paned_action_get_child_by_name (paned_action, "Search");
-    GtkAllocation allocation;
-    MidoriWebSettings* settings = browser->settings;
-    if (!search)
-        return;
-
-    gtk_widget_get_allocation (search, &allocation);
-    g_object_set (settings, "search-width", allocation.width, NULL);
-}
-
 /**
  * midori_browser_get_toolbar_actions:
  *
@@ -5538,8 +5535,6 @@ midori_browser_destroy_cb (MidoriBrowser* browser)
     if (G_UNLIKELY (browser->alloc_timeout))
         g_source_remove (browser->alloc_timeout);
 
-    _midori_browser_save_search_item (browser);
-
     /* Destroy panel first, so panels don't need special care */
     gtk_widget_destroy (browser->panel);
     /* Destroy tabs second, so child widgets don't need special care */
@@ -6392,6 +6387,16 @@ midori_browser_toolbar_item_button_press_event_cb (GtkWidget*      toolitem,
     return FALSE;
 }
 
+static void
+_midori_browser_search_item_allocate_cb (GtkWidget* widget,
+                                         GdkRectangle* allocation,
+                                         gpointer user_data)
+{
+    MidoriBrowser* browser = MIDORI_BROWSER (user_data);
+    MidoriWebSettings* settings = browser->settings;
+    g_object_set (settings, "search-width", allocation->width, NULL);
+}
+
 static void
 _midori_browser_set_toolbar_items (MidoriBrowser* browser,
                                    const gchar*   items)
@@ -6440,6 +6445,8 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser,
                     token_last == token_search ? FALSE : TRUE, TRUE);
                 midori_paned_action_set_child2 (paned_action, toolitem_second, token_current,
                     token_current == token_search ? FALSE : TRUE, TRUE);
+                g_signal_connect (G_OBJECT (token_current == token_search ? toolitem_second : toolitem_first),
+                    "size-allocate", G_CALLBACK (_midori_browser_search_item_allocate_cb), (gpointer) browser);
 
                 gtk_widget_set_size_request (
                     token_last == token_search ? toolitem_first : toolitem_second,
index b6f615a72049ab41c5b30a1980bbaf1419472bef..e858b8a5c04d4b4b35e23857292cfde38f9f99d3 100644 (file)
@@ -197,3 +197,31 @@ midori_paned_action_get_child_by_name (MidoriPanedAction* paned_action,
 
     return NULL;
 }
+
+/**
+ * midori_paned_action_get_child1_name:
+ * @paned_action a #MidoriPanedAction
+ *
+ * Returns: The name of the first child
+ **/
+const gchar*
+midori_paned_action_get_child1_name (MidoriPanedAction* paned_action)
+{
+    g_return_val_if_fail (MIDORI_IS_PANED_ACTION (paned_action), NULL);
+
+    return paned_action->child1.name;
+}
+
+/**
+ * midori_paned_action_get_child2_name:
+ * @paned_action a #MidoriPanedAction
+ *
+ * Returns: The name of the second child
+ **/
+const gchar*
+midori_paned_action_get_child2_name (MidoriPanedAction* paned_action)
+{
+    g_return_val_if_fail (MIDORI_IS_PANED_ACTION (paned_action), NULL);
+
+    return paned_action->child2.name;
+}
index 384529bd21d0415bcf0f54a08405fab88acf8109..5844473508d2dc9d2792bc9f9ca807183d8c8260 100644 (file)
@@ -59,6 +59,12 @@ GtkWidget*
 midori_paned_action_get_child_by_name              (MidoriPanedAction* paned_action,
                                                     const gchar* name);
 
+const gchar*
+midori_paned_action_get_child1_name                (MidoriPanedAction* paned_action);
+
+const gchar*
+midori_paned_action_get_child2_name                (MidoriPanedAction* paned_action);
+
 G_END_DECLS
 
 #endif // __MIDORI_PANED_ACTION_H__