gint value = hildon_picker_button_get_active (button);
const gchar* property = g_object_get_data (G_OBJECT (button), "property");
g_object_set (object, property, value, NULL);
+ /* FIXME: Implement custom-PROPERTY */
}
#else
static void
{
gint value = gtk_combo_box_get_active (button);
const gchar* property = g_object_get_data (G_OBJECT (button), "property");
+ gint custom_value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
+ "katze-custom-value"));
+ if (custom_value)
+ {
+ GtkWidget* child = gtk_bin_get_child (GTK_BIN (button));
+ if (value == custom_value && GTK_IS_CELL_VIEW (child))
+ {
+ GtkWidget* entry = gtk_entry_new ();
+ const gchar* custom_property = g_object_get_data (G_OBJECT (button),
+ "katze-custom-property");
+ /* FIXME: Fill in the previous value for convenience
+ gint old_value = katze_object_get_integer (object, custom_property);
+ if (old_value && *old_value)
+ gtk_entry_set_text (GTK_ENTRY (entry), ""); */
+ gtk_widget_show (entry);
+ gtk_container_add (GTK_CONTAINER (button), entry);
+ gtk_widget_grab_focus (entry);
+ g_signal_connect (entry, "focus-out-event",
+ G_CALLBACK (proxy_entry_focus_out_event_cb), object);
+ g_object_set_data_full (G_OBJECT (entry), "property",
+ g_strdup (custom_property), g_free);
+ }
+ else if (value != custom_value && GTK_IS_ENTRY (child))
+ {
+ /* Force the combo to change the item again */
+ gtk_widget_destroy (child);
+ gtk_combo_box_set_active (button, value + 1);
+ gtk_combo_box_set_active (button, value);
+ }
+ }
g_object_set (object, property, value, NULL);
}
#endif
* for choosing an application to open TYPE files, ie. "text/plain".
* "application-CATEGORY": the widget created will be particularly suitable
* for choosing an application to open CATEGORY files, ie. "Network".
+ * "custom-PROPERTY": the last value of an enumeration will be the "custom"
+ * value, where the user may enter text freely, which then updates
+ * the property PROPERTY instead. This applies only to enumerations.
*
* Any other values for @hint are silently ignored.
*
GEnumClass* enum_class = G_ENUM_CLASS (
g_type_class_ref (pspec->value_type));
gint value = katze_object_get_enum (object, property);
+ const gchar* custom = NULL;
+
+ if (hint && g_str_has_prefix (hint, "custom-"))
+ custom = &hint[7];
#ifdef HAVE_HILDON_2_2
GtkWidget* selector;
g_signal_connect (widget, "changed",
G_CALLBACK (proxy_combo_box_changed_cb), object);
#endif
+ if (custom)
+ {
+ if (value == (gint)(enum_class->n_values - 1))
+ {
+ GtkWidget* entry = gtk_entry_new ();
+ gchar* text = katze_object_get_string (object, custom);
+ if (text && *text)
+ gtk_entry_set_text (GTK_ENTRY (entry), text);
+ gtk_widget_show (entry);
+ gtk_container_add (GTK_CONTAINER (widget), entry);
+ g_signal_connect (entry, "focus-out-event",
+ G_CALLBACK (proxy_entry_focus_out_event_cb), object);
+ g_object_set_data_full (G_OBJECT (entry), "property",
+ g_strdup (custom), g_free);
+ }
+ g_object_set_data (G_OBJECT (widget), "katze-custom-value",
+ GINT_TO_POINTER (enum_class->n_values - 1));
+ g_object_set_data (G_OBJECT (widget), "katze-custom-property",
+ (gpointer)custom);
+ }
g_type_class_unref (enum_class);
}
else
}
}
-static void
-midori_preferences_notify_preferred_encoding_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- GtkWidget* entry)
-{
- MidoriPreferredEncoding preferred_encoding;
-
- preferred_encoding = katze_object_get_enum (settings, "preferred-encoding");
- gtk_widget_set_sensitive (entry, preferred_encoding == MIDORI_ENCODING_CUSTOM);
-}
-
#if !HAVE_HILDON
static void
midori_preferences_notify_auto_detect_proxy_cb (MidoriWebSettings* settings,
}
#endif
-static void
-midori_preferences_notify_identify_as_cb (MidoriWebSettings* settings,
- GParamSpec* pspec,
- GtkWidget* entry)
-{
- MidoriIdentity identify_as = katze_object_get_enum (settings, "identify-as");
-
- gtk_widget_set_sensitive (entry, identify_as == MIDORI_IDENT_CUSTOM);
-}
-
#if HAVE_OSX
static void
midori_preferences_help_clicked_cb (GtkWidget* button,
#endif
label = katze_property_label (settings, "preferred-encoding");
INDENTED_ADD (label);
- button = katze_property_proxy (settings, "preferred-encoding", NULL);
+ button = katze_property_proxy (settings, "preferred-encoding", "custom-default-encoding");
SPANNED_ADD (button);
- entry = katze_property_proxy (settings, "default-encoding", NULL);
- gtk_widget_set_tooltip_text (entry, _("The character encoding to use by default"));
- g_signal_connect (settings, "notify::preferred-encoding",
- G_CALLBACK (midori_preferences_notify_preferred_encoding_cb), entry);
- midori_preferences_notify_preferred_encoding_cb (settings, NULL, entry);
- SPANNED_ADD (entry);
/* Page "Behavior" */
PAGE_NEW (GTK_STOCK_SELECT_COLOR, _("Behavior"));
#endif
label = katze_property_label (settings, "identify-as");
INDENTED_ADD (label);
- button = katze_property_proxy (settings, "identify-as", NULL);
+ button = katze_property_proxy (settings, "identify-as", "custom-ident-string");
SPANNED_ADD (button);
- entry = katze_property_proxy (settings, "ident-string", NULL);
- g_signal_connect (settings, "notify::identify-as",
- G_CALLBACK (midori_preferences_notify_identify_as_cb), entry);
- midori_preferences_notify_identify_as_cb (settings, NULL, entry);
- SPANNED_ADD (entry);
/* Page "Privacy" */
PAGE_NEW (GTK_STOCK_INDEX, _("Privacy"));