Add clutter-text properties to NbtkEntry and NbtkLabel

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 NbtkEntry 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
This commit is contained in:
Owen W. Taylor 2009-09-21 19:22:31 -04:00
parent 4b4a1be420
commit 3e90b11cfb
2 changed files with 45 additions and 20 deletions

View File

@ -69,8 +69,9 @@ enum
{
PROP_0,
PROP_ENTRY,
PROP_HINT
PROP_CLUTTER_TEXT,
PROP_HINT_TEXT,
PROP_TEXT,
};
/* signals */
@ -111,12 +112,12 @@ nbtk_entry_set_property (GObject *gobject,
switch (prop_id)
{
case PROP_ENTRY:
nbtk_entry_set_text (entry, g_value_get_string (value));
case PROP_HINT_TEXT:
nbtk_entry_set_hint_text (entry, g_value_get_string (value));
break;
case PROP_HINT:
nbtk_entry_set_hint_text (entry, g_value_get_string (value));
case PROP_TEXT:
nbtk_entry_set_text (entry, g_value_get_string (value));
break;
default:
@ -135,12 +136,17 @@ nbtk_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);
@ -582,18 +588,25 @@ nbtk_entry_class_init (NbtkEntryClass *klass)
widget_class->style_changed = nbtk_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 */
/**
@ -734,7 +747,7 @@ nbtk_entry_set_text (NbtkEntry *entry,
*
* Retrieve the internal #ClutterText so that extra parameters can be set
*
* Returns: (transfer none): ethe #ClutterText used by #NbtkEntry. The entry is
* Returns: (transfer none): the #ClutterText used by #NbtkEntry. The entry is
* owned by the #NbtkEntry and should not be unref'ed by the application.
*/
ClutterActor*

View File

@ -49,7 +49,8 @@ enum
{
PROP_0,
PROP_LABEL
PROP_CLUTTER_TEXT,
PROP_TEXT
};
#define NBTK_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), NBTK_TYPE_LABEL, NbtkLabelPrivate))
@ -71,7 +72,7 @@ nbtk_label_set_property (GObject *gobject,
switch (prop_id)
{
case PROP_LABEL:
case PROP_TEXT:
nbtk_label_set_text (label, g_value_get_string (value));
break;
@ -91,7 +92,11 @@ nbtk_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;
@ -231,11 +236,18 @@ nbtk_label_class_init (NbtkLabelClass *klass)
widget_class->style_changed = nbtk_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);
}