]> spindle.queued.net Git - midori/commitdiff
Remember options in Clear private data dialogue
authorJean-François Guchens <zcx000@gmail.com>
Fri, 22 May 2009 21:53:54 +0000 (23:53 +0200)
committerChristian Dywan <christian@twotoasts.de>
Fri, 22 May 2009 21:53:54 +0000 (23:53 +0200)
midori/midori-browser.c
midori/midori-websettings.c

index d955917f158fa8327bd4a07ad280071d23d7e7b0..8b70e8d89b50b9b343f8cb970e1cf33034de14ae 100644 (file)
@@ -75,6 +75,8 @@ struct _MidoriBrowser
     guint alloc_timeout;
     guint panel_timeout;
 
+    gint clear_private_data;
+
     MidoriWebSettings* settings;
     KatzeArray* proxy_array;
     KatzeArray* bookmarks;
@@ -133,6 +135,16 @@ enum
     LAST_SIGNAL
 };
 
+enum
+{
+    MIDORI_CLEAR_NONE = 0,
+    MIDORI_CLEAR_HISTORY = 1,
+    MIDORI_CLEAR_COOKIES = 2,
+    MIDORI_CLEAR_FLASH_COOKIES = 4,
+    MIDORI_CLEAR_WEBSITE_ICONS = 8,
+    MIDORI_CLEAR_TRASH = 16
+};
+
 static guint signals[LAST_SIGNAL];
 
 static void
@@ -3450,10 +3462,17 @@ midori_browser_clear_private_data_response_cb (GtkWidget*     dialog,
     if (response_id == GTK_RESPONSE_ACCEPT)
     {
         GtkToggleButton* button;
+        gint clear_prefs = MIDORI_CLEAR_NONE;
+        gint saved_prefs = MIDORI_CLEAR_NONE;
+
+        g_object_get (browser->settings, "clear-private-data", &saved_prefs, NULL);
 
         button = g_object_get_data (G_OBJECT (dialog), "history");
         if (gtk_toggle_button_get_active (button))
+        {
             katze_array_clear (browser->history);
+            clear_prefs |= MIDORI_CLEAR_HISTORY;
+        }
         button = g_object_get_data (G_OBJECT (dialog), "cookies");
         if (gtk_toggle_button_get_active (button))
         {
@@ -3469,6 +3488,7 @@ midori_browser_clear_private_data_response_cb (GtkWidget*     dialog,
                 soup_cookie_free (cookie);
             }
             g_slist_free (cookies);
+            clear_prefs |= MIDORI_CLEAR_COOKIES;
         }
         button = g_object_get_data (G_OBJECT (dialog), "flash-cookies");
         if (gtk_toggle_button_get_active (button))
@@ -3477,6 +3497,7 @@ midori_browser_clear_private_data_response_cb (GtkWidget*     dialog,
                                              "Flash_Player", NULL);
             sokoke_remove_path (cache, TRUE);
             g_free (cache);
+            clear_prefs |= MIDORI_CLEAR_FLASH_COOKIES;
         }
         button = g_object_get_data (G_OBJECT (dialog), "website-icons");
         if (gtk_toggle_button_get_active (button))
@@ -3485,6 +3506,7 @@ midori_browser_clear_private_data_response_cb (GtkWidget*     dialog,
                                              PACKAGE_NAME, "icons", NULL);
             sokoke_remove_path (cache, TRUE);
             g_free (cache);
+            clear_prefs |= MIDORI_CLEAR_WEBSITE_ICONS;
         }
         button = g_object_get_data (G_OBJECT (dialog), "trash");
         if (gtk_toggle_button_get_active (button))
@@ -3494,7 +3516,11 @@ midori_browser_clear_private_data_response_cb (GtkWidget*     dialog,
                 katze_array_clear (browser->trash);
                 _midori_browser_update_actions (browser);
             }
+            clear_prefs |= MIDORI_CLEAR_TRASH;
         }
+
+        if (clear_prefs != saved_prefs)
+            g_object_set (browser->settings, "clear-private-data", clear_prefs, NULL);
     }
     if (response_id != GTK_RESPONSE_DELETE_EVENT)
         gtk_widget_destroy (dialog);
@@ -3520,6 +3546,9 @@ _action_clear_private_data_activate (GtkAction*     action,
         GtkWidget* label;
         GtkWidget* button;
 
+        gint clear_prefs = MIDORI_CLEAR_NONE;
+        g_object_get (browser->settings, "clear-private-data", &clear_prefs, NULL);
+
         dialog = gtk_dialog_new_with_buttons (_("Clear Private Data"),
             GTK_WINDOW (browser), GTK_DIALOG_DESTROY_WITH_PARENT,
             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -3545,19 +3574,29 @@ _action_clear_private_data_activate (GtkAction*     action,
         gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
         vbox = gtk_vbox_new (TRUE, 4);
         button = gtk_check_button_new_with_mnemonic (_("History"));
+        if ((clear_prefs & MIDORI_CLEAR_HISTORY) == MIDORI_CLEAR_HISTORY)
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
         g_object_set_data (G_OBJECT (dialog), "history", button);
         gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
         button = gtk_check_button_new_with_mnemonic (_("Cookies"));
+        if ((clear_prefs & MIDORI_CLEAR_COOKIES) == MIDORI_CLEAR_COOKIES)
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
         g_object_set_data (G_OBJECT (dialog), "cookies", button);
         gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
         button = gtk_check_button_new_with_mnemonic (_("'Flash' Cookies"));
+        if ((clear_prefs & MIDORI_CLEAR_FLASH_COOKIES) == MIDORI_CLEAR_FLASH_COOKIES)
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
         g_object_set_data (G_OBJECT (dialog), "flash-cookies", button);
         gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
         button = gtk_check_button_new_with_mnemonic (_("Website icons"));
+        if ((clear_prefs & MIDORI_CLEAR_WEBSITE_ICONS) == MIDORI_CLEAR_WEBSITE_ICONS)
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
         g_object_set_data (G_OBJECT (dialog), "website-icons", button);
         gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
         gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
         button = gtk_check_button_new_with_mnemonic (_("_Closed Tabs and Windows"));
+        if ((clear_prefs & MIDORI_CLEAR_TRASH) == MIDORI_CLEAR_TRASH)
+            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), TRUE);
         g_object_set_data (G_OBJECT (dialog), "trash", button);
         gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
         gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 8);
index d2a4e72da2f7d02e8c341cf79ec244b464ee3379..2a92d2aa422407fc07f24732362dce09b3689540 100644 (file)
@@ -84,6 +84,8 @@ struct _MidoriWebSettings
     MidoriIdentity identify_as;
     gchar* ident_string;
     gint cache_size;
+
+    gint clear_private_data;
 };
 
 struct _MidoriWebSettingsClass
@@ -156,7 +158,9 @@ enum
     PROP_AUTO_DETECT_PROXY,
     PROP_IDENTIFY_AS,
     PROP_IDENT_STRING,
-    PROP_CACHE_SIZE
+    PROP_CACHE_SIZE,
+
+    PROP_CLEAR_PRIVATE_DATA
 };
 
 GType
@@ -947,6 +951,23 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
                                      _("The allowed size of the cache"),
                                      0, G_MAXINT, 100,
                                      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+    /**
+     * MidoriWebSettings:clear-private-data:
+     *
+     * The private data selected for deletion.
+     *
+     * Since: 0.1.7
+     */
+    g_object_class_install_property (gobject_class,
+                                     PROP_CLEAR_PRIVATE_DATA,
+                                     g_param_spec_int (
+                                     "clear-private-data",
+                                     _("Clear private data"),
+                                     _("The private data selected for deletion"),
+                                     0, G_MAXINT, 0,
+                                     flags));
+
 }
 
 static void
@@ -1280,6 +1301,9 @@ midori_web_settings_set_property (GObject*      object,
     case PROP_CACHE_SIZE:
         web_settings->cache_size = g_value_get_int (value);
         break;
+    case PROP_CLEAR_PRIVATE_DATA:
+        web_settings->clear_private_data = g_value_get_int (value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -1467,6 +1491,9 @@ midori_web_settings_get_property (GObject*    object,
     case PROP_CACHE_SIZE:
         g_value_set_int (value, web_settings->cache_size);
         break;
+    case PROP_CLEAR_PRIVATE_DATA:
+        g_value_set_int (value, web_settings->clear_private_data);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;