From a37c86636b0b2ee67fabe977a4fc4a00377b49d2 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 21 Sep 2009 19:22:31 -0400 Subject: [PATCH] Add clutter-text properties to StEntry and StLabel Add clutter-text properties to allow getting access to the underlying ClutterText actor. This corresponds to the get_clutter_text() methods. The PROP_LABEL and PROP_ENTRY enum values are renamed to PROP_TEXT to match the names of the properties that they correspond to, and the properties of StEntry are reordered into alphabetical order. Based on a patch from Colin Walters https://bugzilla.gnome.org/show_bug.cgi?id=591245 http://bugzilla.moblin.org/show_bug.cgi?id=6313 --- src/st/st-entry.c | 45 +++++++++++++++++++++++++++++---------------- src/st/st-label.c | 20 ++++++++++++++++---- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/st/st-entry.c b/src/st/st-entry.c index d746b0a6e..c3f57d6a2 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -70,8 +70,9 @@ enum { PROP_0, - PROP_ENTRY, - PROP_HINT + PROP_CLUTTER_TEXT, + PROP_HINT_TEXT, + PROP_TEXT, }; /* signals */ @@ -112,12 +113,12 @@ st_entry_set_property (GObject *gobject, switch (prop_id) { - case PROP_ENTRY: - st_entry_set_text (entry, g_value_get_string (value)); + case PROP_HINT_TEXT: + st_entry_set_hint_text (entry, g_value_get_string (value)); break; - case PROP_HINT: - st_entry_set_hint_text (entry, g_value_get_string (value)); + case PROP_TEXT: + st_entry_set_text (entry, g_value_get_string (value)); break; default: @@ -136,12 +137,17 @@ st_entry_get_property (GObject *gobject, switch (prop_id) { - case PROP_ENTRY: - g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->entry))); + case PROP_CLUTTER_TEXT: + g_value_set_object (value, priv->entry); break; - case PROP_HINT: + case PROP_HINT_TEXT: g_value_set_string (value, priv->hint); + break; + + case PROP_TEXT: + g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->entry))); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); @@ -583,18 +589,25 @@ st_entry_class_init (StEntryClass *klass) widget_class->style_changed = st_entry_style_changed; - pspec = g_param_spec_string ("text", - "Text", - "Text of the entry", - NULL, G_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_ENTRY, pspec); + pspec = g_param_spec_object ("clutter-text", + "Clutter Text", + "Internal ClutterText actor", + CLUTTER_TYPE_TEXT, + G_PARAM_READABLE); + g_object_class_install_property (gobject_class, PROP_CLUTTER_TEXT, pspec); pspec = g_param_spec_string ("hint-text", "Hint Text", "Text to display when the entry is not focused " "and the text property is empty", NULL, G_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_ENTRY, pspec); + g_object_class_install_property (gobject_class, PROP_HINT_TEXT, pspec); + + pspec = g_param_spec_string ("text", + "Text", + "Text of the entry", + NULL, G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_TEXT, pspec); /* signals */ /** @@ -735,7 +748,7 @@ st_entry_set_text (StEntry *entry, * * Retrieve the internal #ClutterText so that extra parameters can be set * - * Returns: (transfer none): ethe #ClutterText used by #StEntry. The entry is + * Returns: (transfer none): the #ClutterText used by #StEntry. The entry is * owned by the #StEntry and should not be unref'ed by the application. */ ClutterActor* diff --git a/src/st/st-label.c b/src/st/st-label.c index d1193f994..88fa868b0 100644 --- a/src/st/st-label.c +++ b/src/st/st-label.c @@ -50,7 +50,8 @@ enum { PROP_0, - PROP_LABEL + PROP_CLUTTER_TEXT, + PROP_TEXT }; #define ST_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_LABEL, StLabelPrivate)) @@ -72,7 +73,7 @@ st_label_set_property (GObject *gobject, switch (prop_id) { - case PROP_LABEL: + case PROP_TEXT: st_label_set_text (label, g_value_get_string (value)); break; @@ -92,7 +93,11 @@ st_label_get_property (GObject *gobject, switch (prop_id) { - case PROP_LABEL: + case PROP_CLUTTER_TEXT: + g_value_set_object (value, priv->label); + break; + + case PROP_TEXT: g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->label))); break; @@ -232,11 +237,18 @@ st_label_class_init (StLabelClass *klass) widget_class->style_changed = st_label_style_changed; + pspec = g_param_spec_object ("clutter-text", + "Clutter Text", + "Internal ClutterText actor", + CLUTTER_TYPE_TEXT, + G_PARAM_READABLE); + g_object_class_install_property (gobject_class, PROP_CLUTTER_TEXT, pspec); + pspec = g_param_spec_string ("text", "Text", "Text of the label", NULL, G_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_LABEL, pspec); + g_object_class_install_property (gobject_class, PROP_TEXT, pspec); }