a11y: cally-atktext-example cleanups

Added an early return in test_atk_text().
Fixed a unichar conversion
Print the run_attributes too.
This commit is contained in:
Philippe Normand 2011-02-04 09:36:19 +01:00 committed by Alejandro Piñeiro
parent 11efaf8297
commit 6812ed7d3a

View File

@ -42,24 +42,28 @@ test_atk_text (ClutterActor *actor)
AtkText *cally_text = NULL; AtkText *cally_text = NULL;
gboolean bool = FALSE; gboolean bool = FALSE;
gunichar unichar; gunichar unichar;
gchar buf[7];
gint count = -1; gint count = -1;
gint start = -1; gint start = -1;
gint end = -1; gint end = -1;
gint pos = -1; gint pos = -1;
AtkAttributeSet *at_set = NULL; AtkAttributeSet *at_set = NULL;
GSList *attrs;
gchar *buf;
object = atk_gobject_accessible_for_object (G_OBJECT (actor)); object = atk_gobject_accessible_for_object (G_OBJECT (actor));
cally_text = ATK_TEXT (object); cally_text = ATK_TEXT (object);
if (cally_text != NULL) { if (!cally_text)
return;
text = atk_text_get_text (cally_text, 0, -1); text = atk_text_get_text (cally_text, 0, -1);
g_print ("atk_text_get_text output: %s\n", text); g_print ("atk_text_get_text output: %s\n", text);
g_free (text); text = NULL;
unichar = atk_text_get_character_at_offset (cally_text, 5); unichar = atk_text_get_character_at_offset (cally_text, 5);
g_unichar_to_utf8 (unichar, buf); buf = g_ucs4_to_utf8 (&unichar, 1, NULL, NULL, NULL);
g_print ("atk_text_get_character_at_offset: %s\n", buf); g_print ("atk_text_get_character_at_offset(5): '%s' vs '%c'\n", buf, text[5]);
g_free (text); text = NULL;
g_free (buf); buf = NULL;
text = atk_text_get_text_before_offset (cally_text, text = atk_text_get_text_before_offset (cally_text,
5, ATK_TEXT_BOUNDARY_WORD_END, 5, ATK_TEXT_BOUNDARY_WORD_END,
@ -109,17 +113,20 @@ test_atk_text (ClutterActor *actor)
bool = atk_text_set_selection (cally_text, 0, 6, 10); bool = atk_text_set_selection (cally_text, 0, 6, 10);
g_print ("atk_text_set_selection: %i\n", bool); g_print ("atk_text_set_selection: %i\n", bool);
at_set = atk_text_get_run_attributes (cally_text, 10, at_set = atk_text_get_run_attributes (cally_text, 0,
&start, &end); &start, &end);
g_print ("atk_text_get_run_attributes: %i, %i\n", start, end); g_print ("atk_text_get_run_attributes: %i, %i\n", start, end);
attrs = (GSList*) at_set;
at_set = atk_text_get_default_attributes (cally_text); while (attrs)
g_print ("atk_text_get_default_attributes: (at_set==NULL) == %i \n", {
at_set == NULL); AtkAttribute *at = (AtkAttribute *) attrs->data;
g_print ("text run %s = %s\n", at->name, at->value);
attrs = g_slist_next (attrs);
} }
} }
static gboolean static gboolean
button_press_cb (ClutterActor *actor, button_press_cb (ClutterActor *actor,
ClutterButtonEvent *event, ClutterButtonEvent *event,