diff options
author | Matthias Clasen <mclasen@redhat.com> | 2012-08-16 14:27:51 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-08-20 18:54:21 -0400 |
commit | eaaee081b1a8f2a3233608af2789eb6817151d38 (patch) | |
tree | a8d7634bad91a403fc1bf888f23bd5e78ef28eea /gtk | |
parent | 3cb4aa44b3b31c87d205b8aead57c7875923b179 (diff) | |
download | gtk+-eaaee081b1a8f2a3233608af2789eb6817151d38.tar.gz |
GtkEntry: Add input purpose and hints
Add input-purpose and input-hints properties to GtkEntry,
and pass these on to GtkIMContext.
https://bugzilla.gnome.org/show_bug.cgi?id=651244
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtk.symbols | 4 | ||||
-rw-r--r-- | gtk/gtkentry.c | 101 | ||||
-rw-r--r-- | gtk/gtkentry.h | 12 |
3 files changed, 116 insertions, 1 deletions
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 84002789e8..b3e37d0995 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -908,6 +908,8 @@ gtk_entry_get_icon_storage_type gtk_entry_get_icon_tooltip_markup gtk_entry_get_icon_tooltip_text gtk_entry_get_inner_border +gtk_entry_get_input_hints +gtk_entry_get_input_purpose gtk_entry_get_invisible_char gtk_entry_get_layout gtk_entry_get_layout_offsets @@ -945,6 +947,8 @@ gtk_entry_set_icon_sensitive gtk_entry_set_icon_tooltip_markup gtk_entry_set_icon_tooltip_text gtk_entry_set_inner_border +gtk_entry_set_input_hints +gtk_entry_set_input_purpose gtk_entry_set_invisible_char gtk_entry_set_max_length gtk_entry_set_overwrite_mode diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 6d9491e07d..de43d97b9a 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -308,7 +308,9 @@ enum { PROP_IM_MODULE, PROP_EDITING_CANCELED, PROP_PLACEHOLDER_TEXT, - PROP_COMPLETION + PROP_COMPLETION, + PROP_INPUT_PURPOSE, + PROP_INPUT_HINTS }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -1359,6 +1361,25 @@ gtk_entry_class_init (GtkEntryClass *class) GTK_TYPE_ENTRY_COMPLETION, GTK_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_INPUT_PURPOSE, + g_param_spec_enum ("input-purpose", + P_("Purpose"), + P_("Purpose of the text field"), + GTK_TYPE_INPUT_PURPOSE, + GTK_INPUT_PURPOSE_FREE_FORM, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, + PROP_INPUT_HINTS, + g_param_spec_flags ("input-hints", + P_("hints"), + P_("Hints for the text field behaviour"), + GTK_TYPE_INPUT_HINTS, + GTK_INPUT_HINT_NONE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** * GtkEntry:icon-prelight: * @@ -2162,6 +2183,14 @@ gtk_entry_set_property (GObject *object, gtk_entry_set_completion (entry, GTK_ENTRY_COMPLETION (g_value_get_object (value))); break; + case PROP_INPUT_PURPOSE: + gtk_entry_set_input_purpose (entry, g_value_get_enum (value)); + break; + + case PROP_INPUT_HINTS: + gtk_entry_set_input_hints (entry, g_value_get_flags (value)); + break; + case PROP_SCROLL_OFFSET: case PROP_CURSOR_POSITION: default: @@ -2386,6 +2415,14 @@ gtk_entry_get_property (GObject *object, g_value_set_object (value, G_OBJECT (gtk_entry_get_completion (entry))); break; + case PROP_INPUT_PURPOSE: + g_value_set_enum (value, gtk_entry_get_input_purpose (entry)); + break; + + case PROP_INPUT_HINTS: + g_value_set_flags (value, gtk_entry_get_input_hints (entry)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -10295,3 +10332,65 @@ _gtk_entry_set_is_cell_renderer (GtkEntry *entry, { entry->priv->is_cell_renderer = is_cell_renderer; } + +void +gtk_entry_set_input_purpose (GtkEntry *entry, + GtkInputPurpose purpose) + +{ + g_return_if_fail (GTK_IS_ENTRY (entry)); + + if (gtk_entry_get_input_purpose (entry) != purpose) + { + g_object_set (G_OBJECT (entry->priv->im_context), + "input-purpose", purpose, + NULL); + + g_object_notify (G_OBJECT (entry), "input-purpose"); + } +} + +GtkInputPurpose +gtk_entry_get_input_purpose (GtkEntry *entry) +{ + GtkInputPurpose purpose; + + g_return_val_if_fail (GTK_IS_ENTRY (entry), GTK_INPUT_PURPOSE_FREE_FORM); + + g_object_get (G_OBJECT (entry->priv->im_context), + "input-purpose", &purpose, + NULL); + + return purpose; +} + +void +gtk_entry_set_input_hints (GtkEntry *entry, + GtkInputHints hints) + +{ + g_return_if_fail (GTK_IS_ENTRY (entry)); + + if (gtk_entry_get_input_hints (entry) != hints) + { + g_object_set (G_OBJECT (entry->priv->im_context), + "input-hints", hints, + NULL); + + g_object_notify (G_OBJECT (entry), "input-hints"); + } +} + +GtkInputHints +gtk_entry_get_input_hints (GtkEntry *entry) +{ + GtkInputHints hints; + + g_return_val_if_fail (GTK_IS_ENTRY (entry), GTK_INPUT_HINT_NONE); + + g_object_get (G_OBJECT (entry->priv->im_context), + "input-hints", &hints, + NULL); + + return hints; +} diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h index 1d44ae9aa0..86efd7e098 100644 --- a/gtk/gtkentry.h +++ b/gtk/gtkentry.h @@ -277,6 +277,18 @@ gboolean gtk_entry_im_context_filter_keypress (GtkEntry * GdkEventKey *event); void gtk_entry_reset_im_context (GtkEntry *entry); +GDK_AVAILABLE_IN_3_6 +void gtk_entry_set_input_purpose (GtkEntry *entry, + GtkInputPurpose purpose); +GDK_AVAILABLE_IN_3_6 +GtkInputPurpose gtk_entry_get_input_purpose (GtkEntry *entry); + +GDK_AVAILABLE_IN_3_6 +void gtk_entry_set_input_hints (GtkEntry *entry, + GtkInputHints hints); +GDK_AVAILABLE_IN_3_6 +GtkInputHints gtk_entry_get_input_hints (GtkEntry *entry); + G_END_DECLS |