Loading icon image from files if absolute path is provided

By: Otavio Pontes <otavio@profusion.mobi>


SVN revision: 54188
This commit is contained in:
Bruno Dilly 2010-11-05 18:22:42 +00:00
parent 8a118ee12e
commit 53aba73f94
2 changed files with 36 additions and 2 deletions

View File

@ -541,7 +541,7 @@ test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
elm_toolbar_item_disabled_set(item, EINA_TRUE);
elm_toolbar_item_priority_set(item, 100);
item = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
item = elm_toolbar_item_append(tb, PACKAGE_DATA_DIR"/images/icon_04.png", "World", tb_2, ph1);
elm_toolbar_item_priority_set(item, -100);
item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3a, ph4);

View File

@ -43,6 +43,22 @@ static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static Eina_Bool _icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name);
static Eina_Bool _icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size);
//FIXME: move this code to ecore
#ifdef _WIN32
static Eina_Bool
_path_is_absolute(const char *path)
{
//TODO: Check if this works with all absolute paths in windows
return ((isalpha (*path)) && (*(path + 1) == ':') && ((*(path + 2) == '\\') || (*(path + 2) == '/')));
}
#else
static Eina_Bool
_path_is_absolute(const char *path)
{
return (*path == '/');
}
#endif
static void
_del_hook(Evas_Object *obj)
{
@ -256,6 +272,19 @@ _icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name)
return EINA_FALSE;
}
static Eina_Bool
_icon_file_set(Widget_Data *wd, Evas_Object *obj, const char *path)
{
if (elm_icon_file_set(obj, path, NULL))
{
#ifdef ELM_EFREET
wd->freedesktop.use = EINA_FALSE;
#endif
return EINA_TRUE;
}
return EINA_FALSE;
}
static Eina_Bool
_icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size)
{
@ -294,7 +323,9 @@ _icon_size_min_get(Evas_Object *icon)
}
/**
* Set the theme, as standard, for a icon
* Set the theme, as standard, for a icon.
* If theme was not found and it is the absolute path of an image file, this
* image will be used.
*
* @param obj The icon object
* @param name The theme name
@ -340,6 +371,9 @@ elm_icon_standard_set(Evas_Object *obj, const char *name)
return EINA_TRUE;
}
if (_path_is_absolute(name))
return _icon_file_set(wd, obj, name);
/* if that fails, see if icon name is in the format size/name. if so,
try locating a fallback without the size specification */
if (!(tmp = strchr(name, '/'))) return EINA_FALSE;