2010-10-13 18:18:14 -07:00
|
|
|
#include "private.h"
|
|
|
|
|
|
|
|
typedef struct _Elm_Params_fileselector_entry
|
|
|
|
{
|
|
|
|
Elm_Params base;
|
2010-10-21 15:03:43 -07:00
|
|
|
const char *label;
|
2010-10-13 18:18:14 -07:00
|
|
|
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;
|
|
|
|
|
2010-10-21 15:03:43 -07:00
|
|
|
if (p->label)
|
2011-07-04 03:14:08 -07:00
|
|
|
elm_object_text_set(obj, p->label);
|
2012-01-09 00:06:43 -08:00
|
|
|
if (p->icon) elm_object_part_content_set(obj, "button icon", p->icon);
|
2010-10-13 18:18:14 -07:00
|
|
|
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"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
elm_object_text_set(obj, param->s);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
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_object_part_content_set(obj, "button icon", icon);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "path"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
elm_fileselector_entry_selected_set(obj, param->s);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "save"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
elm_fileselector_entry_is_save_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "folder only"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
elm_fileselector_entry_folder_only_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "expandable"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
elm_fileselector_entry_expandable_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "inwin mode"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
elm_fileselector_entry_inwin_mode_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
param->s = elm_object_text_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
/* not easy to get icon name back from live object */
|
|
|
|
return EINA_FALSE;
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "path"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
param->s = elm_fileselector_entry_selected_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "save"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
param->i = elm_fileselector_entry_is_save_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "folder only"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
param->i = elm_fileselector_entry_folder_only_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "expandable"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
param->i = elm_fileselector_entry_expandable_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "inwin mode"))
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
param->i = elm_fileselector_entry_inwin_mode_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2010-10-22 05:05:45 -07:00
|
|
|
external_fileselector_entry_params_parse(void *data __UNUSED__, Evas_Object *obj, const Eina_List *params)
|
2010-10-13 18:18:14 -07:00
|
|
|
{
|
|
|
|
Elm_Params_fileselector_entry *mem;
|
|
|
|
Edje_External_Param *param;
|
|
|
|
const Eina_List *l;
|
|
|
|
|
2010-10-21 15:03:43 -07:00
|
|
|
mem = calloc(1, sizeof(Elm_Params_fileselector_entry));
|
2010-10-13 18:18:14 -07:00
|
|
|
if (!mem)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
external_common_icon_param_parse(&mem->icon, obj, params);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(params, l, param)
|
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "label"))
|
|
|
|
mem->label = eina_stringshare_add(param->s);
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *external_fileselector_entry_content_get(void *data __UNUSED__,
|
2012-01-09 00:06:43 -08:00
|
|
|
const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
|
2010-10-13 18:18:14 -07:00
|
|
|
{
|
2012-01-09 00:06:43 -08:00
|
|
|
ERR("No content.");
|
|
|
|
return NULL;
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
|
2012-01-09 00:06:43 -08:00
|
|
|
static void
|
2010-10-13 18:18:14 -07:00
|
|
|
external_fileselector_entry_params_free(void *params)
|
|
|
|
{
|
|
|
|
Elm_Params_fileselector_entry *mem = params;
|
|
|
|
|
|
|
|
if (mem->fs.path)
|
|
|
|
eina_stringshare_del(mem->fs.path);
|
2010-10-21 15:03:43 -07:00
|
|
|
if (mem->label)
|
|
|
|
eina_stringshare_del(mem->label);
|
|
|
|
free(params);
|
2010-10-13 18:18:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Edje_External_Param_Info external_fileselector_entry_params[] = {
|
|
|
|
DEFINE_EXTERNAL_COMMON_PARAMS,
|
2010-10-21 15:03:43 -07:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
|
2010-10-13 18:18:14 -07:00
|
|
|
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");
|