3 # include "elementary_config.h"
6 #include <Elementary.h>
7 #ifndef ELM_LIB_QUICKLAUNCH
10 unsigned int state; /* What state we are testing */
11 void *box; /* Use this to get box content */
13 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_entry_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 char *file = event_info;
93 elm_object_text_set(entry, file);
94 printf("File chosen: %s\n", file);
98 _inwin_mode_toggle(void *data,
99 Evas_Object *obj __UNUSED__,
100 void *event_info __UNUSED__)
102 Evas_Object *fs_en = data;
103 Eina_Bool value = elm_fileselector_entry_inwin_mode_get(fs_en);
104 elm_fileselector_entry_inwin_mode_set(fs_en, !value);
105 printf("Inwin mode set to: %s\n", value ? "false" : "true");
109 _folder_only_toggle(void *data,
110 Evas_Object *obj __UNUSED__,
111 void *event_info __UNUSED__)
113 Evas_Object *fs_en = data;
114 Evas_Object *ic = elm_object_part_content_get(fs_en, "button icon");
115 Eina_Bool value = elm_fileselector_entry_folder_only_get(fs_en);
116 elm_fileselector_entry_folder_only_set(fs_en, !value);
117 printf("Folder only flag set to: %s\n", value ? "false" : "true");
120 elm_icon_standard_set(ic, "folder");
121 elm_object_text_set(fs_en, "Select a folder");
125 elm_icon_standard_set(ic, "file");
126 elm_object_text_set(fs_en, "Select a file");
131 _expandable_toggle(void *data,
132 Evas_Object *obj __UNUSED__,
133 void *event_info __UNUSED__)
135 Evas_Object *fs_en = data;
136 Eina_Bool value = elm_fileselector_entry_expandable_get(fs_en);
137 elm_fileselector_entry_expandable_set(fs_en, !value);
138 printf("Expandable flag set to: %s\n", value ? "false" : "true");
142 _disabled_toggle(void *data,
143 Evas_Object *obj __UNUSED__,
144 void *event_info __UNUSED__)
146 Evas_Object *fs_en = data;
147 Eina_Bool value = elm_object_disabled_get(fs_en);
148 elm_object_disabled_set(fs_en, !value);
149 printf("Disabled flag set to: %s\n", value ? "false" : "true");
153 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
159 test_fileselector_entry(void *data __UNUSED__,
160 Evas_Object *obj __UNUSED__,
161 void *event_info __UNUSED__)
163 Evas_Object *win, *vbox, *hbox, *ic, *bt, *fs_en, *en, *lb, *bxx;
164 api_data *api = calloc(1, sizeof(api_data));
166 win = elm_win_util_standard_add("fileselector-entry", "File Selector Entry");
167 elm_win_autodel_set(win, EINA_TRUE);
168 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
170 bxx = elm_box_add(win);
171 elm_win_resize_object_add(win, bxx);
172 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
173 evas_object_show(bxx);
175 vbox = elm_box_add(win);
176 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
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 */
191 /* file selector entry */
192 ic = elm_icon_add(win);
193 elm_icon_standard_set(ic, "file");
194 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
195 fs_en = elm_fileselector_entry_add(win);
196 elm_fileselector_entry_path_set(fs_en, "/tmp/test_fs_bt");
197 elm_object_text_set(fs_en, "Select a file");
198 elm_object_part_content_set(fs_en, "button icon", ic);
199 evas_object_size_hint_weight_set(fs_en, EVAS_HINT_EXPAND, 0.0);
200 evas_object_size_hint_align_set(fs_en, EVAS_HINT_FILL, EVAS_HINT_FILL);
202 elm_box_pack_end(vbox, fs_en);
203 evas_object_show(fs_en);
204 evas_object_show(ic);
206 /* attribute setting buttons */
207 hbox = elm_box_add(win);
208 elm_box_horizontal_set(hbox, EINA_TRUE);
209 elm_box_pack_end(vbox, hbox);
210 evas_object_show(hbox);
212 bt = elm_button_add(win);
213 elm_object_text_set(bt, "Toggle inwin mode");
214 evas_object_smart_callback_add(bt, "clicked", _inwin_mode_toggle, fs_en);
215 elm_box_pack_end(hbox, bt);
216 evas_object_show(bt);
218 bt = elm_button_add(win);
219 elm_object_text_set(bt, "Toggle folder only mode");
220 evas_object_smart_callback_add(bt, "clicked", _folder_only_toggle, fs_en);
221 elm_box_pack_end(hbox, bt);
222 evas_object_show(bt);
224 bt = elm_button_add(win);
225 elm_object_text_set(bt, "Toggle expandable mode");
226 evas_object_smart_callback_add(bt, "clicked", _expandable_toggle, fs_en);
227 elm_box_pack_end(hbox, bt);
228 evas_object_show(bt);
230 lb = elm_label_add(win);
231 elm_object_text_set(lb, "Last selection:");
232 elm_box_pack_end(vbox, lb);
233 evas_object_show(lb);
235 hbox = elm_box_add(win);
236 elm_box_horizontal_set(hbox, EINA_TRUE);
237 elm_box_pack_end(vbox, hbox);
238 evas_object_show(hbox);
240 bt = elm_button_add(win);
241 elm_object_text_set(bt, "Toggle disabled");
242 evas_object_smart_callback_add(bt, "clicked", _disabled_toggle, fs_en);
243 elm_box_pack_end(hbox, bt);
244 evas_object_show(bt);
246 en = elm_entry_add(win);
247 elm_entry_line_wrap_set(en, ELM_WRAP_NONE);
248 elm_entry_editable_set(en, EINA_FALSE);
249 evas_object_smart_callback_add(fs_en, "file,chosen", _file_chosen, en);
250 elm_box_pack_end(vbox, en);
251 evas_object_show(en);
253 evas_object_resize(win, 400, 500);
254 evas_object_show(win);