2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2011-10-06 22:56:07 -07:00
|
|
|
#include "els_icon.h"
|
2011-12-06 01:39:38 -08:00
|
|
|
#include <assert.h>
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2010-11-26 03:37:45 -08:00
|
|
|
#ifdef ELM_EFREET
|
|
|
|
#define NON_EXISTING (void *)-1
|
2010-12-10 12:29:50 -08:00
|
|
|
static const char *icon_theme = NULL;
|
2010-11-26 03:37:45 -08:00
|
|
|
#endif
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
typedef struct _Widget_Data Widget_Data;
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
struct _Widget_Data
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Evas_Object *img;
|
2009-09-26 11:41:19 -07:00
|
|
|
const char *stdicon;
|
2010-10-14 15:21:43 -07:00
|
|
|
Elm_Icon_Lookup_Order lookup_order;
|
2011-05-31 09:16:01 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
const char *path;
|
|
|
|
const char *key;
|
|
|
|
} file, thumb;
|
|
|
|
|
|
|
|
Ecore_Event_Handler *eeh;
|
|
|
|
|
|
|
|
Ethumb_Thumb_Format format;
|
|
|
|
|
2011-12-01 07:37:56 -08:00
|
|
|
Ethumb_Client_Async *request;
|
|
|
|
|
2011-05-31 09:16:01 -07:00
|
|
|
Eina_Bool retry : 1;
|
|
|
|
} thumb;
|
|
|
|
#endif
|
|
|
|
|
2010-10-14 15:21:43 -07:00
|
|
|
#ifdef ELM_EFREET
|
|
|
|
struct {
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
int requested_size;
|
|
|
|
Eina_Bool use : 1;
|
2010-10-14 15:21:43 -07:00
|
|
|
} freedesktop;
|
|
|
|
#endif
|
2011-10-13 22:07:25 -07:00
|
|
|
int in_eval;
|
2009-09-26 11:41:19 -07:00
|
|
|
Eina_Bool scale_up : 1;
|
|
|
|
Eina_Bool scale_down : 1;
|
|
|
|
Eina_Bool smooth : 1;
|
|
|
|
Eina_Bool fill_outside : 1;
|
|
|
|
Eina_Bool no_scale : 1;
|
2011-08-10 23:05:05 -07:00
|
|
|
|
|
|
|
/* for animation feature */
|
|
|
|
Ecore_Timer *timer;
|
|
|
|
int frame_count;
|
|
|
|
int cur_frame;
|
|
|
|
double duration;
|
|
|
|
Eina_Bool anim : 1;
|
|
|
|
Eina_Bool play : 1;
|
2008-09-29 23:58:56 -07:00
|
|
|
};
|
|
|
|
|
2011-05-31 09:16:01 -07:00
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
|
|
|
static Eina_List *_elm_icon_retry = NULL;
|
|
|
|
static int _icon_pending_request = 0;
|
|
|
|
#endif
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2008-10-06 18:23:49 -07:00
|
|
|
static void _del_hook(Evas_Object *obj);
|
2008-11-15 05:58:50 -08:00
|
|
|
static void _theme_hook(Evas_Object *obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2010-10-14 15:21:43 -07:00
|
|
|
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);
|
|
|
|
|
2011-04-15 10:05:34 -07:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
|
|
|
|
static const Evas_Smart_Cb_Description _signals[] = {
|
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-05 11:22:42 -07:00
|
|
|
//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
|
|
|
|
|
2011-06-25 21:53:43 -07:00
|
|
|
static inline int
|
|
|
|
_icon_size_min_get(Evas_Object *icon)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
_els_smart_icon_size_get(icon, &size, NULL);
|
2011-09-02 09:19:22 -07:00
|
|
|
return (size < 16) ? 16 : size;
|
2011-06-25 21:53:43 -07:00
|
|
|
}
|
|
|
|
|
2011-05-31 09:16:01 -07:00
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
|
|
|
static void
|
|
|
|
_icon_thumb_stop(Widget_Data *wd, void *ethumbd)
|
|
|
|
{
|
2011-12-01 07:37:56 -08:00
|
|
|
if (wd->thumb.request)
|
2011-05-31 09:16:01 -07:00
|
|
|
{
|
2011-12-01 07:37:56 -08:00
|
|
|
ethumb_client_thumb_async_cancel(ethumbd, wd->thumb.request);
|
|
|
|
wd->thumb.request = NULL;
|
2011-05-31 09:16:01 -07:00
|
|
|
_icon_pending_request--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wd->thumb.retry)
|
|
|
|
{
|
|
|
|
_elm_icon_retry = eina_list_remove(_elm_icon_retry, wd);
|
|
|
|
wd->thumb.retry = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_icon_thumb_display(Widget_Data *wd)
|
|
|
|
{
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
|
|
|
|
|
|
|
if (wd->thumb.format == ETHUMB_THUMB_EET)
|
|
|
|
{
|
|
|
|
static const char *extensions[] = {
|
|
|
|
".avi", ".mp4", ".ogv", ".mov", ".mpg", ".wmv", NULL
|
|
|
|
};
|
|
|
|
const char **ext, *ptr;
|
|
|
|
int prefix_size;
|
|
|
|
Eina_Bool video = EINA_FALSE;
|
|
|
|
|
|
|
|
prefix_size = eina_stringshare_strlen(wd->thumb.file.path) - 4;
|
|
|
|
if (prefix_size >= 0)
|
|
|
|
{
|
|
|
|
ptr = wd->thumb.file.path + prefix_size;
|
|
|
|
for (ext = extensions; *ext; ++ext)
|
|
|
|
if (!strcasecmp(ptr, *ext))
|
|
|
|
{
|
|
|
|
video = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (video)
|
2011-06-28 07:32:42 -07:00
|
|
|
ret = _els_smart_icon_file_edje_set(wd->img, wd->thumb.thumb.path, wd->thumb.thumb.key);
|
2011-05-31 09:16:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
ret = _els_smart_icon_file_key_set(wd->img, wd->thumb.thumb.path, wd->thumb.thumb.key);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_icon_thumb_retry(Widget_Data *wd)
|
|
|
|
{
|
|
|
|
return _icon_thumb_display(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_icon_thumb_cleanup(Ethumb_Client *ethumbd)
|
|
|
|
{
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH_SAFE(_elm_icon_retry, l, ll, wd)
|
|
|
|
if (_icon_thumb_retry(wd))
|
|
|
|
{
|
|
|
|
_elm_icon_retry = eina_list_remove_list(_elm_icon_retry, l);
|
|
|
|
wd->thumb.retry = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_icon_pending_request == 0)
|
|
|
|
EINA_LIST_FREE(_elm_icon_retry, wd)
|
|
|
|
_icon_thumb_stop(wd, ethumbd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_icon_thumb_finish(Widget_Data *wd, Ethumb_Client *ethumbd)
|
|
|
|
{
|
2011-06-09 03:24:26 -07:00
|
|
|
const char *file = NULL, *group = NULL;
|
2011-05-31 09:16:01 -07:00
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
_els_smart_icon_file_get(wd->img, &file, &group);
|
|
|
|
file = eina_stringshare_ref(file);
|
|
|
|
group = eina_stringshare_ref(group);
|
|
|
|
|
|
|
|
ret = _icon_thumb_display(wd);
|
|
|
|
|
2011-06-09 03:24:26 -07:00
|
|
|
if (!ret && file)
|
2011-05-31 09:16:01 -07:00
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
if (!wd->thumb.retry)
|
|
|
|
{
|
|
|
|
_elm_icon_retry = eina_list_append(_elm_icon_retry, wd);
|
|
|
|
wd->thumb.retry = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Back to previous image */
|
|
|
|
if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
|
|
|
|
_els_smart_icon_file_edje_set(wd->img, file, group);
|
|
|
|
else
|
|
|
|
_els_smart_icon_file_key_set(wd->img, file, group);
|
|
|
|
}
|
|
|
|
|
|
|
|
_icon_thumb_cleanup(ethumbd);
|
|
|
|
|
|
|
|
eina_stringshare_del(file);
|
|
|
|
eina_stringshare_del(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-12-01 07:37:56 -08:00
|
|
|
_icon_thumb_done(Ethumb_Client *client, const char *thumb_path, const char *thumb_key, void *data)
|
2011-05-31 09:16:01 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = data;
|
|
|
|
|
2011-12-01 07:37:56 -08:00
|
|
|
assert(wd->thumb.request);
|
2011-05-31 09:16:01 -07:00
|
|
|
|
|
|
|
_icon_pending_request--;
|
2011-12-01 07:37:56 -08:00
|
|
|
wd->thumb.request = NULL;
|
2011-05-31 09:16:01 -07:00
|
|
|
|
2011-12-01 07:37:56 -08:00
|
|
|
eina_stringshare_replace(&wd->thumb.thumb.path, thumb_path);
|
|
|
|
eina_stringshare_replace(&wd->thumb.thumb.key, thumb_key);
|
|
|
|
wd->thumb.format = ethumb_client_format_get(client);
|
2011-05-31 09:16:01 -07:00
|
|
|
|
2011-12-01 07:37:56 -08:00
|
|
|
_icon_thumb_finish(wd, client);
|
2011-05-31 09:16:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-12-01 07:37:56 -08:00
|
|
|
_icon_thumb_error(Ethumb_Client *client, void *data)
|
2011-05-31 09:16:01 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = data;
|
|
|
|
|
2011-12-01 07:37:56 -08:00
|
|
|
assert(wd->thumb.request);
|
2011-05-31 09:16:01 -07:00
|
|
|
|
2011-12-01 07:37:56 -08:00
|
|
|
_icon_pending_request--;
|
|
|
|
wd->thumb.request = NULL;
|
2011-05-31 09:16:01 -07:00
|
|
|
|
2011-12-01 07:37:56 -08:00
|
|
|
ERR("could not generate thumbnail for %s (key: %s)", wd->thumb.file.path, wd->thumb.file.key);
|
|
|
|
_icon_thumb_cleanup(client);
|
2011-05-31 09:16:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_icon_thumb_apply(Widget_Data *wd)
|
|
|
|
{
|
|
|
|
Ethumb_Client *ethumbd;
|
|
|
|
|
|
|
|
ethumbd = elm_thumb_ethumb_client_get();
|
|
|
|
|
|
|
|
_icon_thumb_stop(wd, ethumbd);
|
|
|
|
|
|
|
|
if (!wd->thumb.file.path) return ;
|
|
|
|
|
|
|
|
_icon_pending_request++;
|
2011-06-28 07:32:42 -07:00
|
|
|
if (!ethumb_client_file_set(ethumbd, wd->thumb.file.path, wd->thumb.file.key)) return ;
|
2011-06-24 01:59:56 -07:00
|
|
|
ethumb_client_size_set(ethumbd, _icon_size_min_get(wd->img), _icon_size_min_get(wd->img));
|
2011-12-01 07:37:56 -08:00
|
|
|
wd->thumb.request = ethumb_client_thumb_async_get(ethumbd, _icon_thumb_done, _icon_thumb_error, wd);
|
2011-05-31 09:16:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_icon_thumb_apply_cb(void *data, int type __UNUSED__, void *ev __UNUSED__)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = data;
|
|
|
|
|
|
|
|
_icon_thumb_apply(wd);
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
static void
|
2008-10-06 18:23:49 -07:00
|
|
|
_del_hook(Evas_Object *obj)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2011-05-31 09:16:01 -07:00
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
|
|
|
Ethumb_Client *ethumbd;
|
|
|
|
#endif
|
2009-09-26 11:41:19 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-11-15 05:58:50 -08:00
|
|
|
if (wd->stdicon) eina_stringshare_del(wd->stdicon);
|
2011-05-31 09:16:01 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
|
|
|
ethumbd = elm_thumb_ethumb_client_get();
|
|
|
|
_icon_thumb_stop(wd, ethumbd);
|
|
|
|
|
|
|
|
eina_stringshare_del(wd->thumb.file.path);
|
|
|
|
eina_stringshare_del(wd->thumb.file.key);
|
|
|
|
eina_stringshare_del(wd->thumb.thumb.path);
|
|
|
|
eina_stringshare_del(wd->thumb.thumb.key);
|
|
|
|
|
|
|
|
if (wd->thumb.eeh)
|
|
|
|
ecore_event_handler_del(wd->thumb.eeh);
|
|
|
|
#endif
|
|
|
|
|
2011-08-10 23:05:05 -07:00
|
|
|
if (wd->timer)
|
|
|
|
ecore_timer_del(wd->timer);
|
2008-10-06 18:23:49 -07:00
|
|
|
free(wd);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2008-11-15 05:58:50 -08:00
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-11-15 05:58:50 -08:00
|
|
|
if (wd->stdicon)
|
2010-07-14 14:14:52 -07:00
|
|
|
_elm_theme_object_icon_set(obj, wd->img, wd->stdicon, elm_widget_style_get(obj));
|
2008-11-15 05:58:50 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2010-10-29 11:42:01 -07:00
|
|
|
static void
|
|
|
|
_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
Evas_Object *icon_edje;
|
|
|
|
icon_edje = _els_smart_icon_edje_get(wd->img);
|
|
|
|
if (!icon_edje) return;
|
|
|
|
edje_object_signal_emit(icon_edje, emission, source);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-02 22:32:17 -07:00
|
|
|
_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
|
2010-10-29 11:42:01 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
Evas_Object *icon_edje;
|
|
|
|
icon_edje = _els_smart_icon_edje_get(wd->img);
|
|
|
|
if (!icon_edje) return;
|
|
|
|
edje_object_signal_callback_add(icon_edje, emission, source, func_cb, data);
|
|
|
|
}
|
|
|
|
|
2010-11-01 05:44:30 -07:00
|
|
|
static void
|
2011-04-02 22:32:17 -07:00
|
|
|
_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
|
2010-10-29 11:42:01 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-11-01 05:44:30 -07:00
|
|
|
if (!wd) return;
|
2010-10-29 11:42:01 -07:00
|
|
|
Evas_Object *icon_edje;
|
|
|
|
icon_edje = _els_smart_icon_edje_get(wd->img);
|
2010-11-01 05:44:30 -07:00
|
|
|
if (!icon_edje) return;
|
|
|
|
edje_object_signal_callback_del_full(icon_edje, emission, source, func_cb,
|
|
|
|
data);
|
2010-10-29 11:42:01 -07:00
|
|
|
}
|
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
static void
|
2008-10-06 18:23:49 -07:00
|
|
|
_sizing_eval(Evas_Object *obj)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
|
|
|
int w, h;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2011-10-13 22:07:25 -07:00
|
|
|
wd->in_eval++;
|
2008-10-06 18:23:49 -07:00
|
|
|
_els_smart_icon_size_get(wd->img, &w, &h);
|
2010-10-14 15:21:43 -07:00
|
|
|
#ifdef ELM_EFREET
|
2011-09-22 06:51:22 -07:00
|
|
|
if (wd->freedesktop.use && wd->stdicon)
|
2010-10-14 15:21:43 -07:00
|
|
|
{
|
2011-09-22 06:51:22 -07:00
|
|
|
int size;
|
2010-10-14 15:21:43 -07:00
|
|
|
/* This icon has been set to a freedesktop icon, and the requested
|
|
|
|
appears to have a different size than the requested size, so try to
|
|
|
|
request another, higher resolution, icon.
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
FIXME: Find a better heuristic to determine if there should be
|
|
|
|
an icon with a different resolution. */
|
2011-09-22 06:51:22 -07:00
|
|
|
size = ((w / 16) + 1) * 16;
|
|
|
|
_icon_freedesktop_set(wd, obj, wd->stdicon, size);
|
2010-10-14 15:21:43 -07:00
|
|
|
}
|
|
|
|
#endif
|
2008-10-06 18:23:49 -07:00
|
|
|
_els_smart_icon_scale_up_set(wd->img, wd->scale_up);
|
|
|
|
_els_smart_icon_scale_down_set(wd->img, wd->scale_down);
|
|
|
|
_els_smart_icon_smooth_scale_set(wd->img, wd->smooth);
|
|
|
|
_els_smart_icon_fill_inside_set(wd->img, !(wd->fill_outside));
|
|
|
|
if (wd->no_scale) _els_smart_icon_scale_set(wd->img, 1.0);
|
|
|
|
else
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
_els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) *
|
|
|
|
_elm_config->scale);
|
|
|
|
_els_smart_icon_size_get(wd->img, &w, &h);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
2008-10-06 18:23:49 -07:00
|
|
|
if (!wd->scale_down)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
minw = w;
|
|
|
|
minh = h;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
2008-10-06 18:23:49 -07:00
|
|
|
if (!wd->scale_up)
|
|
|
|
{
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
maxw = w;
|
|
|
|
maxh = h;
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
2011-10-13 22:07:25 -07:00
|
|
|
wd->in_eval--;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2008-10-08 02:33:05 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2008-10-08 02:33:05 -07:00
|
|
|
{
|
2010-01-22 04:36:32 -08:00
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2011-04-15 10:05:34 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_CLICKED, event_info);
|
2008-10-08 02:33:05 -07:00
|
|
|
}
|
|
|
|
|
2011-08-10 23:05:05 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_elm_icon_animate_cb(void *data)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = data;
|
|
|
|
Evas_Object *img_obj;
|
|
|
|
|
|
|
|
if (!wd) return ECORE_CALLBACK_CANCEL;
|
|
|
|
if (!wd->anim) return ECORE_CALLBACK_CANCEL;
|
|
|
|
|
|
|
|
img_obj = _els_smart_icon_object_get(wd->img);
|
|
|
|
wd->cur_frame++;
|
|
|
|
if (wd->cur_frame > wd->frame_count)
|
|
|
|
wd->cur_frame = wd->cur_frame % wd->frame_count;
|
|
|
|
evas_object_image_animated_frame_set(img_obj, wd->cur_frame);
|
|
|
|
|
|
|
|
wd->duration = evas_object_image_animated_frame_duration_get(img_obj, wd->cur_frame, 0);
|
|
|
|
|
|
|
|
if (wd->duration > 0)
|
|
|
|
ecore_timer_interval_set(wd->timer, wd->duration);
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2011-09-14 11:28:22 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name)
|
|
|
|
{
|
|
|
|
if (_elm_theme_object_icon_set(obj, wd->img, name, "default"))
|
|
|
|
{
|
|
|
|
#ifdef ELM_EFREET
|
|
|
|
/* TODO: elm_unneed_efreet() */
|
|
|
|
wd->freedesktop.use = EINA_FALSE;
|
|
|
|
#endif
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2011-09-26 23:40:06 -07:00
|
|
|
#ifdef ELM_EFREET
|
2011-09-14 11:28:22 -07:00
|
|
|
_icon_file_set(Widget_Data *wd, Evas_Object *obj, const char *path)
|
2011-09-26 23:40:06 -07:00
|
|
|
#else
|
|
|
|
_icon_file_set(Widget_Data *wd __UNUSED__, Evas_Object *obj, const char *path)
|
|
|
|
#endif
|
2011-09-14 11:28:22 -07:00
|
|
|
{
|
|
|
|
if (elm_icon_file_set(obj, path, NULL))
|
|
|
|
{
|
|
|
|
#ifdef ELM_EFREET
|
|
|
|
/* TODO: elm_unneed_efreet() */
|
|
|
|
wd->freedesktop.use = EINA_FALSE;
|
|
|
|
#endif
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2011-09-26 23:40:06 -07:00
|
|
|
#ifdef ELM_EFREET
|
2011-09-14 11:28:22 -07:00
|
|
|
_icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size)
|
2011-09-26 23:40:06 -07:00
|
|
|
#else
|
|
|
|
_icon_freedesktop_set(Widget_Data *wd __UNUSED__, Evas_Object *obj __UNUSED__, const char *name __UNUSED__, int size __UNUSED__)
|
|
|
|
#endif
|
2011-09-14 11:28:22 -07:00
|
|
|
{
|
|
|
|
#ifdef ELM_EFREET
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
elm_need_efreet();
|
|
|
|
if (icon_theme == NON_EXISTING) return EINA_FALSE;
|
|
|
|
if (!icon_theme)
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
/* TODO: Listen for EFREET_EVENT_ICON_CACHE_UPDATE */
|
|
|
|
theme = efreet_icon_theme_find(getenv("E_ICON_THEME"));
|
|
|
|
if (!theme)
|
|
|
|
{
|
|
|
|
const char **itr;
|
|
|
|
static const char *themes[] = {
|
|
|
|
"gnome", "Human", "oxygen", "hicolor", NULL
|
|
|
|
};
|
|
|
|
for (itr = themes; *itr; itr++)
|
|
|
|
{
|
|
|
|
theme = efreet_icon_theme_find(*itr);
|
|
|
|
if (theme) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!theme)
|
|
|
|
{
|
|
|
|
icon_theme = NON_EXISTING;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
icon_theme = eina_stringshare_add(theme->name.internal);
|
|
|
|
}
|
|
|
|
path = efreet_icon_path_find(icon_theme, name, size);
|
|
|
|
wd->freedesktop.use = !!path;
|
|
|
|
if (wd->freedesktop.use)
|
|
|
|
{
|
|
|
|
wd->freedesktop.requested_size = size;
|
|
|
|
elm_icon_file_set(obj, path, NULL);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_elm_icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name, Eina_Bool *fdo)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
/* try locating the icon using the specified lookup order */
|
|
|
|
switch (wd->lookup_order)
|
|
|
|
{
|
|
|
|
case ELM_ICON_LOOKUP_FDO:
|
|
|
|
ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
|
|
|
|
if (ret && fdo) *fdo = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
case ELM_ICON_LOOKUP_THEME:
|
|
|
|
ret = _icon_standard_set(wd, obj, name);
|
|
|
|
break;
|
|
|
|
case ELM_ICON_LOOKUP_THEME_FDO:
|
|
|
|
ret = _icon_standard_set(wd, obj, name);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
|
|
|
|
if (ret && fdo) *fdo = EINA_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ELM_ICON_LOOKUP_FDO_THEME:
|
|
|
|
default:
|
|
|
|
ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
|
|
|
|
if (!ret)
|
|
|
|
ret = _icon_standard_set(wd, obj, name);
|
|
|
|
else if (fdo)
|
|
|
|
*fdo = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&wd->stdicon, name);
|
2011-10-13 22:07:25 -07:00
|
|
|
if (!wd->in_eval) _sizing_eval(obj);
|
2011-09-14 11:28:22 -07:00
|
|
|
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;
|
|
|
|
++tmp;
|
|
|
|
if (*tmp) return elm_icon_standard_set(obj, tmp);
|
|
|
|
/* give up */
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_icon_standard_resize(void *data,
|
|
|
|
Evas *e __UNUSED__,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = data;
|
|
|
|
const char *refup = eina_stringshare_ref(wd->stdicon);
|
|
|
|
Eina_Bool fdo = EINA_FALSE;
|
|
|
|
|
|
|
|
if (!_elm_icon_standard_set(wd, obj, wd->stdicon, &fdo) || (!fdo))
|
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_icon_standard_resize, wd);
|
|
|
|
eina_stringshare_del(refup);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
|
|
|
static void
|
|
|
|
_elm_icon_thumb_resize(void *data,
|
|
|
|
Evas *e __UNUSED__,
|
|
|
|
Evas_Object *obj,
|
|
|
|
void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = data;
|
|
|
|
|
|
|
|
if (wd->thumb.file.path)
|
|
|
|
elm_icon_thumb_set(obj, wd->thumb.file.path, wd->thumb.file.key);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_icon_add(Evas_Object *parent)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2011-03-31 23:08:02 -07:00
|
|
|
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "icon");
|
2009-05-13 05:21:52 -07:00
|
|
|
elm_widget_type_set(obj, "icon");
|
From: RAJEEV RANJAN <rajeev.r@samsung.com>
Subject: Patch to address some focus and disabling issue in elementary
widgets
We have observed some generic issues in Elementary widgets.
1. Widgets not getting disabled if we call elm_object_disabled_set(ob,
EINA_TRUE) followed by elm_object_style_set(obj, <style_name>);
This works fine if we disable the widget after changing the style(call
to theme_hook happens here).
It happens because we are not sending the edje signal in theme_hook of
the widgets, if the widget is already in disabled state.
I have added this code in theme_hook of elm_button as an example and
we will need to apply the similar stuff in all other widgets if needed.
2. The widget gets focused in a particular scenario even though we
call elm_object_focus_allow_set(obj, EINA_FALSE).
The code snippet to explain the scenario which we observed was like
this:
Evas_Object *button = NULL, *icon = NULL;
button = elm_button_add(parent);
elm_object_focus_allow_set(button, EINA_FALSE);
icon = elm_icon_add(button);
elm_icon_file_set(icon, EDJE_PATH, "test.icon");
elm_button_icon_set(button, icon);
An icon object does not take focus by default. But still whenever
the focus returned to the parent(layout in this case) after closing
some popup, the button gets focused though we had disabled it
explicitly.
The reason is in this case, when we call elm_icon_add(button), icon
gets added to button as a sub-object and in this call, we set
sd->child_can_focus for button(the parent) as true because till now,
the focus property for icon has not been set to false which by default
is true.
This was set later in the function elm_icon_add() as follows:
elm_widget_can_focus_set(obj, EINA_FALSE);
Actually this should be set before adding icon as sub-object of the
parent which in this case is a button.
I have done the required modification in the function elm_icon_add().
Attached to this mail is the patch file for these two issues.The
revision from which I have created this patch file is 53129.
We may need to do similar changes in other widgets if required.
SVN revision: 53137
2010-10-07 00:31:24 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
2009-05-13 05:21:52 -07:00
|
|
|
elm_widget_sub_object_add(parent, obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
2008-11-15 05:58:50 -08:00
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
2010-10-29 11:42:01 -07:00
|
|
|
elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
|
|
|
|
elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
|
|
|
|
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2010-11-08 11:57:57 -08:00
|
|
|
wd->lookup_order = ELM_ICON_LOOKUP_THEME_FDO;
|
2008-10-06 18:23:49 -07:00
|
|
|
wd->img = _els_smart_icon_add(e);
|
2008-10-08 02:33:05 -07:00
|
|
|
evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
_mouse_up, obj);
|
2010-09-27 21:28:14 -07:00
|
|
|
evas_object_repeat_events_set(wd->img, EINA_TRUE);
|
2009-07-06 23:46:51 -07:00
|
|
|
elm_widget_resize_object_set(obj, wd->img);
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2011-04-15 10:08:04 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _signals);
|
|
|
|
|
2011-05-31 09:16:01 -07:00
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
2011-12-01 07:37:56 -08:00
|
|
|
wd->thumb.request = NULL;
|
2011-05-31 09:16:01 -07:00
|
|
|
#endif
|
|
|
|
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->smooth = EINA_TRUE;
|
|
|
|
wd->scale_up = EINA_TRUE;
|
|
|
|
wd->scale_down = EINA_TRUE;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2011-07-22 16:03:46 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, EINA_FALSE);
|
|
|
|
eina_stringshare_del(wd->stdicon);
|
|
|
|
wd->stdicon = NULL;
|
|
|
|
ret = _els_smart_icon_memfile_set(wd->img, img, size, format, key);
|
2011-10-13 22:07:25 -07:00
|
|
|
if (!wd->in_eval) _sizing_eval(obj);
|
2011-07-22 16:03:46 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-04-03 14:52:01 -07:00
|
|
|
EAPI Eina_Bool
|
2008-10-06 18:23:49 -07:00
|
|
|
elm_icon_file_set(Evas_Object *obj, const char *file, const char *group)
|
|
|
|
{
|
2010-03-08 23:30:48 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-04-03 14:52:01 -07:00
|
|
|
Eina_Bool ret;
|
|
|
|
|
2010-12-03 06:08:33 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
|
2011-09-22 06:51:22 -07:00
|
|
|
|
2011-09-26 23:40:06 -07:00
|
|
|
#ifdef ELM_EFREET
|
2011-09-22 06:51:22 -07:00
|
|
|
if (!wd->freedesktop.use)
|
|
|
|
{
|
|
|
|
if (wd->stdicon) eina_stringshare_del(wd->stdicon);
|
2011-09-26 23:40:06 -07:00
|
|
|
wd->stdicon = NULL;
|
2011-09-22 06:51:22 -07:00
|
|
|
}
|
2011-09-26 23:40:06 -07:00
|
|
|
#endif
|
2011-07-22 15:41:32 -07:00
|
|
|
if (eina_str_has_extension(file, ".edj"))
|
2009-04-03 14:52:01 -07:00
|
|
|
ret = _els_smart_icon_file_edje_set(wd->img, file, group);
|
|
|
|
else
|
|
|
|
ret = _els_smart_icon_file_key_set(wd->img, file, group);
|
2011-10-13 22:07:25 -07:00
|
|
|
if (!wd->in_eval) _sizing_eval(obj);
|
2009-04-03 14:52:01 -07:00
|
|
|
return ret;
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI void
|
|
|
|
elm_icon_file_get(const Evas_Object *obj, const char **file, const char **group)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
_els_smart_icon_file_get(wd->img, file, group);
|
|
|
|
}
|
|
|
|
|
2011-05-31 09:16:01 -07:00
|
|
|
EAPI void
|
2011-09-14 11:28:22 -07:00
|
|
|
elm_icon_thumb_set(Evas_Object *obj, const char *file, const char *group)
|
2011-05-31 09:16:01 -07:00
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
|
|
|
|
#ifdef HAVE_ELEMENTARY_ETHUMB
|
2011-09-14 19:20:26 -07:00
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
|
2011-09-14 11:28:22 -07:00
|
|
|
_elm_icon_standard_resize, wd);
|
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_icon_thumb_resize, wd);
|
|
|
|
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_icon_thumb_resize, wd);
|
|
|
|
|
2011-05-31 09:16:01 -07:00
|
|
|
eina_stringshare_replace(&wd->thumb.file.path, file);
|
|
|
|
eina_stringshare_replace(&wd->thumb.file.key, group);
|
|
|
|
|
2012-02-15 21:58:23 -08:00
|
|
|
if (elm_thumb_ethumb_client_connected_get())
|
2011-05-31 09:16:01 -07:00
|
|
|
{
|
|
|
|
_icon_thumb_apply(wd);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wd->thumb.eeh)
|
|
|
|
{
|
|
|
|
wd->thumb.eeh = ecore_event_handler_add(ELM_ECORE_EVENT_ETHUMB_CONNECT, _icon_thumb_apply_cb, wd);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
(void) obj;
|
|
|
|
(void) file;
|
|
|
|
(void) group;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-08-10 23:05:05 -07:00
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_animated_available_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Evas_Object *img_obj ;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
|
|
|
|
img_obj = _els_smart_icon_object_get(wd->img);
|
|
|
|
|
|
|
|
return evas_object_image_animated_get(img_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_icon_animated_set(Evas_Object *obj, Eina_Bool anim)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Evas_Object *img_obj ;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (wd->anim == anim) return;
|
|
|
|
|
|
|
|
img_obj = _els_smart_icon_object_get(wd->img);
|
|
|
|
if (!evas_object_image_animated_get(img_obj)) return;
|
|
|
|
if (anim)
|
|
|
|
{
|
|
|
|
wd->frame_count = evas_object_image_animated_frame_count_get(img_obj);
|
|
|
|
wd->cur_frame = 1;
|
|
|
|
wd->duration = evas_object_image_animated_frame_duration_get(img_obj, wd->cur_frame, 0);
|
|
|
|
evas_object_image_animated_frame_set(img_obj, wd->cur_frame);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wd->frame_count = -1;
|
|
|
|
wd->cur_frame = -1;
|
|
|
|
wd->duration = -1;
|
|
|
|
}
|
|
|
|
wd->anim = anim;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_animated_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 wd->anim;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_icon_animated_play_set(Evas_Object *obj, Eina_Bool play)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (!wd->anim) return;
|
|
|
|
if (wd->play == play) return;
|
|
|
|
|
|
|
|
if (play)
|
|
|
|
{
|
|
|
|
wd->timer = ecore_timer_add(wd->duration, _elm_icon_animate_cb, wd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(wd->timer);
|
|
|
|
wd->timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wd->play = play;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_animated_play_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 wd->play;
|
|
|
|
}
|
|
|
|
|
2011-06-23 07:54:29 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_standard_set(Evas_Object *obj, const char *name)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2011-06-24 01:59:56 -07:00
|
|
|
Eina_Bool fdo = EINA_FALSE;
|
|
|
|
Eina_Bool ret;
|
2011-06-23 07:54:29 -07:00
|
|
|
|
|
|
|
if ((!wd) || (!name)) return EINA_FALSE;
|
|
|
|
|
|
|
|
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_icon_standard_resize, wd);
|
|
|
|
|
2011-06-24 01:59:56 -07:00
|
|
|
ret = _elm_icon_standard_set(wd, obj, name, &fdo);
|
|
|
|
|
|
|
|
if (fdo)
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
|
|
|
|
_elm_icon_standard_resize, wd);
|
|
|
|
|
|
|
|
return ret;
|
2011-06-23 07:54:29 -07:00
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI const char *
|
|
|
|
elm_icon_standard_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->stdicon;
|
|
|
|
}
|
|
|
|
|
2010-10-14 15:21:43 -07:00
|
|
|
EAPI void
|
|
|
|
elm_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (wd) wd->lookup_order = order;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Icon_Lookup_Order
|
2010-10-25 07:34:22 -07:00
|
|
|
elm_icon_order_lookup_get(const Evas_Object *obj)
|
2010-10-14 15:21:43 -07:00
|
|
|
{
|
2010-11-08 11:57:57 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
|
2010-10-14 15:21:43 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-11-08 11:57:57 -08:00
|
|
|
if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
|
2010-10-14 15:21:43 -07:00
|
|
|
return wd->lookup_order;
|
2008-10-08 02:33:05 -07:00
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_icon_smooth_set(Evas_Object *obj, Eina_Bool smooth)
|
2008-10-06 18:23:49 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:41:19 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
wd->smooth = smooth;
|
2011-10-13 22:07:25 -07:00
|
|
|
if (!wd->in_eval) _sizing_eval(obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_smooth_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 wd->smooth;
|
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_icon_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
|
2008-10-06 18:23:49 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:41:19 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
wd->no_scale = no_scale;
|
2011-10-13 22:07:25 -07:00
|
|
|
if (!wd->in_eval) _sizing_eval(obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_no_scale_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 wd->no_scale;
|
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_icon_scale_set(Evas_Object *obj, Eina_Bool scale_up, Eina_Bool scale_down)
|
2008-10-06 18:23:49 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:41:19 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
wd->scale_up = scale_up;
|
|
|
|
wd->scale_down = scale_down;
|
2011-10-13 22:07:25 -07:00
|
|
|
if (!wd->in_eval) _sizing_eval(obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI void
|
|
|
|
elm_icon_scale_get(const Evas_Object *obj, Eina_Bool *scale_up, Eina_Bool *scale_down)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (scale_up) *scale_up = wd->scale_up;
|
|
|
|
if (scale_down) *scale_down = wd->scale_down;
|
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_icon_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
|
2008-10-06 18:23:49 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:41:19 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
wd->fill_outside = fill_outside;
|
2011-10-13 22:07:25 -07:00
|
|
|
if (!wd->in_eval) _sizing_eval(obj);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
2009-03-12 22:50:38 -07:00
|
|
|
|
2011-07-27 13:31:40 -07:00
|
|
|
EAPI void
|
|
|
|
elm_icon_size_get(const Evas_Object *obj, int *w, int *h)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return;
|
|
|
|
_els_smart_icon_size_get(wd->img, w, h);
|
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_icon_fill_outside_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 wd->fill_outside;
|
|
|
|
}
|
2009-09-17 15:39:18 -07:00
|
|
|
|
2009-03-12 22:50:38 -07:00
|
|
|
EAPI void
|
|
|
|
elm_icon_prescale_set(Evas_Object *obj, int size)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-03-12 22:50:38 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:41:19 -07:00
|
|
|
|
2009-03-12 22:50:38 -07:00
|
|
|
if (!wd) return;
|
|
|
|
_els_smart_icon_scale_size_set(wd->img, size);
|
|
|
|
}
|
2010-06-30 06:20:58 -07:00
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI int
|
|
|
|
elm_icon_prescale_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) 0;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-06-30 06:20:58 -07:00
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
if (!wd) return 0;
|
|
|
|
return _els_smart_icon_scale_size_get(wd->img);
|
|
|
|
}
|
2011-11-06 07:56:31 -08:00
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_icon_object_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) 0;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return NULL;
|
2011-11-06 08:19:25 -08:00
|
|
|
return _els_smart_icon_object_get(wd->img);
|
2011-11-06 07:56:31 -08:00
|
|
|
}
|
2011-11-06 20:25:16 -08:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_icon_preload_set(Evas_Object *obj, Eina_Bool disable)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return;
|
|
|
|
_els_smart_icon_preload_set(wd->img, disable);
|
|
|
|
}
|