add elm_fileselector_entry

works, but focus chain is not giving focus to button.



SVN revision: 53384
This commit is contained in:
Gustavo Sverzut Barbieri 2010-10-14 01:18:14 +00:00
parent c50a1a4063
commit cb2ebb9303
10 changed files with 1052 additions and 0 deletions

View File

@ -28569,6 +28569,33 @@ collections {
}
}
group { name: "elm/fileselector_entry/base/default";
parts {
part { name: "elm.swallow.entry";
type: SWALLOW;
description { state: "default" 0.0;
align: 0.0 0.0;
min: 50 10;
rel2 { to_x: "elm.swallow.button";
relative: 0.0 1.0;
offset: -1 -1;
}
}
}
part { name: "elm.swallow.button";
type: SWALLOW;
description { state: "default" 0.0;
align: 1.0 0.0;
min: 10 10;
fixed: 1 1;
rel1 {
relative: 1.0 0.0;
offset: -21 0;
}
}
}
}
}
////////////////////////////////////////////////////////////////////////
// Standard layouts to be used //

View File

@ -36,6 +36,7 @@ test_icon.c \
test_box.c \
test_button.c \
test_fileselector_button.c \
test_fileselector_entry.c \
test_toggle.c \
test_table.c \
test_gengrid.c \

View File

@ -11,6 +11,7 @@ void test_box_vert2(void *data, Evas_Object *obj, void *event_info);
void test_box_horiz(void *data, Evas_Object *obj, void *event_info);
void test_button(void *data, Evas_Object *obj, void *event_info);
void test_fileselector_button(void *data, Evas_Object *obj, void *event_info);
void test_fileselector_entry(void *data, Evas_Object *obj, void *event_info);
void test_toggle(void *data, Evas_Object *obj, void *event_info);
void test_clock(void *data, Evas_Object *obj, void *event_info);
void test_clock2(void *data, Evas_Object *obj, void *event_info);
@ -223,6 +224,7 @@ my_win_main(char *autorun)
ADD_TEST("Box Horiz", test_box_horiz);
ADD_TEST("Buttons", test_button);
ADD_TEST("File Selector Button", test_fileselector_button);
ADD_TEST("File Selector Entry", test_fileselector_entry);
ADD_TEST("Toggles", test_toggle);
ADD_TEST("Table", test_table);
ADD_TEST("Clock", test_clock);

View File

@ -0,0 +1,150 @@
#include <Elementary.h>
#ifndef ELM_LIB_QUICKLAUNCH
static void
_file_chosen(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *entry = data;
char *file = event_info;
elm_entry_entry_set(entry, file);
printf("File chosen: %s\n", file);
}
static void
_inwin_mode_toggle(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *fs_en = data;
Eina_Bool value = elm_fileselector_entry_inwin_mode_get(fs_en);
elm_fileselector_entry_inwin_mode_set(fs_en, !value);
printf("Inwin mode set to: %s\n", value ? "false" : "true");
}
static void
_folder_only_toggle(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *fs_en = data;
Evas_Object *ic = elm_fileselector_entry_button_icon_get(fs_en);
Eina_Bool value = elm_fileselector_entry_folder_only_get(fs_en);
elm_fileselector_entry_folder_only_set(fs_en, !value);
printf("Folder only flag set to: %s\n", value ? "false" : "true");
if (!value)
{
elm_icon_standard_set(ic, "folder");
elm_fileselector_entry_button_label_set(fs_en, "Select a folder");
}
else
{
elm_icon_standard_set(ic, "file");
elm_fileselector_entry_button_label_set(fs_en, "Select a file");
}
}
static void
_expandable_toggle(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *fs_en = data;
Eina_Bool value = elm_fileselector_entry_expandable_get(fs_en);
elm_fileselector_entry_expandable_set(fs_en, !value);
printf("Expandable flag set to: %s\n", value ? "false" : "true");
}
static void
_disabled_toggle(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *fs_en = data;
Eina_Bool value = elm_object_disabled_get(fs_en);
elm_object_disabled_set(fs_en, !value);
printf("Disabled flag set to: %s\n", value ? "false" : "true");
}
void
test_fileselector_entry(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *win, *bg, *vbox, *hbox, *ic, *bt, *fs_en, *en, *lb;
win = elm_win_add(NULL, "fileselector entry", ELM_WIN_BASIC);
elm_win_title_set(win, "File Selector Entry");
elm_win_autodel_set(win, 1);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
vbox = elm_box_add(win);
elm_win_resize_object_add(win, vbox);
evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(vbox);
vbox = elm_box_add(win);
evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, vbox);
evas_object_show(vbox);
/* file selector entry */
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "file");
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
fs_en = elm_fileselector_entry_add(win);
elm_fileselector_entry_button_label_set(fs_en, "Select a file");
elm_fileselector_entry_button_icon_set(fs_en, ic);
elm_fileselector_entry_inwin_mode_set(fs_en, EINA_TRUE);
evas_object_size_hint_weight_set(fs_en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(fs_en, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(vbox, fs_en);
evas_object_show(fs_en);
evas_object_show(ic);
/* attribute setting buttons */
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(vbox, hbox);
evas_object_show(hbox);
bt = elm_button_add(win);
elm_button_label_set(bt, "Toggle inwin mode");
evas_object_smart_callback_add(bt, "clicked", _inwin_mode_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_button_label_set(bt, "Toggle folder only mode");
evas_object_smart_callback_add(bt, "clicked", _folder_only_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_button_label_set(bt, "Toggle expandable mode");
evas_object_smart_callback_add(bt, "clicked", _expandable_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
lb = elm_label_add(win);
elm_label_label_set(lb, "Last selection:");
elm_box_pack_end(vbox, lb);
evas_object_show(lb);
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(vbox, hbox);
evas_object_show(hbox);
bt = elm_button_add(win);
elm_button_label_set(bt, "Toggle disabled");
evas_object_smart_callback_add(bt, "clicked", _disabled_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
en = elm_entry_add(win);
elm_entry_line_wrap_set(en, EINA_FALSE);
elm_entry_editable_set(en, EINA_FALSE);
evas_object_smart_callback_add(fs_en, "file,chosen", _file_chosen, en);
elm_box_pack_end(vbox, en);
evas_object_show(en);
evas_object_resize(win, 400, 500);
evas_object_show(win);
}
#endif

View File

@ -36,6 +36,7 @@ elm_check.c \
elm_clock.c \
elm_fileselector.c \
elm_fileselector_button.c \
elm_fileselector_entry.c \
elm_genlist.c \
elm_hoversel.c \
elm_list.c \

View File

@ -0,0 +1,247 @@
#include "private.h"
typedef struct _Elm_Params_fileselector_entry
{
Elm_Params base;
Evas_Object *icon;
struct {
const char *path;
Eina_Bool is_save:1;
Eina_Bool is_save_set:1;
Eina_Bool folder_only:1;
Eina_Bool folder_only_set:1;
Eina_Bool expandable:1;
Eina_Bool expandable_set:1;
Eina_Bool inwin_mode:1;
Eina_Bool inwin_mode_set:1;
} fs;
} Elm_Params_fileselector_entry;
static void
external_fileselector_entry_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
{
const Elm_Params_fileselector_entry *p;
if (to_params) p = to_params;
else if (from_params) p = from_params;
else return;
if (p->base.label)
elm_fileselector_entry_button_label_set(obj, p->base.label);
if (p->icon) elm_fileselector_entry_button_icon_set(obj, p->icon);
if (p->fs.path) elm_fileselector_entry_selected_set(obj, p->fs.path);
if (p->fs.is_save_set)
elm_fileselector_entry_is_save_set(obj, p->fs.is_save);
if (p->fs.folder_only_set)
elm_fileselector_entry_folder_only_set(obj, p->fs.folder_only);
if (p->fs.expandable_set)
elm_fileselector_entry_expandable_set(obj, p->fs.expandable);
if (p->fs.inwin_mode_set)
elm_fileselector_entry_inwin_mode_set(obj, p->fs.inwin_mode);
}
static Eina_Bool
external_fileselector_entry_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
{
if (!strcmp(param->name, "label"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
{
elm_fileselector_entry_button_label_set(obj, param->s);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "icon"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
{
Evas_Object *icon = external_common_param_icon_get(obj, param);
if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
elm_fileselector_entry_button_icon_set(obj, icon);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "path"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
{
elm_fileselector_entry_selected_set(obj, param->s);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "save"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
elm_fileselector_entry_is_save_set(obj, param->i);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "folder only"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
elm_fileselector_entry_folder_only_set(obj, param->i);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "expandable"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
elm_fileselector_entry_expandable_set(obj, param->i);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "inwin mode"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
elm_fileselector_entry_inwin_mode_set(obj, param->i);
return EINA_TRUE;
}
}
ERR("unknown parameter '%s' of type '%s'",
param->name, edje_external_param_type_str(param->type));
return EINA_FALSE;
}
static Eina_Bool
external_fileselector_entry_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
{
if (!strcmp(param->name, "label"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
{
param->s = elm_fileselector_entry_button_label_get(obj);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "icon"))
{
/* not easy to get icon name back from live object */
return EINA_FALSE;
}
else if (!strcmp(param->name, "path"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
{
param->s = elm_fileselector_entry_selected_get(obj);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "save"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
param->i = elm_fileselector_entry_is_save_get(obj);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "folder only"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
param->i = elm_fileselector_entry_folder_only_get(obj);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "expandable"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
param->i = elm_fileselector_entry_expandable_get(obj);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "inwin mode"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
param->i = elm_fileselector_entry_inwin_mode_get(obj);
return EINA_TRUE;
}
}
ERR("unknown parameter '%s' of type '%s'",
param->name, edje_external_param_type_str(param->type));
return EINA_FALSE;
}
static void *
external_fileselector_entry_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
{
Elm_Params_fileselector_entry *mem;
Edje_External_Param *param;
const Eina_List *l;
mem = external_common_params_parse(Elm_Params_fileselector_entry,
data, obj, params);
if (!mem)
return NULL;
external_common_icon_param_parse(&mem->icon, obj, params);
EINA_LIST_FOREACH(params, l, param)
{
if (!strcmp(param->name, "path"))
mem->fs.path = eina_stringshare_add(param->s);
else if (!strcmp(param->name, "save"))
{
mem->fs.is_save = !!param->i;
mem->fs.is_save_set = EINA_TRUE;
}
else if (!strcmp(param->name, "folder only"))
{
mem->fs.folder_only = !!param->i;
mem->fs.folder_only_set = EINA_TRUE;
}
else if (!strcmp(param->name, "expandable"))
{
mem->fs.expandable = !!param->i;
mem->fs.expandable_set = EINA_TRUE;
}
else if (!strcmp(param->name, "inwin mode"))
{
mem->fs.inwin_mode = !!param->i;
mem->fs.inwin_mode_set = EINA_TRUE;
}
}
return mem;
}
static Evas_Object *external_fileselector_entry_content_get(void *data __UNUSED__,
const Evas_Object *obj, const char *content)
{
ERR("so content");
return NULL;
}
static void
external_fileselector_entry_params_free(void *params)
{
Elm_Params_fileselector_entry *mem = params;
if (mem->fs.path)
eina_stringshare_del(mem->fs.path);
external_common_params_free(params);
}
static Edje_External_Param_Info external_fileselector_entry_params[] = {
DEFINE_EXTERNAL_COMMON_PARAMS,
EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
EDJE_EXTERNAL_PARAM_INFO_STRING("path"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("save"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("folder only"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("expandable"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("inwin mode"),
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
};
DEFINE_EXTERNAL_ICON_ADD(fileselector_entry, "fileselector_entry");
DEFINE_EXTERNAL_TYPE_SIMPLE(fileselector_entry, "File Selector Entry");

View File

@ -6,6 +6,7 @@ DEFINE_TYPE(check)
DEFINE_TYPE(clock)
DEFINE_TYPE(fileselector)
DEFINE_TYPE(fileselector_button)
DEFINE_TYPE(fileselector_entry)
DEFINE_TYPE(genlist)
DEFINE_TYPE(hoversel)
DEFINE_TYPE(list)

View File

@ -554,6 +554,29 @@ extern "C" {
EAPI void elm_fileselector_button_selected_set(Evas_Object *obj, const char *path);
EAPI const char *elm_fileselector_button_selected_get(const Evas_Object *obj);
EAPI Evas_Object *elm_fileselector_entry_add(Evas_Object *parent);
EAPI void elm_fileselector_entry_button_label_set(Evas_Object *obj, const char *label);
EAPI const char *elm_fileselector_entry_button_label_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_button_icon_set(Evas_Object *obj, Evas_Object *icon);
EAPI Evas_Object *elm_fileselector_entry_button_icon_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_window_title_set(Evas_Object *obj, const char *title);
EAPI const char *elm_fileselector_entry_window_title_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_window_size_set(Evas_Object *obj, Evas_Coord width, Evas_Coord height);
EAPI void elm_fileselector_entry_window_size_get(const Evas_Object *obj, Evas_Coord *width, Evas_Coord *height);
EAPI void elm_fileselector_entry_path_set(Evas_Object *obj, const char *path);
EAPI const char *elm_fileselector_entry_path_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_expandable_set(Evas_Object *obj, Eina_Bool value);
EAPI Eina_Bool elm_fileselector_entry_expandable_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_folder_only_set(Evas_Object *obj, Eina_Bool value);
EAPI Eina_Bool elm_fileselector_entry_folder_only_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_is_save_set(Evas_Object *obj, Eina_Bool value);
EAPI Eina_Bool elm_fileselector_entry_is_save_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_inwin_mode_set(Evas_Object *obj, Eina_Bool value);
EAPI Eina_Bool elm_fileselector_entry_inwin_mode_get(const Evas_Object *obj);
EAPI void elm_fileselector_entry_selected_set(Evas_Object *obj, const char *path);
EAPI const char *elm_fileselector_entry_selected_get(const Evas_Object *obj);
/* available styles:
* default
* anchor

View File

@ -90,6 +90,7 @@ elc_anchorblock.c \
elc_anchorview.c \
elc_fileselector.c \
elc_fileselector_button.c \
elc_fileselector_entry.c \
elc_hoversel.c \
elc_notepad.c \
elc_scrolled_entry.c \

View File

@ -0,0 +1,599 @@
#include <Elementary.h>
#include "elm_priv.h"
/**
* @defgroup File_Selector_Entry File Selector Entry
*
* An entry that shows to enter/display path and have an associated
* button to allow selecting the file from a dialog.
*
* The button, when clicked, creates an Elementary window (or inner
* window) with an Elementary File Selector within. When a file is
* chosen, the (inner) window is closed and the selected file is
* exposed as an evas_object_smart_callback_call() of the button.
*/
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
{
Evas_Object *edje;
Evas_Object *button;
Evas_Object *entry;
};
static const char *widtype = NULL;
static const char SIG_CHANGED[] = "changed";
static const char SIG_ACTIVATED[] = "activated";
static const char SIG_PRESS[] = "press";
static const char SIG_LONGPRESSED[] = "longpressed";
static const char SIG_CLICKED[] = "clicked";
static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
static const char SIG_FOCUSED[] = "focused";
static const char SIG_UNFOCUSED[] = "unfocused";
static const char SIG_SELECTION_PASTE[] = "selection,paste";
static const char SIG_SELECTION_COPY[] = "selection,copy";
static const char SIG_SELECTION_CUT[] = "selection,cut";
static const char SIG_UNPRESSED[] = "unpressed";
static const char SIG_FILE_CHOSEN[] = "file,chosen";
static const Evas_Smart_Cb_Description _signals[] =
{
{SIG_CHANGED, ""},
{SIG_ACTIVATED, ""},
{SIG_PRESS, ""},
{SIG_LONGPRESSED, ""},
{SIG_CLICKED, ""},
{SIG_CLICKED_DOUBLE, ""},
{SIG_FOCUSED, ""},
{SIG_UNFOCUSED, ""},
{SIG_SELECTION_PASTE, ""},
{SIG_SELECTION_COPY, ""},
{SIG_SELECTION_CUT, ""},
{SIG_UNPRESSED, ""},
{SIG_FILE_CHOSEN, "s"},
{NULL, NULL}
};
#define SIG_FWD(name) \
static void \
_##name##_fwd(void *data, Evas_Object *obj __UNUSED__, void *event_info) \
{ \
evas_object_smart_callback_call(data, SIG_##name, event_info); \
}
SIG_FWD(CHANGED)
SIG_FWD(PRESS)
SIG_FWD(LONGPRESSED)
SIG_FWD(CLICKED)
SIG_FWD(CLICKED_DOUBLE)
SIG_FWD(FOCUSED)
SIG_FWD(UNFOCUSED)
SIG_FWD(SELECTION_PASTE)
SIG_FWD(SELECTION_COPY)
SIG_FWD(SELECTION_CUT)
SIG_FWD(UNPRESSED)
#undef SIG_FWD
static void
_FILE_CHOSEN_fwd(void *data, Evas_Object *obj __UNUSED__, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
const char *file = event_info;
elm_scrolled_entry_entry_set(wd->entry, file);
evas_object_smart_callback_call(data, SIG_FILE_CHOSEN, event_info);
}
static void
_ACTIVATED_fwd(void *data, Evas_Object *obj __UNUSED__, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
const char *file = elm_scrolled_entry_entry_get(wd->entry);
elm_fileselector_button_path_set(wd->button, file);
evas_object_smart_callback_call(data, SIG_ACTIVATED, event_info);
}
static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
free(wd);
}
static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1;
if (!wd) return;
edje_object_size_min_calc(wd->edje, &minw, &minh);
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, -1, -1);
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->edje, "elm,action,focus", "elm");
evas_object_focus_set(wd->edje, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->edje, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->edje, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
_elm_theme_object_set
(obj, wd->edje, "fileselector_entry", "base", elm_widget_style_get(obj));
if (elm_object_disabled_get(obj))
edje_object_signal_emit(wd->edje, "elm,state,disabled", "elm");
edje_object_part_swallow(obj, "elm.swallow.button", wd->button);
edje_object_part_swallow(obj, "elm.swallow.entry", wd->entry);
edje_object_message_signal_process(wd->edje);
edje_object_scale_set
(wd->edje, elm_widget_scale_get(obj) * _elm_config->scale);
_sizing_eval(obj);
}
static void
_disable_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_Bool val = elm_widget_disabled_get(obj);
if (!wd) return;
if (val)
edje_object_signal_emit(wd->edje, "elm,state,disabled", "elm");
else
edje_object_signal_emit(wd->edje, "elm,state,enabled", "elm");
elm_widget_disabled_set(wd->button, val);
elm_widget_disabled_set(wd->entry, val);
}
static void
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
_sizing_eval(data);
}
/**
* Add a new file selector entry into the parent object.
*
* @param parent The parent object
* @return The new object or NULL if it cannot be created
*
* @ingroup File_Selector_Entry
*/
EAPI Evas_Object *
elm_fileselector_entry_add(Evas_Object *parent)
{
Evas_Object *obj;
Evas *e = evas_object_evas_get(parent);
Widget_Data *wd;
Eina_List *l;
wd = ELM_NEW(Widget_Data);
obj = elm_widget_add(e);
ELM_SET_WIDTYPE(widtype, "fileselector_entry");
elm_widget_type_set(obj, "fileselector_entry");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_disable_hook_set(obj, _disable_hook);
elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_theme_hook_set(obj, _theme_hook);
wd->edje = edje_object_add(e);
_elm_theme_object_set(obj, wd->edje, "fileselector_entry", "base", "default");
elm_widget_resize_object_set(obj, wd->edje);
wd->button = elm_fileselector_button_add(obj);
edje_object_part_swallow(wd->edje, "elm.swallow.button", wd->button);
elm_widget_sub_object_add(obj, wd->button);
evas_object_event_callback_add
(wd->button, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
#define SIG_FWD(name) \
evas_object_smart_callback_add(wd->button, SIG_##name, _##name##_fwd, obj)
SIG_FWD(CLICKED);
SIG_FWD(UNPRESSED);
SIG_FWD(FILE_CHOSEN);
#undef SIG_FWD
wd->entry = elm_scrolled_entry_add(obj);
elm_scrolled_entry_single_line_set(wd->entry, EINA_TRUE);
elm_scrolled_entry_editable_set(wd->entry, EINA_TRUE);
edje_object_part_swallow(wd->edje, "elm.swallow.entry", wd->entry);
elm_widget_sub_object_add(obj, wd->entry);
evas_object_event_callback_add
(wd->entry, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
#define SIG_FWD(name) \
evas_object_smart_callback_add(wd->entry, SIG_##name, _##name##_fwd, obj)
SIG_FWD(CHANGED);
SIG_FWD(ACTIVATED);
SIG_FWD(PRESS);
SIG_FWD(LONGPRESSED);
SIG_FWD(CLICKED);
SIG_FWD(CLICKED_DOUBLE);
SIG_FWD(FOCUSED);
SIG_FWD(UNFOCUSED);
SIG_FWD(SELECTION_PASTE);
SIG_FWD(SELECTION_COPY);
SIG_FWD(SELECTION_CUT);
#undef SIG_FWD
_sizing_eval(obj);
// TODO: convert Elementary to subclassing of Evas_Smart_Class
// TODO: and save some bytes, making descriptions per-class and not instance!
evas_object_smart_callbacks_descriptions_set(obj, _signals);
return obj;
}
/**
* Set the label used in the file selector entry.
*
* @param obj The entry object
* @param label The text label text to be displayed on the entry
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_button_label_set(Evas_Object *obj, const char *label)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_label_set(wd->button, label);
}
EAPI const char *
elm_fileselector_entry_button_label_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return elm_fileselector_button_label_get(wd->button);
}
/**
* Set the path to start the entry's file selector with, when clicked.
*
* @param obj The entry object
* @param path Path to a file/directory
*
* Default path is "HOME" environment variable's value.
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_selected_set(Evas_Object *obj, const char *path)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_selected_set(wd->button, path);
}
/**
* Get the <b>last</b> path which the entry's file selector was set to.
*
* @param obj The entry object
* @param path Path to a file/directory
*
* Default path is "HOME" environment variable's value.
*
* @ingroup File_Selector_Entry
*/
EAPI const char *
elm_fileselector_entry_selected_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return elm_fileselector_button_selected_get(wd->button);
}
/**
* Set the title of the file selector entry's window.
*
* @param obj The entry object
* @param title The title string
*
* Note that it will only take any effect if the fileselector entry
* not at "inwin mode".
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_window_title_set(Evas_Object *obj, const char *title)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_window_title_set(wd->button, title);
}
/**
* Get the title of the file selector entry's window.
*
* @param obj The entry object
*
* @ingroup File_Selector_Entry
*/
EAPI const char *
elm_fileselector_entry_window_title_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return elm_fileselector_button_window_title_get(wd->button);
}
/**
* Set the size of the file selector entry's window.
*
* @param obj The entry object
* @param width The width
* @param height The height
*
* Note that it will only take any effect if the fileselector entry not at
* "inwin mode". Default size for the window (when applicable) is 400x400.
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_window_size_set(Evas_Object *obj, Evas_Coord width, Evas_Coord height)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_window_size_set(wd->button, width, height);
}
/**
* Get the size of the file selector entry's window.
*
* @param obj The entry object
* @param width Pointer into which to store the width value
* @param height Pointer into which to store the height value
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_window_size_get(const Evas_Object *obj, Evas_Coord *width, Evas_Coord *height)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_window_size_get(wd->button, width, height);
}
/**
* Set the starting path of the file selector entry's window.
*
* @param obj The entry object
* @param path The path string
*
* It must be a <b>directory</b> path.
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_path_set(Evas_Object *obj, const char *path)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_path_set(wd->button, path);
elm_scrolled_entry_entry_set(wd->entry, path);
}
/**
* Get the <b>last</b> path of the file selector entry's window.
*
* @param obj The entry object
*
* @ingroup File_Selector_Entry
*/
EAPI const char *
elm_fileselector_entry_path_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return elm_scrolled_entry_entry_get(wd->entry);
}
/**
* Set whether the entry's file selector is to present itself as an
* Elementary Generic List (which will expand its entries for nested
* directories) or as canonical list, which will be rendered again
* with the contents of each selected directory.
*
* @param obj The entry object
* @param value The expandable flag
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_expandable_set(Evas_Object *obj, Eina_Bool value)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_expandable_set(wd->button, value);
}
/**
* Get the entry's file selector expandable flag.
*
* @param obj The entry object
* @return value The expandable flag
*
* @ingroup File_Selector_Entry
*/
EAPI Eina_Bool
elm_fileselector_entry_expandable_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return elm_fileselector_button_expandable_get(wd->button);
}
/**
* Set whether the entry's file selector list is to display folders
* only or the directory contents, as well.
*
* @param obj The entry object
* @param value The "folder only" flag
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_folder_only_set(Evas_Object *obj, Eina_Bool value)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_folder_only_set(wd->button, value);
}
/**
* Get the entry's file selector "folder only" flag.
*
* @param obj The entry object
* @return value The "folder only" flag
*
* @ingroup File_Selector_Entry
*/
EAPI Eina_Bool
elm_fileselector_entry_folder_only_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return elm_fileselector_button_folder_only_get(wd->button);
}
/**
* Set whether the entry's file selector has an editable text entry
* which will hold its current selection.
*
* @param obj The entry object
* @param value The "is save" flag
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_is_save_set(Evas_Object *obj, Eina_Bool value)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_is_save_set(wd->button, value);
}
/**
* Get the entry's file selector "is save" flag.
*
* @param obj The entry object
* @return value The "is save" flag
*
* @ingroup File_Selector_Entry
*/
EAPI Eina_Bool
elm_fileselector_entry_is_save_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return elm_fileselector_button_is_save_get(wd->button);
}
/**
* Set whether the entry's file selector will raise an Elementary
* Inner Window, instead of a dedicated Elementary Window. By default,
* it won't.
*
* @param obj The entry object
* @param value The "inwin mode" flag
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_inwin_mode_set(Evas_Object *obj, Eina_Bool value)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_inwin_mode_set(wd->button, value);
}
/**
* Get the entry's file selector "inwin mode" flag.
*
* @param obj The entry object
* @return value The "inwin mode" flag
*
* @ingroup File_Selector_Entry
*/
EAPI Eina_Bool
elm_fileselector_entry_inwin_mode_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return elm_fileselector_button_inwin_mode_get(wd->button);
}
/**
* Set the icon used for the entry
*
* Once the icon object is set, a previously set one will be deleted.
*
* @param obj The entry object
* @param icon The image for the entry
*
* @ingroup File_Selector_Entry
*/
EAPI void
elm_fileselector_entry_button_icon_set(Evas_Object *obj, Evas_Object *icon)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_fileselector_button_icon_set(wd->button, icon);
}
/**
* Get the icon used for the entry
*
* @param obj The entry object
* @return The image for the entry
*
* @ingroup File_Selector_Entry
*/
EAPI Evas_Object *
elm_fileselector_entry_button_icon_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return elm_fileselector_button_icon_get(wd->button);
}