2 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 * @file eail_fileselector_entry.c
22 * @brief EailFileselectorEntry implementation
25 #include <Elementary.h>
27 #include "eail_fileselector_entry.h"
28 #include "eail_factory.h"
29 #include "eail_utils.h"
30 #include "eail_priv.h"
32 static void atk_text_interface_init(AtkTextIface *iface);
33 static void eail_fileselector_entry_actions_init(EailActionWidget *widget);
35 #define ICON_CONTENT_NAME "button icon" /**< @brief content name for icon */
36 #define EAIL_FSE_ACTION_CLICK "click"/**< @brief 'click' action name */
37 #define EAIL_FSE_ACTION_LONGPRESS "longpress" /**< @brief 'longpress' action name */
38 #define EAIL_FSE_ACTION_PRESS "press" /**< @brief 'press' action name */
39 #define EAIL_FSE_ACTION_RELEASE "release" /**< @brief 'release' action name */
42 * @brief Definition of EailFileselectorEntry as GObject
44 * EailFileselectorEntry is extended EAIL_TYPE_ACTION_WIDGET with ATK_TYPE_TEXT
45 * interface implemented.
47 G_DEFINE_TYPE_WITH_CODE(EailFileselectorEntry,
48 eail_fileselector_entry,
49 EAIL_TYPE_ACTION_WIDGET,
50 G_IMPLEMENT_INTERFACE(ATK_TYPE_TEXT,
51 atk_text_interface_init));
54 * @brief Initializer for AtkObject
56 * @param obj AtkObject instance
57 * @param data initialization data
60 eail_fileselector_entry_initialize(AtkObject *obj, gpointer data)
62 ATK_OBJECT_CLASS(eail_fileselector_entry_parent_class) ->initialize(obj, data);
63 obj->role = ATK_ROLE_GROUPING;
65 EailActionWidget *action_widget = EAIL_ACTION_WIDGET(obj);
67 /* Initializing possible widget actions table*/
68 eail_fileselector_entry_actions_init(action_widget);
72 * @brief Initializer for EailEntry GObject implementation
74 * @param fileselector_entry EailFileselectorEntry instance
77 eail_fileselector_entry_init(EailFileselectorEntry *fileselector_entry)
79 fileselector_entry->selection_start = 0;
80 fileselector_entry->selection_end = 0;
84 * @brief Gets the accessible name of FileselectorEntry
86 * Name is the label-text on the button.
88 * Implementation of get_name from AtkObject interface.
90 * @param obj AtkObject instance
92 * @returns character string representing the accessible name of
96 eail_fileselector_entry_get_name(AtkObject *obj)
98 Evas_Object *fse_widget = NULL;
99 const gchar *atk_name = NULL;
101 /* returning name from ATK default implementation if available */
102 atk_name = ATK_OBJECT_CLASS(eail_fileselector_entry_parent_class)->get_name(obj);
106 fse_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
107 if (!fse_widget) return NULL;
109 return elm_object_part_text_get(fse_widget, "default");
113 * @brief Gets nested button from FileSelectorEntry
115 * @param obj AtkObject instance
116 * @returns Evas_Object representing the file selector button
117 * or NULL if one was not found
120 _eail_fileselector_entry_get_nested_button(AtkObject *obj)
122 Evas_Object *button_widget = NULL, *fse_widget = NULL;
124 fse_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
125 if (!fse_widget) return NULL;
127 button_widget = elm_object_part_content_get(fse_widget, "elm.swallow.button");
129 DBG("Button widget NOT found!");
131 return button_widget;
135 * @brief Helper function for returning list of nested widgets in fileselector entry
137 * @param obj AtkObject instance
139 * @return Eina_list representing the list of Evas_Object* objects with nested widgets
142 _eail_fileselector_entry_get_items(AtkObject *obj)
144 Eina_List *items = NULL;
145 Evas_Object *icon_widget = NULL, *fse_widget = NULL;
147 fse_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
148 if (!fse_widget) return NULL;
150 icon_widget = elm_object_part_content_get(fse_widget, ICON_CONTENT_NAME);
151 if (!icon_widget) return NULL;
153 items = eina_list_append(items, icon_widget);
159 * @brief Gets the number of accessible children of the accessible
161 * Implementation of get_n_children from AtkObject interface.
163 * @param obj AtkObject instance
165 * @returns integer representing the number of accessible children of
169 eail_fileselector_entry_get_n_children(AtkObject *obj)
174 items = _eail_fileselector_entry_get_items(obj);
175 n_items = eina_list_count(items);
177 eina_list_free(items);
183 * @brief Gets a reference to the specified accessible child of the object
185 * The accessible children are 0-based so the first accessible child
186 * is at index 0, the second at index 1 and so on.
188 * Implementation of get_n_children from AtkObject interface.
190 * @param obj AtkObject instance
191 * @param i index of the child
193 * @returns AtkObject representing the specified accessible child of the
197 eail_fileselector_entry_ref_child(AtkObject *obj, gint i)
199 Eina_List *items = NULL;
200 AtkObject *child = NULL;
202 items = _eail_fileselector_entry_get_items(obj);
203 if (eina_list_count(items) > i)
205 child = eail_factory_get_accessible(eina_list_nth(items, i));
206 if (child) g_object_ref(child);
209 eina_list_free(items);
215 * @brief Destructor of FileselectorEntry class
217 * @param object GObject instance to be finalized
220 eail_fileselector_entry_finalize(GObject *object)
222 G_OBJECT_CLASS(eail_fileselector_entry_parent_class)->finalize(object);
226 * @brief Initializer for EailFileselectorEntry GObject class
228 * Defines callbacks for base AtkObject.
230 * @param klass EailFileselectorEntryClass instance
233 eail_fileselector_entry_class_init(EailFileselectorEntryClass *klass)
235 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
236 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
237 atk_class->initialize = eail_fileselector_entry_initialize;
238 atk_class->get_name = eail_fileselector_entry_get_name;
239 atk_class->get_n_children = eail_fileselector_entry_get_n_children;
240 atk_class->ref_child = eail_fileselector_entry_ref_child;
241 gobject_class->finalize = eail_fileselector_entry_finalize;
245 * Implementation of the *AtkText* interface
249 * @brief Gets text content from item
251 * Implementation of get_text from AtkTextIface.
253 * Use g_free() to free the returned string.
255 * @param text AtkText instance
256 * @param start_offset start position
257 * @param end_offset end position, or -1 for the end of the string
259 * @returns newly allocated string containing the text from start_offset
260 * up to, but not including end_offset
263 eail_fileselector_entry_get_text(AtkText *text,
267 gchar *ret_str = NULL;
268 Evas_Object *fse_widget = NULL;
270 fse_widget = eail_widget_get_widget(EAIL_WIDGET(text));
271 if (!fse_widget) return NULL;
273 ret_str = eail_get_substring
274 (elm_fileselector_path_get(fse_widget),
275 start_offset, end_offset);
281 * @brief Gets the character from popup at the given offset
283 * Implementation of get_character_at_offset from AtkTextIface.
285 * @param text AtkText instance
286 * @param offset character offset
288 * @returns char representing the character at offset
291 eail_fileselector_entry_get_character_at_offset(AtkText *text,
294 gunichar character = '\0';
295 gchar *entry_str = NULL;
297 entry_str = eail_fileselector_entry_get_text(text, 0, -1);
300 character = g_utf8_get_char
301 (g_utf8_offset_to_pointer(entry_str, offset));
309 * @brief Gets the number of characters from text content in item
311 * Implementation of get_character_count from AtkTextIface.
313 * @param text AtkText instance
315 * @returns integer representing the number of characters in text nontent
318 eail_fileselector_entry_get_character_count(AtkText *text)
321 gchar *entry_str = NULL;
322 entry_str = eail_fileselector_entry_get_text(text, 0, -1);
326 count = g_utf8_strlen(entry_str, -1);
334 * @brief Gets the specified text after offset
336 * Use g_free() to free the returned string.
338 * @param text AtkText instance
339 * @param offset character offset
340 * @param boundary_type AtkTextBoundary instance
341 * @param [out] start_offset start offset of the returned string
342 * @param [out] end_offset offset of the first character after the returned
344 * @returns newly allocated string containing the text after offset bounded
345 * by the specified boundary_type
348 eail_fileselector_entry_get_text_after_offset(AtkText *text,
350 AtkTextBoundary boundary_type,
355 Evas_Object *textblock;
356 Evas_Object *entry = NULL;
357 Evas_Object *fileselector_entry_edje_layer = NULL;
359 widget = eail_widget_get_widget(EAIL_WIDGET(text));
360 if (!widget) return NULL;
362 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
363 if (!fileselector_entry_edje_layer) return NULL;
365 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
366 "elm.swallow.entry");
367 if (!entry) return NULL;
369 textblock = elm_entry_textblock_get(entry);
370 if (!textblock) return NULL;
372 return eail_get_text_after(textblock, offset, boundary_type, start_offset,
378 * @brief Gets the specified text at offset
380 * Use g_free() to free the returned string.
382 * @param text AtkText instance
383 * @param offset character offset
384 * @param boundary_type AtkTextBoundary instance
385 * @param [out] start_offset start offset of the returned string
386 * @param [out] end_offset offset of the first character after the returned
388 * @returns newly allocated string containing the text after offset bounded
389 * by the specified boundary_type
392 eail_fileselector_entry_get_text_at_offset(AtkText *text,
394 AtkTextBoundary boundary_type,
399 Evas_Object *textblock;
400 Evas_Object *entry = NULL;
401 Evas_Object *fileselector_entry_edje_layer = NULL;
403 widget = eail_widget_get_widget(EAIL_WIDGET(text));
404 if (!widget) return NULL;
406 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
407 if (!fileselector_entry_edje_layer) return NULL;
409 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
410 "elm.swallow.entry");
411 if (!entry) return NULL;
413 textblock = elm_entry_textblock_get(entry);
414 if (!textblock) return NULL;
416 return eail_get_text_at(textblock, offset, boundary_type, start_offset,
421 * @brief Gets the specified text before offset
423 * Use g_free() to free the returned string.
425 * @param text AtkText instance
426 * @param offset character offset
427 * @param boundary_type AtkTextBoundary instance
428 * @param [out] start_offset start offset of the returned string
429 * @param [out] end_offset offset of the first character after the returned
431 * @returns newly allocated string containing the text after offset bounded
432 * by the specified boundary_type
435 eail_fileselector_entry_get_text_before_offset(AtkText *text,
437 AtkTextBoundary boundary_type,
442 Evas_Object *textblock;
443 Evas_Object *entry = NULL;
444 Evas_Object *fileselector_entry_edje_layer = NULL;
446 widget = eail_widget_get_widget(EAIL_WIDGET(text));
447 if (!widget) return NULL;
449 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
450 if (!fileselector_entry_edje_layer) return NULL;
452 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
453 "elm.swallow.entry");
454 if (!entry) return NULL;
456 textblock = elm_entry_textblock_get(entry);
457 if (!textblock) return NULL;
459 return eail_get_text_before(textblock, offset, boundary_type, start_offset,
464 * @brief Get the bounding box containing the glyph
465 * representing the character at a particular text offset.
467 * @param text AtkText instance
468 * @param offset The offset of the text character for which
469 * bounding information is required.
470 * @param x Pointer for the x cordinate of the bounding box
471 * @param y Pointer for the y cordinate of the bounding box
472 * @param width Pointer for the width of the bounding box
473 * @param height Pointer for the height of the bounding box
474 * @param coords specify whether coordinates are relative to the
475 * screen or widget window
479 eail_fileselector_entry_get_character_extents(AtkText *text,
488 const Evas_Object *textblock = NULL;
489 Evas_Textblock_Cursor *cur = NULL;
490 Evas_Object *entry = NULL;
491 Evas_Object *fileselector_entry_edje_layer = NULL;
493 Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
496 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
497 if (!fileselector_entry_edje_layer) return;
499 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
500 "elm.swallow.entry");
503 textblock = elm_entry_textblock_get(entry);
504 if (!textblock) return;
506 cur = evas_object_textblock_cursor_new(textblock);
509 evas_textblock_cursor_pos_set(cur, offset);
511 result = evas_textblock_cursor_char_geometry_get(cur, x, y, width, height);
513 evas_textblock_cursor_free(cur);
515 if (-1 == result) return;
517 if (coords == ATK_XY_SCREEN)
520 Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(widget));
522 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
529 * @brief Adds a selection bounded by the specified offsets
531 * @param text AtkText instance
532 * @param start_offset start position of the selection
533 * @param end_offset offset of the first character after selection
534 * @returns TRUE on success, FALSE otherwise
537 eail_fileselector_entry_add_selection(AtkText *text,
543 Evas_Object *fileselector_entry_edje_layer = NULL;
545 widget = eail_widget_get_widget(EAIL_WIDGET(text));
549 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
550 if (!fileselector_entry_edje_layer)
553 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
554 "elm.swallow.entry");
558 elm_entry_cursor_pos_set(entry, start_offset);
559 elm_entry_cursor_selection_begin(entry);
560 elm_entry_cursor_pos_set(entry, end_offset);
561 elm_entry_cursor_selection_end(entry);
563 EAIL_FILESELECTOR_ENTRY(text)->selection_start = start_offset;
564 EAIL_FILESELECTOR_ENTRY(text)->selection_end = end_offset;
570 * @brief Removes text selection
572 * This widget supports only one selection
573 * so selection_num should always be 0.
575 * @param text AtkText instance
576 * @param selection_num selection number
577 * @return TRUE on success, FALSE otherwise
580 eail_fileselector_entry_remove_selection(AtkText *text,
585 Evas_Object *fileselector_entry_edje_layer = NULL;
587 widget = eail_widget_get_widget(EAIL_WIDGET(text));
591 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
592 if (!fileselector_entry_edje_layer)
595 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
596 "elm.swallow.entry");
600 if (selection_num != 0 || !elm_entry_selection_get(entry))
603 elm_entry_select_none(entry);
604 EAIL_FILESELECTOR_ENTRY(text)->selection_start = 0;
605 EAIL_FILESELECTOR_ENTRY(text)->selection_end = 0;
611 * @brief Sets text selection for fileselector_entry
613 * This widget supports only one selection
614 * so selection_num should always be 0.
616 * @param text AtkText instance
617 * @param selection_num selection number
618 * @param start_pos start position of the selected region
619 * @param end_pos end position of the selected region
621 * @returns TRUE on success, FALSE otherwise
624 eail_fileselector_entry_set_selection(AtkText *text,
629 if (0 != selection_num)
632 return eail_fileselector_entry_add_selection(text, start_pos, end_pos);
636 * @brief Gets text selection from fileselector_entry
638 * Use g_free() to free the returned string.
640 * This widget supports only one selection
641 * so selection_num should always be 0.
643 * @param text AtkText instance
644 * @param selection_num selection number
645 * @param start_offset start position of the selected region
646 * @param end_offset end position of the selected region
648 * @returns newly allocated string containing the selected text
651 eail_fileselector_entry_get_selection(AtkText *text,
656 const char* selection;
659 Evas_Object *fileselector_entry_edje_layer = NULL;
661 if (0 != selection_num)
664 widget = eail_widget_get_widget(EAIL_WIDGET(text));
668 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
669 if (!fileselector_entry_edje_layer)
672 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
673 "elm.swallow.entry");
677 selection = elm_entry_selection_get(entry);
680 *start_offset = EAIL_FILESELECTOR_ENTRY(text)->selection_start;
681 *end_offset = EAIL_FILESELECTOR_ENTRY(text)->selection_end;
682 return g_strdup(selection);
690 * @brief Gets the number of selected text regions
692 * Only one selection is supported by this widget
693 * so the returned value is 0 or 1.
695 * @param text AtkText instance
696 * @returns integer representing the number of
697 * selected text regions
700 eail_fileselector_entry_get_n_selections(AtkText *text)
704 Evas_Object *fileselector_entry_edje_layer = NULL;
706 widget = eail_widget_get_widget(EAIL_WIDGET(text));
710 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
711 if (!fileselector_entry_edje_layer)
714 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
715 "elm.swallow.entry");
719 if (elm_entry_selection_get(entry))
726 * @brief Gets the caret offset
728 * @param text AtkText instance
729 * @return integer representing the caret offset
732 eail_fileselector_entry_get_caret_offset(AtkText *text)
735 Evas_Object *entry = NULL;
736 Evas_Object *fileselector_entry_edje_layer = NULL;
738 widget = eail_widget_get_widget(EAIL_WIDGET(text));
739 if (!widget) return 0;
741 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
742 if (!fileselector_entry_edje_layer) return 0;
744 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
745 "elm.swallow.entry");
746 if (!entry) return 0;
748 return elm_entry_cursor_pos_get(entry);
752 * @brief Sets the caret (cursor) position to the specified offset.
754 * Implementation of AtkTextIface->set_caret_offset callback.
756 * @param text AtkText instance
757 * @param offset starting position
759 * @returns TRUE on success, FALSE otherwise
762 eail_fileselector_entry_set_caret_offset (AtkText *text,
766 Evas_Object *entry = NULL;
767 Evas_Object *fileselector_entry_edje_layer = NULL;
769 widget = eail_widget_get_widget(EAIL_WIDGET(text));
770 if (!widget) return FALSE;
772 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
773 if (!fileselector_entry_edje_layer) return FALSE;
775 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
776 "elm.swallow.entry");
777 if (!entry) return FALSE;
779 elm_entry_cursor_pos_set(entry, offset);
786 * @brief Creates an AtkAttributeSet which consists of the default values of
787 * attributes for the text
789 * The returned AtkAttributeSet should be freed by a call to
790 * atk_attribute_set_free().
792 * @param text AtkText instance
794 * @returns AtkAttributeSet which contains the default values of attributes
797 static AtkAttributeSet *
798 eail_fileselector_entry_get_default_attributes(AtkText *text)
800 AtkAttributeSet *at_set = NULL;
802 at_set = eail_utils_text_add_attribute
803 (at_set, ATK_TEXT_ATTR_WRAP_MODE,
804 atk_text_attribute_get_value(ATK_TEXT_ATTR_WRAP_MODE, 0));
806 at_set = eail_utils_text_add_attribute
807 (at_set, ATK_TEXT_ATTR_EDITABLE,
808 atk_text_attribute_get_value
809 (ATK_TEXT_ATTR_EDITABLE, TRUE));
815 * @brief Creates an AtkAttributeSet which consists of the attributes
816 * explicitly set at the position offset in the text
818 * start_offset and end_offset are set to the start and end of the range
819 * around offset where the attributes are invariant. Note that end_offset
820 * is the offset of the first character after the range.
822 * The returned AtkAttributeSet should be freed by a call to
823 * atk_attribute_set_free()
825 * @param text AtkText instance
826 * @param offset offset at which to get the attributes
827 * @param [out] start_offset start offset of the range
828 * @param [out] end_offset end offset of the range
830 * @returns AtkAttributeSet which contains the attributes explicitly set at
833 static AtkAttributeSet *
834 eail_fileselector_entry_get_run_attributes(AtkText *text,
839 AtkAttributeSet *at_set = NULL;
840 Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
842 Evas_Object *fileselector_entry_edje_layer = NULL;
844 if (!widget || offset >= eail_fileselector_entry_get_character_count(text))
852 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
853 if (!fileselector_entry_edje_layer)
856 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
857 "elm.swallow.entry");
862 *end_offset = eail_fileselector_entry_get_character_count(text);
864 /* NOTE: Elm_Wrap_Type value is in 100% compatible with ATK wrap modes, so
865 * no additional conversion is needed*/
866 Elm_Wrap_Type wrap_type = elm_entry_line_wrap_get(entry);
867 at_set = eail_utils_text_add_attribute
868 (at_set, ATK_TEXT_ATTR_WRAP_MODE,
869 atk_text_attribute_get_value
870 (ATK_TEXT_ATTR_WRAP_MODE, wrap_type));
872 Eina_Bool editable = elm_entry_editable_get(entry);
873 at_set = eail_utils_text_add_attribute
874 (at_set, ATK_TEXT_ATTR_EDITABLE,
875 atk_text_attribute_get_value
876 (ATK_TEXT_ATTR_EDITABLE, editable));
883 * @brief Gets the offset of the character located at coordinates
884 * x and y. x and y are interpreted as being relative to the
885 * screen or this widget's window depending on coords.
887 * @param text AtkText instance
888 * @param x screen x-position of character
889 * @param y screen y-position of character
890 * @param coords specify whether coordinates are relative to the
891 * screen or widget window
893 * @returns the offset to the character which is located at the
894 * specified x and y coordinates.
897 eail_fileselector_entry_get_offset_at_point(AtkText *text,
902 Eina_Bool result = EINA_FALSE;
903 Evas_Object *textblock = NULL;
904 Evas_Textblock_Cursor *cur = NULL;
906 Evas_Object *entry = NULL;
907 Evas_Object *fileselector_entry_edje_layer = NULL;
909 Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(text));
911 if (!widget) return offset;
913 fileselector_entry_edje_layer = elm_layout_edje_get(widget);
914 if (!fileselector_entry_edje_layer) return offset;
916 entry = edje_object_part_swallow_get(fileselector_entry_edje_layer,
917 "elm.swallow.entry");
918 if (!entry) return offset;
920 textblock = elm_entry_textblock_get(entry);
921 if (!textblock) return offset;
923 cur = evas_object_textblock_cursor_new(textblock);
924 if (!cur) return offset;
926 if (coords == ATK_XY_SCREEN)
929 Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(widget));
931 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
936 result = evas_textblock_cursor_char_coord_set(cur, x, y);
938 if (result == EINA_FALSE)
940 evas_textblock_cursor_free(cur);
944 offset = evas_textblock_cursor_pos_get(cur);
945 evas_textblock_cursor_free(cur);
951 * @brief Initializer for AtkTextIface interface
953 * @param iface AtkTextIface instance
956 atk_text_interface_init(AtkTextIface *iface)
958 iface->get_text = eail_fileselector_entry_get_text;
959 iface->get_character_at_offset = eail_fileselector_entry_get_character_at_offset;
960 iface->get_character_count = eail_fileselector_entry_get_character_count;
961 iface->get_text_after_offset = eail_fileselector_entry_get_text_after_offset;
962 iface->get_text_at_offset = eail_fileselector_entry_get_text_at_offset;
963 iface->get_text_before_offset = eail_fileselector_entry_get_text_before_offset;
964 iface->get_character_extents = eail_fileselector_entry_get_character_extents;
965 iface->get_selection = eail_fileselector_entry_get_selection;
966 iface->set_selection = eail_fileselector_entry_set_selection;
967 iface->get_n_selections = eail_fileselector_entry_get_n_selections;
968 iface->add_selection = eail_fileselector_entry_add_selection;
969 iface->remove_selection = eail_fileselector_entry_remove_selection;
970 iface->get_caret_offset = eail_fileselector_entry_get_caret_offset;
971 iface->set_caret_offset = eail_fileselector_entry_set_caret_offset;
972 iface->get_run_attributes = eail_fileselector_entry_get_run_attributes;
973 iface->get_default_attributes = eail_fileselector_entry_get_default_attributes;
974 iface->get_offset_at_point = eail_fileselector_entry_get_offset_at_point;
978 * Implementation of the Actions
982 * @brief Calls callback with given name
984 * @param action AtkAction instance
985 * @param action_name action name to be called
987 * @returns TRUE on success, FALSE otherwise
990 eail_fileselector_entry_do_action(AtkAction *action,
991 const char *action_name)
993 Evas_Object *button = NULL;
995 button = _eail_fileselector_entry_get_nested_button(ATK_OBJECT(action));
996 if (!button) return FALSE;
998 if (action_name == NULL) return FALSE;
1000 evas_object_smart_callback_call(button, action_name, NULL);
1005 * @brief Handle for 'click' action
1007 * @param action AtkAction instance
1008 * @param data additional action data (not used here)
1010 * @return TRUE if action was triggered successfully, FALSE otherwise
1013 eail_action_click(AtkAction *action, void *data)
1015 return eail_fileselector_entry_do_action(action, "clicked");
1019 * @brief Calls action with given name for actions based on x-y coordinates
1021 * @param action AtkAction instance
1022 * @param name name string of the action to be called
1024 * @returns TRUE on success, FALSE otherwise
1027 _eail_action_handle_coords_action(AtkAction *action, gchar *name)
1029 Evas_Object *button = NULL;
1032 if (name == NULL) return FALSE;
1034 button = _eail_fileselector_entry_get_nested_button(ATK_OBJECT(action));
1035 if (!button) return FALSE;
1037 /* getting coordinates of center of the widget to make sure, that
1038 * click will be performed on active widget area */
1039 eail_get_coords_widget_center(button, &x, &y);
1041 if (0 == g_strcmp0(name, EAIL_FSE_ACTION_PRESS))
1043 DBG("Calling 'press' on button");
1044 eail_mouse_press_on_coords(button, x, y);
1046 else if (0 == g_strcmp0(name, EAIL_FSE_ACTION_RELEASE))
1048 DBG("Calling 'release' on button");
1049 eail_mouse_release_on_coords(button, x, y);
1053 DBG("No action by given name %s", name);
1060 * @brief Handle for 'longpress' action
1062 * @param action AtkAction instance
1063 * @param data additional action data (not used here)
1065 * @return TRUE if action was triggered successfully, FALSE otherwise
1068 eail_action_longpress(AtkAction *action, void *data)
1070 return eail_fileselector_entry_do_action(action, "longpressed");
1074 * @brief Handle for 'press' action
1076 * @param action AtkAction instance
1077 * @param data additional action data (not used here)
1079 * @return TRUE if action was triggered successfully, FALSE otherwise
1082 eail_action_press(AtkAction *action, void *data)
1084 /* this is being done to action press/release raise properly click event.
1085 * Without that for standard behavior of fileselector entry, nothing will
1086 * happen (that why not launching event but emulating mouse press)*/
1087 return _eail_action_handle_coords_action(action, EAIL_FSE_ACTION_PRESS);
1091 * @brief Handle for 'release' action
1093 * @param action AtkAction instance
1094 * @param data additional action data (not used here)
1096 * @return TRUE if action was triggered successfully, FALSE otherwise
1099 eail_action_release(AtkAction *action, void *data)
1101 /* this is being done to action press/release raise properly click event.
1102 * Without that for standard behavior of fileselector entry, nothing will
1103 * happen (that why not launching event but emulating mouse release)*/
1104 return _eail_action_handle_coords_action(action, EAIL_FSE_ACTION_RELEASE);
1108 * @brief Adds fileselector actions to actions table
1110 * @param action_widget widget that implements EailActionWidget interface
1113 eail_fileselector_entry_actions_init(EailActionWidget *action_widget)
1115 eail_action_widget_action_append(action_widget,
1116 EAIL_FSE_ACTION_CLICK, NULL,
1118 eail_action_widget_action_append(action_widget,
1119 EAIL_FSE_ACTION_LONGPRESS, NULL,
1120 eail_action_longpress);
1121 eail_action_widget_action_append(action_widget,
1122 EAIL_FSE_ACTION_PRESS, NULL,
1124 eail_action_widget_action_append(action_widget,
1125 EAIL_FSE_ACTION_RELEASE, NULL,
1126 eail_action_release);