2009-08-12 09:08:53 -07:00
|
|
|
/*
|
|
|
|
* TODO
|
|
|
|
* userdefined icon/label cb
|
|
|
|
* show/hide/add buttons ???
|
|
|
|
* need a background ???
|
|
|
|
* show/Hide hidden files
|
|
|
|
* double click to choose a file
|
|
|
|
* multiselection
|
|
|
|
* write docs
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Ecore_Str.h>
|
2009-08-27 22:28:44 -07:00
|
|
|
#include <Elementary.h>
|
2009-08-12 09:08:53 -07:00
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
2009-09-06 17:00:33 -07:00
|
|
|
Evas_Object *vbox, *entry, *entry2, *list, *scr2;
|
2009-08-12 09:08:53 -07:00
|
|
|
const char *path;
|
2009-09-06 17:00:33 -07:00
|
|
|
const char *selection;
|
2009-08-12 09:08:53 -07:00
|
|
|
Eina_Bool expand;
|
|
|
|
};
|
|
|
|
|
|
|
|
Elm_Genlist_Item_Class itc;
|
|
|
|
|
|
|
|
static void _populate(Evas_Object *obj, const char *path, Elm_Genlist_Item *parent);
|
|
|
|
|
|
|
|
/*** ELEMENTARY WIDGET ***/
|
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (wd->path) eina_stringshare_del(wd->path);
|
2009-09-06 17:00:33 -07:00
|
|
|
if (wd->selection) eina_stringshare_del(wd->selection);
|
2009-08-12 09:08:53 -07:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord minw = -1, minh = -1;
|
|
|
|
|
|
|
|
evas_object_size_hint_min_get(wd->vbox, &minw, &minh);
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
|
2009-08-26 10:59:41 -07:00
|
|
|
// printf("***** SIZING EVAL [min %d %d] *************\n", minw, minh);
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** GENLIST "MODEL" ***/
|
|
|
|
static char*
|
|
|
|
_itc_label_get(const void *data, Evas_Object *obj, const char *source)
|
|
|
|
{
|
|
|
|
//~ printf("LABEL_GET: %s\n", (char*) data);
|
|
|
|
return strdup(ecore_file_file_get(data)); // NOTE this will be free() by the caller
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object*
|
|
|
|
_itc_icon_get(const void *data, Evas_Object *obj, const char *source)
|
|
|
|
{
|
|
|
|
Evas_Object *ic;
|
|
|
|
|
|
|
|
//~ printf("ICON GET for %s (source: %s)\n", (char*)data, source);
|
|
|
|
|
|
|
|
if (!strcmp(source, "elm.swallow.icon"))
|
|
|
|
{
|
|
|
|
ic = elm_icon_add(obj);
|
|
|
|
if (ecore_file_is_dir((char*)data))
|
2009-09-06 17:00:33 -07:00
|
|
|
elm_icon_standard_set(ic, "folder");
|
2009-08-12 09:08:53 -07:00
|
|
|
else
|
2009-08-26 10:59:41 -07:00
|
|
|
elm_icon_standard_set(ic, "file");
|
2009-08-12 09:08:53 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
|
|
evas_object_show(ic);
|
|
|
|
return ic;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_itc_state_get(const void *data, Evas_Object *obj, const char *source)
|
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_itc_del(const void *data, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
//~ printf("DEL DATA [%s]\n", (char*)data);
|
|
|
|
eina_stringshare_del(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-26 16:39:17 -07:00
|
|
|
_expand_done(void *data, Evas_Object *obj, void *event_info)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
|
|
|
Elm_Genlist_Item *it = event_info;
|
|
|
|
const char *path = elm_genlist_item_data_get(it);
|
|
|
|
|
2009-08-26 10:59:41 -07:00
|
|
|
// printf("EXPAND %s\n", path);
|
2009-08-12 09:08:53 -07:00
|
|
|
_populate(data, path, it);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-26 16:39:17 -07:00
|
|
|
_contract_done(void *data, Evas_Object *obj, void *event_info)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
|
|
|
Elm_Genlist_Item *it = event_info;
|
|
|
|
const char *path = elm_genlist_item_data_get(it);
|
|
|
|
|
2009-08-26 10:59:41 -07:00
|
|
|
// printf("CONTRACT %s\n", path);
|
2009-08-12 09:08:53 -07:00
|
|
|
elm_genlist_item_subitems_clear(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_expand_req(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Elm_Genlist_Item *it = event_info;
|
|
|
|
elm_genlist_item_expanded_set(it, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_contract_req(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Elm_Genlist_Item *it = event_info;
|
|
|
|
elm_genlist_item_expanded_set(it, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** PRIVATES ***/
|
|
|
|
static void
|
|
|
|
_sel(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-09-06 17:00:33 -07:00
|
|
|
Evas_Object *fs = data;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(fs);
|
2009-08-12 09:08:53 -07:00
|
|
|
const char *path = elm_genlist_item_data_get(event_info);
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
if (ecore_file_is_dir(path))
|
|
|
|
{
|
2009-08-26 10:59:41 -07:00
|
|
|
// printf("SELECTED DIR: %s\n", path);
|
2009-09-06 17:00:33 -07:00
|
|
|
if (wd->expand)
|
|
|
|
{
|
|
|
|
_do_anchors(fs, path);
|
|
|
|
if (wd->entry2) elm_entry_entry_set(wd->entry2, "");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// keep a ref to path 'couse it will be destroyed by _populate
|
|
|
|
p = eina_stringshare_add(path);
|
|
|
|
_populate(fs, p, NULL);
|
|
|
|
eina_stringshare_del(p);
|
|
|
|
}
|
2009-08-12 09:08:53 -07:00
|
|
|
return;
|
|
|
|
}
|
2009-09-06 17:00:33 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// printf("SELECTED FILE: %s\n", path);
|
|
|
|
if (wd->entry2)
|
|
|
|
elm_entry_entry_set(wd->entry2, ecore_file_file_get(path));
|
|
|
|
}
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
evas_object_smart_callback_call(fs, "selected", (void*)path);
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_up(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-09-06 17:00:33 -07:00
|
|
|
Evas_Object *fs = data;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(fs);
|
2009-08-12 09:08:53 -07:00
|
|
|
char *parent = ecore_file_dir_get(wd->path);
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
_populate(fs, parent, NULL);
|
2009-08-12 09:08:53 -07:00
|
|
|
free(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_home(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-09-06 17:00:33 -07:00
|
|
|
Evas_Object *fs = data;
|
|
|
|
_populate(fs, getenv("HOME"), NULL);
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ok(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-09-06 17:00:33 -07:00
|
|
|
Evas_Object *fs = data;
|
|
|
|
evas_object_smart_callback_call(fs, "done",
|
|
|
|
(void*)elm_fileselector_selected_get(fs));
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_canc(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-09-06 17:00:33 -07:00
|
|
|
Evas_Object *fs = data;
|
|
|
|
evas_object_smart_callback_call(fs, "done", NULL);
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_anchor_clicked(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-09-06 17:00:33 -07:00
|
|
|
Evas_Object *fs = data;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(fs);
|
2009-08-12 09:08:53 -07:00
|
|
|
Elm_Entry_Anchor_Info *info = event_info;
|
|
|
|
const char *p;
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
//~ printf("ANCHOR CLICKED %s\n", info->name);
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
// keep a ref to path 'couse it will be destroyed by _populate
|
|
|
|
p = eina_stringshare_add(info->name);
|
|
|
|
_populate(fs, p, NULL);
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
evas_object_smart_callback_call(data, "selected", (void*)p);
|
|
|
|
eina_stringshare_del(p);
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
_do_anchors(Evas_Object *obj, const char *path)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
char **tok, buf[PATH_MAX*3];
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
//~ printf("ANCHORIZE...\n");
|
|
|
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
tok = ecore_str_split(path, "/", 0);
|
|
|
|
for (i = 0; tok[i]; i++)
|
|
|
|
{
|
|
|
|
if (strlen(tok[i]) < 1) continue;
|
|
|
|
//~ printf("TOK: %s\n", tok[i]);
|
|
|
|
ecore_strlcat(buf, "/<a href=", sizeof(buf));
|
|
|
|
for (j = 0; j <= i; j++)
|
|
|
|
{
|
|
|
|
if (strlen(tok[j]) < 1) continue;
|
|
|
|
//~ printf("REV: %s\n",tok[j]);
|
|
|
|
ecore_strlcat(buf, "/", sizeof(buf));
|
|
|
|
ecore_strlcat(buf, tok[j], sizeof(buf));
|
|
|
|
}
|
|
|
|
ecore_strlcat(buf, ">", sizeof(buf));
|
|
|
|
ecore_strlcat(buf, tok[i], sizeof(buf));
|
|
|
|
ecore_strlcat(buf, "</a>", sizeof(buf));
|
|
|
|
}
|
|
|
|
free(tok[0]);
|
|
|
|
free(tok);
|
|
|
|
|
|
|
|
//~ printf("ANCHOR: %s\n", buf);
|
|
|
|
elm_entry_entry_set(wd->entry, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_populate(Evas_Object *obj, const char *path, Elm_Genlist_Item *parent)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-08-12 15:43:50 -07:00
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dp;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
char *real;
|
2009-08-12 15:43:50 -07:00
|
|
|
Eina_List *files = NULL, *dirs = NULL, *l;
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2009-08-12 15:43:50 -07:00
|
|
|
if (!wd || !ecore_file_is_dir(path)) return;
|
2009-08-12 09:08:53 -07:00
|
|
|
|
|
|
|
dir = opendir(path);
|
|
|
|
if (!dir) return;
|
|
|
|
|
|
|
|
if (!parent)
|
|
|
|
{
|
|
|
|
elm_genlist_clear(wd->list);
|
|
|
|
if (wd->path) eina_stringshare_del(wd->path);
|
|
|
|
wd->path = eina_stringshare_add(path);
|
|
|
|
_do_anchors(obj, path);
|
|
|
|
}
|
2009-09-06 17:00:33 -07:00
|
|
|
|
|
|
|
if (wd->entry2)
|
|
|
|
elm_entry_entry_set(wd->entry2, "");
|
2009-08-12 09:08:53 -07:00
|
|
|
|
|
|
|
while ((dp = readdir(dir)) != NULL)
|
|
|
|
{
|
2009-08-12 15:43:50 -07:00
|
|
|
if (dp->d_name[0] == '.') continue; // TODO make this configurable
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", path, dp->d_name);
|
|
|
|
real = ecore_file_realpath(buf); //TODO this will resolv symlinks...I dont like it
|
2009-08-12 15:43:50 -07:00
|
|
|
if (ecore_file_is_dir(real))
|
|
|
|
dirs = eina_list_append(dirs, real);
|
|
|
|
else
|
|
|
|
files = eina_list_append(files, real);
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
|
|
|
|
files = eina_list_sort(files, ECORE_SORT_MIN, ECORE_COMPARE_CB(strcoll));
|
|
|
|
dirs = eina_list_sort(dirs, ECORE_SORT_MIN, ECORE_COMPARE_CB(strcoll));
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(dirs, l, real)
|
2009-09-06 17:00:33 -07:00
|
|
|
{
|
|
|
|
//~ printf("DIR: %s\n", real);
|
2009-08-12 09:08:53 -07:00
|
|
|
elm_genlist_item_append(wd->list, &itc,
|
|
|
|
eina_stringshare_add(real), /* item data */
|
|
|
|
parent,
|
2009-08-12 15:43:50 -07:00
|
|
|
wd->expand ? ELM_GENLIST_ITEM_SUBITEMS :
|
|
|
|
ELM_GENLIST_ITEM_NONE,
|
2009-08-12 09:08:53 -07:00
|
|
|
NULL, NULL);
|
|
|
|
free(real);
|
2009-09-06 17:00:33 -07:00
|
|
|
}
|
2009-08-12 15:43:50 -07:00
|
|
|
eina_list_free(dirs);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(files, l, real)
|
2009-09-06 17:00:33 -07:00
|
|
|
{
|
|
|
|
//~ printf("FILE: %s [%p]\n", real, wd->list);
|
2009-08-12 15:43:50 -07:00
|
|
|
elm_genlist_item_append(wd->list, &itc,
|
|
|
|
eina_stringshare_add(real), /* item data */
|
|
|
|
parent, ELM_GENLIST_ITEM_NONE,
|
|
|
|
NULL, NULL);
|
|
|
|
free(real);
|
2009-09-06 17:00:33 -07:00
|
|
|
}
|
2009-08-12 15:43:50 -07:00
|
|
|
eina_list_free(files);
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** API ***/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_fileselector_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj, *ic, *bt, *box;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
// Elementary Widget
|
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
wd->expand = EINA_FALSE;
|
2009-09-06 17:00:33 -07:00
|
|
|
obj = elm_widget_add(evas_object_evas_get(parent));
|
2009-08-12 09:08:53 -07:00
|
|
|
elm_widget_type_set(obj, "fileselector");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
|
|
|
|
|
|
|
// TODO Do we need a bg object? a frame?
|
|
|
|
// vbox
|
|
|
|
wd->vbox = elm_box_add(parent);
|
2009-10-09 17:32:27 -07:00
|
|
|
evas_object_size_hint_weight_set(wd->vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2009-08-12 09:08:53 -07:00
|
|
|
elm_widget_resize_object_set(obj, wd->vbox);
|
|
|
|
evas_object_show(wd->vbox);
|
|
|
|
|
|
|
|
// buttons box
|
|
|
|
box = elm_box_add(parent);
|
|
|
|
elm_box_horizontal_set(box, 1);
|
|
|
|
elm_widget_sub_object_add(obj, box);
|
|
|
|
elm_box_pack_end(wd->vbox, box);
|
|
|
|
evas_object_size_hint_align_set(box, 0.0, 0.0);
|
|
|
|
evas_object_show(box);
|
|
|
|
|
|
|
|
// up btn
|
|
|
|
ic = elm_icon_add(parent);
|
|
|
|
elm_icon_standard_set(ic, "arrow_up");
|
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
|
|
bt = elm_button_add(parent);
|
|
|
|
elm_button_icon_set(bt, ic);
|
|
|
|
elm_button_label_set(bt, "Up");
|
|
|
|
evas_object_size_hint_align_set(bt, 0.0, 0.0);
|
|
|
|
elm_widget_sub_object_add(obj, bt);
|
|
|
|
elm_box_pack_end(box, bt);
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _up, obj);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
// home btn
|
|
|
|
ic = elm_icon_add(parent);
|
|
|
|
elm_icon_standard_set(ic, "home");
|
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
|
|
bt = elm_button_add(parent);
|
|
|
|
elm_button_icon_set(bt, ic);
|
|
|
|
elm_button_label_set(bt, "Home");
|
|
|
|
evas_object_size_hint_align_set(bt, 0.0, 0.0);
|
|
|
|
elm_widget_sub_object_add(obj, bt);
|
|
|
|
elm_box_pack_end(box, bt);
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _home, obj);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
// genlist
|
|
|
|
itc.item_style = "default";
|
|
|
|
itc.func.label_get = _itc_label_get;
|
|
|
|
itc.func.icon_get = _itc_icon_get;
|
|
|
|
itc.func.state_get = _itc_state_get;
|
|
|
|
itc.func.del = _itc_del;
|
|
|
|
|
|
|
|
wd->list = elm_genlist_add(parent);
|
2009-10-09 17:32:27 -07:00
|
|
|
evas_object_size_hint_align_set(wd->list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_weight_set(wd->list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2009-08-12 09:08:53 -07:00
|
|
|
evas_object_size_hint_min_set(wd->list, 100, 100);
|
|
|
|
elm_widget_sub_object_add(obj, wd->list);
|
|
|
|
elm_box_pack_end(wd->vbox, wd->list);
|
|
|
|
evas_object_show(wd->list);
|
|
|
|
|
|
|
|
evas_object_smart_callback_add(wd->list, "selected", _sel, obj);
|
|
|
|
evas_object_smart_callback_add(wd->list, "expand,request", _expand_req, obj);
|
|
|
|
evas_object_smart_callback_add(wd->list, "contract,request", _contract_req, obj);
|
2009-08-26 16:39:17 -07:00
|
|
|
evas_object_smart_callback_add(wd->list, "expanded", _expand_done, obj);
|
|
|
|
evas_object_smart_callback_add(wd->list, "contracted", _contract_done, obj);
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
// path entry
|
|
|
|
wd->entry = elm_entry_add(parent);
|
|
|
|
elm_widget_sub_object_add(obj, wd->entry);
|
|
|
|
elm_entry_editable_set(wd->entry, 0);
|
|
|
|
elm_entry_single_line_set(wd->entry, EINA_TRUE);
|
2009-10-09 17:32:27 -07:00
|
|
|
evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, 0.0);
|
2009-09-06 17:00:33 -07:00
|
|
|
elm_box_pack_end(wd->vbox, wd->entry);
|
|
|
|
evas_object_show(wd->entry);
|
|
|
|
evas_object_smart_callback_add(wd->entry, "anchor,clicked", _anchor_clicked, obj);
|
|
|
|
|
|
|
|
// name entry scroller
|
|
|
|
wd->scr2 = elm_scroller_add(parent);
|
|
|
|
elm_scroller_content_min_limit(wd->scr2, 0, 1);
|
|
|
|
elm_scroller_policy_set(wd->scr2, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
|
2009-10-09 17:32:27 -07:00
|
|
|
evas_object_size_hint_weight_set(wd->scr2, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(wd->scr2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2009-09-06 17:00:33 -07:00
|
|
|
elm_box_pack_end(wd->vbox, wd->scr2);
|
|
|
|
evas_object_show(wd->scr2);
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
// buttons box
|
|
|
|
box = elm_box_add(parent);
|
|
|
|
elm_box_horizontal_set(box, 1);
|
|
|
|
elm_widget_sub_object_add(obj, box);
|
|
|
|
elm_box_pack_end(wd->vbox, box);
|
|
|
|
evas_object_show(box);
|
|
|
|
|
|
|
|
// cancel btn
|
|
|
|
bt = elm_button_add(parent);
|
2009-10-09 19:53:22 -07:00
|
|
|
elm_button_label_set(bt, "Cancel");
|
2009-08-12 09:08:53 -07:00
|
|
|
elm_widget_sub_object_add(obj, bt);
|
|
|
|
elm_box_pack_end(box, bt);
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _canc, obj);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
// ok btn
|
|
|
|
bt = elm_button_add(parent);
|
2009-10-09 19:53:22 -07:00
|
|
|
elm_button_label_set(bt, "OK");
|
2009-08-12 09:08:53 -07:00
|
|
|
elm_widget_sub_object_add(obj, bt);
|
|
|
|
elm_box_pack_end(box, bt);
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _ok, obj);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
2009-08-12 15:43:50 -07:00
|
|
|
// Is this the right way to show sub-objs ?? or use the show/hide cbs ??
|
2009-08-12 09:08:53 -07:00
|
|
|
//~ evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _show, obj);
|
|
|
|
//~ evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
//~ _changed_size_hints, obj);
|
|
|
|
|
|
|
|
|
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
EAPI void
|
|
|
|
elm_fileselector_is_save_set(Evas_Object *obj, Eina_Bool is_save)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (is_save)
|
|
|
|
{
|
|
|
|
if (wd->entry2) return;
|
|
|
|
wd->entry2 = elm_entry_add(elm_widget_parent_get(obj));
|
|
|
|
elm_widget_sub_object_add(obj, wd->entry2);
|
|
|
|
elm_entry_editable_set(wd->entry2, 1);
|
|
|
|
elm_entry_single_line_set(wd->entry2, EINA_TRUE);
|
2009-10-09 17:35:05 -07:00
|
|
|
evas_object_size_hint_weight_set(wd->entry2, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(wd->entry2, EVAS_HINT_FILL, 0.0);
|
2009-09-06 17:00:33 -07:00
|
|
|
elm_scroller_content_set(wd->scr2, wd->entry2);
|
|
|
|
evas_object_show(wd->entry2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_object_del(wd->entry2);
|
|
|
|
wd->entry2 = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_fileselector_is_save_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
return wd->entry2 ? EINA_TRUE : EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
EAPI void
|
|
|
|
elm_fileselector_expandable_set(Evas_Object *obj, Eina_Bool expand)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
wd->expand = expand;
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
EAPI void
|
|
|
|
elm_fileselector_path_set(Evas_Object *obj, const char *path)
|
|
|
|
{
|
|
|
|
_populate(obj, path, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
elm_fileselector_path_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
return wd->path;
|
|
|
|
}
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
EAPI const char*
|
|
|
|
elm_fileselector_selected_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Elm_Genlist_Item *it;
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
if (wd->entry2)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
name = elm_entry_entry_get(wd->entry2);
|
|
|
|
//TODO remove <br>
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", wd->path, name);
|
|
|
|
if (wd->selection) eina_stringshare_del(wd->selection);
|
|
|
|
wd->selection = eina_stringshare_add(buf);
|
|
|
|
return wd->selection;
|
|
|
|
}
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
it = elm_genlist_selected_item_get(wd->list);
|
|
|
|
if (it) return elm_genlist_item_data_get(it);
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
return wd->path;
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|