diff options
author | David Walter Seikel | 2014-05-04 19:47:26 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-04 19:47:26 +1000 |
commit | 678db28766fb6bcc7bcdc8e598f8aab3bda5f148 (patch) | |
tree | a1e107ce4632ee97fb3028d3a68f1a72467b5813 /src | |
parent | Major clean up of the file selector. (diff) | |
download | SledjHamr-678db28766fb6bcc7bcdc8e598f8aab3bda5f148.zip SledjHamr-678db28766fb6bcc7bcdc8e598f8aab3bda5f148.tar.gz SledjHamr-678db28766fb6bcc7bcdc8e598f8aab3bda5f148.tar.bz2 SledjHamr-678db28766fb6bcc7bcdc8e598f8aab3bda5f148.tar.xz |
Make the file selector actually useful.
Diffstat (limited to 'src')
-rw-r--r-- | src/extantz/extantz.c | 15 | ||||
-rw-r--r-- | src/extantz/extantz.h | 5 | ||||
-rw-r--r-- | src/extantz/files.c | 45 |
3 files changed, 47 insertions, 18 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 0579552..4ef9ecc 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c | |||
@@ -128,7 +128,13 @@ static void _del_gl(Evas_Object *obj) | |||
128 | _clean_gl(ourGlobals, NULL, NULL, NULL); | 128 | _clean_gl(ourGlobals, NULL, NULL, NULL); |
129 | } | 129 | } |
130 | 130 | ||
131 | // Callback for when the app quits. | 131 | static void _on_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
132 | { | ||
133 | globals *ourGlobals = data; | ||
134 | |||
135 | filesShow(ourGlobals->files, NULL, NULL); | ||
136 | } | ||
137 | |||
132 | static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | 138 | static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
133 | { | 139 | { |
134 | // GLData *gld = data; | 140 | // GLData *gld = data; |
@@ -286,6 +292,7 @@ static void makeMainMenu(globals *ourGlobals) | |||
286 | 292 | ||
287 | // Menus. | 293 | // Menus. |
288 | menu = _toolbar_menu_add(ourGlobals->win, tb, "file"); | 294 | menu = _toolbar_menu_add(ourGlobals->win, tb, "file"); |
295 | elm_menu_item_add(menu, NULL, NULL, "open", _on_open, ourGlobals); | ||
289 | elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld); | 296 | elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld); |
290 | 297 | ||
291 | menu = _toolbar_menu_add(ourGlobals->win, tb, "edit"); | 298 | menu = _toolbar_menu_add(ourGlobals->win, tb, "edit"); |
@@ -327,7 +334,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
327 | Evas_Object *obj; | 334 | Evas_Object *obj; |
328 | EPhysics_World *world; | 335 | EPhysics_World *world; |
329 | GLData *gld = NULL; | 336 | GLData *gld = NULL; |
330 | fangWin *chat = NULL, *files = NULL, *woMan = NULL; | 337 | fangWin *chat = NULL, *woMan = NULL; |
331 | char buf[PATH_MAX]; | 338 | char buf[PATH_MAX]; |
332 | // Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. | 339 | // Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. |
333 | 340 | ||
@@ -413,7 +420,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
413 | // overlay_add(&ourGlobals); | 420 | // overlay_add(&ourGlobals); |
414 | woMan = woMan_add(&ourGlobals); | 421 | woMan = woMan_add(&ourGlobals); |
415 | chat = chat_add(&ourGlobals); | 422 | chat = chat_add(&ourGlobals); |
416 | files = files_add(&ourGlobals); | 423 | ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); |
417 | 424 | ||
418 | // Gotta do this after adding the windows, otherwise the menu renders under the window. | 425 | // Gotta do this after adding the windows, otherwise the menu renders under the window. |
419 | // This sucks, gotta redefine this menu each time we create a new window? | 426 | // This sucks, gotta redefine this menu each time we create a new window? |
@@ -448,7 +455,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
448 | { | 455 | { |
449 | Evas_3D_Demo_fini(&ourGlobals); | 456 | Evas_3D_Demo_fini(&ourGlobals); |
450 | eo_unref(ourGlobals.tb); | 457 | eo_unref(ourGlobals.tb); |
451 | fang_win_del(&ourGlobals, files); | 458 | fang_win_del(&ourGlobals, ourGlobals.files); |
452 | fang_win_del(&ourGlobals, chat); | 459 | fang_win_del(&ourGlobals, chat); |
453 | fang_win_del(&ourGlobals, woMan); | 460 | fang_win_del(&ourGlobals, woMan); |
454 | eo_unref(ourGlobals.bx); | 461 | eo_unref(ourGlobals.bx); |
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index a5fb794..84ebcba 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h | |||
@@ -241,6 +241,8 @@ typedef struct _globals | |||
241 | 241 | ||
242 | GLData gld; | 242 | GLData gld; |
243 | Scene_Data *scene; | 243 | Scene_Data *scene; |
244 | |||
245 | fangWin *files; | ||
244 | } globals; | 246 | } globals; |
245 | 247 | ||
246 | extern globals ourGlobals; | 248 | extern globals ourGlobals; |
@@ -274,7 +276,8 @@ void overlay_add(globals *ourGlobals); | |||
274 | Widget *widgetAdd(fangWin *win); | 276 | Widget *widgetAdd(fangWin *win); |
275 | 277 | ||
276 | fangWin *chat_add(globals *ourGlobals); | 278 | fangWin *chat_add(globals *ourGlobals); |
277 | fangWin *files_add(globals *ourGlobals); | 279 | fangWin *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save); |
280 | void filesShow(fangWin *me, Evas_Smart_Cb func, void *data); | ||
278 | fangWin *woMan_add(globals *ourGlobals); | 281 | fangWin *woMan_add(globals *ourGlobals); |
279 | 282 | ||
280 | 283 | ||
diff --git a/src/extantz/files.c b/src/extantz/files.c index b705e21..024e2df 100644 --- a/src/extantz/files.c +++ b/src/extantz/files.c | |||
@@ -58,9 +58,10 @@ static void _big_icon_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *ev | |||
58 | elm_fileselector_thumbnail_size_set(fs, 128, 128); | 58 | elm_fileselector_thumbnail_size_set(fs, 128, 128); |
59 | } | 59 | } |
60 | 60 | ||
61 | static void _OK_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | 61 | static void my_fileselector_activated(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
62 | { | 62 | { |
63 | Evas_Object *fs = data; | 63 | fangWin *me = data; |
64 | Evas_Object *fs = me->data; | ||
64 | 65 | ||
65 | if (elm_fileselector_multi_select_get(fs)) | 66 | if (elm_fileselector_multi_select_get(fs)) |
66 | { | 67 | { |
@@ -79,16 +80,19 @@ static void _OK_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_in | |||
79 | 80 | ||
80 | printf("SELECTED file : %s\n", file); | 81 | printf("SELECTED file : %s\n", file); |
81 | } | 82 | } |
83 | evas_object_hide(me->win); | ||
82 | } | 84 | } |
83 | 85 | ||
84 | static void _CANCEL_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | 86 | static void _CANCEL_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
85 | { | 87 | { |
86 | // Evas_Object *fs = data; | 88 | fangWin *me = data; |
89 | |||
90 | evas_object_hide(me->win); | ||
87 | } | 91 | } |
88 | 92 | ||
89 | static void my_fileselector_activated(void *data, Evas_Object *obj, void *event_info) | 93 | static void _OK_clicked(void *data, Evas_Object *obj, void *event_info) |
90 | { | 94 | { |
91 | _OK_clicked(data, obj, event_info); | 95 | my_fileselector_activated(data, obj, event_info); |
92 | } | 96 | } |
93 | 97 | ||
94 | #if 0 | 98 | #if 0 |
@@ -136,7 +140,7 @@ void _on_fs_del(void *data, Evas_Object *obj, void *event_info) | |||
136 | elm_entry_editable_set(obj, EINA_FALSE); | 140 | elm_entry_editable_set(obj, EINA_FALSE); |
137 | } | 141 | } |
138 | 142 | ||
139 | fangWin *files_add(globals *ourGlobals) | 143 | fangWin *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save) |
140 | { | 144 | { |
141 | fangWin *me; | 145 | fangWin *me; |
142 | Widget *wid; | 146 | Widget *wid; |
@@ -153,8 +157,10 @@ fangWin *files_add(globals *ourGlobals) | |||
153 | elm_win_resize_object_add(me->win, bx); | 157 | elm_win_resize_object_add(me->win, bx); |
154 | 158 | ||
155 | fs = eo_add(ELM_OBJ_FILESELECTOR_CLASS, bx); | 159 | fs = eo_add(ELM_OBJ_FILESELECTOR_CLASS, bx); |
160 | me->data = fs; | ||
156 | wid = widgetAdd(me); | 161 | wid = widgetAdd(me); |
157 | wid->obj = fs; | 162 | wid->obj = fs; |
163 | wid->data = ourGlobals; | ||
158 | wid->on_del = _on_fs_del; | 164 | wid->on_del = _on_fs_del; |
159 | eo_do(fs, | 165 | eo_do(fs, |
160 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), | 166 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), |
@@ -166,10 +172,9 @@ fangWin *files_add(globals *ourGlobals) | |||
166 | ); | 172 | ); |
167 | elm_box_pack_end(bx, fs); | 173 | elm_box_pack_end(bx, fs); |
168 | 174 | ||
169 | // TODO - Should allow these to be set from the caller. | 175 | elm_fileselector_path_set(fs, path); |
170 | elm_fileselector_path_set(fs, elm_app_data_dir_get()); | 176 | elm_fileselector_is_save_set(fs, save); |
171 | elm_fileselector_is_save_set(fs, EINA_FALSE); | 177 | elm_fileselector_multi_select_set(fs, multi); |
172 | elm_fileselector_multi_select_set(fs, EINA_TRUE); | ||
173 | 178 | ||
174 | // TODO - Should allow these to be set from the caller. | 179 | // TODO - Should allow these to be set from the caller. |
175 | // TODO - Don't do these, it adds a horribly out of place button. | 180 | // TODO - Don't do these, it adds a horribly out of place button. |
@@ -182,7 +187,7 @@ fangWin *files_add(globals *ourGlobals) | |||
182 | // elm_fileselector_mime_types_filter_append(fs, "text/*", "text files"); | 187 | // elm_fileselector_mime_types_filter_append(fs, "text/*", "text files"); |
183 | 188 | ||
184 | // Call back for double click or Enter pressed on file. | 189 | // Call back for double click or Enter pressed on file. |
185 | evas_object_smart_callback_add(fs, "activated", my_fileselector_activated, fs); | 190 | evas_object_smart_callback_add(fs, "activated", my_fileselector_activated, me); |
186 | 191 | ||
187 | vbox = eo_add(ELM_OBJ_BOX_CLASS, me->win); | 192 | vbox = eo_add(ELM_OBJ_BOX_CLASS, me->win); |
188 | eo_do(vbox, | 193 | eo_do(vbox, |
@@ -264,14 +269,14 @@ fangWin *files_add(globals *ourGlobals) | |||
264 | bt = eo_add(ELM_OBJ_BUTTON_CLASS, me->win); | 269 | bt = eo_add(ELM_OBJ_BUTTON_CLASS, me->win); |
265 | elm_object_text_set(bt, "OK"); | 270 | elm_object_text_set(bt, "OK"); |
266 | eo_do(bt, evas_obj_visibility_set(EINA_TRUE)); | 271 | eo_do(bt, evas_obj_visibility_set(EINA_TRUE)); |
267 | evas_object_smart_callback_add(bt, "clicked", _OK_clicked, fs); | 272 | evas_object_smart_callback_add(bt, "clicked", _OK_clicked, me); |
268 | elm_box_pack_end(vbox, bt); | 273 | elm_box_pack_end(vbox, bt); |
269 | eo_unref(bt); | 274 | eo_unref(bt); |
270 | 275 | ||
271 | bt = eo_add(ELM_OBJ_BUTTON_CLASS, me->win); | 276 | bt = eo_add(ELM_OBJ_BUTTON_CLASS, me->win); |
272 | elm_object_text_set(bt, "CANCEL"); | 277 | elm_object_text_set(bt, "CANCEL"); |
273 | eo_do(bt, evas_obj_visibility_set(EINA_TRUE)); | 278 | eo_do(bt, evas_obj_visibility_set(EINA_TRUE)); |
274 | evas_object_smart_callback_add(bt, "clicked", _CANCEL_clicked, fs); | 279 | evas_object_smart_callback_add(bt, "clicked", _CANCEL_clicked, me); |
275 | elm_box_pack_end(vbox, bt); | 280 | elm_box_pack_end(vbox, bt); |
276 | eo_unref(bt); | 281 | eo_unref(bt); |
277 | 282 | ||
@@ -282,5 +287,19 @@ fangWin *files_add(globals *ourGlobals) | |||
282 | eo_unref(bx); | 287 | eo_unref(bx); |
283 | 288 | ||
284 | fang_win_complete(ourGlobals, me, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500); | 289 | fang_win_complete(ourGlobals, me, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500); |
290 | evas_object_hide(me->win); | ||
285 | return me; | 291 | return me; |
286 | } | 292 | } |
293 | |||
294 | void filesShow(fangWin *me, Evas_Smart_Cb func, void *data) | ||
295 | { | ||
296 | Evas_Object *fs = me->data; | ||
297 | |||
298 | if (!data) data = me; | ||
299 | |||
300 | if (func) | ||
301 | evas_object_smart_callback_add(fs, "activated", func, data); | ||
302 | else | ||
303 | evas_object_smart_callback_add(fs, "activated", my_fileselector_activated, me); | ||
304 | evas_object_show(me->win); | ||
305 | } | ||