elementary: Replace icon lookup_order with icon_theme.
authorAndy Williams <andy@andywilliams.me>
Mon, 25 Apr 2016 15:57:13 +0000 (16:57 +0100)
committerAndy Williams <andy@andywilliams.me>
Mon, 25 Apr 2016 15:57:13 +0000 (16:57 +0100)
The definition of where to load icons is now up to the user
(through the configuration of the icon_theme config value)
rather than being defined in code per-app or even per-component

src/lib/elementary/elm_config.c
src/lib/elementary/elm_icon.c
src/lib/elementary/elm_icon.eo
src/lib/elementary/elm_toolbar.c
src/lib/elementary/elm_toolbar.eo
src/lib/elementary/elm_widget_icon.h
src/lib/elementary/elm_widget_toolbar.h

index 8dfe1b4..36ee5c7 100644 (file)
@@ -1550,6 +1550,7 @@ _config_free(Elm_Config *cfg)
    eina_stringshare_del(cfg->indicator_service_90);
    eina_stringshare_del(cfg->indicator_service_180);
    eina_stringshare_del(cfg->indicator_service_270);
+   eina_stringshare_del(cfg->icon_theme);
    free(cfg);
 }
 
@@ -2661,6 +2662,9 @@ elm_config_scale_set(double scale)
 EAPI const char *
 elm_config_icon_theme_get(void)
 {
+   if (!_elm_config->icon_theme)
+     return ELM_CONFIG_ICON_THEME_ELEMENTARY;
+
    return _elm_config->icon_theme;
 }
 
index d049c16..55fc2d9 100644 (file)
@@ -446,35 +446,16 @@ _internal_elm_icon_standard_set(Evas_Object *obj,
 
    ELM_ICON_DATA_GET(obj, sd);
 
-   /* try locating the icon using the specified lookup order */
-   switch (sd->lookup_order)
+   /* try locating the icon using the specified theme */
+   if (!strcmp(ELM_CONFIG_ICON_THEME_ELEMENTARY, elm_config_icon_theme_get()))
      {
-      case ELM_ICON_LOOKUP_FDO:
-        ret = _icon_freedesktop_set(obj, name, _icon_size_min_get(obj));
-        if (ret && fdo) *fdo = EINA_TRUE;
-        break;
-
-      case ELM_ICON_LOOKUP_THEME:
-        ret = _icon_standard_set(obj, name);
-        break;
-
-      case ELM_ICON_LOOKUP_THEME_FDO:
         ret = _icon_standard_set(obj, name);
-        if (!ret)
-          {
-             ret = _icon_freedesktop_set(obj, name, _icon_size_min_get(obj));
-             if (ret && fdo) *fdo = EINA_TRUE;
-          }
-        break;
-
-      case ELM_ICON_LOOKUP_FDO_THEME:
-      default:
+        if (ret && fdo) *fdo = EINA_FALSE;
+     }
+   else
+     {
         ret = _icon_freedesktop_set(obj, name, _icon_size_min_get(obj));
-        if (!ret)
-          ret = _icon_standard_set(obj, name);
-        else if (fdo)
-          *fdo = EINA_TRUE;
-        break;
+        if (ret && fdo) *fdo = EINA_TRUE;
      }
 
    if (ret)
@@ -485,13 +466,17 @@ _internal_elm_icon_standard_set(Evas_Object *obj,
      }
 
    if (_path_is_absolute(name))
-     return _icon_file_set(sd, obj, name);
+     {
+        if (fdo)
+          *fdo = EINA_FALSE;
+        return _icon_file_set(sd, 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);
+   if (*tmp) return _internal_elm_icon_standard_set(obj, tmp, fdo);
    /* give up */
    return EINA_FALSE;
 }
@@ -530,8 +515,6 @@ _elm_icon_evas_object_smart_add(Eo *obj, Elm_Icon_Data *priv)
    evas_obj_smart_add(eo_super(obj, MY_CLASS));
    elm_widget_sub_object_parent_add(obj);
 
-   priv->lookup_order = ELM_ICON_LOOKUP_THEME_FDO;
-
    priv->thumb.request = NULL;
 }
 
@@ -774,16 +757,17 @@ _elm_icon_standard_get(Eo *obj EINA_UNUSED, Elm_Icon_Data *sd)
    return sd->stdicon;
 }
 
-EOLIAN static void
-_elm_icon_order_lookup_set(Eo *obj EINA_UNUSED, Elm_Icon_Data *sd, Elm_Icon_Lookup_Order order)
+EINA_DEPRECATED EOLIAN static void
+_elm_icon_order_lookup_set(Eo *obj EINA_UNUSED, Elm_Icon_Data *sd EINA_UNUSED,
+                           Elm_Icon_Lookup_Order order EINA_UNUSED)
 {
-   sd->lookup_order = order;
+   // this method's behaviour has been overridden by elm_config_icon_theme_set
 }
 
-EOLIAN static Elm_Icon_Lookup_Order
-_elm_icon_order_lookup_get(Eo *obj EINA_UNUSED, Elm_Icon_Data *sd)
+EINA_DEPRECATED EOLIAN static Elm_Icon_Lookup_Order
+_elm_icon_order_lookup_get(Eo *obj EINA_UNUSED, Elm_Icon_Data *sd EINA_UNUSED)
 {
-   return sd->lookup_order;
+   return ELM_ICON_LOOKUP_FDO_THEME;
 }
 
 EAPI void
index 146c5b3..e783d76 100644 (file)
@@ -10,6 +10,8 @@ enum Elm.Icon.Lookup_Order
 {
    [[Lookup order used by elm_icon_standard_set(). Should look for icons in
      the theme, FDO paths, or both?
+
+     Warning: This enum will be removed as the lookup_order is deprecated.
    ]]
    legacy: elm_icon_lookup;
    fdo_theme, [[Icon look up order: freedesktop, theme.]]
@@ -24,6 +26,8 @@ class Elm.Icon (Elm.Image)
    eo_prefix: elm_obj_icon;
    methods {
       @property order_lookup {
+         [[Warning: the order_lookup property is deprecated.
+           See elm_config_icon_theme_set instead.]]
          set {
             [[Sets the icon lookup order used by elm_icon_standard_set().
 
index 6c1662f..039cebf 100644 (file)
@@ -2484,7 +2484,6 @@ _item_new(Evas_Object *obj,
    elm_interface_atspi_accessible_type_set(VIEW(it), ELM_ATSPI_TYPE_DISABLED);
 
    icon_obj = elm_icon_add(VIEW(it));
-   elm_icon_order_lookup_set(icon_obj, sd->lookup_order);
 
    if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
      _access_widget_item_register(it);
@@ -2896,7 +2895,6 @@ _elm_toolbar_evas_object_smart_add(Eo *obj, Elm_Toolbar_Data *priv)
    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move_cb, obj);
    evas_object_event_callback_add
      (priv->bx, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
-   elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
 
    _elm_toolbar_highlight_in_theme(obj);
    _sizing_eval(obj);
@@ -3646,7 +3644,6 @@ _elm_toolbar_item_state_add(Eo *eo_item, Elm_Toolbar_Item_Data *item,
      }
 
    icon_obj = elm_icon_add(obj);
-   elm_icon_order_lookup_set(icon_obj, sd->lookup_order);
    if (!icon_obj) goto error_state_add;
 
    if (!_item_icon_set(icon_obj, "toolbar/", icon))
@@ -3810,24 +3807,17 @@ _elm_toolbar_item_state_prev(Eo *eo_item EINA_UNUSED, Elm_Toolbar_Item_Data *ite
    return eina_list_data_get(prev_state);
 }
 
-EOLIAN static void
-_elm_toolbar_icon_order_lookup_set(Eo *obj EINA_UNUSED, Elm_Toolbar_Data *sd, Elm_Icon_Lookup_Order order)
+EINA_DEPRECATED EOLIAN static void
+_elm_toolbar_icon_order_lookup_set(Eo *obj EINA_UNUSED, Elm_Toolbar_Data *sd EINA_UNUSED,
+                                   Elm_Icon_Lookup_Order order EINA_UNUSED)
 {
-   Elm_Toolbar_Item_Data *it;
-
-
-   if (sd->lookup_order == order) return;
-   sd->lookup_order = order;
-   EINA_INLIST_FOREACH(sd->items, it)
-     elm_icon_order_lookup_set(it->icon, order);
-   if (sd->more_item)
-     elm_icon_order_lookup_set(sd->more_item->icon, order);
+   // this method's behaviour has been overridden by elm_config_icon_theme_set
 }
 
-EOLIAN static Elm_Icon_Lookup_Order
-_elm_toolbar_icon_order_lookup_get(Eo *obj EINA_UNUSED, Elm_Toolbar_Data *sd)
+EINA_DEPRECATED EOLIAN static Elm_Icon_Lookup_Order
+_elm_toolbar_icon_order_lookup_get(Eo *obj EINA_UNUSED, Elm_Toolbar_Data *sd EINA_UNUSED)
 {
-   return sd->lookup_order;
+   return ELM_ICON_LOOKUP_FDO_THEME;
 }
 
 EOLIAN static void
index 96e5865..17af717 100644 (file)
@@ -106,7 +106,10 @@ class Elm.Toolbar (Elm.Widget, Elm.Interface_Scrollable,
          [[Sets icon lookup order, for toolbar items' icons.
 
            Icons added before calling this function will not be affected.
-           The default lookup order is #ELM_ICON_LOOKUP_THEME_FDO.]]
+           The default lookup order is #ELM_ICON_LOOKUP_THEME_FDO.
+
+           Warning: the icon_order_lookup property is deprecated.
+           See elm_config_icon_theme_set instead.]]
          set {
          }
          get {
index 477a02b..ab1e7f1 100644 (file)
@@ -24,7 +24,6 @@ struct _Elm_Icon_Data
 {
    Evas_Object          *obj; // the object itself
    const char           *stdicon;
-   Elm_Icon_Lookup_Order lookup_order;
 
    struct
    {
index 51be616..79ba5a8 100644 (file)
@@ -39,7 +39,6 @@ struct _Elm_Toolbar_Data
    Elm_Object_Item                      *last_focused_item; /**< This records the last focused item when widget looses focus. This is required to set the focus on last focused item when widgets gets focus. */
    Elm_Toolbar_Item_Data                *reorder_empty, *reorder_item;
    Elm_Toolbar_Shrink_Mode               shrink_mode;
-   Elm_Icon_Lookup_Order                 lookup_order;
    int                                   theme_icon_size, priv_icon_size,
                                          icon_size;
    int                                   standard_priority;