1 #include <Elementary.h>
3 # include "elementary_config.h"
6 #ifndef ELM_LIB_QUICKLAUNCH
8 _file_chosen(void *data,
9 Evas_Object *obj __UNUSED__,
12 Evas_Object *entry = data;
13 const char *file = event_info;
16 elm_entry_entry_set(entry, file);
17 printf("File chosen: %s\n", file);
20 printf("File selection canceled.\n");
24 _inwin_mode_toggle(void *data,
25 Evas_Object *obj __UNUSED__,
26 void *event_info __UNUSED__)
28 Evas_Object *fs_bt = data;
29 Eina_Bool value = elm_fileselector_button_inwin_mode_get(fs_bt);
30 elm_fileselector_button_inwin_mode_set(fs_bt, !value);
31 printf("Inwin mode set to: %s\n", value ? "false" : "true");
35 _current_sel_toggle(void *data,
36 Evas_Object *obj __UNUSED__,
37 void *event_info __UNUSED__)
39 Evas_Object *fs_bt = data;
40 Eina_Bool value = elm_fileselector_button_is_save_get(fs_bt);
41 elm_fileselector_button_is_save_set(fs_bt, !value);
42 printf("Current selection editable entry set to: %s\n",
43 value ? "false" : "true");
47 _folder_only_toggle(void *data,
48 Evas_Object *obj __UNUSED__,
49 void *event_info __UNUSED__)
51 Evas_Object *fs_bt = data;
52 Eina_Bool value = elm_fileselector_button_folder_only_get(fs_bt);
53 elm_fileselector_button_folder_only_set(fs_bt, !value);
54 printf("Folder only flag set to: %s\n", value ? "false" : "true");
58 _expandable_toggle(void *data,
59 Evas_Object *obj __UNUSED__,
60 void *event_info __UNUSED__)
62 Evas_Object *fs_bt = data;
63 Eina_Bool value = elm_fileselector_button_expandable_get(fs_bt);
64 elm_fileselector_button_expandable_set(fs_bt, !value);
65 printf("Expandable flag set to: %s\n", value ? "false" : "true");
69 test_fileselector_button(void *data __UNUSED__,
70 Evas_Object *obj __UNUSED__,
71 void *event_info __UNUSED__)
73 Evas_Object *win, *bg, *vbox, *hbox, *ic, *bt, *fs_bt, *en, *lb;
75 win = elm_win_add(NULL, "fileselector button", ELM_WIN_BASIC);
76 elm_win_title_set(win, "File Selector Button");
77 elm_win_autodel_set(win, 1);
80 elm_win_resize_object_add(win, bg);
81 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
84 vbox = elm_box_add(win);
85 elm_win_resize_object_add(win, vbox);
86 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
87 evas_object_show(vbox);
89 /* file selector button */
90 ic = elm_icon_add(win);
91 elm_icon_standard_set(ic, "file");
92 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
93 fs_bt = elm_fileselector_button_add(win);
94 elm_fileselector_button_label_set(fs_bt, "Select a file");
95 elm_fileselector_button_icon_set(fs_bt, ic);
97 elm_box_pack_end(vbox, fs_bt);
98 evas_object_show(fs_bt);
101 /* attribute setting buttons */
102 hbox = elm_box_add(win);
103 elm_box_horizontal_set(hbox, EINA_TRUE);
104 elm_box_pack_end(vbox, hbox);
105 evas_object_show(hbox);
107 bt = elm_button_add(win);
108 elm_button_label_set(bt, "Toggle current selection text entry");
109 evas_object_smart_callback_add(bt, "clicked", _current_sel_toggle, fs_bt);
110 elm_box_pack_end(hbox, bt);
111 evas_object_show(bt);
113 bt = elm_button_add(win);
114 elm_button_label_set(bt, "Toggle inwin mode");
115 evas_object_smart_callback_add(bt, "clicked", _inwin_mode_toggle, fs_bt);
116 elm_box_pack_end(hbox, bt);
117 evas_object_show(bt);
119 bt = elm_button_add(win);
120 elm_button_label_set(bt, "Toggle folder only mode");
121 evas_object_smart_callback_add(bt, "clicked", _folder_only_toggle, fs_bt);
122 elm_box_pack_end(hbox, bt);
123 evas_object_show(bt);
125 bt = elm_button_add(win);
126 elm_button_label_set(bt, "Toggle expandable mode");
127 evas_object_smart_callback_add(bt, "clicked", _expandable_toggle, fs_bt);
128 elm_box_pack_end(hbox, bt);
129 evas_object_show(bt);
131 lb = elm_label_add(win);
132 elm_label_label_set(lb, "Last selection:");
133 elm_box_pack_end(vbox, lb);
134 evas_object_show(lb);
136 en = elm_entry_add(win);
137 elm_entry_line_wrap_set(en, EINA_FALSE);
138 elm_entry_editable_set(en, EINA_FALSE);
139 evas_object_smart_callback_add(fs_bt, "file,chosen", _file_chosen, en);
140 elm_box_pack_end(vbox, en);
141 evas_object_show(en);
143 evas_object_resize(win, 400, 400);
144 evas_object_show(win);