mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
clutter-text: Allow setting attributes for editable text
The behaviour imitates GtkEntry and ignores attributes from markup because Pango barfs on invalid markup. Also add an example to the text-field interactive test. https://bugzilla.gnome.org/show_bug.cgi?id=686477
This commit is contained in:

committed by
Emmanuele Bassi

parent
aa85a8e94d
commit
a783e6d3f2
@ -207,6 +207,7 @@ create_label (const ClutterColor *color,
|
||||
static ClutterActor *
|
||||
create_entry (const ClutterColor *color,
|
||||
const gchar *text,
|
||||
PangoAttrList *attrs,
|
||||
gunichar password_char,
|
||||
gint max_length)
|
||||
{
|
||||
@ -227,6 +228,8 @@ create_entry (const ClutterColor *color,
|
||||
clutter_text_set_max_length (CLUTTER_TEXT (retval), max_length);
|
||||
clutter_text_set_selected_text_color (CLUTTER_TEXT (retval), &selected_text);
|
||||
clutter_actor_set_background_color (retval, CLUTTER_COLOR_LightGray);
|
||||
if (attrs)
|
||||
clutter_text_set_attributes (CLUTTER_TEXT (retval), attrs);
|
||||
|
||||
g_signal_connect (retval, "activate",
|
||||
G_CALLBACK (on_entry_activate),
|
||||
@ -245,6 +248,7 @@ test_text_field_main (gint argc,
|
||||
ClutterActor *stage;
|
||||
ClutterActor *box, *label, *entry;
|
||||
ClutterLayoutManager *table;
|
||||
PangoAttrList *entry_attrs;
|
||||
|
||||
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
||||
return EXIT_FAILURE;
|
||||
@ -275,7 +279,10 @@ test_text_field_main (gint argc,
|
||||
"y-expand", FALSE,
|
||||
NULL);
|
||||
|
||||
entry = create_entry (CLUTTER_COLOR_Black, "<i>some</i> text", 0, 0);
|
||||
entry_attrs = pango_attr_list_new ();
|
||||
pango_attr_list_insert (entry_attrs, pango_attr_underline_new (PANGO_UNDERLINE_ERROR));
|
||||
pango_attr_list_insert (entry_attrs, pango_attr_underline_color_new (65535, 0, 0));
|
||||
entry = create_entry (CLUTTER_COLOR_Black, "somme misspeeled textt", entry_attrs, 0, 0);
|
||||
clutter_actor_add_child (box, entry);
|
||||
clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), entry,
|
||||
"row", 0,
|
||||
@ -295,7 +302,7 @@ test_text_field_main (gint argc,
|
||||
"y-expand", FALSE,
|
||||
NULL);
|
||||
|
||||
entry = create_entry (CLUTTER_COLOR_Black, "password", '*', 8);
|
||||
entry = create_entry (CLUTTER_COLOR_Black, "password", NULL, '*', 8);
|
||||
clutter_actor_add_child (box, entry);
|
||||
clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), entry,
|
||||
"row", 1,
|
||||
|
Reference in New Issue
Block a user