[gtk+/composite-templates] GtkEntry: Add input purpose and hints
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/composite-templates] GtkEntry: Add input purpose and hints
- Date: Fri, 14 Sep 2012 21:15:44 +0000 (UTC)
commit 4fb30a9e8f0c1900613ccac5a35d978514479e98
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Aug 16 14:27:51 2012 -0400
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
gtk/gtk.symbols | 4 ++
gtk/gtkentry.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
gtk/gtkentry.h | 12 ++++++
3 files changed, 116 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 8400278..b3e37d0 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 6d9491e..de43d97 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 1d44ae9..86efd7e 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]