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
This commit is contained in:
Matthias Clasen 2012-08-16 14:27:51 -04:00
parent 3cb4aa44b3
commit eaaee081b1
3 changed files with 116 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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