Save paned actions as separate toolbar items

This commit is contained in:
Peter Hatina 2011-11-16 23:54:27 +01:00 committed by Christian Dywan
parent 9e02157c6a
commit d809cd6040
4 changed files with 60 additions and 18 deletions

View file

@ -617,6 +617,7 @@ settings_notify_cb (MidoriWebSettings* settings,
/* Skip state related properties to avoid disk IO */ /* Skip state related properties to avoid disk IO */
if ((pspec && g_str_has_prefix (pspec->name, "last-window-")) if ((pspec && g_str_has_prefix (pspec->name, "last-window-"))
|| (pspec && g_str_has_prefix (pspec->name, "user-stylesheet-uri")) || (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-"))) || (pspec && g_str_has_prefix (pspec->name, "last-panel-")))
return; return;

View file

@ -2709,8 +2709,19 @@ _midori_browser_save_toolbar_items (MidoriBrowser* browser)
g_warn_if_fail (action != NULL); g_warn_if_fail (action != NULL);
if (action) if (action)
{ {
g_string_append (toolbar_items, gtk_action_get_name (action)); const char* action_name = gtk_action_get_name (action);
g_string_append (toolbar_items, ","); 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); items = g_string_free (toolbar_items, FALSE);
@ -2718,20 +2729,6 @@ _midori_browser_save_toolbar_items (MidoriBrowser* browser)
g_free (items); 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: * midori_browser_get_toolbar_actions:
* *
@ -5538,8 +5535,6 @@ midori_browser_destroy_cb (MidoriBrowser* browser)
if (G_UNLIKELY (browser->alloc_timeout)) if (G_UNLIKELY (browser->alloc_timeout))
g_source_remove (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 */ /* Destroy panel first, so panels don't need special care */
gtk_widget_destroy (browser->panel); gtk_widget_destroy (browser->panel);
/* Destroy tabs second, so child widgets don't need special care */ /* 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; 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 static void
_midori_browser_set_toolbar_items (MidoriBrowser* browser, _midori_browser_set_toolbar_items (MidoriBrowser* browser,
const gchar* items) const gchar* items)
@ -6440,6 +6445,8 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser,
token_last == token_search ? FALSE : TRUE, TRUE); token_last == token_search ? FALSE : TRUE, TRUE);
midori_paned_action_set_child2 (paned_action, toolitem_second, token_current, midori_paned_action_set_child2 (paned_action, toolitem_second, token_current,
token_current == token_search ? FALSE : TRUE, TRUE); 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 ( gtk_widget_set_size_request (
token_last == token_search ? toolitem_first : toolitem_second, token_last == token_search ? toolitem_first : toolitem_second,

View file

@ -197,3 +197,31 @@ midori_paned_action_get_child_by_name (MidoriPanedAction* paned_action,
return NULL; 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;
}

View file

@ -59,6 +59,12 @@ GtkWidget*
midori_paned_action_get_child_by_name (MidoriPanedAction* paned_action, midori_paned_action_get_child_by_name (MidoriPanedAction* paned_action,
const gchar* name); 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 G_END_DECLS
#endif // __MIDORI_PANED_ACTION_H__ #endif // __MIDORI_PANED_ACTION_H__