forked from enlightenment/efl
Review Elm_fileselector_button.
Removed the selected_{get,set} because is the same of path_{get,set}. Now it uses elm_button like hoversel. SVN revision: 53622
This commit is contained in:
parent
0e436c7431
commit
6e9551b087
|
@ -5,9 +5,14 @@ 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);
|
||||
const char *file = event_info;
|
||||
if (file)
|
||||
{
|
||||
elm_entry_entry_set(entry, file);
|
||||
printf("File chosen: %s\n", file);
|
||||
}
|
||||
else
|
||||
printf("File selection canceled.\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -30,7 +30,7 @@ external_fileselector_button_state_set(void *data __UNUSED__, Evas_Object *obj,
|
|||
if (p->base.label)
|
||||
elm_fileselector_button_label_set(obj, p->base.label);
|
||||
if (p->icon) elm_fileselector_button_icon_set(obj, p->icon);
|
||||
if (p->fs.path) elm_fileselector_button_selected_set(obj, p->fs.path);
|
||||
if (p->fs.path) elm_fileselector_button_path_set(obj, p->fs.path);
|
||||
if (p->fs.is_save_set)
|
||||
elm_fileselector_button_is_save_set(obj, p->fs.is_save);
|
||||
if (p->fs.folder_only_set)
|
||||
|
@ -66,7 +66,7 @@ external_fileselector_button_param_set(void *data __UNUSED__, Evas_Object *obj,
|
|||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
||||
{
|
||||
elm_fileselector_button_selected_set(obj, param->s);
|
||||
elm_fileselector_button_path_set(obj, param->s);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ external_fileselector_button_param_get(void *data __UNUSED__, const Evas_Object
|
|||
{
|
||||
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
||||
{
|
||||
param->s = elm_fileselector_button_selected_get(obj);
|
||||
param->s = elm_fileselector_button_path_get(obj);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -572,8 +572,6 @@ extern "C" {
|
|||
EAPI Eina_Bool elm_fileselector_button_is_save_get(const Evas_Object *obj);
|
||||
EAPI void elm_fileselector_button_inwin_mode_set(Evas_Object *obj, Eina_Bool value);
|
||||
EAPI Eina_Bool elm_fileselector_button_inwin_mode_get(const Evas_Object *obj);
|
||||
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);
|
||||
|
|
|
@ -14,9 +14,8 @@ typedef struct _Widget_Data Widget_Data;
|
|||
|
||||
struct _Widget_Data
|
||||
{
|
||||
Evas_Object *btn, *icon, *fs;
|
||||
Evas_Object *self, *btn, *fs, *fsw;
|
||||
const char *window_title;
|
||||
const char *btn_label;
|
||||
Evas_Coord w, h;
|
||||
struct {
|
||||
const char *path;
|
||||
|
@ -36,42 +35,16 @@ static void _theme_hook(Evas_Object *obj);
|
|||
static void _disable_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
||||
static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _signal_pressed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _signal_unpressed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _on_focus_hook(void *data, Evas_Object *obj);
|
||||
static void _selection_done(void *data, Evas_Object *obj, void *event_info);
|
||||
static void _activate(Evas_Object *obj);
|
||||
static void _activate_hook(Evas_Object *obj);
|
||||
static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
|
||||
Evas_Callback_Type type, void *event_info);
|
||||
static void _activate(Widget_Data *wd);
|
||||
|
||||
#define SIG_CLICKED "clicked"
|
||||
#define SIG_UNPRESSED "unpressed"
|
||||
#define SIG_FILE_CHOSEN "file,chosen"
|
||||
static const Evas_Smart_Cb_Description _signals[] =
|
||||
{
|
||||
{SIG_CLICKED, ""},
|
||||
{SIG_UNPRESSED, ""},
|
||||
{SIG_FILE_CHOSEN, "s"},
|
||||
{NULL, NULL}
|
||||
static const char SIG_FILE_CHOSEN[] = "file,chosen";
|
||||
static const Evas_Smart_Cb_Description _signals[] = {
|
||||
{SIG_FILE_CHOSEN, "s"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
|
||||
{
|
||||
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
||||
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
|
||||
if (strcmp(ev->keyname, "Return") && strcmp(ev->keyname, "space"))
|
||||
return EINA_FALSE;
|
||||
_activate(obj);
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
|
@ -81,7 +54,6 @@ _del_hook(Evas_Object *obj)
|
|||
wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
|
||||
if (wd->btn_label) eina_stringshare_del(wd->btn_label);
|
||||
if (wd->window_title) eina_stringshare_del(wd->window_title);
|
||||
if (wd->fsd.path) eina_stringshare_del(wd->fsd.path);
|
||||
if (wd->fs)
|
||||
|
@ -98,39 +70,17 @@ _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->btn, "elm,action,focus", "elm");
|
||||
evas_object_focus_set(wd->btn, EINA_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_signal_emit(wd->btn, "elm,action,unfocus", "elm");
|
||||
evas_object_focus_set(wd->btn, EINA_FALSE);
|
||||
}
|
||||
elm_widget_focus_steal(wd->btn);
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
char buf[4096];
|
||||
if (!wd) return;
|
||||
_elm_theme_object_set(obj, wd->btn, "button", "base", elm_widget_style_get(obj));
|
||||
if (wd->icon)
|
||||
edje_object_part_swallow(wd->btn, "elm.swallow.content", wd->icon);
|
||||
if (wd->btn_label)
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
|
||||
else
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
|
||||
if (wd->icon)
|
||||
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
|
||||
else
|
||||
edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
|
||||
edje_object_part_text_set(wd->btn, "elm.text", wd->btn_label);
|
||||
if (elm_object_disabled_get(obj))
|
||||
edje_object_signal_emit(wd->btn, "elm,state,disabled", "elm");
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
edje_object_scale_set(wd->btn,
|
||||
elm_widget_scale_get(obj) * _elm_config->scale);
|
||||
snprintf(buf, sizeof(buf), "fileselector_button/%s", elm_widget_style_get(obj));
|
||||
elm_object_style_set(wd->btn, buf);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
|
@ -139,10 +89,7 @@ _disable_hook(Evas_Object *obj)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
if (elm_widget_disabled_get(obj))
|
||||
edje_object_signal_emit(wd->btn, "elm,state,disabled", "elm");
|
||||
else
|
||||
edje_object_signal_emit(wd->btn, "elm,state,enabled", "elm");
|
||||
elm_widget_disabled_set(wd->btn, elm_widget_disabled_get(obj));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -150,11 +97,9 @@ _sizing_eval(Evas_Object *obj)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
|
||||
if (!wd) return;
|
||||
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
||||
edje_object_size_min_restricted_calc(wd->btn, &minw, &minh, minw, minh);
|
||||
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
||||
evas_object_size_hint_min_get(wd->btn, &minw, &minh);
|
||||
evas_object_size_hint_max_get(wd->btn, &maxw, &maxh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
|
@ -164,48 +109,20 @@ _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *even
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
if (!wd) return;
|
||||
if (obj != wd->icon) return;
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Object *sub = event_info;
|
||||
if (!wd) return;
|
||||
if (sub == wd->icon)
|
||||
{
|
||||
edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
|
||||
evas_object_event_callback_del_full(sub,
|
||||
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
wd->icon = NULL;
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_activate(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
|
||||
evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
|
||||
|
||||
/* safe guard when the theme does not emit the 'unpress' signal */
|
||||
_signal_unpressed(obj, wd->btn, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_activate_hook(Evas_Object *obj)
|
||||
{
|
||||
_activate(obj);
|
||||
Widget_Data *wd;
|
||||
wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
_activate(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_signal_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||
_button_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
_activate(data);
|
||||
}
|
||||
|
@ -213,19 +130,10 @@ _signal_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __
|
|||
static Evas_Object *
|
||||
_parent_win_get(Evas_Object *obj)
|
||||
{
|
||||
Evas_Object *ret;
|
||||
while (obj && strcmp(elm_widget_type_get(obj), "win"))
|
||||
obj = elm_object_parent_widget_get(obj);
|
||||
|
||||
ret = elm_object_parent_widget_get(obj);
|
||||
if (!ret) return NULL;
|
||||
|
||||
if (strcmp(elm_widget_type_get(ret), "win") != 0)
|
||||
{
|
||||
DBG("Widget type (%s) is not \"win\", going up\n",
|
||||
elm_widget_type_get(ret));
|
||||
return _parent_win_get(ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return obj;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
|
@ -247,44 +155,28 @@ _new_window_add(Widget_Data *wd)
|
|||
}
|
||||
|
||||
static void
|
||||
_fs_launch(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||
_activate(Widget_Data *wd)
|
||||
{
|
||||
Evas_Object *fs_btn, *win = NULL, *iw = NULL;
|
||||
Eina_Bool win_fallback;
|
||||
Widget_Data *wd;
|
||||
Eina_Bool is_inwin = EINA_FALSE;
|
||||
|
||||
fs_btn = data;
|
||||
wd = elm_widget_data_get(fs_btn);
|
||||
|
||||
if (!wd) return;
|
||||
if (wd->fs) return;
|
||||
|
||||
win_fallback = EINA_FALSE;
|
||||
if (wd->inwin_mode)
|
||||
{
|
||||
win = _parent_win_get(fs_btn);
|
||||
wd->fsw = _parent_win_get(wd->self);
|
||||
|
||||
if (!win)
|
||||
{
|
||||
ERR("No elementary window found as parent of the file selector "
|
||||
"button! Launching the file selector inside a new elementary"
|
||||
" window, then.");
|
||||
win_fallback = EINA_TRUE;
|
||||
}
|
||||
if (!wd->fsw)
|
||||
wd->fsw = _new_window_add(wd);
|
||||
else
|
||||
{
|
||||
iw = elm_win_inwin_add(win);
|
||||
evas_object_data_set(fs_btn, "win", iw);
|
||||
}
|
||||
{
|
||||
wd->fsw = elm_win_inwin_add(wd->fsw);
|
||||
is_inwin = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
wd->fsw = _new_window_add(wd);
|
||||
|
||||
if ((!wd->inwin_mode) || (win_fallback))
|
||||
{
|
||||
win = _new_window_add(wd);
|
||||
evas_object_data_set(fs_btn, "win", win);
|
||||
}
|
||||
|
||||
wd->fs = elm_fileselector_add(win);
|
||||
wd->fs = elm_fileselector_add(wd->fsw);
|
||||
elm_fileselector_expandable_set(wd->fs, wd->fsd.expandable);
|
||||
elm_fileselector_folder_only_set(wd->fs, wd->fsd.folder_only);
|
||||
elm_fileselector_is_save_set(wd->fs, wd->fsd.is_save);
|
||||
|
@ -292,56 +184,37 @@ _fs_launch(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSE
|
|||
evas_object_size_hint_weight_set(wd->fs, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(wd->fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_smart_callback_add(wd->fs, "done", _selection_done, fs_btn);
|
||||
evas_object_smart_callback_add(wd->fs, "done", _selection_done, wd);
|
||||
evas_object_show(wd->fs);
|
||||
|
||||
if ((wd->inwin_mode) && (!win_fallback))
|
||||
if (is_inwin)
|
||||
{
|
||||
elm_win_inwin_content_set(iw, wd->fs);
|
||||
elm_win_inwin_activate(iw);
|
||||
elm_win_inwin_content_set(wd->fsw, wd->fs);
|
||||
elm_win_inwin_activate(wd->fsw);
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_win_resize_object_add(win, wd->fs);
|
||||
evas_object_show(win);
|
||||
elm_win_resize_object_add(wd->fsw, wd->fs);
|
||||
evas_object_show(wd->fsw);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_selection_done(void *data, Evas_Object *obj __UNUSED__, void *event_info)
|
||||
{
|
||||
Evas_Object *fs_btn, *win;
|
||||
const char *file;
|
||||
Widget_Data *wd;
|
||||
|
||||
file = event_info;
|
||||
fs_btn = data;
|
||||
|
||||
wd = elm_widget_data_get(fs_btn);
|
||||
const char *file = event_info;
|
||||
Widget_Data *wd = data;
|
||||
Evas_Object *del;
|
||||
if (!wd) return;
|
||||
|
||||
win = evas_object_data_del(fs_btn, "win");
|
||||
|
||||
evas_object_smart_callback_call(fs_btn, SIG_FILE_CHOSEN, event_info);
|
||||
if (file) eina_stringshare_replace(&wd->fsd.path, file);
|
||||
|
||||
del = wd->fsw;
|
||||
wd->fs = NULL;
|
||||
evas_object_del(win);
|
||||
}
|
||||
wd->fsw = NULL;
|
||||
evas_object_del(del);
|
||||
|
||||
static void
|
||||
_signal_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
if (!wd) return;
|
||||
}
|
||||
|
||||
static void
|
||||
_signal_unpressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
if (!wd) return;
|
||||
evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
|
||||
evas_object_smart_callback_call(wd->self, SIG_FILE_CHOSEN, event_info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -370,6 +243,7 @@ elm_fileselector_button_add(Evas_Object *parent)
|
|||
ELM_SET_WIDTYPE(widtype, "fileselector_button");
|
||||
elm_widget_type_set(obj, "fileselector_button");
|
||||
elm_widget_sub_object_add(parent, obj);
|
||||
wd->self = 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);
|
||||
|
@ -377,27 +251,15 @@ elm_fileselector_button_add(Evas_Object *parent)
|
|||
elm_widget_disable_hook_set(obj, _disable_hook);
|
||||
elm_widget_can_focus_set(obj, EINA_TRUE);
|
||||
elm_widget_activate_hook_set(obj, _activate_hook);
|
||||
elm_widget_event_hook_set(obj, _event_hook);
|
||||
|
||||
wd->btn = edje_object_add(e);
|
||||
_elm_theme_object_set(obj, wd->btn, "button", "base", "default");
|
||||
edje_object_signal_callback_add(wd->btn, "elm,action,click", "",
|
||||
_signal_clicked, obj);
|
||||
edje_object_signal_callback_add(wd->btn, "elm,action,click", "",
|
||||
_fs_launch, obj);
|
||||
edje_object_signal_callback_add(wd->btn, "elm,action,press", "",
|
||||
_signal_pressed, obj);
|
||||
edje_object_signal_callback_add(wd->btn, "elm,action,unpress", "",
|
||||
_signal_unpressed, obj);
|
||||
wd->btn = elm_button_add(parent);
|
||||
elm_widget_resize_object_set(obj, wd->btn);
|
||||
evas_object_event_callback_add(wd->btn, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
evas_object_smart_callback_add(wd->btn, "clicked", _button_clicked, wd);
|
||||
elm_widget_sub_object_add(obj, wd->btn);
|
||||
|
||||
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||
|
||||
_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);
|
||||
_theme_hook(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -414,66 +276,26 @@ elm_fileselector_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;
|
||||
eina_stringshare_replace(&wd->btn_label, label);
|
||||
if (label)
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
|
||||
else
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
edje_object_part_text_set(wd->btn, "elm.text", label);
|
||||
_sizing_eval(obj);
|
||||
elm_button_label_set(wd->btn, label);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the label used in the file selector button.
|
||||
*
|
||||
* @param obj The button object
|
||||
* @return The button label
|
||||
*
|
||||
* @ingroup File_Selector_Button
|
||||
*/
|
||||
EAPI const char *
|
||||
elm_fileselector_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 wd->btn_label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path to start the button's file selector with, when clicked.
|
||||
*
|
||||
* @param obj The button object
|
||||
* @param path Path to a file/directory
|
||||
*
|
||||
* Default path is "HOME" environment variable's value.
|
||||
*
|
||||
* @ingroup File_Selector_Button
|
||||
*/
|
||||
EAPI void
|
||||
elm_fileselector_button_selected_set(Evas_Object *obj, const char *path)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
||||
if (!wd) return;
|
||||
eina_stringshare_replace(&wd->fsd.path, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the <b>last</b> path which the button's file selector was set to.
|
||||
*
|
||||
* @param obj The button object
|
||||
* @param path Path to a file/directory
|
||||
*
|
||||
* Default path is "HOME" environment variable's value.
|
||||
*
|
||||
* @ingroup File_Selector_Button
|
||||
*/
|
||||
EAPI const char *
|
||||
elm_fileselector_button_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 wd->fsd.path;
|
||||
return elm_button_label_get(wd->btn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -495,12 +317,16 @@ elm_fileselector_button_window_title_set(Evas_Object *obj, const char *title)
|
|||
|
||||
if (!wd) return;
|
||||
eina_stringshare_replace(&wd->window_title, title);
|
||||
|
||||
if (wd->fsw)
|
||||
elm_win_title_set(wd->fsw, wd->window_title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the file selector button's window.
|
||||
*
|
||||
* @param obj The button object
|
||||
* @return Title of the file selector button's window
|
||||
*
|
||||
* @ingroup File_Selector_Button
|
||||
*/
|
||||
|
@ -535,6 +361,9 @@ elm_fileselector_button_window_size_set(Evas_Object *obj, Evas_Coord width, Evas
|
|||
if (!wd) return;
|
||||
wd->w = width;
|
||||
wd->h = height;
|
||||
|
||||
if (wd->fsw)
|
||||
evas_object_resize(wd->fsw, wd->w, wd->h);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -564,6 +393,7 @@ elm_fileselector_button_window_size_get(const Evas_Object *obj, Evas_Coord *widt
|
|||
* @param path The path string
|
||||
*
|
||||
* It must be a <b>directory</b> path.
|
||||
* Default path is "HOME" environment variable's value.
|
||||
*
|
||||
* @ingroup File_Selector_Button
|
||||
*/
|
||||
|
@ -575,6 +405,10 @@ elm_fileselector_button_path_set(Evas_Object *obj, const char *path)
|
|||
|
||||
if (!wd) return;
|
||||
eina_stringshare_replace(&wd->fsd.path, path);
|
||||
|
||||
if (wd->fs)
|
||||
elm_fileselector_selected_set(wd->fs, wd->fsd.path);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -612,6 +446,9 @@ elm_fileselector_button_expandable_set(Evas_Object *obj, Eina_Bool value)
|
|||
|
||||
if (!wd) return;
|
||||
wd->fsd.expandable = value;
|
||||
|
||||
if (wd->fs)
|
||||
elm_fileselector_expandable_set(wd->fs, wd->fsd.expandable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -649,6 +486,9 @@ elm_fileselector_button_folder_only_set(Evas_Object *obj, Eina_Bool value)
|
|||
|
||||
if (!wd) return;
|
||||
wd->fsd.folder_only = value;
|
||||
|
||||
if (wd->fs)
|
||||
elm_fileselector_folder_only_set(wd->fs, wd->fsd.folder_only);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -686,6 +526,9 @@ elm_fileselector_button_is_save_set(Evas_Object *obj, Eina_Bool value)
|
|||
|
||||
if (!wd) return;
|
||||
wd->fsd.is_save = value;
|
||||
|
||||
if (wd->fs)
|
||||
elm_fileselector_is_save_set(wd->fs, wd->fsd.is_save);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -761,21 +604,12 @@ elm_fileselector_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;
|
||||
if (wd->icon == icon) return;
|
||||
if (wd->icon) evas_object_del(wd->icon);
|
||||
wd->icon = icon;
|
||||
if (icon)
|
||||
if (!wd)
|
||||
{
|
||||
elm_widget_sub_object_add(obj, icon);
|
||||
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
|
||||
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
evas_object_del(icon);
|
||||
return;
|
||||
}
|
||||
_sizing_eval(obj);
|
||||
elm_button_icon_set(wd->btn, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -791,9 +625,8 @@ elm_fileselector_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 wd->icon;
|
||||
return elm_button_icon_get(wd->btn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -812,10 +645,5 @@ elm_fileselector_button_icon_unset(Evas_Object *obj)
|
|||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return NULL;
|
||||
if (!wd->icon) return NULL;
|
||||
Evas_Object *icon = wd->icon;
|
||||
elm_widget_sub_object_del(obj, wd->icon);
|
||||
edje_object_part_unswallow(wd->btn, wd->icon);
|
||||
wd->icon = NULL;
|
||||
return icon;
|
||||
return elm_button_icon_unset(wd->btn);
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ 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);
|
||||
elm_fileselector_button_path_set(wd->button, path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,7 +337,7 @@ 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);
|
||||
return elm_fileselector_button_path_get(wd->button);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue