/* reason: discard text length parameter and handle in-out position it's probably too much trouble to add automatic in-out support, especially because it only affects primitive types - why couldn't they just return that by value? */ USER_OBJECT_ S_atk_editable_text_insert_text(USER_OBJECT_ s_object, USER_OBJECT_ s_string, USER_OBJECT_ s_position) { AtkEditableText* object = ATK_EDITABLE_TEXT(getPtrValue(s_object)); const gchar* string = (const gchar*)asCString(s_string); gint* position = (gint*)asCArray(s_position, gint, asCInteger); gint length = strlen(string); USER_OBJECT_ _result = NULL_USER_OBJECT; atk_editable_text_insert_text(object, string, length, position); _result = retByVal(_result, "position", asRInteger(*position), NULL); return(_result); }
static gboolean set_text_press_cb (ClutterActor *actor, ClutterButtonEvent *event, gpointer data) { AtkObject *object = NULL; AtkEditableText *cally_editable_text = NULL; object = atk_gobject_accessible_for_object (G_OBJECT (text_editable_actor)); cally_editable_text = ATK_EDITABLE_TEXT (object); atk_editable_text_set_text_contents (cally_editable_text, "New text"); return TRUE; }
static gboolean insert_text_press_cb (ClutterActor *actor, ClutterButtonEvent *event, gpointer data) { AtkObject *object = NULL; AtkEditableText *cally_editable_text = NULL; gint pos = 0; object = atk_gobject_accessible_for_object (G_OBJECT (text_editable_actor)); cally_editable_text = ATK_EDITABLE_TEXT (object); pos = 3; atk_editable_text_insert_text (cally_editable_text, "New", 0, &pos); return TRUE; }
static void _set_values (AtkObject *obj) { GValue *value_back, val; static gint count = 0; gdouble double_value; value_back = &val; if(ATK_IS_VALUE(obj)) { /* Spin button also inherits the text interfaces from GailEntry. * Check when spin button recieves focus. */ if(ATK_IS_TEXT(obj) && ATK_IS_EDITABLE_TEXT(obj)) { if(count == 0) { gint x; gchar* text; count++; x = atk_text_get_character_count (ATK_TEXT (obj)); text = atk_text_get_text (ATK_TEXT (obj), 0, x); g_print("Text : %s\n", text); text = "5.7"; atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj),text); g_print("Set text to %s\n",text); atk_value_get_current_value(ATK_VALUE(obj), value_back); g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back)); g_print("atk_value_get_current_value returns %f\n", g_value_get_double( value_back)); } } else { memset (value_back, 0, sizeof (GValue)); g_value_init (value_back, G_TYPE_DOUBLE); g_value_set_double (value_back, 10.0); if (atk_value_set_current_value (ATK_VALUE (obj), value_back)) { double_value = g_value_get_double (value_back); g_print("atk_value_set_current_value returns %f\n", double_value); } } } }
/* * Test AtkText interface */ static void test_atk_text (ClutterActor *actor) { AtkObject *object = NULL; AtkEditableText *cally_editable_text = NULL; gint pos = 0; object = atk_gobject_accessible_for_object (G_OBJECT (actor)); cally_editable_text = ATK_EDITABLE_TEXT (object); if (cally_editable_text != NULL) { atk_editable_text_set_text_contents (cally_editable_text, "New text"); atk_editable_text_delete_text (cally_editable_text, 0, 3); pos = 3; atk_editable_text_insert_text (cally_editable_text, "New", 0, &pos); /* Not implemented in cally, just checking that we can call this functions */ atk_editable_text_copy_text (cally_editable_text, 0, -1); atk_editable_text_paste_text (cally_editable_text, 5); atk_editable_text_cut_text (cally_editable_text, 0, -1); } }
static void _do_test(AtkObject *obj) { gchar *text; int start_offset, end_offset; g_assert(ATK_IS_EDITABLE_TEXT(obj)); text = atk_text_get_text(ATK_TEXT(obj), 0, -1); if (!g_strcmp0(text, ENTRY_FIRST)) { g_free(text); text = g_strdup(ENTRY_TEXT); atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj), text); g_free(text); start_offset = 0; end_offset = -1; text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset); g_assert_cmpstr(text, ==, ENTRY_TEXT); g_free(text); start_offset = 0; end_offset = 7; atk_editable_text_delete_text(ATK_EDITABLE_TEXT(obj), start_offset, end_offset); text = atk_text_get_text(ATK_TEXT(obj), 0, -1); g_assert_cmpstr(text, ==, " lololololo olololo"); g_free(text); atk_editable_text_insert_text(ATK_EDITABLE_TEXT(obj), "Trololo", 7, &start_offset); text = atk_text_get_text(ATK_TEXT(obj), 0, -1); g_assert(start_offset == 7); g_assert_cmpstr(text, ==, ENTRY_TEXT); g_free(text); start_offset = 8; end_offset = 18; atk_editable_text_copy_text(ATK_EDITABLE_TEXT(obj), start_offset, end_offset); atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj), "123"); atk_editable_text_paste_text(ATK_EDITABLE_TEXT(obj), 3); start_offset = 0; end_offset = -1; text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset); g_assert_cmpstr(text, ==, "123lololololo"); g_free(text); start_offset = 0; end_offset = 3; atk_editable_text_cut_text(ATK_EDITABLE_TEXT(obj), start_offset, end_offset); text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset); g_assert_cmpstr(text, ==, "lol"); g_free(text); start_offset = 0; end_offset = -1; atk_editable_text_paste_text(ATK_EDITABLE_TEXT(obj), 3); text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset); g_assert_cmpstr(text, ==, "lol123olololo"); g_free(text); atk_editable_text_cut_text(ATK_EDITABLE_TEXT(obj), 3, 6); text = atk_text_get_text(ATK_TEXT(obj), 0, -1); g_assert_cmpstr(text, ==, "lololololo"); g_free(text); }