elementary: decorelate fdo from thumbnail resizing.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 14 Sep 2011 18:28:22 +0000 (18:28 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 14 Sep 2011 18:28:22 +0000 (18:28 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@63393 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Elementary.h.in
src/lib/elm_icon.c

index 6b5628b..81a7120 100644 (file)
@@ -4666,7 +4666,7 @@ extern "C" {
     * @ingroup Icon
     */
    EAPI void                  elm_icon_file_get(const Evas_Object *obj, const char **file, const char **group) EINA_ARG_NONNULL(1);
-   EAPI void                  elm_icon_thumb_set(const Evas_Object *obj, const char *file, const char *group) EINA_ARG_NONNULL(1, 2);
+   EAPI void                  elm_icon_thumb_set(Evas_Object *obj, const char *file, const char *group) EINA_ARG_NONNULL(1, 2);
    /**
     * Set the icon by icon standards names.
     *
index d2f7d55..e349586 100644 (file)
@@ -462,6 +462,163 @@ _elm_icon_animate_cb(void *data)
    return ECORE_CALLBACK_RENEW;
 }
 
+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
+_icon_file_set(Widget_Data *wd, Evas_Object *obj, const char *path)
+{
+   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
+_icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size)
+{
+#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);
+        _sizing_eval(obj);
+        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
+
 EAPI Evas_Object *
 elm_icon_add(Evas_Object *parent)
 {
@@ -549,13 +706,21 @@ elm_icon_file_get(const Evas_Object *obj, const char **file, const char **group)
 }
 
 EAPI void
-elm_icon_thumb_set(const Evas_Object *obj, const char *file, const char *group)
+elm_icon_thumb_set(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;
 
 #ifdef HAVE_ELEMENTARY_ETHUMB
+   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE, 
+                                      _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);
+
    eina_stringshare_replace(&wd->thumb.file.path, file);
    eina_stringshare_replace(&wd->thumb.file.key, group);
 
@@ -661,154 +826,6 @@ elm_icon_animated_play_get(const Evas_Object *obj)
    return wd->play;
 }
 
-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
-_icon_file_set(Widget_Data *wd, Evas_Object *obj, const char *path)
-{
-   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
-_icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size)
-{
-#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);
-        _sizing_eval(obj);
-        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);
-#ifdef HAVE_ELEMENTARY_ETHUMB
-   if (wd->thumb.file.path)
-     elm_icon_thumb_set(obj, wd->thumb.file.path, wd->thumb.file.key);
-#endif
-
-   eina_stringshare_del(refup);
-}
-
 EAPI Eina_Bool
 elm_icon_standard_set(Evas_Object *obj, const char *name)
 {