[gnome-shell/gnome-3-8] st-entry: add input purpose and hints
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-8] st-entry: add input purpose and hints
- Date: Mon, 13 May 2013 22:42:25 +0000 (UTC)
commit f7de35b85248fef66ddbbb93e6f5c8bdf90c1065
Author: Daiki Ueno <ueno unixuser org>
Date: Wed Jan 9 18:00:52 2013 +0900
st-entry: add input purpose and hints
Add input-purpose and input-hints properties to StEntry,
and pass these on to StIMText.
https://bugzilla.gnome.org/show_bug.cgi?id=691392
src/st/st-entry.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/st/st-entry.h | 35 +++++++++------
2 files changed, 140 insertions(+), 14 deletions(-)
---
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index e3c684d..6aa4dc3 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -82,6 +82,8 @@ enum
PROP_CLUTTER_TEXT,
PROP_HINT_TEXT,
PROP_TEXT,
+ PROP_INPUT_PURPOSE,
+ PROP_INPUT_HINTS,
};
/* signals */
@@ -136,6 +138,14 @@ st_entry_set_property (GObject *gobject,
st_entry_set_text (entry, g_value_get_string (value));
break;
+ case PROP_INPUT_PURPOSE:
+ st_entry_set_input_purpose (entry, g_value_get_enum (value));
+ break;
+
+ case PROP_INPUT_HINTS:
+ st_entry_set_input_hints (entry, g_value_get_flags (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -164,6 +174,14 @@ st_entry_get_property (GObject *gobject,
g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->entry)));
break;
+ case PROP_INPUT_PURPOSE:
+ g_value_set_enum (value, st_im_text_get_input_purpose (ST_IM_TEXT (priv->entry)));
+ break;
+
+ case PROP_INPUT_HINTS:
+ g_value_set_flags (value, st_im_text_get_input_hints (ST_IM_TEXT (priv->entry)));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -759,6 +777,26 @@ st_entry_class_init (StEntryClass *klass)
NULL, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_TEXT, pspec);
+ pspec = g_param_spec_enum ("input-purpose",
+ "Purpose",
+ "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_PURPOSE,
+ pspec);
+
+ pspec = g_param_spec_flags ("input-hints",
+ "hints",
+ "Hints for the text field behaviour",
+ GTK_TYPE_INPUT_HINTS,
+ GTK_INPUT_HINT_NONE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gobject_class,
+ PROP_INPUT_HINTS,
+ pspec);
+
/* signals */
/**
* StEntry::primary-icon-clicked:
@@ -966,6 +1004,87 @@ st_entry_get_hint_text (StEntry *entry)
return entry->priv->hint;
}
+/**
+ * st_entry_set_input_purpose:
+ * @entry: a #StEntry
+ * @purpose: the purpose
+ *
+ * Sets the #StEntry:input-purpose property which
+ * can be used by on-screen keyboards and other input
+ * methods to adjust their behaviour.
+ */
+void
+st_entry_set_input_purpose (StEntry *entry,
+ GtkInputPurpose purpose)
+{
+ StIMText *imtext;
+
+ g_return_if_fail (ST_IS_ENTRY (entry));
+
+ imtext = ST_IM_TEXT (entry->priv->entry);
+
+ if (st_im_text_get_input_purpose (imtext) != purpose)
+ {
+ st_im_text_set_input_purpose (imtext, purpose);
+
+ g_object_notify (G_OBJECT (entry), "input-purpose");
+ }
+}
+
+/**
+ * st_entry_get_input_purpose:
+ * @entry: a #StEntry
+ *
+ * Gets the value of the #StEntry:input-purpose property.
+ */
+GtkInputPurpose
+st_entry_get_input_purpose (StEntry *entry)
+{
+ g_return_val_if_fail (ST_IS_ENTRY (entry), GTK_INPUT_PURPOSE_FREE_FORM);
+
+ return st_im_text_get_input_purpose (ST_IM_TEXT (entry->priv->entry));
+}
+
+/**
+ * st_entry_set_input_hints:
+ * @entry: a #StEntry
+ * @hints: the hints
+ *
+ * Sets the #StEntry:input-hints property, which
+ * allows input methods to fine-tune their behaviour.
+ */
+void
+st_entry_set_input_hints (StEntry *entry,
+ GtkInputHints hints)
+{
+ StIMText *imtext;
+
+ g_return_if_fail (ST_IS_ENTRY (entry));
+
+ imtext = ST_IM_TEXT (entry->priv->entry);
+
+ if (st_im_text_get_input_hints (imtext) != hints)
+ {
+ st_im_text_set_input_hints (imtext, hints);
+
+ g_object_notify (G_OBJECT (entry), "input-hints");
+ }
+}
+
+/**
+ * st_entry_get_input_hints:
+ * @entry: a #StEntry
+ *
+ * Gets the value of the #StEntry:input-hints property.
+ */
+GtkInputHints
+st_entry_get_input_hints (StEntry *entry)
+{
+ g_return_val_if_fail (ST_IS_ENTRY (entry), GTK_INPUT_HINT_NONE);
+
+ return st_im_text_get_input_hints (ST_IM_TEXT (entry->priv->entry));
+}
+
static gboolean
_st_entry_icon_press_cb (ClutterActor *actor,
ClutterButtonEvent *event,
diff --git a/src/st/st-entry.h b/src/st/st-entry.h
index f48dc53..ebe95bf 100644
--- a/src/st/st-entry.h
+++ b/src/st/st-entry.h
@@ -64,20 +64,27 @@ struct _StEntryClass
GType st_entry_get_type (void) G_GNUC_CONST;
-StWidget * st_entry_new (const gchar *text);
-const gchar * st_entry_get_text (StEntry *entry);
-void st_entry_set_text (StEntry *entry,
- const gchar *text);
-ClutterActor* st_entry_get_clutter_text (StEntry *entry);
-
-void st_entry_set_hint_text (StEntry *entry,
- const gchar *text);
-const gchar * st_entry_get_hint_text (StEntry *entry);
-
-void st_entry_set_primary_icon (StEntry *entry,
- ClutterActor *icon);
-void st_entry_set_secondary_icon (StEntry *entry,
- ClutterActor *icon);
+StWidget *st_entry_new (const gchar *text);
+const gchar *st_entry_get_text (StEntry *entry);
+void st_entry_set_text (StEntry *entry,
+ const gchar *text);
+ClutterActor *st_entry_get_clutter_text (StEntry *entry);
+
+void st_entry_set_hint_text (StEntry *entry,
+ const gchar *text);
+const gchar *st_entry_get_hint_text (StEntry *entry);
+
+void st_entry_set_input_purpose (StEntry *entry,
+ GtkInputPurpose purpose);
+GtkInputPurpose st_entry_get_input_purpose (StEntry *entry);
+void st_entry_set_input_hints (StEntry *entry,
+ GtkInputHints hints);
+GtkInputHints st_entry_get_input_hints (StEntry *entry);
+
+void st_entry_set_primary_icon (StEntry *entry,
+ ClutterActor *icon);
+void st_entry_set_secondary_icon (StEntry *entry,
+ ClutterActor *icon);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]