]> spindle.queued.net Git - midori/commitdiff
Count both cookies and history expiry in months
authorChristian Dywan <christian@twotoasts.de>
Mon, 16 May 2011 01:19:21 +0000 (03:19 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 16 May 2011 01:19:21 +0000 (03:19 +0200)
katze/katze-utils.c
midori/main.c
midori/midori-preferences.c
midori/midori-websettings.c

index 9cbd72fd75bd2a6ac50824258c80ba1f7122cb54..53fd7dc65cd6c9a8af8096e575833f37926215d5 100644 (file)
@@ -189,6 +189,26 @@ proxy_entry_focus_out_event_cb (GtkEntry*      entry,
     return FALSE;
 }
 
+static void
+proxy_days_changed_cb (GtkComboBox* combo,
+                       GObject*     object)
+{
+    gint active = gtk_combo_box_get_active (combo);
+    const gchar* property = g_object_get_data (G_OBJECT (combo), "property");
+    gint max_age;
+    switch (active)
+    {
+    case 0: max_age =   0; break;
+    case 1: max_age =   1; break;
+    case 2: max_age =   7; break;
+    case 3: max_age =  30; break;
+    case 4: max_age = 365; break;
+    default:
+        max_age = 30;
+    }
+    g_object_set (object, property, max_age, NULL);
+}
+
 static void
 proxy_spin_button_changed_cb (GtkSpinButton* button,
                               GObject*       object)
@@ -480,6 +500,9 @@ g_icon_to_string (GIcon *icon)
  *     Since 0.3.6 the following hints are also supported:
  *     "address": the widget will be particularly suitable for typing
  *         a valid URI or IP address and highlight errors.
+ *     Since 0.3.7 the following hints are also supported:
+ *     "days": the widget will be particularly suitable for choosing
+ *         a period of time in days.
  *
  * Any other values for @hint are silently ignored.
  *
@@ -788,6 +811,30 @@ katze_property_proxy (gpointer     object,
         g_signal_connect (widget, "value-changed",
                           G_CALLBACK (proxy_spin_button_changed_cb), object);
     }
+    else if (type == G_TYPE_PARAM_INT && _hint == I_("days"))
+    {
+        gint value = katze_object_get_int (object, property);
+        gint active;
+        widget = gtk_combo_box_new_text ();
+        gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 hour"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 day"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 week"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 month"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("1 year"));
+        switch (value)
+        {
+        case   0: active = 0; break;
+        case   1: active = 1; break;
+        case   7: active = 2; break;
+        case  30: active = 3; break;
+        case 365: active = 4; break;
+        default:
+            active = 3;
+        }
+        gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active);
+        g_signal_connect (widget, "changed",
+            G_CALLBACK (proxy_days_changed_cb), object);
+    }
     else if (type == G_TYPE_PARAM_INT)
     {
         gint value = katze_object_get_int (object, property);
index feadcfb20e14dd5492c796299c2eeab762f37c27..7faa5e8475e05c3e2fddd9b7f124d035a9cb7794 100644 (file)
@@ -717,25 +717,6 @@ midori_browser_show_preferences_cb (MidoriBrowser*    browser,
     gtk_box_pack_start (GTK_BOX (page), scrolled, TRUE, TRUE, 4);
 }
 
-static void
-midori_preferences_delete_cookies_changed_cb (GtkComboBox*       combo,
-                                              MidoriWebSettings* settings)
-{
-    gint active = gtk_combo_box_get_active (combo);
-    gint max_age;
-    switch (active)
-    {
-    case 0: max_age =   0; break;
-    case 1: max_age =   1; break;
-    case 2: max_age =   7; break;
-    case 3: max_age =  30; break;
-    case 4: max_age = 365; break;
-    default:
-        max_age = 30;
-    }
-    g_object_set (settings, "maximum-cookie-age", max_age, NULL);
-}
-
 static void
 midori_browser_privacy_preferences_cb (MidoriBrowser*    browser,
                                        KatzePreferences* preferences,
@@ -744,34 +725,13 @@ midori_browser_privacy_preferences_cb (MidoriBrowser*    browser,
     MidoriWebSettings* settings = midori_browser_get_settings (browser);
     GtkWidget* button;
     GtkWidget* label;
-    gint max_age = katze_object_get_int (settings, "maximum-cookie-age");
-    guint active;
     gchar* markup;
 
     katze_preferences_add_category (preferences, _("Privacy"), GTK_STOCK_INDEX);
     katze_preferences_add_group (preferences, NULL);
     button = katze_property_label (settings, "maximum-cookie-age");
     katze_preferences_add_widget (preferences, button, "indented");
-    button = gtk_combo_box_new_text ();
-    gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 hour"));
-    gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 day"));
-    gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 week"));
-    gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 month"));
-    gtk_combo_box_append_text (GTK_COMBO_BOX (button), _("Delete old cookies after 1 year"));
-
-    switch (max_age)
-    {
-    case   0: active = 0; break;
-    case   1: active = 1; break;
-    case   7: active = 2; break;
-    case  30: active = 3; break;
-    case 365: active = 4; break;
-    default:
-        active = 3;
-    }
-    gtk_combo_box_set_active (GTK_COMBO_BOX (button), active);
-    g_signal_connect (button, "changed",
-        G_CALLBACK (midori_preferences_delete_cookies_changed_cb), settings);
+    button = katze_property_proxy (settings, "maximum-cookie-age", "days");
     katze_preferences_add_widget (preferences, button, "spanned");
 
     markup = g_strdup_printf ("<span size=\"smaller\">%s</span>",
@@ -797,13 +757,11 @@ midori_browser_privacy_preferences_cb (MidoriBrowser*    browser,
     button = katze_property_proxy (settings, "strip-referer", NULL);
     katze_preferences_add_widget (preferences, button, "indented");
     #endif
-    katze_preferences_add_group (preferences, NULL);
+    katze_preferences_add_widget (preferences, gtk_label_new (NULL), "indented");
     button = katze_property_label (settings, "maximum-history-age");
     katze_preferences_add_widget (preferences, button, "indented");
-    button = katze_property_proxy (settings, "maximum-history-age", NULL);
+    button = katze_property_proxy (settings, "maximum-history-age", "days");
     katze_preferences_add_widget (preferences, button, "spanned");
-    label = gtk_label_new (_("days"));
-    katze_preferences_add_widget (preferences, label, "spanned");
 }
 
 static void
index fbd0e0f68a1a8ef7277c73531ebda8bb7012b653..2c27660607e739b9e1439e26d7f81a2eae28a7fd 100644 (file)
@@ -425,7 +425,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
     button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL);
     SPANNED_ADD (button);
     #if !HAVE_HILDON
-    FRAME_NEW (NULL);
+    INDENTED_ADD (gtk_label_new (NULL));
     label = katze_property_label (settings, "text-editor");
     INDENTED_ADD (label);
     entry = katze_property_proxy (settings, "text-editor", "application-text/plain");
index f741a0862e3c3c328bee7cf84088074cab5fea87..6678a817b57b2a36ae0d1b44a5eea66047edf422 100644 (file)
@@ -828,7 +828,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
                                      PROP_MAXIMUM_COOKIE_AGE,
                                      g_param_spec_int (
                                      "maximum-cookie-age",
-                                     _("Maximum cookie age"),
+                                     _("Delete old Cookies after:"),
                                      _("The maximum number of days to save cookies for"),
                                      0, G_MAXINT, 30,
                                      flags));
@@ -838,7 +838,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
                                      PROP_MAXIMUM_HISTORY_AGE,
                                      g_param_spec_int (
                                      "maximum-history-age",
-                                     _("Maximum history age"),
+                                     _("Delete pages from history after:"),
                                      _("The maximum number of days to save the history for"),
                                      0, G_MAXINT, 30,
                                      flags));