2011-07-15 07:02:54 -07:00
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* - child elements focusing support
|
|
|
|
* - user defined icon/label cb
|
|
|
|
* - show/hide/add buttons ???
|
2013-06-18 17:00:41 -07:00
|
|
|
* - Pattern Filter support
|
2009-08-12 09:08:53 -07:00
|
|
|
*/
|
2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2014-10-17 08:56:11 -07:00
|
|
|
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
|
|
|
|
#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2014-01-21 05:50:35 -08:00
|
|
|
#include "elm_interface_fileselector.h"
|
2012-08-01 14:03:33 -07:00
|
|
|
#include "elm_widget_fileselector.h"
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_FILESELECTOR_CLASS
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_CLASS_NAME "Elm_Fileselector"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_fileselector"
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2013-12-03 01:28:52 -08:00
|
|
|
/* FIXME: need a way to find a gap between the size of item and thumbnail */
|
|
|
|
#define GENGRID_PADDING 16
|
|
|
|
|
2012-02-20 00:26:17 -08:00
|
|
|
static Elm_Genlist_Item_Class *list_itc[ELM_FILE_LAST];
|
2012-02-22 23:36:12 -08:00
|
|
|
static Elm_Gengrid_Item_Class *grid_itc[ELM_FILE_LAST];
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2013-09-02 16:39:02 -07:00
|
|
|
#define ELM_PRIV_FILESELECTOR_SIGNALS(cmd) \
|
2013-10-01 20:35:23 -07:00
|
|
|
cmd(SIG_ACTIVATED, "activated", "s") \
|
2013-09-02 16:39:02 -07:00
|
|
|
cmd(SIG_DIRECTORY_OPEN, "directory,open", "s") \
|
|
|
|
cmd(SIG_DONE, "done", "s") \
|
2013-09-12 06:17:07 -07:00
|
|
|
cmd(SIG_SELECTED, "selected", "s") \
|
|
|
|
cmd(SIG_SELECTED_INVALID, "selected,invalid", "s")
|
2013-09-02 16:39:02 -07:00
|
|
|
|
|
|
|
ELM_PRIV_FILESELECTOR_SIGNALS(ELM_PRIV_STATIC_VARIABLE_DECLARE);
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
2013-09-02 16:39:02 -07:00
|
|
|
ELM_PRIV_FILESELECTOR_SIGNALS(ELM_PRIV_SMART_CALLBACKS_DESC)
|
2014-02-05 23:18:57 -08:00
|
|
|
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
|
|
|
|
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
|
2010-12-07 11:18:14 -08:00
|
|
|
{NULL, NULL}
|
2010-04-05 12:18:36 -07:00
|
|
|
};
|
2013-10-18 10:20:34 -07:00
|
|
|
#undef ELM_PRIV_FILESELECTOR_SIGNALS
|
2010-04-05 12:18:36 -07:00
|
|
|
|
2014-04-14 21:58:01 -07:00
|
|
|
static Eina_Bool _key_action_select(Evas_Object *obj, const char *params);
|
|
|
|
static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
|
2016-03-04 15:32:22 -08:00
|
|
|
static Eina_Bool _key_action_backspace(Evas_Object *obj, const char *params);
|
2014-04-14 21:58:01 -07:00
|
|
|
|
|
|
|
static const Elm_Action key_actions[] = {
|
|
|
|
{"select", _key_action_select},
|
|
|
|
{"escape", _key_action_escape},
|
2016-03-04 15:32:22 -08:00
|
|
|
{"backspace", _key_action_backspace},
|
2014-04-14 21:58:01 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2016-02-29 03:32:52 -08:00
|
|
|
static Eina_Bool _ok(void *data, const Eo_Event *event);
|
|
|
|
static Eina_Bool _canc(void *data, const Eo_Event *event);
|
2016-03-04 15:32:22 -08:00
|
|
|
static Eina_Bool _on_dir_up(void *data, const Eo_Event *event);
|
|
|
|
static void _populate(Evas_Object *obj, const char *path, Elm_Object_Item *parent_it, const char *selected);
|
2014-01-21 22:53:49 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
/* final routine on deletion */
|
|
|
|
static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_smart_del_do(Elm_Fileselector_Data *sd)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2014-01-21 16:55:58 -08:00
|
|
|
eina_stringshare_del(sd->path);
|
2016-03-04 15:32:22 -08:00
|
|
|
eina_stringshare_del(sd->prev_path);
|
2014-01-21 16:55:58 -08:00
|
|
|
eina_stringshare_del(sd->selection);
|
|
|
|
free(ecore_idler_del(sd->populate_idler));
|
2014-09-02 20:44:05 -07:00
|
|
|
ecore_idler_del(sd->path_entry_idler);
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
evas_obj_smart_del(eo_super(sd->obj, MY_CLASS));
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
2011-02-08 04:08:28 -08:00
|
|
|
static void
|
|
|
|
_mirrored_set(Evas_Object *obj, Eina_Bool rtl)
|
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
ELM_FILESELECTOR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
elm_widget_mirrored_set(sd->cancel_button, rtl);
|
|
|
|
elm_widget_mirrored_set(sd->ok_button, rtl);
|
2013-10-17 22:25:20 -07:00
|
|
|
elm_widget_mirrored_set(sd->files_view, rtl);
|
2012-05-03 15:44:26 -07:00
|
|
|
elm_widget_mirrored_set(sd->up_button, rtl);
|
|
|
|
elm_widget_mirrored_set(sd->home_button, rtl);
|
2011-02-08 04:08:28 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_widget_theme_apply(Eo *obj, Elm_Fileselector_Data *sd)
|
2010-11-22 11:24:48 -08:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
const char *style;
|
2010-11-22 11:24:48 -08:00
|
|
|
const char *data;
|
|
|
|
char buf[1024];
|
2014-04-03 05:53:04 -07:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
2016-03-04 15:39:29 -08:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
|
2014-03-30 00:15:55 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
style = elm_widget_style_get(obj);
|
|
|
|
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
data = edje_object_data_get
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, "path_separator");
|
2012-05-03 15:44:26 -07:00
|
|
|
if (data) sd->path_separator = data;
|
|
|
|
else sd->path_separator = "/";
|
2010-11-22 11:24:48 -08:00
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "fileselector/%s", style);
|
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_widget_style_set(sd->up_button, buf);
|
|
|
|
elm_widget_style_set(sd->home_button, buf);
|
|
|
|
elm_widget_style_set(sd->spinner, "wheel");
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_widget_style_set(sd->path_entry, buf);
|
|
|
|
elm_widget_style_set(sd->name_entry, buf);
|
|
|
|
elm_widget_style_set(sd->search_entry, buf);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "fileselector/actions/%s", style);
|
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
if (sd->filter_hoversel)
|
|
|
|
elm_widget_style_set(sd->filter_hoversel, buf);
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
if (sd->ok_button)
|
|
|
|
{
|
|
|
|
elm_widget_style_set(sd->cancel_button, buf);
|
|
|
|
elm_widget_style_set(sd->ok_button, buf);
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_TRUE;
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
2014-04-14 21:58:01 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED)
|
|
|
|
{
|
2016-04-05 23:22:20 -07:00
|
|
|
Eo_Event event = {};
|
2016-02-29 03:32:52 -08:00
|
|
|
_ok(obj, &event);
|
2014-04-14 21:58:01 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED)
|
|
|
|
{
|
2016-04-05 23:22:20 -07:00
|
|
|
Eo_Event event = {};
|
2016-02-29 03:32:52 -08:00
|
|
|
_canc(obj, &event);
|
2014-04-14 21:58:01 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2016-03-04 15:32:22 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_backspace(Evas_Object *obj, const char *params EINA_UNUSED)
|
|
|
|
{
|
|
|
|
ELM_FILESELECTOR_DATA_GET(obj, sd);
|
|
|
|
if (sd->prev_path)
|
|
|
|
_populate(obj, sd->prev_path, NULL, NULL);
|
|
|
|
else
|
|
|
|
_on_dir_up(obj, NULL);
|
|
|
|
|
|
|
|
eina_stringshare_del(sd->prev_path);
|
|
|
|
sd->prev_path = NULL;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_widget_event(Eo *obj, Elm_Fileselector_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
|
2014-01-21 22:53:49 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
2014-01-21 22:53:49 -08:00
|
|
|
(void) src;
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
2014-01-21 22:53:49 -08:00
|
|
|
|
2015-12-21 04:55:23 -08:00
|
|
|
if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions))
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_FALSE;
|
2014-01-21 22:53:49 -08:00
|
|
|
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_TRUE;
|
2014-01-21 22:53:49 -08:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
/*** GENLIST/GENGRID "MODEL" ***/
|
2010-12-07 11:18:14 -08:00
|
|
|
static char *
|
2012-05-03 15:44:26 -07:00
|
|
|
_itc_text_get(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
return elm_entry_utf8_to_markup
|
|
|
|
(ecore_file_file_get(data)); /* NOTE this will be free()'d by
|
|
|
|
* the caller */
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
2010-12-07 11:18:14 -08:00
|
|
|
static Evas_Object *
|
2014-01-06 06:30:02 -08:00
|
|
|
_itc_icon_folder_get(void *data EINA_UNUSED,
|
2011-06-25 16:39:43 -07:00
|
|
|
Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
const char *source)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
2013-12-03 01:28:52 -08:00
|
|
|
Evas_Object *ic, *grid, *f;
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2011-06-25 16:39:43 -07:00
|
|
|
if (strcmp(source, "elm.swallow.icon")) return NULL;
|
2011-05-31 09:16:01 -07:00
|
|
|
|
2013-12-03 01:28:52 -08:00
|
|
|
f = evas_object_data_get(obj, "parent");
|
|
|
|
ELM_FILESELECTOR_DATA_GET(f, sd);
|
|
|
|
|
2011-06-25 16:39:43 -07:00
|
|
|
ic = elm_icon_add(obj);
|
|
|
|
elm_icon_standard_set(ic, "folder");
|
2012-05-03 15:44:26 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
2013-12-03 01:28:52 -08:00
|
|
|
evas_object_show(ic);
|
|
|
|
|
|
|
|
grid = elm_grid_add(obj);
|
|
|
|
elm_grid_size_set(grid, 1, 1);
|
|
|
|
elm_grid_pack(grid, ic, 0, 0, 1, 1);
|
|
|
|
evas_object_size_hint_min_set(grid, sd->thumbnail_size.w, sd->thumbnail_size.h);
|
|
|
|
evas_object_show(grid);
|
|
|
|
|
|
|
|
return grid;
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2012-05-03 15:44:26 -07:00
|
|
|
_itc_icon_image_get(void *data,
|
2011-06-25 16:39:43 -07:00
|
|
|
Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
const char *source)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
|
|
|
const char *filename = data;
|
2013-12-03 01:28:52 -08:00
|
|
|
Evas_Object *ic, *grid, *f;
|
2011-06-25 16:39:43 -07:00
|
|
|
|
|
|
|
if (strcmp(source, "elm.swallow.icon")) return NULL;
|
|
|
|
|
2013-12-03 01:28:52 -08:00
|
|
|
f = evas_object_data_get(obj, "parent");
|
|
|
|
ELM_FILESELECTOR_DATA_GET(f, sd);
|
|
|
|
|
2011-06-25 16:39:43 -07:00
|
|
|
ic = elm_icon_add(obj);
|
|
|
|
elm_icon_standard_set(ic, "image");
|
|
|
|
elm_icon_thumb_set(ic, filename, NULL);
|
2012-05-03 15:44:26 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
2013-12-03 01:28:52 -08:00
|
|
|
evas_object_show(ic);
|
|
|
|
|
|
|
|
grid = elm_grid_add(obj);
|
|
|
|
elm_grid_size_set(grid, 1, 1);
|
|
|
|
elm_grid_pack(grid, ic, 0, 0, 1, 1);
|
|
|
|
evas_object_size_hint_min_set(grid, sd->thumbnail_size.w, sd->thumbnail_size.h);
|
|
|
|
evas_object_show(grid);
|
|
|
|
|
|
|
|
return grid;
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2014-01-06 06:30:02 -08:00
|
|
|
_itc_icon_file_get(void *data EINA_UNUSED,
|
2011-06-25 16:39:43 -07:00
|
|
|
Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
const char *source)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2013-12-03 01:28:52 -08:00
|
|
|
Evas_Object *ic, *grid, *f;
|
2011-06-25 16:39:43 -07:00
|
|
|
|
|
|
|
if (strcmp(source, "elm.swallow.icon")) return NULL;
|
|
|
|
|
2013-12-03 01:28:52 -08:00
|
|
|
f = evas_object_data_get(obj, "parent");
|
|
|
|
ELM_FILESELECTOR_DATA_GET(f, sd);
|
|
|
|
|
2011-06-25 16:39:43 -07:00
|
|
|
ic = elm_icon_add(obj);
|
|
|
|
elm_icon_standard_set(ic, "file");
|
2012-05-03 15:44:26 -07:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
2013-12-03 01:28:52 -08:00
|
|
|
evas_object_show(ic);
|
|
|
|
|
|
|
|
grid = elm_grid_add(obj);
|
|
|
|
elm_grid_size_set(grid, 1, 1);
|
|
|
|
elm_grid_pack(grid, ic, 0, 0, 1, 1);
|
|
|
|
evas_object_size_hint_min_set(grid, sd->thumbnail_size.w, sd->thumbnail_size.h);
|
|
|
|
evas_object_show(grid);
|
|
|
|
|
|
|
|
return grid;
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
static Eina_Bool
|
2014-01-06 06:30:02 -08:00
|
|
|
_itc_state_get(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:44:26 -07:00
|
|
|
_itc_del(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
|
|
|
eina_stringshare_del(data);
|
|
|
|
}
|
|
|
|
|
2012-05-03 15:45:01 -07:00
|
|
|
static void
|
|
|
|
_anchors_do(Evas_Object *obj,
|
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
char **tok, buf[PATH_MAX * 3], *s;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
s = elm_entry_utf8_to_markup(path);
|
2013-07-17 18:25:57 -07:00
|
|
|
if (!s) return;
|
2012-05-03 15:45:01 -07:00
|
|
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
tok = eina_str_split(s, "/", 0);
|
|
|
|
free(s);
|
|
|
|
|
2014-01-27 23:16:44 -08:00
|
|
|
eina_strlcat(buf, "<a href='/'>root</a>", sizeof(buf));
|
2012-05-03 15:45:01 -07:00
|
|
|
for (i = 0; tok[i]; i++)
|
|
|
|
{
|
|
|
|
if ((!tok[i]) || (!tok[i][0])) continue;
|
|
|
|
eina_strlcat(buf, sd->path_separator, sizeof(buf));
|
|
|
|
eina_strlcat(buf, "<a href=", sizeof(buf));
|
|
|
|
for (j = 0; j <= i; j++)
|
|
|
|
{
|
|
|
|
if (strlen(tok[j]) < 1) continue;
|
|
|
|
eina_strlcat(buf, "/", sizeof(buf));
|
|
|
|
eina_strlcat(buf, tok[j], sizeof(buf));
|
|
|
|
}
|
|
|
|
eina_strlcat(buf, ">", sizeof(buf));
|
|
|
|
eina_strlcat(buf, tok[i], sizeof(buf));
|
|
|
|
eina_strlcat(buf, "</a>", sizeof(buf));
|
|
|
|
}
|
|
|
|
free(tok[0]);
|
|
|
|
free(tok);
|
|
|
|
|
|
|
|
elm_object_text_set(sd->path_entry, buf);
|
|
|
|
}
|
|
|
|
|
2013-06-18 17:00:41 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_mime_type_matched(const char *mime_filter, const char *mime_type)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (mime_filter[i] != '\0')
|
|
|
|
{
|
|
|
|
if (mime_filter[i] != mime_type[i])
|
|
|
|
{
|
|
|
|
if (mime_filter[i] == '*' && mime_filter[i + 1] == '\0')
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mime_type[i] != '\0') return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-12-28 20:23:17 -08:00
|
|
|
_check_mime_type_filter(const Elm_Fileselector_Filter *filter,
|
|
|
|
const char *file_name)
|
2013-06-18 17:00:41 -07:00
|
|
|
{
|
|
|
|
const char *mime_type = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
mime_type = efreet_mime_type_get(file_name);
|
|
|
|
|
|
|
|
if (!mime_type) return EINA_FALSE;
|
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
for (i = 0; filter->filter.mime_types[i]; ++i)
|
2013-06-18 17:00:41 -07:00
|
|
|
{
|
2013-12-28 20:23:17 -08:00
|
|
|
if (_mime_type_matched(filter->filter.mime_types[i], mime_type))
|
2013-06-18 17:00:41 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2011-06-25 16:39:43 -07:00
|
|
|
static Eina_Bool
|
2012-05-13 05:23:39 -07:00
|
|
|
_ls_filter_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Eio_File *handler EINA_UNUSED,
|
2012-05-03 15:44:26 -07:00
|
|
|
const Eina_File_Direct_Info *info)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2012-05-13 05:23:39 -07:00
|
|
|
Listing_Request *lreq = data;
|
2013-12-28 20:23:17 -08:00
|
|
|
Elm_Fileselector_Filter *cf;
|
|
|
|
Eina_Bool dir = EINA_FALSE;
|
2014-06-10 02:50:01 -07:00
|
|
|
char *pch = NULL, *temp = NULL;
|
|
|
|
char temp_path[EINA_PATH_MAX];
|
2015-01-07 02:33:27 -08:00
|
|
|
ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2015-01-07 02:33:27 -08:00
|
|
|
if (!sd) return EINA_FALSE;
|
|
|
|
if (!sd->hidden_visible && info->path[info->name_start] == '.')
|
2011-06-25 16:39:43 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
if (info->type == EINA_FILE_DIR)
|
|
|
|
dir = EINA_TRUE;
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2015-01-07 02:33:27 -08:00
|
|
|
if (sd->only_folder && !dir)
|
2013-06-18 17:00:41 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
2014-06-10 02:50:01 -07:00
|
|
|
//Search entry filter
|
2015-01-07 02:33:27 -08:00
|
|
|
if ((sd->search_string) && (sd->search_string[0] != '\0'))
|
2014-06-10 02:50:01 -07:00
|
|
|
{
|
|
|
|
strcpy(temp_path, info->path);
|
|
|
|
pch = strchr(temp_path, '/');
|
|
|
|
while (pch != NULL)
|
|
|
|
{
|
|
|
|
temp = pch;
|
|
|
|
pch = strchr(pch + 1, '/');
|
|
|
|
}
|
|
|
|
temp++;
|
2015-01-07 02:33:27 -08:00
|
|
|
if ((temp) && (sd->search_string) &&
|
|
|
|
(!strstr(temp, sd->search_string)))
|
2014-06-10 02:50:01 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:33:27 -08:00
|
|
|
cf = sd->current_filter;
|
2013-12-28 20:23:17 -08:00
|
|
|
if (!cf)
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
switch (cf->filter_type)
|
|
|
|
{
|
|
|
|
case ELM_FILESELECTOR_MIME_FILTER:
|
|
|
|
return dir || _check_mime_type_filter(cf, info->path);
|
|
|
|
case ELM_FILESELECTOR_CUSTOM_FILTER:
|
|
|
|
return cf->filter.custom->func(info->path, dir,
|
|
|
|
cf->filter.custom->data);
|
|
|
|
default:
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
2013-12-18 03:05:35 -08:00
|
|
|
static const char *
|
|
|
|
_file_type(const char *a)
|
|
|
|
{
|
|
|
|
char *p = strrchr(a, '.');
|
|
|
|
if (!p) return "";
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_strcoll_rev(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
return strcoll(b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_strcoll_type(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
return strcoll(_file_type(a), _file_type(b));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_strcoll_type_rev(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
return _strcoll_type(b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_size_cmp(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
return ecore_file_size(a) - ecore_file_size(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_size_cmp_rev(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
return _size_cmp(b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_modified_cmp(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
if (ecore_file_mod_time(a) > ecore_file_mod_time(b))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_modified_cmp_rev(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
return _modified_cmp(b, a);
|
|
|
|
}
|
|
|
|
|
2011-06-25 16:39:43 -07:00
|
|
|
static int
|
2013-12-18 03:05:35 -08:00
|
|
|
_file_grid_cmp(const void *a, const void *b)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2013-12-18 03:05:35 -08:00
|
|
|
Evas_Object *f;
|
|
|
|
|
2012-01-30 02:29:51 -08:00
|
|
|
const Elm_Object_Item *ga = a;
|
|
|
|
const Elm_Object_Item *gb = b;
|
2011-06-25 16:39:43 -07:00
|
|
|
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);
|
|
|
|
|
2012-02-22 23:36:12 -08:00
|
|
|
if (ca == grid_itc[ELM_DIRECTORY])
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2012-02-22 23:36:12 -08:00
|
|
|
if (cb != grid_itc[ELM_DIRECTORY])
|
2011-06-25 16:39:43 -07:00
|
|
|
return -1;
|
|
|
|
}
|
2012-02-22 23:36:12 -08:00
|
|
|
else if (cb == grid_itc[ELM_DIRECTORY])
|
2011-09-05 13:30:12 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2013-12-18 03:05:35 -08:00
|
|
|
f = evas_object_data_get(elm_object_item_widget_get(ga), "parent");
|
|
|
|
ELM_FILESELECTOR_DATA_GET(f, sd);
|
|
|
|
return sd->sort_method(elm_object_item_data_get(ga),
|
|
|
|
elm_object_item_data_get(gb));
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-12-18 03:05:35 -08:00
|
|
|
_file_list_cmp(const void *a, const void *b)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2013-12-18 03:05:35 -08:00
|
|
|
Evas_Object *f;
|
|
|
|
|
2012-01-19 21:18:31 -08:00
|
|
|
const Elm_Object_Item *la = a;
|
|
|
|
const Elm_Object_Item *lb = b;
|
2011-06-25 16:39:43 -07:00
|
|
|
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);
|
|
|
|
|
2012-02-20 00:26:17 -08:00
|
|
|
if (ca == list_itc[ELM_DIRECTORY])
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2012-02-20 00:26:17 -08:00
|
|
|
if (cb != list_itc[ELM_DIRECTORY])
|
2011-06-25 16:39:43 -07:00
|
|
|
return -1;
|
|
|
|
}
|
2012-02-20 00:26:17 -08:00
|
|
|
else if (cb == list_itc[ELM_DIRECTORY])
|
2011-09-05 13:30:12 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2013-12-18 03:05:35 -08:00
|
|
|
f = evas_object_data_get(elm_object_item_widget_get(la), "parent");
|
|
|
|
ELM_FILESELECTOR_DATA_GET(f, sd);
|
|
|
|
return sd->sort_method(elm_object_item_data_get(la),
|
|
|
|
elm_object_item_data_get(lb));
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
static void
|
|
|
|
_signal_first(Listing_Request *lreq)
|
2012-05-02 10:01:48 -07:00
|
|
|
{
|
2015-01-07 02:33:27 -08:00
|
|
|
ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
if (!lreq->first) return;
|
2015-01-07 02:33:27 -08:00
|
|
|
if (!sd) return;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2015-01-07 02:33:27 -08:00
|
|
|
if (sd->multi)
|
2013-10-16 19:04:57 -07:00
|
|
|
{
|
|
|
|
char *path;
|
2015-01-07 02:33:27 -08:00
|
|
|
EINA_LIST_FREE(sd->paths, path) free(path);
|
2013-10-16 19:04:57 -07:00
|
|
|
}
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(lreq->obj, ELM_FILESELECTOR_EVENT_DIRECTORY_OPEN, (void *)lreq->path);
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
if (!lreq->parent_it)
|
2012-05-02 10:01:48 -07:00
|
|
|
{
|
2015-01-07 02:33:27 -08:00
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
|
|
|
elm_genlist_clear(sd->files_view);
|
2013-10-17 22:25:20 -07:00
|
|
|
else
|
2015-01-07 02:33:27 -08:00
|
|
|
elm_gengrid_clear(sd->files_view);
|
|
|
|
eina_stringshare_replace(&sd->path, lreq->path);
|
2012-05-03 15:44:26 -07:00
|
|
|
_anchors_do(lreq->obj, lreq->path);
|
2012-05-02 10:01:48 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
lreq->first = EINA_FALSE;
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:44:26 -07:00
|
|
|
_ls_main_cb(void *data,
|
|
|
|
Eio_File *handler,
|
2012-05-15 13:02:59 -07:00
|
|
|
const Eina_File_Direct_Info *info)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
Listing_Request *lreq = data;
|
2013-09-10 02:47:30 -07:00
|
|
|
Elm_Object_Item *item;
|
2012-05-15 13:02:59 -07:00
|
|
|
int itcn = ELM_FILE_UNKNOW;
|
2015-01-07 02:33:27 -08:00
|
|
|
ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
if (eio_file_check(handler)) return;
|
2015-01-07 02:33:27 -08:00
|
|
|
if (!sd) return;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2015-01-07 02:33:27 -08:00
|
|
|
if (!sd->files_view || sd->current != handler)
|
2011-06-27 03:26:06 -07:00
|
|
|
{
|
|
|
|
eio_file_cancel(handler);
|
2012-05-03 15:44:26 -07:00
|
|
|
return;
|
2011-06-27 03:26:06 -07:00
|
|
|
}
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
_signal_first(lreq);
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2012-05-15 13:02:59 -07:00
|
|
|
if (info->type == EINA_FILE_DIR)
|
|
|
|
itcn = ELM_DIRECTORY;
|
|
|
|
else
|
2012-07-25 04:19:59 -07:00
|
|
|
{
|
|
|
|
if (evas_object_image_extension_can_load_get
|
2012-08-01 14:03:33 -07:00
|
|
|
(info->path + info->name_start))
|
2012-07-25 04:19:59 -07:00
|
|
|
itcn = ELM_FILE_IMAGE;
|
|
|
|
}
|
2012-05-15 13:02:59 -07:00
|
|
|
|
2015-01-07 02:33:27 -08:00
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
2013-09-10 02:47:30 -07:00
|
|
|
{
|
2015-01-07 02:33:27 -08:00
|
|
|
item = elm_genlist_item_sorted_insert(sd->files_view, list_itc[itcn],
|
2013-09-10 02:47:30 -07:00
|
|
|
eina_stringshare_add(info->path),
|
|
|
|
lreq->parent_it,
|
2015-01-07 02:33:27 -08:00
|
|
|
((sd->expand) && (itcn == ELM_DIRECTORY))
|
2013-09-10 02:47:30 -07:00
|
|
|
? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
|
|
|
|
_file_list_cmp, NULL, NULL);
|
|
|
|
|
|
|
|
if (lreq->selected && !strcmp(info->path, lreq->selected))
|
2013-09-25 07:43:22 -07:00
|
|
|
{
|
|
|
|
elm_genlist_item_selected_set(item, EINA_TRUE);
|
2015-01-07 02:33:27 -08:00
|
|
|
elm_object_text_set(sd->name_entry, ecore_file_file_get(info->path));
|
2013-09-25 07:43:22 -07:00
|
|
|
}
|
2013-09-10 02:47:30 -07:00
|
|
|
}
|
2015-01-07 02:33:27 -08:00
|
|
|
else if (sd->mode == ELM_FILESELECTOR_GRID)
|
2013-09-10 02:47:30 -07:00
|
|
|
{
|
2015-01-07 02:33:27 -08:00
|
|
|
item = elm_gengrid_item_sorted_insert(sd->files_view, grid_itc[itcn],
|
2013-09-10 02:47:30 -07:00
|
|
|
eina_stringshare_add(info->path),
|
|
|
|
_file_grid_cmp, NULL, NULL);
|
|
|
|
|
|
|
|
if (lreq->selected && !strcmp(info->path, lreq->selected))
|
2013-09-25 07:43:22 -07:00
|
|
|
{
|
|
|
|
elm_gengrid_item_selected_set(item, EINA_TRUE);
|
2015-01-07 02:33:27 -08:00
|
|
|
elm_object_text_set(sd->name_entry, ecore_file_file_get(info->path));
|
2013-09-25 07:43:22 -07:00
|
|
|
}
|
2013-09-10 02:47:30 -07:00
|
|
|
}
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:44:26 -07:00
|
|
|
_listing_request_cleanup(Listing_Request *lreq)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
eina_stringshare_del(lreq->path);
|
2013-09-10 02:47:30 -07:00
|
|
|
eina_stringshare_del(lreq->selected);
|
2012-05-03 15:44:26 -07:00
|
|
|
free(lreq);
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_ls_done_cb(void *data, Eio_File *handler EINA_UNUSED)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
Listing_Request *lreq = data;
|
2015-01-07 02:33:27 -08:00
|
|
|
ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
_signal_first(lreq);
|
2015-01-07 02:33:27 -08:00
|
|
|
if (sd)
|
|
|
|
{
|
|
|
|
elm_progressbar_pulse(sd->spinner, EINA_FALSE);
|
|
|
|
elm_layout_signal_emit(lreq->obj, "elm,action,spinner,hide", "elm");
|
|
|
|
sd->current = NULL;
|
|
|
|
}
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
_listing_request_cleanup(lreq);
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_ls_error_cb(void *data, Eio_File *handler, int error EINA_UNUSED)
|
2011-06-25 16:39:43 -07:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
Listing_Request *lreq = data;
|
2015-01-07 02:33:27 -08:00
|
|
|
ELM_FILESELECTOR_DATA_GET(lreq->obj, sd);
|
2011-06-25 16:39:43 -07:00
|
|
|
|
2015-01-07 02:33:27 -08:00
|
|
|
if (sd)
|
|
|
|
{
|
|
|
|
elm_progressbar_pulse(sd->spinner, EINA_FALSE);
|
|
|
|
elm_layout_signal_emit(lreq->obj, "elm,action,spinner,hide", "elm");
|
|
|
|
if (sd->current == handler) sd->current = NULL;
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
_listing_request_cleanup(lreq);
|
2011-06-25 16:39:43 -07:00
|
|
|
}
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
static void
|
2012-05-03 15:44:26 -07:00
|
|
|
_populate(Evas_Object *obj,
|
|
|
|
const char *path,
|
2013-09-10 02:47:30 -07:00
|
|
|
Elm_Object_Item *parent_it,
|
|
|
|
const char *selected)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
ELM_FILESELECTOR_DATA_GET(obj, sd);
|
2013-06-11 23:03:47 -07:00
|
|
|
if (!path) return;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
Listing_Request *lreq;
|
2009-08-12 15:43:50 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
if (sd->expand && sd->current) return;
|
|
|
|
|
2013-10-20 19:14:47 -07:00
|
|
|
if (sd->monitor) eio_monitor_del(sd->monitor);
|
2012-05-03 15:44:26 -07:00
|
|
|
if (sd->current) eio_file_cancel(sd->current);
|
2015-01-07 02:33:27 -08:00
|
|
|
sd->monitor = NULL;
|
|
|
|
sd->current = NULL;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
lreq = malloc(sizeof (Listing_Request));
|
|
|
|
if (!lreq) return;
|
|
|
|
|
|
|
|
lreq->parent_it = parent_it; /* FIXME: should we refcount the parent_it ? */
|
|
|
|
lreq->obj = obj;
|
|
|
|
lreq->path = eina_stringshare_add(path);
|
|
|
|
lreq->first = EINA_TRUE;
|
|
|
|
|
2013-09-10 02:47:30 -07:00
|
|
|
if (selected)
|
|
|
|
lreq->selected = eina_stringshare_add(selected);
|
|
|
|
else
|
|
|
|
lreq->selected = NULL;
|
|
|
|
|
2013-10-20 19:14:47 -07:00
|
|
|
/* TODO: sub directory should be monitored for expand mode */
|
|
|
|
sd->monitor = eio_monitor_add(path);
|
2012-05-03 15:44:26 -07:00
|
|
|
sd->current = eio_file_stat_ls(path, _ls_filter_cb, _ls_main_cb,
|
|
|
|
_ls_done_cb, _ls_error_cb, lreq);
|
2012-05-16 12:40:47 -07:00
|
|
|
elm_progressbar_pulse(sd->spinner, EINA_TRUE);
|
|
|
|
elm_layout_signal_emit(lreq->obj, "elm,action,spinner,show", "elm");
|
2014-10-05 16:08:24 -07:00
|
|
|
|
|
|
|
// Clear name entry not in case of save mode.
|
|
|
|
if (elm_object_disabled_get(sd->name_entry))
|
|
|
|
elm_object_text_set(sd->name_entry, "");
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_list_expanded(void *data, const Eo_Event *event)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Object_Item *it = event->info;
|
2012-05-03 15:44:26 -07:00
|
|
|
const char *path = elm_object_item_data_get(it);
|
|
|
|
|
2013-09-10 02:47:30 -07:00
|
|
|
_populate(data, path, it, NULL);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
2010-09-07 20:54:42 -07:00
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_list_contracted(void *data EINA_UNUSED, const Eo_Event *event)
|
2012-05-02 10:01:48 -07:00
|
|
|
{
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Object_Item *it = event->info;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
elm_genlist_item_subitems_clear(it);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_list_expand_req(void *data EINA_UNUSED, const Eo_Event *event)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Object_Item *it = event->info;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
elm_genlist_item_expanded_set(it, EINA_TRUE);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_list_contract_req(void *data EINA_UNUSED, const Eo_Event *event)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Object_Item *it = event->info;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
elm_genlist_item_expanded_set(it, EINA_FALSE);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-09-30 08:49:50 -07:00
|
|
|
_populate_do(void *data)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
|
|
|
struct sel_data *sdata = data;
|
|
|
|
ELM_FILESELECTOR_DATA_GET(sdata->fs, sd);
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
_populate(sdata->fs, sdata->path, NULL, sdata->selected);
|
|
|
|
eina_stringshare_del(sdata->path);
|
|
|
|
eina_stringshare_del(sdata->selected);
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2013-09-30 08:49:50 -07:00
|
|
|
sd->populate_idler = NULL;
|
2014-10-28 18:07:44 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
free(sdata);
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
static void
|
|
|
|
_schedule_populate(Evas_Object *fs,
|
|
|
|
Elm_Fileselector_Data *sd,
|
|
|
|
Eina_Stringshare *path,
|
|
|
|
Eina_Stringshare *selected)
|
|
|
|
{
|
|
|
|
struct sel_data *sdata;
|
|
|
|
sdata = malloc(sizeof(*sdata));
|
|
|
|
if (!sdata) return;
|
|
|
|
|
|
|
|
sdata->fs = fs;
|
|
|
|
sdata->path = path;
|
|
|
|
sdata->selected = selected;
|
|
|
|
|
|
|
|
if (sd->populate_idler)
|
|
|
|
{
|
|
|
|
struct sel_data *old_sdata;
|
|
|
|
old_sdata = ecore_idler_del(sd->populate_idler);
|
|
|
|
eina_stringshare_del(old_sdata->path);
|
|
|
|
eina_stringshare_del(old_sdata->selected);
|
|
|
|
free(old_sdata);
|
|
|
|
}
|
|
|
|
sd->populate_idler = ecore_idler_add(_populate_do, sdata);
|
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_item_activated(void *data, const Eo_Event *event)
|
2013-09-30 08:49:50 -07:00
|
|
|
{
|
|
|
|
//This event_info could be a list or gengrid item
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Object_Item *it = event->info;
|
2013-09-30 08:49:50 -07:00
|
|
|
const char *path;
|
|
|
|
Eina_Bool is_dir;
|
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
path = elm_object_item_data_get(it);
|
2015-05-10 07:49:01 -07:00
|
|
|
if (!path) return EINA_TRUE;
|
2013-09-30 08:49:50 -07:00
|
|
|
|
|
|
|
is_dir = ecore_file_is_dir(path);
|
2014-01-09 15:24:22 -08:00
|
|
|
if (!is_dir)
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(data, ELM_FILESELECTOR_EVENT_ACTIVATED, (void *)path);
|
2015-05-10 07:49:01 -07:00
|
|
|
return EINA_TRUE;
|
2014-01-09 15:24:22 -08:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
if (!sd->double_tap_navigation) return EINA_TRUE;
|
2013-09-30 08:49:50 -07:00
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
_schedule_populate(data, sd, eina_stringshare_add(path), NULL);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2013-09-30 08:49:50 -07:00
|
|
|
}
|
|
|
|
|
2013-10-16 19:04:57 -07:00
|
|
|
static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_clear_selections(Elm_Fileselector_Data *sd, Elm_Object_Item *last_selected)
|
2013-10-16 19:04:57 -07:00
|
|
|
{
|
|
|
|
Eina_List *items;
|
|
|
|
Elm_Object_Item *sel;
|
|
|
|
|
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
items = eina_list_clone(elm_genlist_selected_items_get(sd->files_view));
|
2013-10-16 19:04:57 -07:00
|
|
|
|
|
|
|
EINA_LIST_FREE(items, sel)
|
|
|
|
{
|
|
|
|
if (sel == last_selected) continue;
|
|
|
|
elm_genlist_item_selected_set(sel, EINA_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sd->mode == ELM_FILESELECTOR_GRID)
|
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
items = eina_list_clone(elm_gengrid_selected_items_get(sd->files_view));
|
2013-10-16 19:04:57 -07:00
|
|
|
|
|
|
|
EINA_LIST_FREE(items, sel)
|
|
|
|
{
|
|
|
|
if (sel == last_selected) continue;
|
|
|
|
elm_gengrid_item_selected_set(sel, EINA_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_item_selected(void *data, const Eo_Event *event)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
|
|
|
//This event_info could be a list or gengrid item
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Object_Item *it = event->info;
|
2013-07-17 10:48:07 -07:00
|
|
|
const char *path;
|
2013-09-30 08:49:50 -07:00
|
|
|
char *parent_path;
|
|
|
|
Eina_Bool is_dir;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(data, sd);
|
|
|
|
|
2013-07-17 10:48:07 -07:00
|
|
|
path = elm_object_item_data_get(it);
|
2015-05-10 07:49:01 -07:00
|
|
|
if (!path) return EINA_TRUE;
|
2013-07-17 10:48:07 -07:00
|
|
|
|
2013-09-30 08:49:50 -07:00
|
|
|
is_dir = ecore_file_is_dir(path);
|
|
|
|
|
|
|
|
/* We need to send callback when:
|
|
|
|
* - path is dir and mode is ONLY FOLDER
|
|
|
|
* - path is file and mode is NOT ONLY FOLDER */
|
|
|
|
if (is_dir == sd->only_folder)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2013-10-16 19:04:57 -07:00
|
|
|
if (sd->multi)
|
|
|
|
{
|
|
|
|
Eina_List *li;
|
|
|
|
const char *p;
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
|
|
|
|
if (sd->dir_selected)
|
|
|
|
{
|
|
|
|
_clear_selections(sd, it);
|
|
|
|
sd->dir_selected = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
EINA_LIST_FOREACH(sd->paths, li, p)
|
|
|
|
{
|
|
|
|
eina_strbuf_append(buf, ecore_file_file_get(p));
|
|
|
|
eina_strbuf_append_length(buf, ", ", 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
sd->paths = eina_list_append(sd->paths, strdup(path));
|
|
|
|
eina_strbuf_append(buf, ecore_file_file_get(path));
|
|
|
|
|
|
|
|
elm_object_text_set(sd->name_entry, eina_strbuf_string_get(buf));
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_object_text_set(sd->name_entry, ecore_file_file_get(path));
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(data, EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, (void *)path);
|
2013-09-30 08:49:50 -07:00
|
|
|
}
|
2014-10-05 16:08:24 -07:00
|
|
|
else if (sd->multi && is_dir && sd->double_tap_navigation)
|
2013-10-16 19:04:57 -07:00
|
|
|
{
|
2014-10-05 16:08:24 -07:00
|
|
|
_clear_selections(sd, it);
|
|
|
|
sd->dir_selected = EINA_TRUE;
|
2013-10-16 19:04:57 -07:00
|
|
|
}
|
2013-09-30 08:49:50 -07:00
|
|
|
|
|
|
|
/* We need to populate, if path is directory and:
|
|
|
|
* - mode is GRID;
|
|
|
|
* - mode is LIST and 'not expand mode';
|
|
|
|
* in other cases update anchors. */
|
2015-05-10 07:49:01 -07:00
|
|
|
if (!is_dir) return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2013-09-30 08:49:50 -07:00
|
|
|
if (sd->expand && sd->mode == ELM_FILESELECTOR_LIST)
|
|
|
|
{
|
|
|
|
if (sd->only_folder)
|
|
|
|
{
|
|
|
|
parent_path = ecore_file_dir_get(path);
|
|
|
|
eina_stringshare_replace(&sd->path, parent_path);
|
|
|
|
_anchors_do(data, parent_path);
|
|
|
|
free(parent_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&sd->path, path);
|
|
|
|
_anchors_do(data, path);
|
|
|
|
}
|
2015-05-10 07:49:01 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
if (sd->double_tap_navigation) return EINA_TRUE;
|
2013-09-30 08:49:50 -07:00
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
_schedule_populate(data, sd, eina_stringshare_add(path), NULL);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_item_unselected(void *data, const Eo_Event *event)
|
2013-10-16 19:04:57 -07:00
|
|
|
{
|
|
|
|
Eina_List *li, *l;
|
|
|
|
char *path;
|
|
|
|
const char *unselected_path;
|
|
|
|
Eina_Strbuf *buf;
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Object_Item *it = event->info;
|
2013-10-16 19:04:57 -07:00
|
|
|
Eina_Bool first = EINA_TRUE;
|
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(data, sd);
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
if (!sd->multi) return EINA_TRUE;
|
2013-10-16 19:04:57 -07:00
|
|
|
|
|
|
|
unselected_path = elm_object_item_data_get(it);
|
2015-05-10 07:49:01 -07:00
|
|
|
if (!unselected_path) return EINA_TRUE;
|
2013-10-16 19:04:57 -07:00
|
|
|
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
EINA_LIST_FOREACH_SAFE(sd->paths, li, l, path)
|
|
|
|
{
|
|
|
|
if (!strcmp(path, unselected_path))
|
|
|
|
{
|
|
|
|
sd->paths = eina_list_remove_list(sd->paths, li);
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
eina_strbuf_append_length(buf, ", ", 2);
|
|
|
|
else
|
|
|
|
first = EINA_FALSE;
|
|
|
|
|
|
|
|
eina_strbuf_append(buf, ecore_file_file_get(path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_object_text_set(sd->name_entry, eina_strbuf_string_get(buf));
|
|
|
|
eina_strbuf_free(buf);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2013-10-16 19:04:57 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_dir_up(void *data, const Eo_Event *event EINA_UNUSED)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
|
|
|
Evas_Object *fs = data;
|
|
|
|
char *parent;
|
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(fs, sd);
|
|
|
|
|
|
|
|
parent = ecore_file_dir_get(sd->path);
|
2013-09-10 02:47:30 -07:00
|
|
|
_populate(fs, parent, NULL, NULL);
|
2012-05-03 15:44:26 -07:00
|
|
|
free(parent);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_home(void *data, const Eo_Event *event EINA_UNUSED)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
|
|
|
Evas_Object *fs = data;
|
|
|
|
|
2015-07-22 04:01:12 -07:00
|
|
|
_populate(fs, eina_environment_home_get(), NULL, NULL);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2013-06-18 17:00:41 -07:00
|
|
|
static void
|
2013-12-26 04:08:33 -08:00
|
|
|
_current_filter_changed(void *data,
|
|
|
|
Evas_Object *obj,
|
2014-01-06 06:30:02 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2013-06-18 17:00:41 -07:00
|
|
|
{
|
|
|
|
Elm_Fileselector_Filter *filter = data;
|
|
|
|
|
|
|
|
if (filter->sd->current_filter == filter) return;
|
|
|
|
|
|
|
|
elm_object_text_set(obj, filter->filter_name);
|
|
|
|
filter->sd->current_filter = filter;
|
|
|
|
|
2013-09-10 02:47:30 -07:00
|
|
|
_populate(filter->sd->obj, filter->sd->path, NULL, NULL);
|
2013-06-18 17:00:41 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_ok(void *data, const Eo_Event *event EINA_UNUSED)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2013-09-25 07:43:22 -07:00
|
|
|
const char *name;
|
|
|
|
const char *selection = NULL;
|
2012-05-03 15:44:26 -07:00
|
|
|
Evas_Object *fs = data;
|
2013-09-25 07:43:22 -07:00
|
|
|
ELM_FILESELECTOR_DATA_GET(fs, sd);
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2013-09-25 07:43:22 -07:00
|
|
|
if (!sd->path)
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call(fs, ELM_FILESELECTOR_EVENT_DONE, NULL);
|
2015-05-10 07:49:01 -07:00
|
|
|
return EINA_TRUE;
|
2013-09-25 07:43:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
name = elm_object_text_get(sd->name_entry);
|
|
|
|
if (name && name[0] != '\0')
|
2014-01-29 06:08:55 -08:00
|
|
|
{
|
|
|
|
int len = eina_stringshare_strlen(sd->path);
|
|
|
|
if (sd->path[len - 1] == '/')
|
|
|
|
selection = eina_stringshare_printf("%s%s", sd->path, name);
|
|
|
|
else
|
|
|
|
selection = eina_stringshare_printf("%s/%s", sd->path, name);
|
|
|
|
}
|
2013-09-25 07:43:22 -07:00
|
|
|
else
|
|
|
|
selection = eina_stringshare_add(elm_fileselector_selected_get(fs));
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(fs, ELM_FILESELECTOR_EVENT_DONE, (void *)selection);
|
2013-09-25 07:43:22 -07:00
|
|
|
eina_stringshare_del(selection);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_canc(void *data, const Eo_Event *event EINA_UNUSED)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
|
|
|
Evas_Object *fs = data;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call(fs, ELM_FILESELECTOR_EVENT_DONE, NULL);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_text_activated(void *data, const Eo_Event *event)
|
2013-01-03 12:48:14 -08:00
|
|
|
{
|
|
|
|
Evas_Object *fs = data;
|
2013-09-10 02:47:30 -07:00
|
|
|
const char *p, *path;
|
|
|
|
char *dir;
|
2013-01-03 12:48:14 -08:00
|
|
|
|
2013-09-10 02:47:30 -07:00
|
|
|
ELM_FILESELECTOR_DATA_GET(fs, sd);
|
|
|
|
|
2016-05-18 08:17:36 -07:00
|
|
|
path = elm_widget_part_text_get(event->object, NULL);
|
2013-09-10 02:47:30 -07:00
|
|
|
|
2013-09-12 06:17:07 -07:00
|
|
|
if (!ecore_file_exists(path))
|
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(fs, EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, (void *)path);
|
|
|
|
eo_event_callback_call
|
|
|
|
(fs, ELM_FILESELECTOR_EVENT_SELECTED_INVALID, (void *)path);
|
2013-09-12 06:17:07 -07:00
|
|
|
goto end;
|
|
|
|
}
|
2013-09-10 02:47:30 -07:00
|
|
|
|
|
|
|
if (ecore_file_is_dir(path))
|
|
|
|
{
|
2016-03-04 15:32:22 -08:00
|
|
|
// keep previous path for backspace key action
|
|
|
|
eina_stringshare_replace(&sd->prev_path, sd->path);
|
2013-09-10 02:47:30 -07:00
|
|
|
// keep a ref to path 'couse it will be destroyed by _populate
|
|
|
|
p = eina_stringshare_add(path);
|
|
|
|
_populate(fs, p, NULL, NULL);
|
|
|
|
eina_stringshare_del(p);
|
2013-09-12 06:17:07 -07:00
|
|
|
|
|
|
|
if (sd->only_folder)
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(fs, EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, (void *)path);
|
2013-09-12 06:17:07 -07:00
|
|
|
|
2013-09-10 02:47:30 -07:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir = ecore_file_dir_get(path);
|
|
|
|
if (!dir) goto end;
|
|
|
|
|
|
|
|
if (strcmp(dir, sd->path))
|
2013-09-12 06:17:07 -07:00
|
|
|
{
|
|
|
|
_populate(fs, dir, NULL, path);
|
|
|
|
|
|
|
|
if (sd->only_folder)
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(fs, EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, (void *)path);
|
2013-09-12 06:17:07 -07:00
|
|
|
}
|
2013-01-03 12:48:14 -08:00
|
|
|
else
|
2013-09-10 02:47:30 -07:00
|
|
|
{
|
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
Elm_Object_Item *item = elm_genlist_first_item_get(sd->files_view);
|
2013-09-10 02:47:30 -07:00
|
|
|
while (item)
|
|
|
|
{
|
2014-09-14 04:51:26 -07:00
|
|
|
const char *item_path = WIDGET_ITEM_DATA_GET(item);
|
2013-09-11 01:07:10 -07:00
|
|
|
if (!strcmp(item_path, path))
|
|
|
|
{
|
|
|
|
elm_genlist_item_selected_set(item, EINA_TRUE);
|
2014-01-25 09:19:23 -08:00
|
|
|
elm_widget_part_text_set(sd->name_entry, NULL,
|
|
|
|
ecore_file_file_get(path));
|
2013-09-11 01:07:10 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
item = elm_genlist_item_next_get(item);
|
2013-09-10 02:47:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
Elm_Object_Item *item = elm_gengrid_first_item_get(sd->files_view);
|
2013-09-10 02:47:30 -07:00
|
|
|
while (item)
|
|
|
|
{
|
2013-09-11 01:07:10 -07:00
|
|
|
const char *item_path = elm_object_item_data_get(item);
|
|
|
|
if (!strcmp(item_path, path))
|
|
|
|
{
|
2013-09-10 02:47:30 -07:00
|
|
|
elm_gengrid_item_selected_set(item, EINA_TRUE);
|
2014-01-25 09:19:23 -08:00
|
|
|
elm_widget_part_text_set(sd->name_entry, NULL,
|
|
|
|
ecore_file_file_get(path));
|
2013-09-10 02:47:30 -07:00
|
|
|
break;
|
2013-09-11 01:07:10 -07:00
|
|
|
}
|
|
|
|
item = elm_gengrid_item_next_get(item);
|
2013-09-10 02:47:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(dir);
|
2013-01-03 12:48:14 -08:00
|
|
|
|
2013-09-10 02:47:30 -07:00
|
|
|
end:
|
2016-05-18 08:17:36 -07:00
|
|
|
elm_object_focus_set(event->object, EINA_FALSE);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2013-01-03 12:48:14 -08:00
|
|
|
}
|
|
|
|
|
2014-09-02 20:44:05 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_anchors_undo(void *data)
|
|
|
|
{
|
|
|
|
ELM_FILESELECTOR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
elm_entry_entry_set(sd->path_entry, sd->path);
|
|
|
|
elm_entry_cursor_pos_set(sd->path_entry, eina_stringshare_strlen(sd->path));
|
|
|
|
|
|
|
|
sd->path_entry_idler = NULL;
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_text_focused(void *data, const Eo_Event *event EINA_UNUSED)
|
2014-09-02 20:44:05 -07:00
|
|
|
{
|
|
|
|
ELM_FILESELECTOR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (!sd->path_entry_idler)
|
|
|
|
sd->path_entry_idler = ecore_idler_add(_anchors_undo, data);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2014-09-02 20:44:05 -07:00
|
|
|
}
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_on_text_unfocused(void *data, const Eo_Event *event EINA_UNUSED)
|
2013-01-03 12:48:14 -08:00
|
|
|
{
|
2013-07-18 07:46:56 -07:00
|
|
|
ELM_FILESELECTOR_DATA_GET(data, sd);
|
|
|
|
_anchors_do(data, sd->path);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2013-01-03 12:48:14 -08:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_anchor_clicked(void *data, const Eo_Event *event)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2016-04-12 07:23:55 -07:00
|
|
|
Elm_Entry_Anchor_Info *info = event->info;
|
2012-05-03 15:44:26 -07:00
|
|
|
Evas_Object *fs = data;
|
|
|
|
const char *p;
|
|
|
|
|
2014-09-02 20:44:05 -07:00
|
|
|
ELM_FILESELECTOR_DATA_GET(fs, sd);
|
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
// keep a ref to path 'couse it will be destroyed by _populate
|
|
|
|
p = eina_stringshare_add(info->name);
|
2013-09-10 02:47:30 -07:00
|
|
|
_populate(fs, p, NULL, NULL);
|
2012-05-03 15:44:26 -07:00
|
|
|
eina_stringshare_del(p);
|
2013-07-23 03:34:34 -07:00
|
|
|
/* After anchor was clicked, entry will be focused, and will be editable.
|
|
|
|
* It's wrong. So remove focus. */
|
2016-05-18 08:17:36 -07:00
|
|
|
elm_object_focus_set(event->object, EINA_FALSE);
|
2014-09-02 20:44:05 -07:00
|
|
|
|
|
|
|
if (sd->path_entry_idler) {
|
|
|
|
ecore_idler_del(sd->path_entry_idler);
|
|
|
|
sd->path_entry_idler = NULL;
|
|
|
|
}
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_files_key_down(void *data, const Eo_Event *event)
|
2015-01-06 22:17:46 -08:00
|
|
|
{
|
2016-04-12 07:23:55 -07:00
|
|
|
Evas_Event_Key_Down *ev = event->info;
|
2015-01-06 22:17:46 -08:00
|
|
|
Evas_Object *par, *searchbar;
|
|
|
|
|
|
|
|
par = data;
|
|
|
|
searchbar = evas_object_data_get(par, "search");
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
if (!searchbar) return EINA_TRUE;
|
2015-01-06 22:17:46 -08:00
|
|
|
|
|
|
|
if (((ev->string) && *(ev->string) &&
|
|
|
|
(isalpha(*ev->string) ||
|
|
|
|
isdigit(*ev->string))))
|
|
|
|
{
|
|
|
|
|
|
|
|
elm_entry_entry_append(searchbar, ev->string);
|
2016-03-29 07:43:07 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2015-01-06 22:17:46 -08:00
|
|
|
}
|
|
|
|
else if (ev->string &&
|
|
|
|
*(ev->string) &&
|
|
|
|
!strcmp(ev->key, "BackSpace"))
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
const char *en;
|
|
|
|
en = elm_entry_entry_get(searchbar);
|
|
|
|
if (strlen(en) > 0)
|
|
|
|
{
|
|
|
|
memmove(buf, en, strlen(en) -1);
|
|
|
|
buf[strlen(en) -1] = '\0';
|
|
|
|
elm_entry_entry_set(searchbar, buf);
|
2016-03-29 07:43:07 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2015-01-06 22:17:46 -08:00
|
|
|
}
|
|
|
|
}
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2015-01-06 22:17:46 -08:00
|
|
|
}
|
|
|
|
|
2013-10-17 22:25:20 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_files_list_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *li;
|
|
|
|
|
|
|
|
li = elm_genlist_add(obj);
|
2013-12-03 01:28:52 -08:00
|
|
|
evas_object_data_set(li, "parent", obj);
|
2013-10-17 22:25:20 -07:00
|
|
|
elm_widget_mirrored_automatic_set(li, EINA_FALSE);
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_add
|
|
|
|
(li, EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, _on_item_selected, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(li, EVAS_SELECTABLE_INTERFACE_EVENT_UNSELECTED, _on_item_unselected, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(li, ELM_GENLIST_EVENT_ACTIVATED, _on_item_activated, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(li, ELM_GENLIST_EVENT_EXPAND_REQUEST, _on_list_expand_req, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(li, ELM_GENLIST_EVENT_CONTRACT_REQUEST, _on_list_contract_req, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(li, ELM_GENLIST_EVENT_EXPANDED, _on_list_expanded, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(li, ELM_GENLIST_EVENT_CONTRACTED, _on_list_contracted, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(li, EVAS_OBJECT_EVENT_KEY_DOWN, _files_key_down, obj);
|
2013-10-17 22:25:20 -07:00
|
|
|
|
|
|
|
return li;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_files_grid_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *grid;
|
2013-12-03 01:28:52 -08:00
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(obj, sd);
|
2013-10-17 22:25:20 -07:00
|
|
|
|
|
|
|
grid = elm_gengrid_add(obj);
|
2013-12-03 01:28:52 -08:00
|
|
|
evas_object_data_set(grid, "parent", obj);
|
2013-10-17 22:25:20 -07:00
|
|
|
elm_widget_mirrored_automatic_set(grid, EINA_FALSE);
|
|
|
|
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);
|
|
|
|
|
2013-12-03 01:28:52 -08:00
|
|
|
elm_gengrid_item_size_set(grid, sd->thumbnail_size.w + GENGRID_PADDING, sd->thumbnail_size.h + GENGRID_PADDING);
|
|
|
|
|
2013-10-17 22:25:20 -07:00
|
|
|
elm_gengrid_align_set(grid, 0.0, 0.0);
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_add
|
|
|
|
(grid, EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, _on_item_selected, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(grid, EVAS_SELECTABLE_INTERFACE_EVENT_UNSELECTED, _on_item_unselected, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(grid, ELM_GENGRID_EVENT_ACTIVATED, _on_item_activated, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(grid, EVAS_OBJECT_EVENT_KEY_DOWN, _files_key_down, obj);
|
2013-10-17 22:25:20 -07:00
|
|
|
|
|
|
|
return grid;
|
|
|
|
}
|
|
|
|
|
2013-10-20 19:14:47 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_resource_created(void *data, int type, void *ev)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Eio_Monitor_Event *event = ev;
|
|
|
|
int itcn = ELM_FILE_UNKNOW;
|
2013-12-28 20:23:17 -08:00
|
|
|
Eina_Bool dir = EINA_FALSE;
|
2013-10-20 19:14:47 -07:00
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (type == EIO_MONITOR_DIRECTORY_CREATED)
|
2013-12-28 20:23:17 -08:00
|
|
|
dir = EINA_TRUE;
|
|
|
|
|
|
|
|
Elm_Fileselector_Filter *cf = sd->current_filter;
|
|
|
|
if (cf)
|
|
|
|
{
|
|
|
|
switch (cf->filter_type)
|
|
|
|
{
|
|
|
|
case ELM_FILESELECTOR_MIME_FILTER:
|
|
|
|
if (!dir && !_check_mime_type_filter(cf, event->filename))
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_CUSTOM_FILTER:
|
|
|
|
if (!cf->filter.custom->func(event->filename, dir, cf->filter.custom->data))
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir)
|
2013-10-20 19:14:47 -07:00
|
|
|
itcn = ELM_DIRECTORY;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (evas_object_image_extension_can_load_get(event->filename))
|
|
|
|
itcn = ELM_FILE_IMAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
|
|
|
elm_genlist_item_sorted_insert(sd->files_view, list_itc[itcn],
|
|
|
|
eina_stringshare_add(event->filename),
|
|
|
|
NULL,
|
|
|
|
(sd->expand && itcn == ELM_DIRECTORY)
|
|
|
|
? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
|
|
|
|
_file_list_cmp, NULL, NULL);
|
|
|
|
else
|
|
|
|
elm_gengrid_item_sorted_insert(sd->files_view, grid_itc[itcn],
|
|
|
|
eina_stringshare_add(event->filename),
|
|
|
|
_file_grid_cmp, NULL, NULL);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_resource_deleted(void *data, int type EINA_UNUSED, void *ev)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = data;
|
|
|
|
Eio_Monitor_Event *event = ev;
|
|
|
|
Elm_Object_Item *it = NULL;
|
|
|
|
Eina_Bool selected = EINA_FALSE;
|
|
|
|
|
|
|
|
ELM_FILESELECTOR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
|
|
|
{
|
|
|
|
it = elm_genlist_first_item_get(sd->files_view);
|
2014-05-10 07:15:54 -07:00
|
|
|
while (it)
|
2013-10-20 19:14:47 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(elm_object_item_data_get(it), event->filename))
|
|
|
|
{
|
|
|
|
selected = elm_genlist_item_selected_get(it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
it = elm_genlist_item_next_get(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
it = elm_gengrid_first_item_get(sd->files_view);
|
2014-05-10 07:15:54 -07:00
|
|
|
while (it)
|
2013-10-20 19:14:47 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(elm_object_item_data_get(it), event->filename))
|
|
|
|
{
|
|
|
|
selected = elm_genlist_item_selected_get(it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
it = elm_gengrid_item_next_get(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
if (it) elm_wdg_item_del(it);
|
2013-10-20 19:14:47 -07:00
|
|
|
|
|
|
|
if (selected)
|
|
|
|
{
|
|
|
|
if (sd->multi)
|
|
|
|
{
|
|
|
|
Eina_List *li, *l;
|
|
|
|
char *path;
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
Eina_Bool first = EINA_TRUE;
|
|
|
|
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
EINA_LIST_FOREACH_SAFE(sd->paths, li, l, path)
|
|
|
|
{
|
|
|
|
if (!strcmp(path, event->filename))
|
|
|
|
{
|
|
|
|
sd->paths = eina_list_remove_list(sd->paths, li);
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
eina_strbuf_append_length(buf, ", ", 2);
|
|
|
|
else
|
|
|
|
first = EINA_FALSE;
|
|
|
|
|
|
|
|
eina_strbuf_append(buf, ecore_file_file_get(path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_object_text_set(sd->name_entry, eina_strbuf_string_get(buf));
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_object_text_set(sd->name_entry, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2015-05-10 07:49:01 -07:00
|
|
|
static Eina_Bool
|
2016-02-29 03:32:52 -08:00
|
|
|
_preedit_cb(void *data, const Eo_Event *event)
|
2014-06-10 02:50:01 -07:00
|
|
|
{
|
|
|
|
ELM_FILESELECTOR_DATA_GET(data, sd);
|
|
|
|
|
2016-05-18 08:17:36 -07:00
|
|
|
sd->search_string = elm_entry_entry_get(event->object);
|
2014-06-10 02:50:01 -07:00
|
|
|
|
|
|
|
if (sd->search_string && sd->path)
|
|
|
|
_populate(data, sd->path, NULL, NULL);
|
2015-05-10 07:49:01 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2014-06-10 02:50:01 -07:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_fileselector_evas_object_smart_add(Eo *obj, Elm_Fileselector_Data *priv)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
Evas_Object *ic, *bt, *en, *pb;
|
2016-03-04 15:39:29 -08:00
|
|
|
const char *data;
|
|
|
|
char buf[1024];
|
2011-04-01 04:51:11 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
evas_obj_smart_add(eo_super(obj, MY_CLASS));
|
2013-09-24 21:33:39 -07:00
|
|
|
elm_widget_sub_object_parent_add(obj);
|
2014-01-21 22:53:49 -08:00
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
priv->expand = !!_elm_config->fileselector_expand_enable;
|
2013-09-30 08:49:50 -07:00
|
|
|
priv->double_tap_navigation = !!_elm_config->fileselector_double_tap_navigation_enable;
|
2011-04-01 04:51:11 -07:00
|
|
|
|
2013-03-01 18:04:31 -08:00
|
|
|
if (!elm_layout_theme_set
|
|
|
|
(obj, "fileselector", "base", elm_widget_style_get(obj)))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2009-10-22 15:10:23 -07:00
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
data = edje_object_data_get
|
|
|
|
(wd->resize_obj, "path_separator");
|
|
|
|
if (data) priv->path_separator = data;
|
|
|
|
else priv->path_separator = "/";
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "fileselector/%s", elm_widget_style_get(obj));
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
// up btn
|
2012-05-03 15:44:26 -07:00
|
|
|
ic = elm_icon_add(obj);
|
2016-04-26 16:01:08 -07:00
|
|
|
elm_icon_standard_set(ic, "go-up");
|
2012-05-03 15:44:26 -07:00
|
|
|
bt = elm_button_add(obj);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
|
2011-11-17 13:02:31 -08:00
|
|
|
elm_object_part_content_set(bt, "icon", ic);
|
2011-10-19 07:17:14 -07:00
|
|
|
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Up"));
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_add
|
|
|
|
(bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_dir_up, obj);
|
2012-05-02 10:01:48 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
priv->up_button = bt;
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_object_style_set(priv->up_button, buf);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.up", priv->up_button);
|
2009-10-22 15:10:23 -07:00
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
// home btn
|
2012-05-03 15:44:26 -07:00
|
|
|
ic = elm_icon_add(obj);
|
2016-04-26 16:01:08 -07:00
|
|
|
elm_icon_standard_set(ic, "go-home");
|
2012-05-03 15:44:26 -07:00
|
|
|
bt = elm_button_add(obj);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
|
2011-11-17 13:02:31 -08:00
|
|
|
elm_object_part_content_set(bt, "icon", ic);
|
2011-10-19 07:17:14 -07:00
|
|
|
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Home"));
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_add
|
|
|
|
(bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _home, obj);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
priv->home_button = bt;
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_object_style_set(priv->home_button, buf);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.home", priv->home_button);
|
|
|
|
|
|
|
|
// search entry
|
|
|
|
ic = elm_icon_add(obj);
|
2016-04-26 16:01:08 -07:00
|
|
|
elm_icon_standard_set(ic, "edit-find");
|
2016-03-04 15:39:29 -08:00
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
|
|
en = elm_entry_add(obj);
|
|
|
|
elm_entry_scrollable_set(en, EINA_TRUE);
|
|
|
|
elm_widget_mirrored_automatic_set(en, EINA_FALSE);
|
|
|
|
elm_entry_editable_set(en, EINA_TRUE);
|
|
|
|
elm_entry_single_line_set(en, EINA_TRUE);
|
|
|
|
elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
|
|
|
|
elm_object_domain_translatable_part_text_set(en, "guide",
|
|
|
|
PACKAGE, N_("Search"));
|
|
|
|
elm_object_part_content_set(en, "icon", ic);
|
|
|
|
elm_entry_icon_visible_set(en, EINA_TRUE);
|
|
|
|
eo_event_callback_add
|
|
|
|
(en, ELM_ENTRY_EVENT_CHANGED, _preedit_cb, obj);
|
|
|
|
evas_object_data_set(obj, "search", en);
|
|
|
|
|
|
|
|
priv->search_entry = en;
|
|
|
|
elm_object_style_set(priv->search_entry, buf);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.search", priv->search_entry);
|
2009-08-12 09:08:53 -07:00
|
|
|
|
2012-05-16 12:40:47 -07:00
|
|
|
// spinner
|
|
|
|
pb = elm_progressbar_add(obj);
|
|
|
|
priv->spinner = pb;
|
2016-03-29 07:45:12 -07:00
|
|
|
elm_progressbar_pulse_set(priv->spinner, EINA_TRUE);
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_object_style_set(priv->spinner, "wheel");
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.spinner", priv->spinner);
|
2012-05-16 12:40:47 -07:00
|
|
|
|
2013-12-03 01:28:52 -08:00
|
|
|
// XXX: will fail for dynamic finger size changing
|
|
|
|
priv->thumbnail_size.w = elm_config_finger_size_get() * 2 - GENGRID_PADDING;
|
|
|
|
priv->thumbnail_size.h = priv->thumbnail_size.w;
|
|
|
|
|
2013-12-18 03:05:35 -08:00
|
|
|
priv->sort_type = ELM_FILESELECTOR_SORT_BY_FILENAME_ASC;
|
|
|
|
priv->sort_method = strcoll;
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
// path entry
|
2012-05-03 15:44:26 -07:00
|
|
|
en = elm_entry_add(obj);
|
2011-06-17 02:44:31 -07:00
|
|
|
elm_entry_scrollable_set(en, EINA_TRUE);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(en, EINA_FALSE);
|
2011-06-17 02:44:31 -07:00
|
|
|
elm_entry_single_line_set(en, EINA_TRUE);
|
|
|
|
elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_add
|
|
|
|
(en, ELM_ENTRY_EVENT_ANCHOR_CLICKED, _anchor_clicked, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(en, ELM_WIDGET_EVENT_FOCUSED, _on_text_focused, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(en, ELM_WIDGET_EVENT_UNFOCUSED, _on_text_unfocused, obj);
|
|
|
|
eo_event_callback_add
|
|
|
|
(en, ELM_ENTRY_EVENT_ACTIVATED, _on_text_activated, obj);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
priv->path_entry = en;
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_object_style_set(priv->path_entry, buf);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.path", priv->path_entry);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2013-09-25 07:43:22 -07:00
|
|
|
// name entry
|
|
|
|
en = elm_entry_add(obj);
|
|
|
|
elm_entry_scrollable_set(en, EINA_TRUE);
|
|
|
|
elm_widget_mirrored_automatic_set(en, EINA_FALSE);
|
|
|
|
elm_entry_editable_set(en, EINA_TRUE);
|
|
|
|
elm_entry_single_line_set(en, EINA_TRUE);
|
|
|
|
elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
|
|
|
|
|
|
|
|
priv->name_entry = en;
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_object_style_set(priv->name_entry, buf);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.filename", priv->name_entry);
|
2013-09-25 07:43:22 -07:00
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
// ok cancel button
|
2010-11-22 11:24:48 -08:00
|
|
|
elm_fileselector_buttons_ok_cancel_set(obj, EINA_TRUE);
|
|
|
|
elm_fileselector_is_save_set(obj, EINA_FALSE);
|
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
// files_view
|
|
|
|
priv->files_view = _files_list_add(obj);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.files", priv->files_view);
|
|
|
|
|
2013-10-20 19:14:47 -07:00
|
|
|
#define HANDLER_ADD(e, fn) \
|
|
|
|
priv->handlers = eina_list_append(priv->handlers, \
|
|
|
|
ecore_event_handler_add(e, fn, obj));
|
|
|
|
|
|
|
|
HANDLER_ADD(EIO_MONITOR_FILE_CREATED, _resource_created);
|
|
|
|
HANDLER_ADD(EIO_MONITOR_DIRECTORY_CREATED, _resource_created);
|
|
|
|
|
|
|
|
HANDLER_ADD(EIO_MONITOR_FILE_DELETED, _resource_deleted);
|
|
|
|
HANDLER_ADD(EIO_MONITOR_DIRECTORY_DELETED, _resource_deleted);
|
|
|
|
#undef HANDLER_ADD
|
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_obj_layout_sizing_eval(obj);
|
2012-05-03 15:44:26 -07:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_fileselector_evas_object_smart_del(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2012-05-03 15:44:26 -07:00
|
|
|
{
|
2013-06-18 17:00:41 -07:00
|
|
|
Elm_Fileselector_Filter *filter;
|
2013-10-16 19:04:57 -07:00
|
|
|
char *path;
|
2013-10-20 19:14:47 -07:00
|
|
|
Ecore_Event_Handler *h;
|
|
|
|
|
|
|
|
if (sd->monitor) eio_monitor_del(sd->monitor);
|
2012-05-03 15:44:26 -07:00
|
|
|
if (sd->current) eio_file_cancel(sd->current);
|
2015-01-07 02:33:27 -08:00
|
|
|
sd->monitor = NULL;
|
|
|
|
sd->current = NULL;
|
2013-10-20 19:14:47 -07:00
|
|
|
|
|
|
|
EINA_LIST_FREE(sd->handlers, h)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(h);
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2013-06-18 17:00:41 -07:00
|
|
|
EINA_LIST_FREE(sd->filter_list, filter)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(filter->filter_name);
|
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
if (filter->filter_type == ELM_FILESELECTOR_MIME_FILTER)
|
|
|
|
{
|
|
|
|
free(filter->filter.mime_types[0]);
|
|
|
|
free(filter->filter.mime_types);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
free(filter->filter.custom);
|
2013-06-18 17:00:41 -07:00
|
|
|
|
|
|
|
free(filter);
|
|
|
|
}
|
|
|
|
|
2013-10-16 19:04:57 -07:00
|
|
|
EINA_LIST_FREE(sd->paths, path)
|
|
|
|
free(path);
|
|
|
|
|
2013-10-17 22:25:20 -07:00
|
|
|
sd->files_view = NULL;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
|
|
|
/* this one matching EINA_REFCOUNT_INIT() */
|
|
|
|
EINA_REFCOUNT_UNREF(sd) _elm_fileselector_smart_del_do(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_fileselector_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2016-03-11 04:34:16 -08:00
|
|
|
Evas_Object *obj = eo_add(MY_CLASS, parent);
|
2012-11-25 22:32:53 -08:00
|
|
|
return obj;
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_eo_base_constructor(Eo *obj, Elm_Fileselector_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
obj = eo_constructor(eo_super(obj, MY_CLASS));
|
2012-11-25 22:32:53 -08:00
|
|
|
sd->obj = obj;
|
2016-03-02 04:10:48 -08:00
|
|
|
evas_obj_type_set(obj, MY_CLASS_NAME_LEGACY);
|
|
|
|
evas_obj_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
|
|
|
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILE_CHOOSER);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
EAPI void
|
2010-12-07 11:18:14 -08:00
|
|
|
elm_fileselector_is_save_set(Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
Eina_Bool is_save)
|
2009-09-06 17:00:33 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_is_save_set(obj, is_save);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_is_save_set(Eo *obj, Elm_Fileselector_Data *sd, Eina_Bool is_save)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-09-25 07:43:22 -07:00
|
|
|
elm_object_disabled_set(sd->name_entry, !is_save);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
if (is_save) elm_layout_signal_emit(obj, "elm,state,save,on", "elm");
|
|
|
|
else elm_layout_signal_emit(obj, "elm,state,save,off", "elm");
|
2009-09-06 17:00:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_fileselector_is_save_get(const Evas_Object *obj)
|
2009-09-06 17:00:33 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, EINA_FALSE);
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_is_save_get((Eo *) obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_is_save_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return !elm_object_disabled_get(sd->name_entry);
|
2009-09-06 17:00:33 -07:00
|
|
|
}
|
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
EAPI void
|
2010-12-07 11:18:14 -08:00
|
|
|
elm_fileselector_folder_only_set(Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
Eina_Bool only)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_folder_only_set(obj, only);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_folder_only_set(Eo *obj, Elm_Fileselector_Data *sd, Eina_Bool only)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
if (sd->only_folder == only) return;
|
|
|
|
|
|
|
|
sd->only_folder = !!only;
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2009-10-22 15:10:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2010-03-31 13:19:55 -07:00
|
|
|
elm_fileselector_folder_only_get(const Evas_Object *obj)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, EINA_FALSE);
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_folder_only_get((Eo *) obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_folder_only_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->only_folder;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_buttons_ok_cancel_set(Eo *obj, Elm_Fileselector_Data *sd, Eina_Bool visible)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2010-11-25 02:01:39 -08:00
|
|
|
Evas_Object *bt;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2016-03-04 15:39:29 -08:00
|
|
|
visible = !!visible;
|
|
|
|
|
2016-03-07 02:26:15 -08:00
|
|
|
if (!visible == !sd->ok_button) return;
|
2016-03-04 15:39:29 -08:00
|
|
|
|
|
|
|
if (visible)
|
2010-11-22 11:24:48 -08:00
|
|
|
{
|
2010-03-09 19:47:33 -08:00
|
|
|
// cancel btn
|
|
|
|
bt = elm_button_add(obj);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
|
2011-10-19 07:17:14 -07:00
|
|
|
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Cancel"));
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_add
|
|
|
|
(bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _canc, obj);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
sd->cancel_button = bt;
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_object_part_content_set(obj, "elm.swallow.cancel", sd->cancel_button);
|
2010-03-31 13:19:55 -07:00
|
|
|
|
2010-03-09 19:47:33 -08:00
|
|
|
// ok btn
|
|
|
|
bt = elm_button_add(obj);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
|
2011-10-19 07:17:14 -07:00
|
|
|
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("OK"));
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_add
|
|
|
|
(bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _ok, obj);
|
2010-11-22 11:24:48 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
sd->ok_button = bt;
|
2016-03-04 15:39:29 -08:00
|
|
|
elm_object_part_content_set(obj, "elm.swallow.ok", sd->ok_button);
|
2009-10-22 15:10:23 -07:00
|
|
|
}
|
2016-03-04 15:39:29 -08:00
|
|
|
else
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
2014-01-21 17:38:55 -08:00
|
|
|
ELM_SAFE_FREE(sd->cancel_button, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->ok_button, evas_object_del);
|
2009-10-22 15:10:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_buttons_ok_cancel_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2009-10-22 15:10:23 -07:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->ok_button ? EINA_TRUE : EINA_FALSE;
|
2009-10-22 15:10:23 -07:00
|
|
|
}
|
|
|
|
|
2009-08-12 09:08:53 -07:00
|
|
|
EAPI void
|
2010-12-07 11:18:14 -08:00
|
|
|
elm_fileselector_expandable_set(Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
Eina_Bool expand)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_expandable_set(obj, expand);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_expandable_set(Eo *obj, Elm_Fileselector_Data *sd, Eina_Bool expand)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-05-03 15:44:26 -07:00
|
|
|
sd->expand = !!expand;
|
2010-04-09 10:52:55 -07:00
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
|
|
|
|
2010-03-31 13:19:55 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_fileselector_expandable_get(const Evas_Object *obj)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, EINA_FALSE);
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_expandable_get((Eo *) obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_expandable_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->expand;
|
2010-03-31 13:19:55 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 17:00:33 -07:00
|
|
|
EAPI void
|
2010-12-07 11:18:14 -08:00
|
|
|
elm_fileselector_path_set(Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
const char *_path)
|
2009-09-06 17:00:33 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_path_set(obj, _path);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-10-28 18:07:44 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_path_set(Eo *obj, Elm_Fileselector_Data *sd, const char *_path)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
|
|
|
char *path;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2012-02-20 01:22:23 -08:00
|
|
|
path = ecore_file_realpath(_path);
|
2014-10-28 18:07:44 -07:00
|
|
|
_schedule_populate(obj, sd, eina_stringshare_add(path), NULL);
|
2012-02-20 01:22:23 -08:00
|
|
|
free(path);
|
2009-09-06 17:00:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_fileselector_path_get(const Evas_Object *obj)
|
2009-09-06 17:00:33 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, NULL);
|
2012-11-25 22:32:53 -08:00
|
|
|
const char *ret = NULL;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_path_get((Eo *) obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static const char*
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_path_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->path;
|
2009-09-06 17:00:33 -07:00
|
|
|
}
|
|
|
|
|
2010-12-10 05:01:51 -08:00
|
|
|
EAPI void
|
2012-05-03 15:44:26 -07:00
|
|
|
elm_fileselector_mode_set(Evas_Object *obj,
|
2010-12-10 05:01:51 -08:00
|
|
|
Elm_Fileselector_Mode mode)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_mode_set(obj, mode);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_mode_set(Eo *obj, Elm_Fileselector_Data *sd, Elm_Fileselector_Mode mode)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
Evas_Object *old;
|
2012-05-02 10:01:48 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
if (mode == sd->mode) return;
|
2010-12-10 05:01:51 -08:00
|
|
|
|
2013-10-17 22:25:20 -07:00
|
|
|
old = elm_layout_content_unset(obj, "elm.swallow.files");
|
2010-12-10 05:01:51 -08:00
|
|
|
|
|
|
|
if (mode == ELM_FILESELECTOR_LIST)
|
2013-10-17 22:25:20 -07:00
|
|
|
{
|
|
|
|
sd->files_view = _files_list_add(obj);
|
|
|
|
if (sd->multi)
|
|
|
|
elm_genlist_multi_select_set(sd->files_view, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->files_view = _files_grid_add(obj);
|
|
|
|
if (sd->multi)
|
|
|
|
elm_gengrid_multi_select_set(sd->files_view, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_layout_content_set(obj, "elm.swallow.files", sd->files_view);
|
|
|
|
|
|
|
|
evas_object_del(old);
|
2010-12-10 05:01:51 -08:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
sd->mode = mode;
|
2010-12-10 05:01:51 -08:00
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2010-12-10 05:01:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Fileselector_Mode
|
|
|
|
elm_fileselector_mode_get(const Evas_Object *obj)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, ELM_FILESELECTOR_LAST);
|
2012-11-25 22:32:53 -08:00
|
|
|
Elm_Fileselector_Mode ret = ELM_FILESELECTOR_LAST;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_mode_get((Eo *) obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Elm_Fileselector_Mode
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_mode_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->mode;
|
2010-12-10 05:01:51 -08:00
|
|
|
}
|
|
|
|
|
2013-10-16 19:04:57 -07:00
|
|
|
EAPI void
|
|
|
|
elm_fileselector_multi_select_set(Evas_Object *obj, Eina_Bool multi)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_multi_select_set(obj, multi);
|
2013-10-16 19:04:57 -07:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_multi_select_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, Eina_Bool multi)
|
2013-10-16 19:04:57 -07:00
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
multi = !!multi;
|
|
|
|
if (sd->multi == multi) return;
|
|
|
|
sd->multi = multi;
|
|
|
|
|
2013-10-17 22:25:20 -07:00
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
|
|
|
elm_genlist_multi_select_set(sd->files_view, multi);
|
|
|
|
else
|
|
|
|
elm_gengrid_multi_select_set(sd->files_view, multi);
|
2013-10-16 19:04:57 -07:00
|
|
|
|
|
|
|
if (!sd->multi)
|
|
|
|
{
|
|
|
|
_clear_selections(sd, NULL);
|
|
|
|
|
|
|
|
EINA_LIST_FREE(sd->paths, path)
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const Eina_List *selected_items, *li;
|
|
|
|
const Elm_Object_Item *it;
|
|
|
|
|
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
2013-10-17 22:25:20 -07:00
|
|
|
selected_items = elm_genlist_selected_items_get(sd->files_view);
|
2013-10-16 19:04:57 -07:00
|
|
|
else
|
2013-10-17 22:25:20 -07:00
|
|
|
selected_items = elm_gengrid_selected_items_get(sd->files_view);
|
2013-10-16 19:04:57 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(selected_items, li, it)
|
|
|
|
{
|
|
|
|
path = elm_object_item_data_get(it);
|
|
|
|
sd->paths = eina_list_append(sd->paths, strdup(path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_fileselector_multi_select_get(const Evas_Object *obj)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, EINA_FALSE);
|
2013-10-16 19:04:57 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_multi_select_get((Eo *) obj);
|
2013-10-16 19:04:57 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_multi_select_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2013-10-16 19:04:57 -07:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->multi;
|
2013-10-16 19:04:57 -07:00
|
|
|
}
|
|
|
|
|
2010-03-09 19:47:33 -08:00
|
|
|
EAPI const char *
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_fileselector_selected_get(const Evas_Object *obj)
|
2009-08-12 09:08:53 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, NULL);
|
2012-11-25 22:32:53 -08:00
|
|
|
const char *ret = NULL;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_selected_get((Eo *) obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static const char*
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_selected_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-01-03 12:48:14 -08:00
|
|
|
const char *fp;
|
2014-03-30 00:15:55 -07:00
|
|
|
if (!sd->path) return NULL;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2013-01-03 12:48:14 -08:00
|
|
|
fp = elm_object_text_get(sd->path_entry);
|
|
|
|
if (ecore_file_exists(fp))
|
2009-09-06 17:00:33 -07:00
|
|
|
{
|
2013-08-21 13:18:09 -07:00
|
|
|
eina_stringshare_replace(&sd->selection, fp);
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->selection;
|
2009-09-06 17:00:33 -07:00
|
|
|
}
|
2010-03-31 13:19:55 -07:00
|
|
|
|
2012-05-03 15:44:26 -07:00
|
|
|
if (sd->mode == ELM_FILESELECTOR_LIST)
|
2010-12-10 05:01:51 -08:00
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
Elm_Object_Item *gl_it = elm_genlist_selected_item_get(sd->files_view);
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
if (gl_it) return elm_object_item_data_get(gl_it);
|
2010-12-10 05:01:51 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-17 22:25:20 -07:00
|
|
|
Elm_Object_Item *gg_it = elm_gengrid_selected_item_get(sd->files_view);
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
if (gg_it) return elm_object_item_data_get(gg_it);
|
2010-12-10 05:01:51 -08:00
|
|
|
}
|
2010-03-31 13:19:55 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
|
|
|
|
return sd->path;
|
2009-08-12 09:08:53 -07:00
|
|
|
}
|
2010-04-08 13:36:37 -07:00
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2010-12-07 11:18:14 -08:00
|
|
|
elm_fileselector_selected_set(Evas_Object *obj,
|
2012-05-03 15:44:26 -07:00
|
|
|
const char *_path)
|
2010-04-08 13:36:37 -07:00
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, EINA_FALSE);
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_selected_set(obj, _path);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_selected_set(Eo *obj, Elm_Fileselector_Data *sd, const char *_path)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
Eina_Bool ret = EINA_TRUE;
|
2014-08-03 07:56:43 -07:00
|
|
|
char *dir;
|
2012-02-20 01:22:23 -08:00
|
|
|
char *path;
|
2012-05-03 15:44:26 -07:00
|
|
|
|
2012-02-20 01:22:23 -08:00
|
|
|
path = ecore_file_realpath(_path);
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (ecore_file_is_dir(path))
|
|
|
|
_schedule_populate(obj, sd, eina_stringshare_add(path), NULL);
|
2010-04-08 13:36:37 -07:00
|
|
|
else
|
|
|
|
{
|
2010-09-07 20:54:42 -07:00
|
|
|
if (!ecore_file_exists(path))
|
2012-02-20 01:22:23 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
ret = EINA_FALSE;
|
2012-02-20 01:22:23 -08:00
|
|
|
goto clean_up;
|
|
|
|
}
|
2010-09-07 20:54:42 -07:00
|
|
|
|
2014-08-03 07:56:43 -07:00
|
|
|
dir = ecore_file_dir_get(path);
|
2013-06-10 07:47:54 -07:00
|
|
|
eina_stringshare_replace(&sd->selection, path);
|
2014-10-28 18:07:44 -07:00
|
|
|
eina_stringshare_ref(sd->selection);
|
|
|
|
_schedule_populate(obj, sd, eina_stringshare_add(dir), sd->selection);
|
2014-08-03 07:56:43 -07:00
|
|
|
free(dir);
|
2010-04-08 13:36:37 -07:00
|
|
|
}
|
|
|
|
|
2012-02-20 01:22:23 -08:00
|
|
|
clean_up:
|
|
|
|
free(path);
|
2014-03-30 00:15:55 -07:00
|
|
|
|
|
|
|
return ret;
|
2010-04-08 13:36:37 -07:00
|
|
|
}
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-10-16 19:04:57 -07:00
|
|
|
EAPI const Eina_List *
|
|
|
|
elm_fileselector_selected_paths_get(const Evas_Object* obj)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, NULL);
|
2013-10-16 19:04:57 -07:00
|
|
|
const Eina_List *ret = NULL;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_selected_paths_get((Eo *) obj);
|
2013-10-16 19:04:57 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static const Eina_List*
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_selected_paths_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2013-10-16 19:04:57 -07:00
|
|
|
{
|
|
|
|
if (sd->multi)
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->paths;
|
2013-10-16 19:04:57 -07:00
|
|
|
else
|
2014-03-30 00:15:55 -07:00
|
|
|
return NULL;
|
2013-10-16 19:04:57 -07:00
|
|
|
}
|
|
|
|
|
2014-10-05 16:08:24 -07:00
|
|
|
EAPI const char *
|
|
|
|
elm_fileselector_current_name_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, NULL);
|
|
|
|
const char *ret = NULL;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_current_name_get((Eo *) obj);
|
2014-10-05 16:08:24 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static const char *
|
|
|
|
_elm_fileselector_elm_interface_fileselector_current_name_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
|
|
|
{
|
|
|
|
return elm_object_text_get(sd->name_entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_fileselector_current_name_set(Evas_Object *obj,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_current_name_set((Eo *) obj, name);
|
2014-10-05 16:08:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_elm_fileselector_elm_interface_fileselector_current_name_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, const char *name)
|
|
|
|
{
|
|
|
|
elm_object_text_set(sd->name_entry, name);
|
|
|
|
}
|
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
static Elm_Fileselector_Filter *
|
2014-04-22 05:51:46 -07:00
|
|
|
_filter_add(Elm_Fileselector_Data *sd, const char *filter_name)
|
2013-12-28 20:23:17 -08:00
|
|
|
{
|
|
|
|
Elm_Fileselector_Filter *ff;
|
|
|
|
ff = malloc(sizeof(Elm_Fileselector_Filter));
|
2015-06-12 23:45:36 -07:00
|
|
|
if (!ff) return NULL;
|
2013-12-28 20:23:17 -08:00
|
|
|
|
|
|
|
ff->filter_name = eina_stringshare_add(filter_name);
|
|
|
|
ff->sd = sd;
|
|
|
|
|
|
|
|
return ff;
|
|
|
|
}
|
|
|
|
|
2013-06-18 17:00:41 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_fileselector_mime_types_filter_append(Evas_Object *obj, const char *mime_type, const char *filter_name)
|
|
|
|
{
|
|
|
|
ELM_FILESELECTOR_CHECK(obj) EINA_FALSE;
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_mime_types_filter_append(obj, mime_type, filter_name);
|
2013-06-18 17:00:41 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_mime_types_filter_append(Eo *obj, Elm_Fileselector_Data *sd, const char *mime_types, const char *filter_name)
|
2013-06-18 17:00:41 -07:00
|
|
|
{
|
|
|
|
Elm_Fileselector_Filter *ff;
|
2016-03-04 15:39:29 -08:00
|
|
|
char buf[1024];
|
2013-06-18 17:00:41 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
if (!mime_types) return EINA_FALSE;
|
2013-06-18 17:00:41 -07:00
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
ff = _filter_add(sd, filter_name ? filter_name : mime_types);
|
2015-06-12 23:45:36 -07:00
|
|
|
if (!ff) return EINA_FALSE;
|
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
ff->filter_type = ELM_FILESELECTOR_MIME_FILTER;
|
2013-06-18 17:00:41 -07:00
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
ff->filter.mime_types = eina_str_split(mime_types, ",", 0);
|
2013-06-18 17:00:41 -07:00
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
if (!sd->filter_list)
|
|
|
|
{
|
|
|
|
sd->current_filter = ff;
|
|
|
|
sd->filter_hoversel = elm_hoversel_add(obj);
|
|
|
|
elm_object_text_set(sd->filter_hoversel, ff->filter_name);
|
2016-03-04 15:39:29 -08:00
|
|
|
snprintf(buf, sizeof(buf), "fileselector/actions/%s", elm_widget_style_get(obj));
|
|
|
|
elm_widget_style_set(sd->filter_hoversel, buf);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.filters", sd->filter_hoversel);
|
2013-12-28 20:23:17 -08:00
|
|
|
}
|
|
|
|
elm_hoversel_item_add(sd->filter_hoversel, ff->filter_name, NULL, ELM_ICON_NONE, _current_filter_changed, ff);
|
2013-06-18 17:00:41 -07:00
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
sd->filter_list = eina_list_append(sd->filter_list, ff);
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2013-12-28 20:23:17 -08:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_TRUE;
|
2013-12-28 20:23:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_fileselector_custom_filter_append(Evas_Object *obj, Elm_Fileselector_Filter_Func func, void *data, const char *filter_name)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, EINA_FALSE);
|
2013-12-28 20:23:17 -08:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_custom_filter_append(obj, func, data, filter_name);
|
2013-12-28 20:23:17 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_custom_filter_append(Eo *obj, Elm_Fileselector_Data *sd, Elm_Fileselector_Filter_Func func, void *data, const char *filter_name)
|
2013-12-28 20:23:17 -08:00
|
|
|
{
|
|
|
|
Elm_Fileselector_Filter *ff;
|
2015-06-12 23:45:36 -07:00
|
|
|
Elm_Fileselector_Custom_Filter *custom_filter;
|
2016-03-04 15:39:29 -08:00
|
|
|
char buf[1024];
|
2013-12-28 20:23:17 -08:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
if (!func) return EINA_FALSE;
|
2013-12-28 20:23:17 -08:00
|
|
|
|
2015-06-12 23:45:36 -07:00
|
|
|
custom_filter = malloc(sizeof(Elm_Fileselector_Custom_Filter));
|
|
|
|
if (!custom_filter) return EINA_FALSE;
|
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
ff = _filter_add(sd, filter_name ? filter_name : "custom");
|
2015-07-24 09:35:22 -07:00
|
|
|
if (!ff)
|
|
|
|
{
|
|
|
|
free(custom_filter);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2013-12-28 20:23:17 -08:00
|
|
|
|
2015-06-12 23:45:36 -07:00
|
|
|
ff->filter_type = ELM_FILESELECTOR_CUSTOM_FILTER;
|
|
|
|
ff->filter.custom = custom_filter;
|
2013-12-28 20:23:17 -08:00
|
|
|
ff->filter.custom->func = func;
|
|
|
|
ff->filter.custom->data = data;
|
2013-06-18 17:00:41 -07:00
|
|
|
|
|
|
|
if (!sd->filter_list)
|
|
|
|
{
|
|
|
|
sd->current_filter = ff;
|
|
|
|
sd->filter_hoversel = elm_hoversel_add(obj);
|
|
|
|
elm_object_text_set(sd->filter_hoversel, ff->filter_name);
|
2016-03-04 15:39:29 -08:00
|
|
|
snprintf(buf, sizeof(buf), "fileselector/actions/%s", elm_widget_style_get(obj));
|
|
|
|
elm_widget_style_set(sd->filter_hoversel, buf);
|
|
|
|
elm_object_part_content_set(obj, "elm.swallow.filters", sd->filter_hoversel);
|
2013-06-18 17:00:41 -07:00
|
|
|
}
|
2013-12-26 04:08:33 -08:00
|
|
|
elm_hoversel_item_add(sd->filter_hoversel, ff->filter_name, NULL, ELM_ICON_NONE, _current_filter_changed, ff);
|
2013-06-18 17:00:41 -07:00
|
|
|
|
|
|
|
sd->filter_list = eina_list_append(sd->filter_list, ff);
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2013-06-18 17:00:41 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_TRUE;
|
2013-06-18 17:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_fileselector_filters_clear(Evas_Object *obj)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_filters_clear(obj);
|
2013-06-18 17:00:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_filters_clear(Eo *obj, Elm_Fileselector_Data *sd)
|
2013-06-18 17:00:41 -07:00
|
|
|
{
|
|
|
|
Elm_Fileselector_Filter *filter;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(sd->filter_list, filter)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(filter->filter_name);
|
|
|
|
|
2013-12-28 20:23:17 -08:00
|
|
|
if (filter->filter_type == ELM_FILESELECTOR_MIME_FILTER)
|
|
|
|
{
|
|
|
|
free(filter->filter.mime_types[0]);
|
|
|
|
free(filter->filter.mime_types);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
free(filter->filter.custom);
|
2013-06-18 17:00:41 -07:00
|
|
|
|
|
|
|
free(filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
ELM_SAFE_FREE(sd->filter_hoversel, evas_object_del);
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2013-06-18 17:00:41 -07:00
|
|
|
}
|
|
|
|
|
2013-10-17 20:16:54 -07:00
|
|
|
EAPI void
|
|
|
|
elm_fileselector_hidden_visible_set(Evas_Object *obj, Eina_Bool visible)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_hidden_visible_set(obj, visible);
|
2013-10-17 20:16:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_hidden_visible_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, Eina_Bool visible)
|
2013-10-17 20:16:54 -07:00
|
|
|
{
|
|
|
|
visible = !!visible;
|
|
|
|
if (sd->hidden_visible == visible) return;
|
|
|
|
sd->hidden_visible = visible;
|
|
|
|
|
|
|
|
_clear_selections(sd, NULL);
|
2014-10-28 18:07:44 -07:00
|
|
|
|
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2013-10-17 20:16:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_fileselector_hidden_visible_get(const Evas_Object *obj)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, EINA_FALSE);
|
2013-10-17 20:16:54 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_hidden_visible_get((Eo *) obj);
|
2013-10-17 20:16:54 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_hidden_visible_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2013-10-17 20:16:54 -07:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->hidden_visible;
|
2013-10-17 20:16:54 -07:00
|
|
|
}
|
|
|
|
|
2013-12-03 01:28:52 -08:00
|
|
|
EAPI void
|
|
|
|
elm_fileselector_thumbnail_size_set(Evas_Object *obj,
|
|
|
|
Evas_Coord w,
|
|
|
|
Evas_Coord h)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_thumbnail_size_set(obj, w, h);
|
2013-12-03 01:28:52 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_thumbnail_size_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, Evas_Coord w, Evas_Coord h)
|
2013-12-03 01:28:52 -08:00
|
|
|
{
|
|
|
|
if (sd->thumbnail_size.w == w && sd->thumbnail_size.h == h) return;
|
|
|
|
|
|
|
|
if (!w || !h)
|
|
|
|
w = h = elm_config_finger_size_get() * 2 - GENGRID_PADDING;
|
|
|
|
|
|
|
|
sd->thumbnail_size.w = w;
|
|
|
|
sd->thumbnail_size.h = h;
|
|
|
|
|
|
|
|
if (sd->mode == ELM_FILESELECTOR_GRID)
|
|
|
|
elm_gengrid_item_size_set(sd->files_view, w + GENGRID_PADDING, h + GENGRID_PADDING);
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2013-12-03 01:28:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_fileselector_thumbnail_size_get(const Evas_Object *obj,
|
|
|
|
Evas_Coord *w,
|
|
|
|
Evas_Coord *h)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_thumbnail_size_get((Eo *) obj, w, h);
|
2013-12-03 01:28:52 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_thumbnail_size_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, Evas_Coord *w, Evas_Coord *h)
|
2013-12-03 01:28:52 -08:00
|
|
|
{
|
|
|
|
if (w) *w = sd->thumbnail_size.w;
|
|
|
|
if (h) *h = sd->thumbnail_size.h;
|
|
|
|
}
|
|
|
|
|
2013-12-18 03:05:35 -08:00
|
|
|
EAPI void
|
|
|
|
elm_fileselector_sort_method_set(Evas_Object *obj, Elm_Fileselector_Sort sort)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_fileselector_sort_method_set(obj, sort);
|
2013-12-18 03:05:35 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_sort_method_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, Elm_Fileselector_Sort sort)
|
2013-12-18 03:05:35 -08:00
|
|
|
{
|
|
|
|
if (sd->sort_type == sort) return;
|
|
|
|
sd->sort_type = sort;
|
|
|
|
|
|
|
|
switch (sd->sort_type)
|
|
|
|
{
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_FILENAME_ASC:
|
|
|
|
sd->sort_method = strcoll;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_FILENAME_DESC:
|
|
|
|
sd->sort_method = _strcoll_rev;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_TYPE_ASC:
|
|
|
|
sd->sort_method = _strcoll_type;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_TYPE_DESC:
|
|
|
|
sd->sort_method = _strcoll_type_rev;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_SIZE_ASC:
|
|
|
|
sd->sort_method = _size_cmp;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_SIZE_DESC:
|
|
|
|
sd->sort_method = _size_cmp_rev;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC:
|
|
|
|
sd->sort_method = _modified_cmp;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC:
|
|
|
|
sd->sort_method = _modified_cmp_rev;
|
|
|
|
break;
|
|
|
|
case ELM_FILESELECTOR_SORT_LAST:
|
|
|
|
default:
|
|
|
|
sd->sort_method = strcoll;
|
|
|
|
}
|
|
|
|
|
2014-10-28 18:07:44 -07:00
|
|
|
if (sd->path)
|
|
|
|
{
|
|
|
|
eina_stringshare_ref(sd->path);
|
|
|
|
_schedule_populate(obj, sd, sd->path, NULL);
|
|
|
|
}
|
2013-12-18 03:05:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Fileselector_Sort
|
|
|
|
elm_fileselector_sort_method_get(const Evas_Object *obj)
|
|
|
|
{
|
2014-01-21 05:50:35 -08:00
|
|
|
ELM_FILESELECTOR_INTERFACE_CHECK(obj, ELM_FILESELECTOR_SORT_LAST);
|
2013-12-18 03:05:35 -08:00
|
|
|
Elm_Fileselector_Sort ret = ELM_FILESELECTOR_SORT_LAST;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_interface_fileselector_sort_method_get((Eo *) obj);
|
2013-12-18 03:05:35 -08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Elm_Fileselector_Sort
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_interface_fileselector_sort_method_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd)
|
2013-12-18 03:05:35 -08:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
return sd->sort_type;
|
2013-12-18 03:05:35 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-05-28 19:35:46 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2015-09-15 03:41:51 -07:00
|
|
|
_elm_fileselector_elm_widget_focus_next(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
|
2014-05-28 19:35:46 -07:00
|
|
|
{
|
|
|
|
Eina_List *items = NULL;
|
|
|
|
|
|
|
|
if (sd->up_button) items = eina_list_append(items, sd->up_button);
|
|
|
|
if (sd->home_button) items = eina_list_append(items, sd->home_button);
|
|
|
|
if (sd->files_view) items = eina_list_append(items, sd->files_view);
|
|
|
|
if (sd->path_entry) items = eina_list_append(items, sd->path_entry);
|
|
|
|
if (sd->name_entry) items = eina_list_append(items, sd->name_entry);
|
2016-03-04 15:39:29 -08:00
|
|
|
if (sd->filter_hoversel) items = eina_list_append(items, sd->filter_hoversel);
|
2014-05-28 19:35:46 -07:00
|
|
|
if (sd->cancel_button) items = eina_list_append(items, sd->cancel_button);
|
2016-03-04 15:39:29 -08:00
|
|
|
if (sd->ok_button) items = eina_list_append(items, sd->ok_button);
|
2014-05-28 19:35:46 -07:00
|
|
|
|
|
|
|
if (_elm_config->access_mode)
|
2015-09-15 03:41:51 -07:00
|
|
|
return elm_widget_focus_list_next_get(obj, items, eina_list_data_get, dir, next, next_item);
|
2014-05-28 19:35:46 -07:00
|
|
|
|
2015-09-15 03:41:51 -07:00
|
|
|
if (!elm_widget_focus_list_next_get(obj, items, eina_list_data_get, dir, next, next_item))
|
2014-05-28 19:35:46 -07:00
|
|
|
*next = (Evas_Object *)obj;
|
|
|
|
|
|
|
|
eina_list_free(items);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-05-28 19:35:46 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2015-09-24 23:24:53 -07:00
|
|
|
_elm_fileselector_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
|
2014-05-28 19:35:46 -07:00
|
|
|
{
|
|
|
|
Eina_List *items = NULL;
|
|
|
|
|
|
|
|
if (sd->up_button) items = eina_list_append(items, sd->up_button);
|
|
|
|
if (sd->home_button) items = eina_list_append(items, sd->home_button);
|
|
|
|
if (sd->files_view) items = eina_list_append(items, sd->files_view);
|
|
|
|
if (sd->path_entry) items = eina_list_append(items, sd->path_entry);
|
|
|
|
if (sd->name_entry) items = eina_list_append(items, sd->name_entry);
|
2016-03-04 15:39:29 -08:00
|
|
|
if (sd->filter_hoversel) items = eina_list_append(items, sd->filter_hoversel);
|
2014-05-28 19:35:46 -07:00
|
|
|
if (sd->cancel_button) items = eina_list_append(items, sd->cancel_button);
|
|
|
|
if (sd->ok_button) items = eina_list_append(items, sd->ok_button);
|
|
|
|
|
|
|
|
elm_widget_focus_list_direction_get
|
2015-09-24 23:24:53 -07:00
|
|
|
(obj, base, items, eina_list_data_get, degree, direction, direction_item, weight);
|
2014-05-28 19:35:46 -07:00
|
|
|
|
|
|
|
eina_list_free(items);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_elm_layout_text_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *sd, const char *part, const char *label)
|
2013-07-22 09:51:27 -07:00
|
|
|
{
|
2014-03-30 00:15:55 -07:00
|
|
|
if (!part) return EINA_FALSE;
|
2013-07-22 09:51:27 -07:00
|
|
|
|
|
|
|
if (sd->ok_button && !strcmp(part, "ok"))
|
|
|
|
{
|
|
|
|
elm_object_text_set(sd->ok_button, label);
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_TRUE;
|
2013-07-22 09:51:27 -07:00
|
|
|
}
|
|
|
|
else if (sd->cancel_button && !strcmp(part, "cancel"))
|
|
|
|
{
|
|
|
|
elm_object_text_set(sd->cancel_button, label);
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_TRUE;
|
2013-07-22 09:51:27 -07:00
|
|
|
}
|
2013-07-22 14:11:30 -07:00
|
|
|
else
|
2014-03-30 00:15:55 -07:00
|
|
|
{
|
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
int_ret = elm_obj_layout_text_set(eo_super(obj, MY_CLASS), part, label);
|
2014-03-30 00:15:55 -07:00
|
|
|
return int_ret;
|
|
|
|
}
|
2013-07-22 14:11:30 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
return EINA_FALSE;
|
2013-07-22 09:51:27 -07:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_class_constructor(Eo_Class *klass)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-06-26 23:21:37 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
2013-06-26 23:21:37 -07:00
|
|
|
|
|
|
|
for (i = 0; i < ELM_FILE_LAST; ++i)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2013-10-17 16:11:10 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2013-06-26 23:21:37 -07:00
|
|
|
|
2014-03-30 00:15:55 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_fileselector_class_destructor(Eo_Class *klass EINA_UNUSED)
|
2013-06-26 23:21:37 -07:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ELM_FILE_LAST; ++i)
|
|
|
|
{
|
|
|
|
elm_genlist_item_class_free(list_itc[i]);
|
|
|
|
elm_gengrid_item_class_free(grid_itc[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-25 01:33:19 -07:00
|
|
|
EOLIAN const Elm_Atspi_Action *
|
|
|
|
_elm_fileselector_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
static Elm_Atspi_Action atspi_actions[] = {
|
|
|
|
{ "select", "select", NULL, _key_action_select },
|
|
|
|
{ "escape", "escape", NULL, _key_action_escape},
|
2016-03-04 15:32:22 -08:00
|
|
|
{ "backspace", "backspace", NULL, _key_action_backspace},
|
2014-07-25 01:33:19 -07:00
|
|
|
{ NULL, NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
return &atspi_actions[0];
|
|
|
|
}
|
|
|
|
|
2014-08-11 07:46:11 -07:00
|
|
|
#include "elm_fileselector.eo.c"
|