From 0255edba43233b8632e1fddaba599af403cbc809 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 18 Jan 2009 04:38:46 +0100 Subject: [PATCH] Save toolbar changes via the menu and remove the Toolbar Items entry --- midori/midori-browser.c | 33 ++++++++++++++++++++++++++++----- midori/midori-preferences.c | 13 +------------ 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 599057e8..b19813cb 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -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; diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index 8d85ca96..d8a389ec 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -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), - "" - "Separator, TabNew, Open, Print, Find, Location, Preferences, Window, Bookmarks\n" - "ReloadStop, ZoomIn, ZoomOut, Back, Forward, Homepage, Search, Trash" - ""); - 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"); -- 2.39.5