1 #include <Elementary.h>
4 # include "elementary_config.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, *bg, *vbox, *hbox, *ic, *bt, *fs_en, *en, *lb, *bxx;
164 api_data *api = calloc(1, sizeof(api_data));
166 win = elm_win_add(NULL, "fileselector-entry", ELM_WIN_BASIC);
167 elm_win_title_set(win, "File Selector Entry");
168 elm_win_autodel_set(win, EINA_TRUE);
169 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
171 bg = elm_bg_add(win);
172 elm_win_resize_object_add(win, bg);
173 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
174 evas_object_show(bg);
176 bxx = elm_box_add(win);
177 elm_win_resize_object_add(win, bxx);
178 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
179 evas_object_show(bxx);
181 vbox = elm_box_add(win);
182 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
184 evas_object_show(vbox);
186 bt = elm_button_add(win);
187 elm_object_text_set(bt, "Next API function");
188 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
189 elm_box_pack_end(bxx, bt);
190 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
191 evas_object_show(bt);
193 elm_box_pack_end(bxx, vbox);
195 create_dir_struct(); /* Create a dir struct in /tmp */
197 /* file selector entry */
198 ic = elm_icon_add(win);
199 elm_icon_standard_set(ic, "file");
200 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
201 fs_en = elm_fileselector_entry_add(win);
202 elm_fileselector_entry_path_set(fs_en, "/tmp/test_fs_bt");
203 elm_object_text_set(fs_en, "Select a file");
204 elm_object_part_content_set(fs_en, "button icon", ic);
205 evas_object_size_hint_weight_set(fs_en, EVAS_HINT_EXPAND, 0.0);
206 evas_object_size_hint_align_set(fs_en, EVAS_HINT_FILL, EVAS_HINT_FILL);
208 elm_box_pack_end(vbox, fs_en);
209 evas_object_show(fs_en);
210 evas_object_show(ic);
212 /* attribute setting buttons */
213 hbox = elm_box_add(win);
214 elm_box_horizontal_set(hbox, EINA_TRUE);
215 elm_box_pack_end(vbox, hbox);
216 evas_object_show(hbox);
218 bt = elm_button_add(win);
219 elm_object_text_set(bt, "Toggle inwin mode");
220 evas_object_smart_callback_add(bt, "clicked", _inwin_mode_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 folder only mode");
226 evas_object_smart_callback_add(bt, "clicked", _folder_only_toggle, fs_en);
227 elm_box_pack_end(hbox, bt);
228 evas_object_show(bt);
230 bt = elm_button_add(win);
231 elm_object_text_set(bt, "Toggle expandable mode");
232 evas_object_smart_callback_add(bt, "clicked", _expandable_toggle, fs_en);
233 elm_box_pack_end(hbox, bt);
234 evas_object_show(bt);
236 lb = elm_label_add(win);
237 elm_object_text_set(lb, "Last selection:");
238 elm_box_pack_end(vbox, lb);
239 evas_object_show(lb);
241 hbox = elm_box_add(win);
242 elm_box_horizontal_set(hbox, EINA_TRUE);
243 elm_box_pack_end(vbox, hbox);
244 evas_object_show(hbox);
246 bt = elm_button_add(win);
247 elm_object_text_set(bt, "Toggle disabled");
248 evas_object_smart_callback_add(bt, "clicked", _disabled_toggle, fs_en);
249 elm_box_pack_end(hbox, bt);
250 evas_object_show(bt);
252 en = elm_entry_add(win);
253 elm_entry_line_wrap_set(en, ELM_WRAP_NONE);
254 elm_entry_editable_set(en, EINA_FALSE);
255 evas_object_smart_callback_add(fs_en, "file,chosen", _file_chosen, en);
256 elm_box_pack_end(vbox, en);
257 evas_object_show(en);
259 evas_object_resize(win, 400, 500);
260 evas_object_show(win);