From 13f8171e24cb39c1c8a26370e93bf24c8adc164b Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 8 Jun 2008 18:42:39 +0200 Subject: [PATCH] Add Zoom Stepping Value to Preferences --- katze/katze-utils.c | 26 ++++++++++++++++++++++++-- midori/main.c | 4 ++-- midori/midori-preferences.c | 24 +++++++++++++++++++++--- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/katze/katze-utils.c b/katze/katze-utils.c index 9b958911..1353fa1b 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -73,9 +73,19 @@ proxy_entry_focus_out_event_cb (GtkEntry* entry, static gboolean proxy_spin_button_changed_cb (GtkSpinButton* button, GObject* object) { - gint value = gtk_spin_button_get_value_as_int (button); + GObjectClass* class = G_OBJECT_GET_CLASS (object); const gchar* property = g_object_get_data (G_OBJECT (button), "property"); - g_object_set (object, property, value, NULL); + GParamSpec* pspec = g_object_class_find_property (class, property); + if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_INT) + { + gint value = gtk_spin_button_get_value_as_int (button); + g_object_set (object, property, value, NULL); + } + else + { + gdouble value = gtk_spin_button_get_value (button); + g_object_set (object, property, value, NULL); + } return FALSE; } @@ -213,6 +223,18 @@ katze_property_proxy (gpointer object, g_signal_connect (widget, "focus-out-event", G_CALLBACK (proxy_entry_focus_out_event_cb), object); } + else if (type == G_TYPE_PARAM_FLOAT) + { + widget = gtk_spin_button_new_with_range ( + G_PARAM_SPEC_FLOAT (pspec)->minimum, + G_PARAM_SPEC_FLOAT (pspec)->maximum, 1); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 2); + gfloat value; + g_object_get (object, property, &value, NULL); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value); + g_signal_connect (widget, "value-changed", + G_CALLBACK (proxy_spin_button_changed_cb), object); + } else if (type == G_TYPE_PARAM_INT) { widget = gtk_spin_button_new_with_range ( diff --git a/midori/main.c b/midori/main.c index 9907e740..f88d0b15 100644 --- a/midori/main.c +++ b/midori/main.c @@ -125,7 +125,7 @@ settings_new_from_file (const gchar* filename) } else if (type == G_TYPE_PARAM_FLOAT) { - gdouble number = sokoke_key_file_get_double_default (key_file, + gfloat number = sokoke_key_file_get_double_default (key_file, "settings", property, G_PARAM_SPEC_FLOAT (pspec)->default_value, NULL); g_object_set (settings, property, number, NULL); @@ -198,7 +198,7 @@ settings_save_to_file (MidoriWebSettings* settings, } else if (type == G_TYPE_PARAM_FLOAT) { - gdouble number; + gfloat number; g_object_get (settings, property, &number, NULL); g_key_file_set_double (key_file, "settings", property, number); } diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index b3ddc9e7..aa2017a5 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -279,7 +279,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences, // Page "Behavior" PAGE_NEW (_("Behavior")); FRAME_NEW (_("Features")); - TABLE_NEW (5, 2); + TABLE_NEW (6, 2); button = katze_property_proxy (settings, "auto-load-images", NULL); INDENTED_ADD (button, 0, 1, 0, 1); button = katze_property_proxy (settings, "auto-shrink-images", NULL); @@ -304,10 +304,28 @@ midori_preferences_set_settings (MidoriPreferences* preferences, G_CALLBACK (clear_button_clicked_cb), entry); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 4); FILLED_ADD (hbox, 1, 2, 3, 4); + if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), "zoom-step")) + { + label = katze_property_label (settings, "zoom-step"); + INDENTED_ADD (label, 0, 1, 4, 5); + hbox = gtk_hbox_new (FALSE, 4); + entry = katze_property_proxy (settings, "zoom-step", NULL); + gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + FILLED_ADD (hbox, 1, 2, 4, 5); + } + else + { + label = gtk_label_new ("Zoom Stepping Value"); + INDENTED_ADD (label, 0, 1, 4, 5); + hbox = gtk_hbox_new (FALSE, 4); + entry = gtk_label_new ("Not available in this WebKit version"); + gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + FILLED_ADD (hbox, 1, 2, 4, 5); + } label = katze_property_label (settings, "location-entry-search"); - INDENTED_ADD (label, 0, 1, 4, 5); + INDENTED_ADD (label, 0, 1, 5, 6); entry = katze_property_proxy (settings, "location-entry-search", NULL); - FILLED_ADD (entry, 1, 2, 4, 5); + FILLED_ADD (entry, 1, 2, 5, 6); // Page "Interface" PAGE_NEW (_("Interface"));