Save toolbar changes via the menu and remove the Toolbar Items entry

This commit is contained in:
Christian Dywan 2009-01-18 04:38:46 +01:00
parent 60fd9b19d1
commit 0255edba43
2 changed files with 29 additions and 17 deletions

View file

@ -1580,13 +1580,36 @@ midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem,
GdkEventButton* event,
MidoriBrowser* browser);
static void
_midori_browser_save_toolbar_items (MidoriBrowser* browser)
{
GString* toolbar_items;
GList* children;
gchar* items;
toolbar_items = g_string_new (NULL);
children = gtk_container_get_children (GTK_CONTAINER (browser->navigationbar));
for (; children != NULL; children = g_list_next (children))
{
GtkAction* action = gtk_widget_get_action (GTK_WIDGET (children->data));
if (strcmp (gtk_action_get_name (action), "Fullscreen"))
{
g_string_append (toolbar_items, gtk_action_get_name (action));
g_string_append (toolbar_items, ",");
}
}
items = g_string_free (toolbar_items, FALSE);
g_object_set (browser->settings, "toolbar-items", items, NULL);
g_free (items);
}
static void
midori_browser_toolbar_add_item_cb (GtkWidget* menuitem,
MidoriBrowser* browser)
{
GtkWidget* widget = g_object_get_data (G_OBJECT (menuitem), "widget");
GtkAction* action = g_object_get_data (G_OBJECT (menuitem), "action");
GtkWidget* toolitem = gtk_action_create_tool_item (action);
GtkAction* widget_action = g_object_get_data (G_OBJECT (menuitem), "action");
GtkWidget* toolitem = gtk_action_create_tool_item (widget_action);
if (widget)
{
gint i = gtk_toolbar_get_item_index (GTK_TOOLBAR (browser->navigationbar),
@ -1601,7 +1624,7 @@ midori_browser_toolbar_add_item_cb (GtkWidget* menuitem,
"button-press-event",
G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb),
browser);
/* FIXME: Save the new list of items */
_midori_browser_save_toolbar_items (browser);
}
static void
@ -1610,7 +1633,7 @@ midori_browser_toolbar_remove_item_cb (GtkWidget* menuitem,
{
GtkWidget* widget = g_object_get_data (G_OBJECT (menuitem), "widget");
gtk_container_remove (GTK_CONTAINER (browser->navigationbar), widget);
/* FIXME: Save the new list of items */
_midori_browser_save_toolbar_items (browser);
}
static gboolean
@ -1644,7 +1667,7 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget,
gtk_widget_is_ancestor (widget, browser->navigationbar))
{
GtkAction* widget_action = gtk_widget_get_action (widget);
const gchar* actions[] = { "TabNew", "Open", "Print", "Find",
const gchar* actions[] = { "TabNew", "Open", "SaveAs", "Print", "Find",
"Preferences", "Window", "Bookmarks", "ReloadStop", "ZoomIn",
"ZoomOut", "Back", "Forward", "Homepage", "Trash", "Search" };
GtkWidget* submenu;

View file

@ -496,21 +496,10 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
/* Page "Interface" */
PAGE_NEW (GTK_STOCK_CONVERT, _("Interface"));
FRAME_NEW (_("Navigationbar"));
TABLE_NEW (3, 2);
TABLE_NEW (1, 2);
INDENTED_ADD (katze_property_label (settings, "toolbar-style"), 0, 1, 0, 1);
button = katze_property_proxy (settings, "toolbar-style", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
INDENTED_ADD (katze_property_label (settings, "toolbar-items"), 0, 1, 1, 2);
button = katze_property_proxy (settings, "toolbar-items", NULL);
FILLED_ADD (button, 1, 2, 1, 2);
button = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (button),
"<span size='smaller'>"
"Separator, TabNew, Open, Print, Find, Location, Preferences, Window, Bookmarks\n"
"ReloadStop, ZoomIn, ZoomOut, Back, Forward, Homepage, Search, Trash"
"</span>");
gtk_label_set_selectable (GTK_LABEL (button), TRUE);
FILLED_ADD (button, 0, 2, 2, 3);
FRAME_NEW (_("Browsing"));
TABLE_NEW (5, 2);
label = katze_property_label (settings, "open-new-pages-in");