elm: Add support for Efl.Model in Elm.Fileselector

Elm.Interface.Fileselector now supports Efl.Model objects, allowing users
to work with paths from different data models.

Example of model attribution:

ELm_Fileselector *fs = eo_add(EFL_FILESELECTOR_CLASS, NULL);
Efl_Model *model = ...;
elm_interface_fileselector_model_set(fs, model, NULL);
This commit is contained in:
Vitor Sousa 2016-06-06 04:16:57 -03:00
parent b2a07ca150
commit 77a2e9744d
11 changed files with 1253 additions and 532 deletions

View File

@ -83,6 +83,7 @@
#include <Efreet_Mime.h>
#include <Efreet_Trash.h>
#include <Ethumb_Client.h>
#include <eio_model.h>
#ifdef ELM_ELOCATION
#include <Elocation.h>

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,12 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
};
#undef ELM_PRIV_FILESELECTOR_BUTTON_SIGNALS
static void
_model_free_eo_cb(void *eo)
{
eo_unref(eo);
}
EOLIAN static Eina_Bool
_elm_fileselector_button_elm_widget_theme_apply(Eo *obj, Elm_Fileselector_Button_Data *sd EINA_UNUSED)
{
@ -61,26 +67,68 @@ _elm_fileselector_button_elm_widget_theme_apply(Eo *obj, Elm_Fileselector_Button
return EINA_TRUE;
}
static void
_replace_path_then(void *data, void *value)
{
Elm_Fileselector_Button_Data *sd = data;
const char *path = NULL;
eina_value_get(value, &path);
eina_stringshare_replace(&sd->fsd.path, path);
}
static void
_replace_path_then_error(void *data, Eina_Error err EINA_UNUSED)
{
Elm_Fileselector_Button_Data *sd = data;
ERR("could not get information from Efl.Model");
eina_stringshare_replace(&sd->fsd.path, NULL);
}
static Eina_Bool
_selection_done(void *data, const Eo_Event *event)
{
Elm_Fileselector_Button_Data *sd = data;
const char *file = event->info;
Efl_Model *model = event->info;
Evas_Object *del;
if (file) eina_stringshare_replace(&sd->fsd.path, file);
if (model)
{
Eina_Promise *promise = NULL;
if (sd->fsd.model)
eo_unref(sd->fsd.model);
sd->fsd.model = eo_ref(model);
efl_model_property_get(model, "path", &promise);
eina_promise_then(promise, _replace_path_then, _replace_path_then_error, sd);
}
del = sd->fsw;
sd->fs = NULL;
sd->fsw = NULL;
evas_object_del(del);
eo_event_callback_call
(sd->obj, ELM_FILESELECTOR_BUTTON_EVENT_FILE_CHOSEN, (void *)file);
// EVENTS: should not call legacy
//eo_event_callback_call
// (sd->obj, ELM_FILESELECTOR_BUTTON_EVENT_FILE_CHOSEN, (void *)model);
return EINA_TRUE;
}
static void
_selection_done_path(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Fileselector_Button_Data *sd = data;
const char *path = event_info;
evas_object_smart_callback_call(sd->obj, "file,chosen", (void *) path);
// EVENTS: code above should not be needed
Eo_Event e = {0,};
if (path)
e.info = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, path));
_selection_done(data, &e);
}
static Evas_Object *
_new_window_add(Elm_Fileselector_Button_Data *sd)
{
@ -139,12 +187,14 @@ _activate(Elm_Fileselector_Button_Data *sd)
elm_fileselector_expandable_set(sd->fs, sd->fsd.expandable);
elm_fileselector_folder_only_set(sd->fs, sd->fsd.folder_only);
elm_fileselector_is_save_set(sd->fs, sd->fsd.is_save);
elm_fileselector_selected_set(sd->fs, sd->fsd.path);
elm_interface_fileselector_selected_model_set(sd->fs, sd->fsd.model, NULL);
evas_object_size_hint_weight_set
(sd->fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(sd->fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
eo_event_callback_add
(sd->fs, ELM_FILESELECTOR_EVENT_DONE, _selection_done, sd);
// EVENTS: should not call legacy
//eo_event_callback_add
// (sd->fs, ELM_FILESELECTOR_EVENT_DONE, _selection_done, sd);
evas_object_smart_callback_add(sd->fs, "done", _selection_done_path, sd);
evas_object_show(sd->fs);
if (is_inwin)
@ -180,6 +230,8 @@ _elm_fileselector_button_evas_object_smart_add(Eo *obj, Elm_Fileselector_Button_
if (path) priv->fsd.path = eina_stringshare_add(path);
else priv->fsd.path = eina_stringshare_add("/");
priv->fsd.model = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, priv->fsd.path));
priv->fsd.expandable = _elm_config->fileselector_expand_enable;
priv->inwin_mode = _elm_config->inwin_dialogs_enable;
priv->w = 400;
@ -197,9 +249,12 @@ _elm_fileselector_button_evas_object_smart_add(Eo *obj, Elm_Fileselector_Button_
EOLIAN static void
_elm_fileselector_button_evas_object_smart_del(Eo *obj, Elm_Fileselector_Button_Data *sd)
{
if (sd->fsd.model)
eo_unref(sd->fsd.model);
eina_stringshare_del(sd->window_title);
eina_stringshare_del(sd->fsd.path);
eina_stringshare_del(sd->fsd.selection);
if (sd->fsd.selection)
eo_unref(sd->fsd.selection);
evas_object_del(sd->fsw);
evas_obj_smart_del(eo_super(obj, MY_CLASS));
@ -275,30 +330,58 @@ elm_fileselector_button_path_set(Evas_Object *obj,
const char *path)
{
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
elm_interface_fileselector_path_set(obj, path);
ELM_FILESELECTOR_BUTTON_DATA_GET_OR_RETURN(obj, sd);
Efl_Model *model = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, path));
if (!model)
{
ERR("Efl.Model allocation error");
return;
}
if (sd->fsd.model)
eo_unref(sd->fsd.model);
sd->fsd.model = eo_ref(model);
eina_stringshare_replace(&sd->fsd.path, path);
if (sd->fs) elm_interface_fileselector_selected_model_set(sd->fs, model, NULL);
}
EOLIAN static void
_elm_fileselector_button_elm_interface_fileselector_path_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd, const char *path)
_elm_fileselector_button_elm_interface_fileselector_model_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd, Efl_Model *model)
{
eina_stringshare_replace(&sd->fsd.path, path);
if (sd->fsd.model)
eo_unref(sd->fsd.model);
if (sd->fs) elm_fileselector_selected_set(sd->fs, sd->fsd.path);
if (model)
{
Eina_Promise *promise = NULL;
sd->fsd.model = eo_ref(model);
efl_model_property_get(model, "path", &promise);
eina_promise_then(promise, _replace_path_then, _replace_path_then_error, sd);
}
else
{
sd->fsd.model = NULL;
eina_stringshare_replace(&sd->fsd.path, NULL);
}
if (sd->fs) elm_interface_fileselector_selected_model_set(sd->fs, model, NULL);
}
EINA_DEPRECATED EAPI const char *
elm_fileselector_button_path_get(const Evas_Object *obj)
{
ELM_FILESELECTOR_INTERFACE_CHECK(obj, NULL);
const char *ret = NULL;
ret = elm_interface_fileselector_path_get((Eo *) obj);
return ret;
ELM_FILESELECTOR_BUTTON_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
return sd->fsd.path;
}
EOLIAN static const char *
_elm_fileselector_button_elm_interface_fileselector_path_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
EOLIAN static Efl_Model *
_elm_fileselector_button_elm_interface_fileselector_model_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
{
return sd->fsd.path;
return sd->fsd.model;
}
EINA_DEPRECATED EAPI void
@ -437,41 +520,48 @@ _elm_fileselector_button_elm_interface_fileselector_multi_select_get(Eo *obj EIN
}
EOLIAN static const Eina_List*
_elm_fileselector_button_elm_interface_fileselector_selected_paths_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
_elm_fileselector_button_elm_interface_fileselector_selected_models_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
{
if (sd->fs) return elm_fileselector_selected_paths_get(sd->fs);
if (sd->fs) return elm_interface_fileselector_selected_models_get(sd->fs);
return NULL;
}
EOLIAN static const char*
_elm_fileselector_button_elm_interface_fileselector_selected_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
EOLIAN static Efl_Model *
_elm_fileselector_button_elm_interface_fileselector_selected_model_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
{
if (sd->fs) return elm_fileselector_selected_get(sd->fs);
if (sd->fs) return elm_interface_fileselector_selected_model_get(sd->fs);
return sd->fsd.selection;
return NULL;
}
EOLIAN static Eina_Bool
_elm_fileselector_button_elm_interface_fileselector_selected_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd, const char *_path)
static void
_selected_model_then(void *data, void *v)
{
Eina_Bool ret = EINA_TRUE;
Eina_Promise_Owner *owner = data;
eina_promise_owner_value_set(owner, eo_ref(v), _model_free_eo_cb);
}
if (sd->fs) ret = elm_fileselector_selected_set(sd->fs, _path);
else
static void
_selected_model_then_error(void *data, Eina_Error err)
{
Eina_Promise_Owner *owner = data;
eina_promise_owner_error_set(owner, err);
}
EOLIAN static void
_elm_fileselector_button_elm_interface_fileselector_selected_model_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd, Efl_Model *model, Eina_Promise_Owner *promise_owner)
{
if (sd->fs)
{
char *path = ecore_file_realpath(_path);
if (!ecore_file_is_dir(path) && !ecore_file_exists(path))
{
free(path);
return EINA_FALSE;
}
free(path);
Eina_Promise *promise = NULL;
elm_interface_fileselector_selected_model_set(sd->fs, model, &promise);
eina_promise_then(promise, _selected_model_then, _selected_model_then_error, promise_owner);
}
eina_stringshare_replace(&sd->fsd.selection, _path);
return ret;
if (sd->fsd.selection)
eo_unref(sd->fsd.selection);
sd->fsd.selection = model ? eo_ref(model) : NULL;
}
EOLIAN static void

View File

@ -1,3 +1,7 @@
typedef Eina_Bool (*Elm_Fileselector_Filter_Func)(const char *path, /**< File path */
Eina_Bool dir, /**< A flag to show if path is a directory or not. True if the path is a directory. */
void *data /**< A user data that was given by elm_fileselector_custom_filter_append. */);
EAPI extern Eina_Error ELM_FILESELECTOR_ERROR_UNKNOWN;
EAPI extern Eina_Error ELM_FILESELECTOR_ERROR_INVALID_MODEL;

View File

@ -33,7 +33,6 @@ EAPI const char ELM_FILESELECTOR_ENTRY_SMART_NAME[] = "elm_fileselector_entry";
cmd(SIG_SELECTION_COPY, "selection,copy", "") \
cmd(SIG_SELECTION_CUT, "selection,cut", "") \
cmd(SIG_UNPRESSED, "unpressed", "") \
cmd(SIG_FILE_CHOSEN, "file,chosen", "s") \
ELM_PRIV_FILESELECTOR_ENTRY_SIGNALS(ELM_PRIV_STATIC_VARIABLE_DECLARE);
@ -67,39 +66,88 @@ SIG_FWD(SELECTION_CUT, EVAS_SELECTABLE_INTERFACE_EVENT_SELECTION_CUT)
SIG_FWD(UNPRESSED, EVAS_CLICKABLE_INTERFACE_EVENT_UNPRESSED)
#undef SIG_FWD
static Eina_Bool
_FILE_CHOSEN_fwd(void *data, const Eo_Event *event)
static void
_file_chosen_path_then(void *data, void *v)
{
const char *file = event->info;
const char *file = NULL;
char *s;
if (!file) return EINA_TRUE;
eina_value_get(v, &file);
if (!file) return;
ELM_FILESELECTOR_ENTRY_DATA_GET(data, sd);
evas_object_smart_callback_call(data, "file,chosen", (void *) file);
s = elm_entry_utf8_to_markup(file);
elm_object_text_set(sd->entry, s);
free(s);
eo_event_callback_call
(data, ELM_FILESELECTOR_ENTRY_EVENT_FILE_CHOSEN, event->info);
}
static Eina_Bool
_FILE_CHOSEN_fwd(void *data, const Eo_Event *event)
{
Efl_Model *model = event->info;
Eina_Promise *promise = NULL;
if (!model) return EINA_TRUE;
efl_model_property_get(model, "path", &promise);
eina_promise_then(promise, _file_chosen_path_then, NULL, data);
// EVENTS: should not call legacy
//eo_event_callback_call
// (data, ELM_FILESELECTOR_ENTRY_EVENT_FILE_CHOSEN, event->info);
return EINA_TRUE;
}
// EVENTS: should not need this function
static void
_FILE_CHOSEN_fwd_path(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
const char *path = event_info;
Eo_Event e = {0,};
if (path)
e.info = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, path));
_FILE_CHOSEN_fwd(data, &e);
}
static Eina_Bool
_ACTIVATED_fwd(void *data, const Eo_Event *event)
{
const char *file;
Efl_Model *bmodel, *model;
Eina_Value path;
ELM_FILESELECTOR_ENTRY_DATA_GET(data, sd);
file = elm_object_text_get(sd->entry);
elm_fileselector_path_set(sd->button, file);
bmodel = elm_interface_fileselector_model_get(sd->button);
if (bmodel)
{
model = eo_add(eo_class_get(bmodel), NULL);
eina_value_setup(&path, EINA_VALUE_TYPE_STRING);
eina_value_set(&path, file);
efl_model_property_set(model, "path", &path, NULL);
eina_value_flush(&path);
elm_interface_fileselector_model_set(sd->button, model);
}
eo_event_callback_call
(data, ELM_FILESELECTOR_ENTRY_EVENT_ACTIVATED, event->info);
return EINA_TRUE;
}
static void
_model_free_eo_cb(void *eo)
{
eo_unref(eo);
}
EOLIAN static void
_elm_fileselector_entry_elm_layout_sizing_eval(Eo *obj, Elm_Fileselector_Entry_Data *sd EINA_UNUSED)
{
@ -286,8 +334,11 @@ _elm_fileselector_entry_evas_object_smart_add(Eo *obj, Elm_Fileselector_Entry_Da
eo_event_callback_add(priv->button, event, _##name##_fwd, obj)
SIG_FWD(CLICKED, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED);
SIG_FWD(UNPRESSED, EVAS_CLICKABLE_INTERFACE_EVENT_UNPRESSED);
SIG_FWD(FILE_CHOSEN, ELM_FILESELECTOR_BUTTON_EVENT_FILE_CHOSEN);
// EVENTS: should not call legacy
//SIG_FWD(FILE_CHOSEN, ELM_FILESELECTOR_BUTTON_EVENT_FILE_CHOSEN);
#undef SIG_FWD
// EVENTS: should not need this "callback_add"
evas_object_smart_callback_add(priv->button, "file,chosen", _FILE_CHOSEN_fwd_path, obj);
priv->entry = elm_entry_add(obj);
elm_entry_scrollable_set(priv->entry, EINA_TRUE);
@ -352,31 +403,35 @@ _elm_fileselector_entry_eo_base_constructor(Eo *obj, Elm_Fileselector_Entry_Data
}
EINA_DEPRECATED EAPI void
elm_fileselector_entry_selected_set(Evas_Object *obj,
const char *path)
elm_fileselector_entry_selected_set(Evas_Object *obj, const char *path)
{
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
elm_interface_fileselector_selected_set(obj, path);
ELM_FILESELECTOR_ENTRY_DATA_GET_OR_RETURN(obj, sd);
elm_fileselector_button_path_set(sd->button, path);
}
EOLIAN static Eina_Bool
_elm_fileselector_entry_elm_interface_fileselector_selected_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Entry_Data *sd, const char *path)
EOLIAN static void
_elm_fileselector_entry_elm_interface_fileselector_selected_model_set(Eo *obj EINA_UNUSED,
Elm_Fileselector_Entry_Data *sd,
Efl_Model *model,
Eina_Promise_Owner *promise_owner)
{
elm_fileselector_path_set(sd->button, path);
return EINA_TRUE;
elm_interface_fileselector_model_set(sd->button, model);
eina_promise_owner_value_set(promise_owner, eo_ref(model), _model_free_eo_cb);
}
EINA_DEPRECATED EAPI const char *
elm_fileselector_entry_selected_get(const Evas_Object *obj)
{
ELM_FILESELECTOR_INTERFACE_CHECK(obj, NULL);
return elm_interface_fileselector_selected_get((Eo *) obj);
ELM_FILESELECTOR_ENTRY_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
return elm_fileselector_button_path_get(sd->button);
}
EOLIAN static const char *
_elm_fileselector_entry_elm_interface_fileselector_selected_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Entry_Data *sd)
EOLIAN static Efl_Model *
_elm_fileselector_entry_elm_interface_fileselector_selected_model_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Entry_Data *sd)
{
return elm_fileselector_path_get(sd->button);
return elm_interface_fileselector_model_get(sd->button);
}
EAPI void
@ -418,15 +473,28 @@ elm_fileselector_entry_path_set(Evas_Object *obj,
const char *path)
{
ELM_FILESELECTOR_INTERFACE_CHECK(obj);
elm_interface_fileselector_path_set(obj, path);
ELM_FILESELECTOR_ENTRY_DATA_GET_OR_RETURN(obj, sd);
char *s = elm_entry_utf8_to_markup(path);
if (s)
{
elm_object_text_set(sd->entry, s);
free(s);
}
elm_fileselector_button_path_set(sd->button, path);
}
EOLIAN static void
_elm_fileselector_entry_elm_interface_fileselector_path_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Entry_Data *sd, const char *path)
static void
_fs_entry_model_path_get_then(void *data, void *v)
{
Elm_Fileselector_Entry_Data *sd = data;
char *path = NULL;
char *s;
elm_fileselector_path_set(sd->button, path);
if (!v)
return;
eina_value_get(v, &path);
s = elm_entry_utf8_to_markup(path);
if (s)
{
@ -435,21 +503,49 @@ _elm_fileselector_entry_elm_interface_fileselector_path_set(Eo *obj EINA_UNUSED,
}
}
EOLIAN static void
_elm_fileselector_entry_elm_interface_fileselector_model_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Entry_Data *sd, Efl_Model *model)
{
Eina_Promise *p = NULL;
elm_interface_fileselector_model_set(sd->button, model);
efl_model_property_get(model, "path", &p);
eina_promise_then(p, _fs_entry_model_path_get_then, NULL, sd);
}
EINA_DEPRECATED EAPI const char *
elm_fileselector_entry_path_get(const Evas_Object *obj)
{
ELM_FILESELECTOR_INTERFACE_CHECK(obj, NULL);
return elm_interface_fileselector_path_get((Eo *) obj);
}
EOLIAN static const char *
_elm_fileselector_entry_elm_interface_fileselector_path_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Entry_Data *sd)
{
ELM_FILESELECTOR_ENTRY_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
free(sd->path);
sd->path = elm_entry_markup_to_utf8(elm_object_text_get(sd->entry));
return sd->path;
}
EOLIAN static Efl_Model *
_elm_fileselector_entry_elm_interface_fileselector_model_get(Eo *obj EINA_UNUSED, Elm_Fileselector_Entry_Data *sd)
{
Efl_Model *bmodel, *ret;
Eina_Value path;
bmodel = elm_interface_fileselector_model_get(sd->button);
if (!bmodel)
{
WRN("no base Efl.Model");
return NULL;
}
ret = eo_add(eo_class_get(bmodel), NULL);
free(sd->path);
sd->path = elm_entry_markup_to_utf8(elm_object_text_get(sd->entry));
eina_value_setup(&path, EINA_VALUE_TYPE_STRING);
eina_value_set(&path, sd->path);
efl_model_property_set(ret, "path", &path, NULL);
eina_value_flush(&path);
return ret;
}
EINA_DEPRECATED EAPI void
elm_fileselector_entry_expandable_set(Evas_Object *obj,
Eina_Bool value)

View File

@ -38,21 +38,22 @@ class Elm.Fileselector (Elm.Layout, Elm.Interface.Fileselector,
Evas.Object.Smart.del;
Elm.Widget.focus_next;
Elm.Widget.focus_direction_manager_is;
Elm.Widget.focus_direction;
Elm.Widget.focus_direction;
Elm.Widget.event;
Elm.Widget.theme_apply;
Elm.Widget.focus_next_manager_is;
Elm.Layout.text.set;
Elm.Interface.Fileselector.selected_paths.get;
Elm.Interface.Fileselector.selected_models.get;
Elm.Interface.Fileselector.selected_model_get;
Elm.Interface.Fileselector.selected_model_set;
Elm.Interface.Fileselector.custom_filter_append;
Elm.Interface.Fileselector.expandable;
Elm.Interface.Fileselector.thumbnail_size;
Elm.Interface.Fileselector.selected;
Elm.Interface.Fileselector.mime_types_filter_append;
Elm.Interface.Fileselector.hidden_visible;
Elm.Interface.Fileselector.filters_clear;
Elm.Interface.Fileselector.is_save;
Elm.Interface.Fileselector.path;
Elm.Interface.Fileselector.model;
Elm.Interface.Fileselector.sort_method;
Elm.Interface.Fileselector.multi_select;
Elm.Interface.Fileselector.folder_only;

View File

@ -7,13 +7,14 @@ class Elm.Fileselector_Button (Elm.Button, Elm.Interface.Fileselector)
Evas.Object.Smart.del;
Elm.Widget.theme_apply;
Elm.Button.admits_autorepeat.get;
Elm.Interface.Fileselector.selected_paths.get;
Elm.Interface.Fileselector.selected_models.get;
Elm.Interface.Fileselector.expandable;
Elm.Interface.Fileselector.thumbnail_size;
Elm.Interface.Fileselector.selected;
Elm.Interface.Fileselector.selected_model_get;
Elm.Interface.Fileselector.selected_model_set;
Elm.Interface.Fileselector.hidden_visible;
Elm.Interface.Fileselector.is_save;
Elm.Interface.Fileselector.path;
Elm.Interface.Fileselector.model;
Elm.Interface.Fileselector.sort_method;
Elm.Interface.Fileselector.multi_select;
Elm.Interface.Fileselector.folder_only;

View File

@ -16,10 +16,11 @@ class Elm.Fileselector_Entry (Elm.Layout, Elm.Interface.Fileselector,
Elm.Layout.text.set;
Elm.Layout.text.get;
Elm.Layout.sizing_eval;
Elm.Interface.Fileselector.selected;
Elm.Interface.Fileselector.selected_model_get;
Elm.Interface.Fileselector.selected_model_set;
Elm.Interface.Fileselector.folder_only;
Elm.Interface.Fileselector.is_save;
Elm.Interface.Fileselector.path;
Elm.Interface.Fileselector.model;
Elm.Interface.Fileselector.expandable;
Efl.Part.part;
}

View File

@ -41,18 +41,6 @@ interface Elm.Interface.Fileselector ()
only: bool;
}
}
@property selected {
set {
[[Set, programmatically, the currently selected file/directory in the given file selector widget]]
return: bool;
}
get {
[[Get the currently selected item's (full) path, in the given file the given file selector widget]]
}
values {
path: string;
}
}
@property thumbnail_size {
set {
[[Set the size for the thumbnail of the file selector widget's view.]]
@ -109,15 +97,15 @@ interface Elm.Interface.Fileselector ()
expand: bool;
}
}
@property path {
@property model {
set {
[[Set, programmatically, the directory that a given file selector widget will display contents from]]
}
get {
[[Get the parent directory's path that a given file selector selector widget will display contents from]]
[[Get the directory's model that a given file selector selector widget display contents from]]
}
values {
path: string;
model: Efl.Model;
}
}
@property mode {
@ -142,12 +130,12 @@ interface Elm.Interface.Fileselector ()
is_save: bool;
}
}
@property selected_paths {
@property selected_models {
get {
[[Get a list of selected paths in the fileselector.]]
[[Get a list of models selected in the fileselector.]]
}
values {
ret: const(list<string>);
ret: const(list<Efl.Model>);
}
}
@property current_name {
@ -159,6 +147,17 @@ interface Elm.Interface.Fileselector ()
name: string;
}
}
selected_model_set {
[[Set, programmatically, the currently selected file/directory in the given file selector widget]]
params {
@in model: Efl.Model; [[Model to be set]]
@inout promise: promise<Efl.Model>; [[Promise returning the recorded selected model or error]]
}
}
selected_model_get {
[[Get the currently selected item's model, in the given file the given file selector widget]]
return: Efl.Model;
}
custom_filter_append {
[[Append custom filter into filter list]]
params {

View File

@ -21,6 +21,8 @@
*/
typedef struct _Elm_Fileselector_Filter Elm_Fileselector_Filter;
typedef struct _Listing_Request Listing_Request;
typedef struct _Elm_Fileselector_Item_Data Elm_Fileselector_Item_Data;
/**
* Base layout smart data extended with fileselector instance data.
@ -42,29 +44,30 @@ struct _Elm_Fileselector_Data
Evas_Object *ok_button;
Evas_Object *cancel_button;
Eina_List *files_item_data;
Eina_List *filter_list;
Elm_Fileselector_Filter *current_filter;
/* a list of selected paths. only for multi selection */
Eina_List *paths;
Eina_List *multi_selection;
Eina_List *multi_selection_tmp;
const char *path;
const char *prev_path;
const char *selection;
Efl_Model *model;
Efl_Model *prev_model;
Ecore_Idler *populate_idler;
Ecore_Idler *path_entry_idler;
const char *path_separator;
const char *search_string;
Eio_File *current;
Eio_Monitor *monitor;
Eina_List *handlers;
Listing_Request *current_populate_lreq;
Evas_Coord_Size thumbnail_size;
/* a sort method to decide orders of files/directories */
int (*sort_method)(const char *, const char *);
int (*sort_method)(const Elm_Fileselector_Item_Data *, const Elm_Fileselector_Item_Data *);
Elm_Fileselector_Mode mode;
Elm_Fileselector_Sort sort_type;
@ -86,20 +89,38 @@ struct _Elm_Fileselector_Data
struct sel_data
{
Evas_Object *fs;
Eina_Stringshare *path;
Eina_Stringshare *selected;
Efl_Model *model;
Efl_Model *selected;
};
typedef struct _Listing_Request Listing_Request;
struct _Listing_Request
{
Elm_Fileselector_Data *sd;
Elm_Object_Item *parent_it;
Evas_Object *obj;
const char *path;
const char *selected;
Efl_Model *model;
Efl_Model *selected;
Eina_Stringshare *path;
Eina_Stringshare *selected_path;
int item_total;
int item_processed_count;
Eina_Bool first : 1;
Eina_Bool valid : 1;
};
struct _Elm_Fileselector_Item_Data
{
void *user_data;
Efl_Model *model;
Eina_Stringshare *path;
Eina_Stringshare *filename;
int64_t size;
double mtime;
Eina_Stringshare *mime_type;
Efl_Model *parent_model;
const char *parent_path;
Eina_Bool is_dir : 1;
};
typedef enum {

View File

@ -37,8 +37,9 @@ struct _Elm_Fileselector_Button_Data
struct
{
Efl_Model *model;
const char *path;
const char *selection;
Efl_Model *selection;
Evas_Coord_Size thumbnail_size;
Elm_Fileselector_Mode mode;
Elm_Fileselector_Sort sort_type;