+elm_toolbar_item_icon_file_set()
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 1 Dec 2011 19:14:48 +0000 (19:14 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 1 Dec 2011 19:14:48 +0000 (19:14 +0000)
at some point this whole item api should probably be replaced with generic object stuff

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@65785 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

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

index 38171d3..65ede2d 100644 (file)
@@ -15185,7 +15185,8 @@ extern "C" {
     * @param it The toolbar item.
     * @return The icon object
     *
-    * @see elm_toolbar_item_icon_set() or elm_toolbar_item_icon_memfile_set() for details.
+    * @see elm_toolbar_item_icon_set(), elm_toolbar_item_icon_file_set(),
+    * or elm_toolbar_item_icon_memfile_set() for details.
     *
     * @ingroup Toolbar
     */
@@ -15207,6 +15208,23 @@ extern "C" {
     * @ingroup Toolbar
     */
    EAPI Eina_Bool elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t size, const char *format, const char *key) EINA_ARG_NONNULL(1);
+
+   /**
+    * Set the icon associated with @p item to an image in a binary buffer.
+    *
+    * @param it The toolbar item.
+    * @param file The file that contains the image
+    * @param key Optional key of @p img to pass to the image loader (eg. if @p img is an edje file)
+    *
+    * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
+    *
+    * @note The icon image set by this function can be changed by
+    * elm_toolbar_item_icon_set().
+    *
+    * @ingroup Toolbar
+    */
+   EAPI Eina_Bool elm_toolbar_item_icon_file_set(Elm_Object_Item *it, const char *file, const char *key) EINA_ARG_NONNULL(1);
+
    /**
     * Delete them item from the toolbar.
     *
index 6c8cfcd..74dfb6f 100644 (file)
@@ -1391,6 +1391,39 @@ elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t s
    return EINA_TRUE;
 }
 
+EAPI Eina_Bool
+elm_toolbar_item_icon_file_set(Elm_Object_Item *it, const char *file, const char *key)
+{
+   ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
+
+   Evas_Object *icon_obj;
+   Widget_Data *wd;
+   Evas_Object *obj;
+   Eina_Bool ret;
+   Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
+
+   obj = WIDGET(item);
+   wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+
+   if (file)
+     {
+        icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
+        evas_object_repeat_events_set(icon_obj, EINA_TRUE);
+        ret = _els_smart_icon_file_key_set(icon_obj, file, key);
+        if (!ret)
+          {
+             evas_object_del(icon_obj);
+             return EINA_FALSE;
+          }
+        _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
+                                         "elm,state,icon_set");
+     }
+   else
+     _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
+   return EINA_TRUE;
+}
+
 EAPI void
 elm_toolbar_item_del(Elm_Object_Item *it)
 {