-/**
- * @defgroup Fileselector Fileselector
- *
- * A fileselector is a widget that allows a user to navigate through a
- * tree of files. It contains buttons for Home(~) and Up(..) as well
- * as cancel/ok buttons to confirm/cancel a selection. This widget is
- * currently very much in progress.
- *
- * TODO
- * child elements focusing support
- * userdefined icon/label cb
- * show/hide/add buttons ???
- * show/Hide hidden files
- * double click to choose a file
- * multiselection
- * make variable/function names that are sensible
- * Filter support
- *
- * Signals that you can add callbacks for are:
- *
- * "selected" - the user clicks on a file
- * "directory,open" - the list is populated with new content.
- * event_info is a directory.
- * "done" - the user clicks on the ok or cancel button
+/*
+ * TODO:
+ * - child elements focusing support
+ * - user defined icon/label cb
+ * - show/hide/add buttons ???
+ * - show/hide hidden files
+ * - double click to choose a file
+ * - multi-selection
+ * - make variable/function names that are sensible
+ * - Filter support
*/
-#include <Elementary.h>
-#include "elm_priv.h"
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
#ifdef HAVE_EIO
# include <Eio.h>
#endif
+#include <Elementary.h>
+#include "elm_priv.h"
+
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
struct _Widget_Request
{
Widget_Data *wd;
- Elm_Genlist_Item *parent;
+ Elm_Object_Item *parent;
Evas_Object *obj;
const char *path;
ELM_FILE_LAST
} Elm_Fileselector_Type;
-static Elm_Genlist_Item_Class list_itc[ELM_FILE_LAST] = {
- { "default", { NULL, NULL, NULL, NULL, NULL }, NULL },
- { "default", { NULL, NULL, NULL, NULL, NULL }, NULL },
- { "default", { NULL, NULL, NULL, NULL, NULL }, NULL }
-};
-static Elm_Gengrid_Item_Class grid_itc[ELM_FILE_LAST] = {
- { "default", { NULL, NULL, NULL, NULL } },
- { "default", { NULL, NULL, NULL, NULL } },
- { "default", { NULL, NULL, NULL, NULL } }
-};
+static Elm_Genlist_Item_Class *list_itc[ELM_FILE_LAST];
+static Elm_Gengrid_Item_Class *grid_itc[ELM_FILE_LAST];
static const char *widtype = NULL;
static void _populate(Evas_Object *obj,
const char *path,
- Elm_Genlist_Item *parent);
+ Elm_Object_Item *parent);
static void _do_anchors(Evas_Object *obj,
const char *path);
_del_hook(Evas_Object *obj)
{
Widget_Data *wd;
+ int i;
wd = elm_widget_data_get(obj);
if (!wd) return;
- eio_file_cancel(wd->current);
+ for (i = 0; i < ELM_FILE_LAST; ++i)
+ {
+ elm_genlist_item_class_free(list_itc[i]);
+ elm_gengrid_item_class_free(grid_itc[i]);
+ }
+
+#ifdef HAVE_EIO
+ if (wd->current)
+ eio_file_cancel(wd->current);
+#endif
wd->files_list = NULL;
wd->files_grid = NULL;
/*** GENLIST "MODEL" ***/
static char *
-_itc_label_get(void *data,
+_itc_text_get(void *data,
Evas_Object *obj __UNUSED__,
const char *source __UNUSED__)
{
Evas_Object *obj __UNUSED__,
void *event_info)
{
- Elm_Genlist_Item *it = event_info;
- const char *path = elm_genlist_item_data_get(it);
+ Elm_Object_Item *it = event_info;
+ const char *path = elm_object_item_data_get(it);
_populate(data, path, it);
}
Evas_Object *obj __UNUSED__,
void *event_info)
{
- Elm_Genlist_Item *it = event_info;
+ Elm_Object_Item *it = event_info;
elm_genlist_item_subitems_clear(it);
}
Evas_Object *obj __UNUSED__,
void *event_info)
{
- Elm_Genlist_Item *it = event_info;
- elm_genlist_item_expanded_set(it, 1);
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_expanded_set(it, EINA_TRUE);
}
static void
Evas_Object *obj __UNUSED__,
void *event_info)
{
- Elm_Genlist_Item *it = event_info;
- elm_genlist_item_expanded_set(it, 0);
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_expanded_set(it, EINA_FALSE);
}
/*** PRIVATES ***/
if (wd->expand && wd->mode == ELM_FILESELECTOR_LIST)
{
_do_anchors(sd->fs, path);
- elm_entry_entry_set(wd->filename_entry, "");
+ elm_object_text_set(wd->filename_entry, "");
}
else
{
_populate(sd->fs, p, NULL);
eina_stringshare_del(p);
}
- elm_entry_entry_set(wd->filename_entry,
+ elm_object_text_set(wd->filename_entry,
ecore_file_file_get(path));
}
Widget_Data *wd;
void *old_sd;
char *dir;
+ //This event_info could be a list or gengrid item
+ Elm_Object_Item *it = event_info;
wd = elm_widget_data_get(data);
if (!wd) return;
sd = malloc(sizeof(*sd));
sd->fs = data;
- sd->path = wd->mode == ELM_FILESELECTOR_LIST ?
- elm_genlist_item_data_get(event_info) :
- elm_gengrid_item_data_get(event_info);
+ sd->path = elm_object_item_data_get(it);
if (!sd->path)
{
free(tok[0]);
free(tok);
- elm_entry_entry_set(wd->path_entry, buf);
+ elm_object_text_set(wd->path_entry, buf);
}
#ifdef HAVE_EIO
if (info->type == EINA_FILE_DIR)
{
- eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_DIRECTORY], NULL);
- eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_DIRECTORY], NULL);
+ eio_file_associate_direct_add(handler, "type/grid", grid_itc[ELM_DIRECTORY], NULL);
+ eio_file_associate_direct_add(handler, "type/list", list_itc[ELM_DIRECTORY], NULL);
}
else
{
if (evas_object_image_extension_can_load_get(info->path + info->name_start))
{
- eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_FILE_IMAGE], NULL);
- eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_FILE_IMAGE], NULL);
+ eio_file_associate_direct_add(handler, "type/grid", grid_itc[ELM_FILE_IMAGE], NULL);
+ eio_file_associate_direct_add(handler, "type/list", list_itc[ELM_FILE_IMAGE], NULL);
}
else
{
- eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_FILE_UNKNOW], NULL);
- eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_FILE_UNKNOW], NULL);
+ eio_file_associate_direct_add(handler, "type/grid", grid_itc[ELM_FILE_UNKNOW], NULL);
+ eio_file_associate_direct_add(handler, "type/list", list_itc[ELM_FILE_UNKNOW], NULL);
}
}
static int
_file_grid_cmp(const void *a, const void *b)
{
- const Elm_Gengrid_Item *ga = a;
- const Elm_Gengrid_Item *gb = b;
+ const Elm_Object_Item *ga = a;
+ const Elm_Object_Item *gb = b;
const Elm_Gengrid_Item_Class *ca = elm_gengrid_item_item_class_get(ga);
const Elm_Gengrid_Item_Class *cb = elm_gengrid_item_item_class_get(gb);
- if (ca == &grid_itc[ELM_DIRECTORY])
+ if (ca == grid_itc[ELM_DIRECTORY])
{
- if (cb != &grid_itc[ELM_DIRECTORY])
+ if (cb != grid_itc[ELM_DIRECTORY])
return -1;
}
+ else if (cb == grid_itc[ELM_DIRECTORY])
+ {
+ return 1;
+ }
- return strcoll(elm_gengrid_item_data_get(ga), elm_gengrid_item_data_get(gb));
+ return strcoll(elm_object_item_data_get(ga), elm_object_item_data_get(gb));
}
static int
_file_list_cmp(const void *a, const void *b)
{
- const Elm_Genlist_Item *la = a;
- const Elm_Genlist_Item *lb = b;
+ const Elm_Object_Item *la = a;
+ const Elm_Object_Item *lb = b;
const Elm_Genlist_Item_Class *ca = elm_genlist_item_item_class_get(la);
const Elm_Genlist_Item_Class *cb = elm_genlist_item_item_class_get(lb);
- if (ca == &list_itc[ELM_DIRECTORY])
+ if (ca == list_itc[ELM_DIRECTORY])
{
- if (cb != &list_itc[ELM_DIRECTORY])
+ if (cb != list_itc[ELM_DIRECTORY])
return -1;
}
+ else if (cb == list_itc[ELM_DIRECTORY])
+ {
+ return 1;
+ }
- return strcoll(elm_genlist_item_data_get(la), elm_genlist_item_data_get(lb));
+ return strcoll(elm_object_item_data_get(la), elm_object_item_data_get(lb));
}
static void
_do_anchors(wr->obj, wr->path);
}
- if (wr->wd->filename_entry) elm_entry_entry_set(wr->wd->filename_entry, "");
+ if (wr->wd->filename_entry) elm_object_text_set(wr->wd->filename_entry, "");
wr->first = EINA_FALSE;
}
if (eio_file_check(handler))
return ;
- if (!wr->wd->files_list || !wr->wd->files_grid) return ;
+ if (!wr->wd->files_list || !wr->wd->files_grid || wr->wd->current != handler)
+ {
+ eio_file_cancel(handler);
+ return ;
+ }
_signal_first(wr);
if (wr->wd->mode == ELM_FILESELECTOR_LIST)
- elm_genlist_item_direct_sorted_insert(wr->wd->files_list, eio_file_associate_find(handler, "type/list"),
- eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
- wr->parent, ELM_GENLIST_ITEM_NONE, _file_list_cmp, NULL, NULL);
+ {
+ Eina_Bool is_dir = (eio_file_associate_find(handler, "type/list") == list_itc[ELM_DIRECTORY]);
+
+ elm_genlist_item_sorted_insert(wr->wd->files_list, eio_file_associate_find(handler, "type/list"),
+ eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
+ wr->parent, wr->wd->expand && is_dir ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
+ _file_list_cmp, NULL, NULL);
+ }
else if (wr->wd->mode == ELM_FILESELECTOR_GRID)
- elm_gengrid_item_direct_sorted_insert(wr->wd->files_grid, eio_file_associate_find(handler, "type/grid"),
+ elm_gengrid_item_sorted_insert(wr->wd->files_grid, eio_file_associate_find(handler, "type/grid"),
eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
_file_grid_cmp, NULL, NULL);
}
static void
_populate(Evas_Object *obj,
const char *path,
- Elm_Genlist_Item *parent)
+ Elm_Object_Item *parent)
{
Widget_Data *wd = elm_widget_data_get(obj);
#ifdef HAVE_EIO
_do_anchors(obj, path);
}
- if (wd->filename_entry) elm_entry_entry_set(wd->filename_entry, "");
+ if (wd->filename_entry) elm_object_text_set(wd->filename_entry, "");
EINA_ITERATOR_FOREACH(it, file)
{
const char *filename;
EINA_LIST_FREE(dirs, real)
{
if (wd->mode == ELM_FILESELECTOR_LIST)
- elm_genlist_item_append(wd->files_list, &list_itc[ELM_DIRECTORY],
+ elm_genlist_item_append(wd->files_list, list_itc[ELM_DIRECTORY],
real, /* item data */
parent,
- wd->expand ? ELM_GENLIST_ITEM_SUBITEMS :
+ wd->expand ? ELM_GENLIST_ITEM_TREE :
ELM_GENLIST_ITEM_NONE,
NULL, NULL);
else if (wd->mode == ELM_FILESELECTOR_GRID)
- elm_gengrid_item_append(wd->files_grid, &grid_itc[ELM_DIRECTORY],
+ elm_gengrid_item_append(wd->files_grid, grid_itc[ELM_DIRECTORY],
real, /* item data */
NULL, NULL);
}
ELM_FILE_IMAGE : ELM_FILE_UNKNOW;
if (wd->mode == ELM_FILESELECTOR_LIST)
- elm_genlist_item_append(wd->files_list, &list_itc[type],
+ elm_genlist_item_append(wd->files_list, list_itc[type],
real, /* item data */
parent, ELM_GENLIST_ITEM_NONE,
NULL, NULL);
else if (wd->mode == ELM_FILESELECTOR_GRID)
- elm_gengrid_item_append(wd->files_grid, &grid_itc[type],
+ elm_gengrid_item_append(wd->files_grid, grid_itc[type],
real, /* item data */
NULL, NULL);
}
#else
+ if (wd->expand && wd->current) return ;
if (wd->current)
eio_file_cancel(wd->current);
wr = malloc(sizeof (Widget_Request));
/*** API ***/
-/**
- * Add a new Fileselector object
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Fileselector
- */
EAPI Evas_Object *
elm_fileselector_add(Evas_Object *parent)
{
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
- elm_button_icon_set(bt, ic);
- elm_button_label_set(bt, E_("Up"));
+ elm_object_part_content_set(bt, "icon", ic);
+ elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Up"));
evas_object_size_hint_align_set(bt, 0.0, 0.0);
evas_object_smart_callback_add(bt, "clicked", _up, obj);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
- elm_button_icon_set(bt, ic);
- elm_button_label_set(bt, E_("Home"));
+ elm_object_part_content_set(bt, "icon", ic);
+ elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Home"));
evas_object_size_hint_align_set(bt, 0.0, 0.0);
evas_object_smart_callback_add(bt, "clicked", _home, obj);
elm_widget_sub_object_add(obj, bt);
wd->home_button = bt;
- list_itc[ELM_DIRECTORY].func.icon_get = grid_itc[ELM_DIRECTORY].func.icon_get = _itc_icon_folder_get;
- list_itc[ELM_FILE_IMAGE].func.icon_get = grid_itc[ELM_FILE_IMAGE].func.icon_get = _itc_icon_image_get;
- list_itc[ELM_FILE_UNKNOW].func.icon_get = grid_itc[ELM_FILE_UNKNOW].func.icon_get = _itc_icon_file_get;
-
for (i = 0; i < ELM_FILE_LAST; ++i)
{
- list_itc[i].func.label_get = grid_itc[i].func.label_get = _itc_label_get;
- list_itc[i].func.state_get = grid_itc[i].func.state_get = _itc_state_get;
- list_itc[i].func.del = grid_itc[i].func.del = _itc_del;
+ list_itc[i] = elm_genlist_item_class_new();
+ grid_itc[i] = elm_gengrid_item_class_new();
+
+ list_itc[i]->item_style = "default";
+ list_itc[i]->func.text_get = grid_itc[i]->func.text_get = _itc_text_get;
+ list_itc[i]->func.state_get = grid_itc[i]->func.state_get = _itc_state_get;
+ list_itc[i]->func.del = grid_itc[i]->func.del = _itc_del;
}
+ list_itc[ELM_DIRECTORY]->func.content_get =
+ grid_itc[ELM_DIRECTORY]->func.content_get = _itc_icon_folder_get;
+ list_itc[ELM_FILE_IMAGE]->func.content_get =
+ grid_itc[ELM_FILE_IMAGE]->func.content_get = _itc_icon_image_get;
+ list_itc[ELM_FILE_UNKNOW]->func.content_get =
+ grid_itc[ELM_FILE_UNKNOW]->func.content_get = _itc_icon_file_get;
+
li = elm_genlist_add(parent);
elm_widget_mirrored_automatic_set(li, EINA_FALSE);
evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- s = elm_finger_size_get() * 2;
+ // XXX: will fail for dynamic finger size changing
+ s = _elm_config->finger_size * 2;
elm_gengrid_item_size_set(grid, s, s);
elm_gengrid_align_set(grid, 0.0, 0.0);
return obj;
}
-/**
- * This enables/disables the file name entry box where the user can
- * type in a name for the file to be saved as.
- *
- * @param obj The fileselector object
- * @param is_save If true, the fileselector is a save dialog
- *
- * @ingroup Fileselector
- */
EAPI void
elm_fileselector_is_save_set(Evas_Object *obj,
Eina_Bool is_save)
edje_object_signal_emit(wd->edje, "elm,state,save,off", "elm");
}
-/**
- * This returns whether the fileselector is a "save" type fileselector
- *
- * @param obj The fileselector object
- * @return If true, the fileselector is a save type.
- *
- * @ingroup Fileselector
- */
EAPI Eina_Bool
elm_fileselector_is_save_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
- return elm_object_disabled_get(wd->filename_entry);
+ return !elm_object_disabled_get(wd->filename_entry);
}
-/**
- * This enables/disables folder-only view in the fileselector.
- *
- * @param obj The fileselector object
- * @param only If true, the fileselector will only display directories.
- * If false, files are displayed also.
- *
- * @ingroup Fileselector
- */
EAPI void
elm_fileselector_folder_only_set(Evas_Object *obj,
Eina_Bool only)
if (wd->path) _populate(obj, wd->path, NULL);
}
-/**
- * This gets the state of file display in the fileselector.
- *
- * @param obj The fileselector object
- * @return If true, files are not being shown in the fileselector.
- * If false, files are being shown.
- *
- * @ingroup Fileselector
- */
EAPI Eina_Bool
elm_fileselector_folder_only_get(const Evas_Object *obj)
{
return wd->only_folder;
}
-/**
- * This enables/disables the ok,cancel buttons.
- *
- * @param obj The fileselector object
- * @param only If true, a box containing ok and cancel buttons is created.
- * If false, the box and the buttons are destroyed.
- *
- * @ingroup Fileselector
- */
EAPI void
elm_fileselector_buttons_ok_cancel_set(Evas_Object *obj,
Eina_Bool visible)
// cancel btn
bt = elm_button_add(obj);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
- elm_button_label_set(bt, E_("Cancel"));
+ elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Cancel"));
evas_object_smart_callback_add(bt, "clicked", _canc, obj);
// ok btn
bt = elm_button_add(obj);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
- elm_button_label_set(bt, E_("OK"));
+ elm_object_domain_translatable_text_set(bt, PACKAGE, N_("OK"));
evas_object_smart_callback_add(bt, "clicked", _ok, obj);
}
}
-/**
- * This gets the state of the box containing ok and cancel buttons.
- *
- * @param obj The fileselector object
- * @return If true, the box exists.
- * If false, the box does not exist.
- *
- * @ingroup Fileselector
- */
EAPI Eina_Bool
elm_fileselector_buttons_ok_cancel_get(const Evas_Object *obj)
{
return wd->ok_button ? EINA_TRUE : EINA_FALSE;
}
-/**
- * This enables a tree view in the fileselector, <b>if in @c
- * ELM_FILESELECTOR_LIST mode</b>. If it's in other mode, the changes
- * made by this function will only be visible when one switches back
- * to list mode.
- *
- * @param obj The fileselector object
- * @param expand If true, tree view is enabled.
- * If false, tree view is disabled.
- *
- * In a tree view, arrows are created on the sides of directories,
- * allowing them to expand in place.
- *
- * @ingroup Fileselector
- */
EAPI void
elm_fileselector_expandable_set(Evas_Object *obj,
Eina_Bool expand)
if (wd->path) _populate(obj, wd->path, NULL);
}
-/**
- * This gets the state of tree view in the fileselector.
- *
- * @param obj The fileselector object
- * @return If true, tree view is enabled and folders will be expandable.
- * If false, tree view is disabled.
- *
- * @ingroup Fileselector
- */
EAPI Eina_Bool
elm_fileselector_expandable_get(const Evas_Object *obj)
{
return wd->expand;
}
-/**
- * This sets the path that the fileselector will display.
- *
- * @param obj The fileselector object
- * @param path The path of the fileselector
- *
- * @ingroup Fileselector
- */
EAPI void
elm_fileselector_path_set(Evas_Object *obj,
- const char *path)
+ const char *_path)
{
ELM_CHECK_WIDTYPE(obj, widtype);
+ char *path;
+ path = ecore_file_realpath(_path);
_populate(obj, path, NULL);
+ free(path);
}
-/**
- * This gets the path that the fileselector displays.
- *
- * @param obj The fileselector object
- * @return The path that the fileselector is displaying
- *
- * @ingroup Fileselector
- */
EAPI const char *
elm_fileselector_path_get(const Evas_Object *obj)
{
return wd->path;
}
-/**
- * This sets the mode in which the fileselector will display files.
- *
- * @param obj The fileselector object
-
- * @param mode The mode of the fileselector, being it one of @c
- * ELM_FILESELECTOR_LIST (default) or @c ELM_FILESELECTOR_GRID. The
- * first one, naturally, will display the files in a list. By using
- * elm_fileselector_expandable_set(), the user will trigger a tree
- * view for that list. The latter will make the widget to display its
- * entries in a grid form.
- *
- * @see elm_fileselector_expandable_set().
- *
- * @ingroup Fileselector
- */
EAPI void
elm_fileselector_mode_set(Evas_Object *obj,
Elm_Fileselector_Mode mode)
_populate(obj, wd->path, NULL);
}
-/**
- * This gets the mode in which the fileselector is displaying files.
- *
- * @param obj The fileselector object
- * @return The mode in which the fileselector is at
- *
- * @ingroup Fileselector
- */
EAPI Elm_Fileselector_Mode
elm_fileselector_mode_get(const Evas_Object *obj)
{
return wd->mode;
}
-/**
- * This gets the currently selected path in the file selector.
- *
- * @param obj The file selector object
- * @return The absolute path of the selected object in the fileselector
- *
- * @ingroup Fileselector
- */
EAPI const char *
elm_fileselector_selected_get(const Evas_Object *obj)
{
{
const char *name;
char buf[PATH_MAX];
+ char *dir;
- name = elm_entry_entry_get(wd->filename_entry);
+ dir = wd->only_folder ? ecore_file_dir_get(wd->path) : strdup(wd->path);
+ name = elm_object_text_get(wd->filename_entry);
snprintf(buf, sizeof(buf), "%s/%s",
- wd->only_folder ? ecore_file_dir_get(wd->path) : wd->path,
- name);
- eina_stringshare_replace(&wd->selection, buf);
+ dir, name);
+ if (wd->only_folder && !ecore_file_is_dir(buf))
+ eina_stringshare_replace(&wd->selection, ecore_file_dir_get(buf));
+ else
+ eina_stringshare_replace(&wd->selection, buf);
+ if (dir) free(dir);
return wd->selection;
}
if (wd->mode == ELM_FILESELECTOR_LIST)
{
- Elm_Genlist_Item *it;
- it = elm_genlist_selected_item_get(wd->files_list);
- if (it) return elm_genlist_item_data_get(it);
+ Elm_Object_Item *gl_it = elm_genlist_selected_item_get(wd->files_list);
+ if (gl_it) return elm_object_item_data_get(gl_it);
}
else
{
- Elm_Gengrid_Item *it;
- it = elm_gengrid_selected_item_get(wd->files_grid);
- if (it) return elm_gengrid_item_data_get(it);
+ Elm_Object_Item *gg_it = elm_gengrid_selected_item_get(wd->files_grid);
+ if (gg_it) return elm_object_item_data_get(gg_it);
}
return wd->path;
}
-/**
- * This sets the currently selected path in the file selector.
- *
- * @param obj The file selector object
- * @param path The path to a file or directory
- * @return @c EINA_TRUE on success, @c EINA_FALSE on failure. The
- * latter case occurs if the directory or file pointed to do not
- * exist.
- *
- * @ingroup Fileselector
- */
EAPI Eina_Bool
elm_fileselector_selected_set(Evas_Object *obj,
- const char *path)
+ const char *_path)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
+ Eina_Bool ret = EINA_TRUE;
+ char *path;
+ path = ecore_file_realpath(_path);
+
if (ecore_file_is_dir(path))
_populate(obj, path, NULL);
else
{
if (!ecore_file_exists(path))
- return EINA_FALSE;
+ {
+ ret = EINA_FALSE;
+ goto clean_up;
+ }
_populate(obj, ecore_file_dir_get(path), NULL);
if (wd->filename_entry)
{
- elm_entry_entry_set(wd->filename_entry,
+ elm_object_text_set(wd->filename_entry,
ecore_file_file_get(path));
eina_stringshare_replace(&wd->selection, path);
}
}
- return EINA_TRUE;
+clean_up:
+ free(path);
+ return ret;
}