2009-08-13 15:41:43 -07:00
|
|
|
#include <Elementary.h>
|
2009-09-13 21:21:34 -07:00
|
|
|
#ifndef ELM_LIB_QUICKLAUNCH
|
2009-08-13 15:41:43 -07:00
|
|
|
static void
|
2009-08-13 15:59:12 -07:00
|
|
|
my_fileselector_done(void *data, Evas_Object *obj, void *event_info)
|
2009-08-13 15:41:43 -07:00
|
|
|
{
|
|
|
|
/* event_info conatin the full path of the selected file
|
|
|
|
* or NULL if none is selected or cancel is pressed */
|
|
|
|
const char *selected = event_info;
|
2009-09-06 17:05:25 -07:00
|
|
|
|
2009-08-13 15:41:43 -07:00
|
|
|
if (selected)
|
|
|
|
printf("Selected file: %s\n", selected);
|
|
|
|
else
|
|
|
|
evas_object_del(data); /* delete the test window */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-13 15:59:12 -07:00
|
|
|
my_fileselector_selected(void *data, Evas_Object *obj, void *event_info)
|
2009-08-13 15:41:43 -07:00
|
|
|
{
|
|
|
|
/* event_info conatin the full path of the selected file */
|
|
|
|
const char *selected = event_info;
|
|
|
|
printf("Selected file: %s\n", selected);
|
2009-09-06 17:05:25 -07:00
|
|
|
|
2009-08-13 15:41:43 -07:00
|
|
|
/* or you can query the selection */
|
|
|
|
printf("or: %s\n", elm_fileselector_selected_get(obj));
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:05:25 -07:00
|
|
|
static void
|
|
|
|
_is_save_clicked(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Object *fs = data;
|
|
|
|
printf("Toggle Is save\n");
|
|
|
|
if (elm_fileselector_is_save_get(fs))
|
|
|
|
elm_fileselector_is_save_set(fs, EINA_FALSE);
|
|
|
|
else
|
|
|
|
elm_fileselector_is_save_set(fs, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sel_get_clicked(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Object *fs = data;
|
|
|
|
printf("Get Selected: %s\n", elm_fileselector_selected_get(fs));
|
|
|
|
}
|
|
|
|
|
2009-08-13 15:41:43 -07:00
|
|
|
void
|
|
|
|
test_fileselector(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-09-06 17:05:25 -07:00
|
|
|
Evas_Object *win, *fs, *bg, *vbox, *hbox, *bt;
|
2009-08-13 15:41:43 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
/* Set the locale according to the system pref.
|
|
|
|
* If you dont do so the file selector will order the files list in
|
|
|
|
* a case sensitive manner
|
|
|
|
*/
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
|
|
|
|
win = elm_win_add(NULL, "fileselector", ELM_WIN_BASIC);
|
|
|
|
elm_win_title_set(win, "File Selector");
|
|
|
|
elm_win_autodel_set(win, 1);
|
|
|
|
|
|
|
|
bg = elm_bg_add(win);
|
|
|
|
elm_win_resize_object_add(win, bg);
|
|
|
|
evas_object_size_hint_weight_set(bg, 1.0, 1.0);
|
|
|
|
evas_object_show(bg);
|
|
|
|
|
2009-09-06 17:05:25 -07:00
|
|
|
vbox = elm_box_add(win);
|
|
|
|
elm_win_resize_object_add(win, vbox);
|
|
|
|
evas_object_size_hint_weight_set(vbox, 1.0, 1.0);
|
|
|
|
evas_object_show(vbox);
|
|
|
|
|
2009-08-13 15:41:43 -07:00
|
|
|
fs = elm_fileselector_add(win);
|
2009-09-06 17:05:25 -07:00
|
|
|
/* enable the fs file name entry */
|
|
|
|
elm_fileselector_is_save_set(fs, EINA_TRUE);
|
|
|
|
/* make the file list a tree with dir expandable in place */
|
2009-08-13 15:41:43 -07:00
|
|
|
elm_fileselector_expandable_set(fs, EINA_FALSE);
|
|
|
|
/* start the fileselector in the home dir */
|
|
|
|
elm_fileselector_path_set(fs, getenv("HOME"));
|
|
|
|
/* allow fs to expand in x & y */
|
|
|
|
evas_object_size_hint_weight_set(fs, 1.0, 1.0);
|
2009-09-06 17:05:25 -07:00
|
|
|
evas_object_size_hint_align_set(fs, -1.0, -1.0);
|
|
|
|
elm_box_pack_end(vbox, fs);
|
|
|
|
evas_object_show(fs); // TODO fix this is the widget
|
|
|
|
|
2009-08-13 15:41:43 -07:00
|
|
|
/* the 'done' cb is called when the user press ok/cancel */
|
2009-08-13 15:59:12 -07:00
|
|
|
evas_object_smart_callback_add(fs, "done", my_fileselector_done, win);
|
2009-09-06 17:05:25 -07:00
|
|
|
/* the 'selected' cb is called when the user click on a file/dir */
|
2009-08-13 15:59:12 -07:00
|
|
|
evas_object_smart_callback_add(fs, "selected", my_fileselector_selected, win);
|
2009-09-06 17:05:25 -07:00
|
|
|
|
|
|
|
/* test buttons */
|
|
|
|
hbox = elm_box_add(win);
|
|
|
|
elm_box_horizontal_set(hbox, EINA_TRUE);
|
|
|
|
elm_box_pack_end(vbox, hbox);
|
|
|
|
evas_object_show(hbox);
|
|
|
|
|
|
|
|
bt = elm_button_add(win);
|
|
|
|
elm_button_label_set(bt, "Toggle is_save");
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _is_save_clicked, fs);
|
|
|
|
elm_box_pack_end(hbox, bt);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
bt = elm_button_add(win);
|
|
|
|
elm_button_label_set(bt, "sel get");
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _sel_get_clicked, fs);
|
|
|
|
elm_box_pack_end(hbox, bt);
|
|
|
|
evas_object_show(bt);
|
2009-08-13 15:41:43 -07:00
|
|
|
|
|
|
|
evas_object_resize(win, 240, 350);
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
2009-09-13 21:21:34 -07:00
|
|
|
#endif
|