diff options
author | David Walter Seikel | 2012-04-22 09:20:32 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:20:32 +1000 |
commit | 3ad3455551be0d7859ecb02290376206d5e66498 (patch) | |
tree | 497917e12b4d7f458dff9765d9b53f64c4e03fc3 /libraries/elementary/src/bin/test_fileselector.c | |
parent | Update EFL to latest beta. (diff) | |
download | SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.zip SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.gz SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.bz2 SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.xz |
And actually include new files, plus elementary libraries.
Diffstat (limited to 'libraries/elementary/src/bin/test_fileselector.c')
-rw-r--r-- | libraries/elementary/src/bin/test_fileselector.c | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_fileselector.c b/libraries/elementary/src/bin/test_fileselector.c new file mode 100644 index 0000000..0b2ce21 --- /dev/null +++ b/libraries/elementary/src/bin/test_fileselector.c | |||
@@ -0,0 +1,218 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "elementary_config.h" | ||
3 | #endif | ||
4 | |||
5 | |||
6 | #include <Elementary.h> | ||
7 | #ifndef ENABLE_NLS | ||
8 | # ifndef setlocale | ||
9 | # define setlocale(c, l) | ||
10 | # endif | ||
11 | # ifndef libintl_setlocale | ||
12 | # define libintl_setlocale(c, l) | ||
13 | # endif | ||
14 | #endif | ||
15 | |||
16 | #include <Elementary.h> | ||
17 | #ifndef ELM_LIB_QUICKLAUNCH | ||
18 | static void | ||
19 | my_fileselector_done(void *data, | ||
20 | Evas_Object *obj __UNUSED__, | ||
21 | void *event_info) | ||
22 | { | ||
23 | /* event_info conatin the full path of the selected file | ||
24 | * or NULL if none is selected or cancel is pressed */ | ||
25 | const char *selected = event_info; | ||
26 | |||
27 | if (selected) | ||
28 | printf("Selected file: %s\n", selected); | ||
29 | else | ||
30 | evas_object_del(data); /* delete the test window */ | ||
31 | } | ||
32 | |||
33 | static void | ||
34 | my_fileselector_selected(void *data __UNUSED__, | ||
35 | Evas_Object *obj, | ||
36 | void *event_info) | ||
37 | { | ||
38 | /* event_info conatin the full path of the selected file */ | ||
39 | const char *selected = event_info; | ||
40 | printf("Selected file: %s\n", selected); | ||
41 | |||
42 | /* or you can query the selection */ | ||
43 | printf("or: %s\n", elm_fileselector_selected_get(obj)); | ||
44 | } | ||
45 | |||
46 | static void | ||
47 | _is_save_clicked(void *data, | ||
48 | Evas_Object *obj __UNUSED__, | ||
49 | void *event_info __UNUSED__) | ||
50 | { | ||
51 | Evas_Object *fs = data; | ||
52 | printf("Toggle Is save\n"); | ||
53 | if (elm_fileselector_is_save_get(fs)) | ||
54 | elm_fileselector_is_save_set(fs, EINA_FALSE); | ||
55 | else | ||
56 | elm_fileselector_is_save_set(fs, EINA_TRUE); | ||
57 | } | ||
58 | |||
59 | static void | ||
60 | _folder_only_clicked(void *data, | ||
61 | Evas_Object *obj __UNUSED__, | ||
62 | void *event_info __UNUSED__) | ||
63 | { | ||
64 | Evas_Object *fs = data; | ||
65 | printf("Toggle Folder only\n"); | ||
66 | if (elm_fileselector_folder_only_get(fs)) | ||
67 | elm_fileselector_folder_only_set(fs, EINA_FALSE); | ||
68 | else | ||
69 | elm_fileselector_folder_only_set(fs, EINA_TRUE); | ||
70 | } | ||
71 | |||
72 | static void | ||
73 | _expandable_clicked(void *data, | ||
74 | Evas_Object *obj __UNUSED__, | ||
75 | void *event_info __UNUSED__) | ||
76 | { | ||
77 | Evas_Object *fs = data; | ||
78 | printf("Toggle Expandable\n"); | ||
79 | if (elm_fileselector_expandable_get(fs)) | ||
80 | elm_fileselector_expandable_set(fs, EINA_FALSE); | ||
81 | else | ||
82 | elm_fileselector_expandable_set(fs, EINA_TRUE); | ||
83 | } | ||
84 | |||
85 | static void | ||
86 | _sel_get_clicked(void *data, | ||
87 | Evas_Object *obj __UNUSED__, | ||
88 | void *event_info __UNUSED__) | ||
89 | { | ||
90 | Evas_Object *fs = data; | ||
91 | printf("Get Selected: %s\n", elm_fileselector_selected_get(fs)); | ||
92 | } | ||
93 | |||
94 | static void | ||
95 | _path_get_clicked(void *data, | ||
96 | Evas_Object *obj __UNUSED__, | ||
97 | void *event_info __UNUSED__) | ||
98 | { | ||
99 | Evas_Object *fs = data; | ||
100 | printf("Get Path: %s\n", elm_fileselector_path_get(fs)); | ||
101 | } | ||
102 | |||
103 | static void | ||
104 | _mode_cycle_clicked(void *data, | ||
105 | Evas_Object *obj __UNUSED__, | ||
106 | void *event_info __UNUSED__) | ||
107 | { | ||
108 | Evas_Object *fs = data; | ||
109 | Elm_Fileselector_Mode mode; | ||
110 | |||
111 | mode = (elm_fileselector_mode_get(fs) + 1) % ELM_FILESELECTOR_LAST; | ||
112 | elm_fileselector_mode_set(fs, mode); | ||
113 | |||
114 | printf("Setting mode to: %d\n", mode); | ||
115 | } | ||
116 | |||
117 | void | ||
118 | test_fileselector(void *data __UNUSED__, | ||
119 | Evas_Object *obj __UNUSED__, | ||
120 | void *event_info __UNUSED__) | ||
121 | { | ||
122 | Evas_Object *win, *fs, *vbox, *hbox, *bt, *sep; | ||
123 | |||
124 | /* Set the locale according to the system pref. | ||
125 | * If you dont do so the file selector will order the files list in | ||
126 | * a case sensitive manner | ||
127 | */ | ||
128 | setlocale(LC_ALL, ""); | ||
129 | |||
130 | elm_need_ethumb(); | ||
131 | |||
132 | win = elm_win_util_standard_add("fileselector", "File Selector"); | ||
133 | elm_win_autodel_set(win, EINA_TRUE); | ||
134 | |||
135 | vbox = elm_box_add(win); | ||
136 | elm_win_resize_object_add(win, vbox); | ||
137 | evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
138 | evas_object_show(vbox); | ||
139 | |||
140 | fs = elm_fileselector_add(win); | ||
141 | /* enable the fs file name entry */ | ||
142 | elm_fileselector_is_save_set(fs, EINA_TRUE); | ||
143 | /* make the file list a tree with dir expandable in place */ | ||
144 | elm_fileselector_expandable_set(fs, EINA_FALSE); | ||
145 | /* start the fileselector in the home dir */ | ||
146 | elm_fileselector_path_set(fs, getenv("HOME")); | ||
147 | /* allow fs to expand in x & y */ | ||
148 | evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
149 | evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
150 | elm_box_pack_end(vbox, fs); | ||
151 | evas_object_show(fs); // TODO fix this is the widget | ||
152 | |||
153 | /* the 'done' cb is called when the user press ok/cancel */ | ||
154 | evas_object_smart_callback_add(fs, "done", my_fileselector_done, win); | ||
155 | /* the 'selected' cb is called when the user click on a file/dir */ | ||
156 | evas_object_smart_callback_add(fs, "selected", my_fileselector_selected, | ||
157 | win); | ||
158 | |||
159 | /* test buttons */ | ||
160 | sep = elm_separator_add(win); | ||
161 | elm_separator_horizontal_set(sep, EINA_TRUE); | ||
162 | elm_box_pack_end(vbox, sep); | ||
163 | evas_object_show(sep); | ||
164 | |||
165 | hbox = elm_box_add(win); | ||
166 | elm_box_horizontal_set(hbox, EINA_TRUE); | ||
167 | elm_box_pack_end(vbox, hbox); | ||
168 | evas_object_show(hbox); | ||
169 | |||
170 | bt = elm_check_add(win); | ||
171 | elm_object_text_set(bt, "is save"); | ||
172 | elm_check_state_set(bt, elm_fileselector_is_save_get(fs)); | ||
173 | evas_object_smart_callback_add(bt, "changed", _is_save_clicked, fs); | ||
174 | elm_box_pack_end(hbox, bt); | ||
175 | evas_object_show(bt); | ||
176 | |||
177 | bt = elm_check_add(win); | ||
178 | elm_object_text_set(bt, "folder only"); | ||
179 | elm_check_state_set(bt, elm_fileselector_folder_only_get(fs)); | ||
180 | evas_object_smart_callback_add(bt, "changed", _folder_only_clicked, fs); | ||
181 | elm_box_pack_end(hbox, bt); | ||
182 | evas_object_show(bt); | ||
183 | |||
184 | bt = elm_check_add(win); | ||
185 | elm_object_text_set(bt, "expandable"); | ||
186 | elm_check_state_set(bt, elm_fileselector_expandable_get(fs)); | ||
187 | evas_object_smart_callback_add(bt, "changed", _expandable_clicked, fs); | ||
188 | elm_box_pack_end(hbox, bt); | ||
189 | evas_object_show(bt); | ||
190 | |||
191 | hbox = elm_box_add(win); | ||
192 | elm_box_horizontal_set(hbox, EINA_TRUE); | ||
193 | elm_box_pack_end(vbox, hbox); | ||
194 | evas_object_show(hbox); | ||
195 | |||
196 | bt = elm_button_add(win); | ||
197 | elm_object_text_set(bt, "selected get"); | ||
198 | evas_object_smart_callback_add(bt, "clicked", _sel_get_clicked, fs); | ||
199 | elm_box_pack_end(hbox, bt); | ||
200 | evas_object_show(bt); | ||
201 | |||
202 | bt = elm_button_add(win); | ||
203 | elm_object_text_set(bt, "path get"); | ||
204 | evas_object_smart_callback_add(bt, "clicked", _path_get_clicked, fs); | ||
205 | elm_box_pack_end(hbox, bt); | ||
206 | evas_object_show(bt); | ||
207 | |||
208 | bt = elm_button_add(win); | ||
209 | elm_object_text_set(bt, "mode cycle"); | ||
210 | evas_object_smart_callback_add(bt, "clicked", _mode_cycle_clicked, fs); | ||
211 | elm_box_pack_end(hbox, bt); | ||
212 | evas_object_show(bt); | ||
213 | |||
214 | evas_object_resize(win, 240, 350); | ||
215 | evas_object_show(win); | ||
216 | } | ||
217 | |||
218 | #endif | ||