3 # include "elementary_config.h"
6 #include <Elementary.h>
7 #ifndef ELM_LIB_QUICKLAUNCH
10 unsigned int state; /* What state we are testing */
11 Evas_Object *box; /* Additional data defined by test */
12 Eina_Bool free_data; /* free data on close */
14 typedef struct _api_data api_data;
21 typedef enum _api_state api_state;
24 set_api_state(api_data *api)
26 const Eina_List *items = elm_box_children_get(api->box);
27 if (!eina_list_count(items))
30 /* Get first item of list of vbox children */
31 Evas_Object *fs_bt = eina_list_nth(items, 0);
33 /* use elm_box_children_get() to get list of children */
35 { /* Put all api-changes under switch */
37 elm_object_part_content_unset(fs_bt, NULL);
40 case WINDOW_TITLE_SET:
41 elm_fileselector_button_window_title_set(fs_bt, "Custom title from API");
53 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
54 { /* Will add here a SWITCH command containing code to modify test-object */
55 /* in accordance a->state value. */
59 printf("clicked event on API Button: api_state=<%d>\n", a->state);
62 sprintf(str, "Next API function (%u)", a->state);
63 elm_object_text_set(obj, str);
64 elm_object_disabled_set(obj, a->state == API_STATE_LAST);
68 create_dir_struct(void)
71 mkdir("/tmp/test_fs_bt", S_IRWXU);
72 fp = fopen("/tmp/test_fs_bt/a_file.txt", "w");
74 fp = fopen("/tmp/test_fs_bt/k_file.txt", "w");
76 fp = fopen("/tmp/test_fs_bt/m_file.txt", "w");
79 mkdir("/tmp/test_fs_bt/a_subdir", S_IRWXU);
80 fp = fopen("/tmp/test_fs_bt/a_subdir/d_sub_file.txt", "w");
82 fp = fopen("/tmp/test_fs_bt/a_subdir/j_sub_file.txt", "w");
87 _file_chosen(void *data,
88 Evas_Object *obj __UNUSED__,
91 Evas_Object *entry = data;
92 const char *file = event_info;
95 elm_object_text_set(entry, file);
96 printf("File chosen: %s\n", file);
99 printf("File selection canceled.\n");
103 _inwin_mode_toggle(void *data,
104 Evas_Object *obj __UNUSED__,
105 void *event_info __UNUSED__)
107 Evas_Object *fs_bt = data;
108 Eina_Bool value = elm_fileselector_button_inwin_mode_get(fs_bt);
109 elm_fileselector_button_inwin_mode_set(fs_bt, !value);
110 printf("Inwin mode set to: %s\n", value ? "false" : "true");
114 _current_sel_toggle(void *data,
115 Evas_Object *obj __UNUSED__,
116 void *event_info __UNUSED__)
118 Evas_Object *fs_bt = data;
119 Eina_Bool value = elm_fileselector_button_is_save_get(fs_bt);
120 elm_fileselector_button_is_save_set(fs_bt, !value);
121 printf("Current selection editable entry set to: %s\n",
122 value ? "false" : "true");
126 _folder_only_toggle(void *data,
127 Evas_Object *obj __UNUSED__,
128 void *event_info __UNUSED__)
130 Evas_Object *fs_bt = data;
131 Eina_Bool value = elm_fileselector_button_folder_only_get(fs_bt);
132 elm_fileselector_button_folder_only_set(fs_bt, !value);
133 printf("Folder only flag set to: %s\n", value ? "false" : "true");
137 _expandable_toggle(void *data,
138 Evas_Object *obj __UNUSED__,
139 void *event_info __UNUSED__)
141 Evas_Object *fs_bt = data;
142 Eina_Bool value = elm_fileselector_button_expandable_get(fs_bt);
143 elm_fileselector_button_expandable_set(fs_bt, !value);
144 printf("Expandable flag set to: %s\n", value ? "false" : "true");
148 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
154 test_fileselector_button(void *data __UNUSED__,
155 Evas_Object *obj __UNUSED__,
156 void *event_info __UNUSED__)
158 Evas_Object *win, *bg, *vbox, *hbox, *ic, *bt, *fs_bt, *en, *lb, *bxx;
159 api_data *api = calloc(1, sizeof(api_data));
161 win = elm_win_add(NULL, "fileselector-button", ELM_WIN_BASIC);
162 elm_win_title_set(win, "File Selector Button");
163 elm_win_autodel_set(win, EINA_TRUE);
164 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
166 bg = elm_bg_add(win);
167 elm_win_resize_object_add(win, bg);
168 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
169 evas_object_show(bg);
171 bxx = elm_box_add(win);
172 elm_win_resize_object_add(win, bxx);
173 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
174 evas_object_show(bxx);
176 vbox = elm_box_add(win);
178 evas_object_show(vbox);
180 bt = elm_button_add(win);
181 elm_object_text_set(bt, "Next API function");
182 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
183 elm_box_pack_end(bxx, bt);
184 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
185 evas_object_show(bt);
187 elm_box_pack_end(bxx, vbox);
189 create_dir_struct(); /* Create a dir struct in /tmp */
190 /* file selector button */
191 ic = elm_icon_add(win);
192 elm_icon_standard_set(ic, "file");
193 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
194 fs_bt = elm_fileselector_button_add(win);
195 elm_object_text_set(fs_bt, "Select a file");
196 elm_object_part_content_set(fs_bt, "icon", ic);
197 elm_fileselector_button_path_set(fs_bt, "/tmp/test_fs_bt");
199 elm_box_pack_end(vbox, fs_bt);
200 evas_object_show(fs_bt);
201 evas_object_show(ic);
203 /* attribute setting buttons */
204 hbox = elm_box_add(win);
205 elm_box_horizontal_set(hbox, EINA_TRUE);
206 elm_box_pack_end(vbox, hbox);
207 evas_object_show(hbox);
209 bt = elm_check_add(win);
210 elm_object_style_set(bt, "toggle");
211 elm_object_text_set(bt, "current selection text entry");
212 evas_object_smart_callback_add(bt, "changed", _current_sel_toggle, fs_bt);
213 elm_box_pack_end(hbox, bt);
214 evas_object_show(bt);
216 bt = elm_check_add(win);
217 elm_object_style_set(bt, "toggle");
218 elm_object_text_set(bt, "Inwin mode");
219 elm_check_state_set (bt, EINA_TRUE);
220 evas_object_smart_callback_add(bt, "changed", _inwin_mode_toggle, fs_bt);
221 elm_box_pack_end(hbox, bt);
222 evas_object_show(bt);
224 bt = elm_check_add(win);
225 elm_object_style_set(bt, "toggle");
226 elm_object_text_set(bt, "Folder only mode");
227 evas_object_smart_callback_add(bt, "changed", _folder_only_toggle, fs_bt);
228 elm_box_pack_end(hbox, bt);
229 evas_object_show(bt);
231 bt = elm_check_add(win);
232 elm_object_style_set(bt, "toggle");
233 elm_object_text_set(bt, "Expandable mode");
234 evas_object_smart_callback_add(bt, "changed", _expandable_toggle, fs_bt);
235 elm_box_pack_end(hbox, bt);
236 evas_object_show(bt);
238 lb = elm_label_add(win);
239 elm_object_text_set(lb, "Last selection:");
240 elm_box_pack_end(vbox, lb);
241 evas_object_show(lb);
243 en = elm_entry_add(win);
244 elm_entry_line_wrap_set(en, ELM_WRAP_NONE);
245 elm_entry_editable_set(en, EINA_FALSE);
246 evas_object_smart_callback_add(fs_bt, "file,chosen", _file_chosen, en);
247 elm_box_pack_end(vbox, en);
248 evas_object_show(en);
250 evas_object_resize(win, 400, 400);
251 evas_object_show(win);