From 4c0fc7559c2624b160b218e52be2c9f7794ad569 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 25 Apr 2016 14:56:55 +0100 Subject: [PATCH 1/4] elementary: Add user setting for icon theme Beginning of the icon lookup rework. The library will now store user preference for the icon theme to use. --- src/lib/elementary/elementary_config.h | 8 ++++++++ src/lib/elementary/elm_config.c | 23 +++++++++++++++++++++++ src/lib/elementary/elm_config.h | 23 +++++++++++++++++++++++ src/lib/elementary/elm_priv.h | 3 ++- 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/lib/elementary/elementary_config.h b/src/lib/elementary/elementary_config.h index a5c0006e26..ae14f49252 100644 --- a/src/lib/elementary/elementary_config.h +++ b/src/lib/elementary/elementary_config.h @@ -1,3 +1,11 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif + +/** + * @file + * @brief Definition of special values for user configuration. + */ + +#define ELM_CONFIG_ICON_THEME_ELEMENTARY "_Elementary_Icon_Theme" + diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index aa72b4a90d..8dfe1b40c9 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -500,6 +500,7 @@ _desc_init(void) ELM_CONFIG_VAL(D, T, popup_horizontal_align, T_DOUBLE); ELM_CONFIG_VAL(D, T, popup_vertical_align, T_DOUBLE); ELM_CONFIG_VAL(D, T, spinner_min_max_filter_enable, T_UCHAR); + ELM_CONFIG_VAL(D, T, icon_theme, T_STRING); #undef T #undef D #undef T_INT @@ -1823,6 +1824,7 @@ _config_load(void) _elm_config->naviframe_prev_btn_auto_pushed = EINA_TRUE; _elm_config->popup_horizontal_align = 0.5; _elm_config->popup_vertical_align = 0.5; + _elm_config->icon_theme = eina_stringshare_add(ELM_CONFIG_ICON_THEME_ELEMENTARY); } static void @@ -2166,6 +2168,10 @@ _config_update(void) IFCFG(0x0009) _elm_config->scroll_accel_factor = 7.0; IFCFGEND + + IFCFG(0x000a) + _elm_config->icon_theme = eina_stringshare_add(ELM_CONFIG_ICON_THEME_ELEMENTARY); + IFCFGEND /** * Fix user config for current ELM_CONFIG_EPOCH here. **/ @@ -2652,6 +2658,23 @@ elm_config_scale_set(double scale) _elm_rescale(); } +EAPI const char * +elm_config_icon_theme_get(void) +{ + return _elm_config->icon_theme; +} + +EAPI void +elm_config_icon_theme_set(const char *theme) +{ + eina_stringshare_del(_elm_config->icon_theme); + + if (theme) + _elm_config->icon_theme = eina_stringshare_add(theme); + else + _elm_config->icon_theme = eina_stringshare_add(ELM_CONFIG_ICON_THEME_ELEMENTARY); +} + EAPI Eina_Bool elm_config_password_show_last_get(void) { diff --git a/src/lib/elementary/elm_config.h b/src/lib/elementary/elm_config.h index 023564f9aa..558d8596b5 100644 --- a/src/lib/elementary/elm_config.h +++ b/src/lib/elementary/elm_config.h @@ -973,6 +973,29 @@ EAPI double elm_config_scale_get(void); */ EAPI void elm_config_scale_set(double scale); +/** + * Get the icon theme the user has set. + * + * This gets the global icon theme currently set or the default value + * ELM_CONFIG_ICON_THEME_ELEMENTARY. + * + * @return the icon theme to use + * @ingroup Elm_Icon + */ +EAPI const char *elm_config_icon_theme_get(void); + +/** + * Set the icon theme for all elementary apps. + * + * This method will set the icon theme for all elm_icon_standard_set calls. + * Valid parameters are the name of an installed freedesktop.org icon theme + * or ELM_CONFIG_ICON_THEME_ELEMENTARY for the built in theme. + * + * @param the name of a freedesktop.org icon theme or ELM_CONFIG_ICON_THEME_ELEMENTARY + * @ingroup Elm_Icon + */ +EAPI void elm_config_icon_theme_set(const char *theme); + /** * @defgroup Elm_Password_last_show Password show last * @ingroup Elementary diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index a9772a9217..d307983607 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -134,7 +134,7 @@ struct _Elm_Theme * the users config doesn't need to be wiped - simply new values need * to be put in */ -#define ELM_CONFIG_FILE_GENERATION 0x0009 +#define ELM_CONFIG_FILE_GENERATION 0x000a #define ELM_CONFIG_VERSION_EPOCH_OFFSET 16 #define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \ ELM_CONFIG_FILE_GENERATION) @@ -317,6 +317,7 @@ struct _Elm_Config int gl_depth; int gl_stencil; int gl_msaa; + const char *icon_theme; /* Not part of the EET file */ Eina_Bool is_mirrored : 1; From 5bb29101a90357b618ec4ed12549655e8744597f Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 25 Apr 2016 16:57:13 +0100 Subject: [PATCH 2/4] elementary: Replace icon lookup_order with icon_theme. 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 | 4 ++ src/lib/elementary/elm_icon.c | 56 +++++++++---------------- src/lib/elementary/elm_icon.eo | 4 ++ src/lib/elementary/elm_toolbar.c | 24 ++++------- src/lib/elementary/elm_toolbar.eo | 5 ++- src/lib/elementary/elm_widget_icon.h | 1 - src/lib/elementary/elm_widget_toolbar.h | 1 - 7 files changed, 39 insertions(+), 56 deletions(-) diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index 8dfe1b40c9..36ee5c7816 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -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; } diff --git a/src/lib/elementary/elm_icon.c b/src/lib/elementary/elm_icon.c index d049c16f1b..55fc2d9414 100644 --- a/src/lib/elementary/elm_icon.c +++ b/src/lib/elementary/elm_icon.c @@ -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())) + { + ret = _icon_standard_set(obj, name); + if (ret && fdo) *fdo = EINA_FALSE; + } + else { - 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: - 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) @@ -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 diff --git a/src/lib/elementary/elm_icon.eo b/src/lib/elementary/elm_icon.eo index 146c5b32d1..e783d764da 100644 --- a/src/lib/elementary/elm_icon.eo +++ b/src/lib/elementary/elm_icon.eo @@ -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(). diff --git a/src/lib/elementary/elm_toolbar.c b/src/lib/elementary/elm_toolbar.c index 6c1662fffc..039cebf8a2 100644 --- a/src/lib/elementary/elm_toolbar.c +++ b/src/lib/elementary/elm_toolbar.c @@ -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 diff --git a/src/lib/elementary/elm_toolbar.eo b/src/lib/elementary/elm_toolbar.eo index 96e5865aba..17af71759c 100644 --- a/src/lib/elementary/elm_toolbar.eo +++ b/src/lib/elementary/elm_toolbar.eo @@ -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 { diff --git a/src/lib/elementary/elm_widget_icon.h b/src/lib/elementary/elm_widget_icon.h index 477a02b5a3..ab1e7f1ea8 100644 --- a/src/lib/elementary/elm_widget_icon.h +++ b/src/lib/elementary/elm_widget_icon.h @@ -24,7 +24,6 @@ struct _Elm_Icon_Data { Evas_Object *obj; // the object itself const char *stdicon; - Elm_Icon_Lookup_Order lookup_order; struct { diff --git a/src/lib/elementary/elm_widget_toolbar.h b/src/lib/elementary/elm_widget_toolbar.h index 51be6168ad..79ba5a809e 100644 --- a/src/lib/elementary/elm_widget_toolbar.h +++ b/src/lib/elementary/elm_widget_toolbar.h @@ -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; From 339e5721717a01bb70c481ffda53f2c246dd29fd Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 25 Apr 2016 19:30:23 +0100 Subject: [PATCH 3/4] elementary: clean code and tests of order_lookup User configuration has replaced the code based setting of lookup --- src/bin/elementary/test_icon.c | 52 +++++--------------------------- src/lib/elementary/elm_store.c | 1 - src/lib/elementary/elm_toolbar.c | 1 - 3 files changed, 8 insertions(+), 46 deletions(-) diff --git a/src/bin/elementary/test_icon.c b/src/bin/elementary/test_icon.c index e84d075c82..3109bdd8e9 100644 --- a/src/bin/elementary/test_icon.c +++ b/src/bin/elementary/test_icon.c @@ -146,7 +146,7 @@ test_icon_transparent(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void /* Test: Icon Standard */ static void -_standard_list_populate(Evas_Object *list, Elm_Icon_Lookup_Order order, int size) +_standard_list_populate(Evas_Object *list, int size) { Evas_Object *ic; Eina_List *l; @@ -168,7 +168,6 @@ _standard_list_populate(Evas_Object *list, Elm_Icon_Lookup_Order order, int size if ((strrchr(name, '-') != NULL) || !strcmp(name, "folder")) { ic = elm_icon_add(list); - elm_icon_order_lookup_set(ic, order); elm_icon_standard_set(ic, name); if (size) evas_object_size_hint_min_set(ic, size, size); @@ -185,14 +184,9 @@ _rdg_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { Evas_Object *li = data; - Evas_Object *icon = evas_object_data_get(li, "resize_icon"); - Evas_Object *order_rdg = evas_object_data_get(li, "order_rdg"); Evas_Object *size_rdg = evas_object_data_get(li, "size_rdg"); - _standard_list_populate(li, elm_radio_value_get(order_rdg), - elm_radio_value_get(size_rdg)); - - elm_icon_order_lookup_set(icon, elm_radio_value_get(order_rdg)); + _standard_list_populate(li, elm_radio_value_get(size_rdg)); } static void @@ -232,7 +226,6 @@ _std_btn_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, icon = elm_icon_add(panes); evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME); elm_icon_standard_set(icon, "folder"); elm_object_part_content_set(panes, "left", icon); evas_object_show(icon); @@ -240,7 +233,6 @@ _std_btn_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, icon = elm_icon_add(panes); evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME); elm_icon_standard_set(icon, "user-home"); elm_object_part_content_set(panes, "right", icon); evas_object_show(icon); @@ -253,7 +245,7 @@ void test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - Evas_Object *win, *li, *box, *hbox, *fr, *rd, *rdg, *icon, *sl, *bt; + Evas_Object *win, *li, *box, *hbox, *fr, *rd, *rdg, *label, *icon, *sl, *bt; win = elm_win_util_standard_add("icon-test-std", "Icon Standard"); elm_win_autodel_set(win, EINA_TRUE); @@ -267,7 +259,7 @@ test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_smart_callback_add(li, "selected", _list_selected_cb, NULL); - _standard_list_populate(li, ELM_ICON_LOOKUP_FDO_THEME, 0); + _standard_list_populate(li, 0); evas_object_show(li); // lookup order @@ -282,37 +274,10 @@ test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, elm_object_content_set(fr, hbox); evas_object_show(hbox); - rdg = elm_radio_add(hbox); - elm_radio_state_value_set(rdg, ELM_ICON_LOOKUP_FDO_THEME); - elm_object_text_set(rdg, "fdo, theme"); - elm_box_pack_end(hbox, rdg); - evas_object_show(rdg); - evas_object_smart_callback_add(rdg, "changed", _rdg_changed_cb, li); - evas_object_data_set(li, "order_rdg", rdg); - - rd = elm_radio_add(hbox); - elm_radio_state_value_set(rd, ELM_ICON_LOOKUP_THEME_FDO); - elm_radio_group_add(rd, rdg); - elm_object_text_set(rd, "theme, fdo"); - elm_box_pack_end(hbox, rd); - evas_object_show(rd); - evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li); - - rd = elm_radio_add(hbox); - elm_radio_state_value_set(rd, ELM_ICON_LOOKUP_FDO); - elm_radio_group_add(rd, rdg); - elm_object_text_set(rd, "fdo only"); - elm_box_pack_end(hbox, rd); - evas_object_show(rd); - evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li); - - rd = elm_radio_add(hbox); - elm_radio_state_value_set(rd, ELM_ICON_LOOKUP_THEME); - elm_radio_group_add(rd, rdg); - elm_object_text_set(rd, "theme only"); - elm_box_pack_end(hbox, rd); - evas_object_show(rd); - evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, li); + label = elm_label_add(hbox); + elm_object_text_set(label, "Lookup order has moved to elementary_config"); + elm_box_pack_end(hbox, label); + evas_object_show(label); // size fr = elm_frame_add(box); @@ -405,7 +370,6 @@ test_icon_standard(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, evas_object_show(hbox); icon = elm_icon_add(hbox); - elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_FDO_THEME); elm_icon_standard_set(icon, "folder"); evas_object_size_hint_min_set(icon, 16, 16); elm_box_pack_end(hbox, icon); diff --git a/src/lib/elementary/elm_store.c b/src/lib/elementary/elm_store.c index a953f910c5..fd5b370da3 100644 --- a/src/lib/elementary/elm_store.c +++ b/src/lib/elementary/elm_store.c @@ -311,7 +311,6 @@ _store_item_content_get(void *data, Evas_Object *obj, const char *part) case ELM_STORE_ITEM_MAPPING_ICON: ic = elm_icon_add(obj); s = *(char **)(((unsigned char *)sti->data) + m->offset); - elm_icon_order_lookup_set(ic, m->details.icon.lookup_order); evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, m->details.icon.w, diff --git a/src/lib/elementary/elm_toolbar.c b/src/lib/elementary/elm_toolbar.c index 039cebf8a2..1056f9d1e8 100644 --- a/src/lib/elementary/elm_toolbar.c +++ b/src/lib/elementary/elm_toolbar.c @@ -3632,7 +3632,6 @@ _elm_toolbar_item_state_add(Eo *eo_item, Elm_Toolbar_Item_Data *item, ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(item, NULL); obj = WIDGET(item); - ELM_TOOLBAR_DATA_GET(WIDGET(item), sd); if (!item->states) { From 9a3a8a1eb2fdaa6cd86bbac1a1f79b9334e5f859 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 25 Apr 2016 23:39:58 +0100 Subject: [PATCH 4/4] elementary: Provide the user an icon config gui This allows users to specify the theme (elm or fdo) to use in elm apps. I'll hook this into E as well... --- src/bin/elementary/config.c | 164 ++++++++++++++++++++++++++++++++++ src/lib/elementary/elm_icon.c | 2 +- 2 files changed, 165 insertions(+), 1 deletion(-) diff --git a/src/bin/elementary/config.c b/src/bin/elementary/config.c index d63bcef157..ed1261a97c 100644 --- a/src/bin/elementary/config.c +++ b/src/bin/elementary/config.c @@ -1031,6 +1031,14 @@ _cf_themes(void *data, _flip_to(data, "themes"); } +static void +_cf_icons(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + _flip_to(data, "icons"); +} + static void _cf_fonts(void *data, Evas_Object *obj EINA_UNUSED, @@ -1525,6 +1533,51 @@ _theme_sel(void *data EINA_UNUSED, printf("not implemented\n"); }*/ +static void +_icon_theme_use(void *data EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Evas_Object *win = elm_object_top_widget_get(obj); + const char *theme = evas_object_data_get(win, "icon_theme"); + + elm_config_icon_theme_set(theme); + elm_config_all_flush(); +} + +static void +_icon_theme_sel(void *data, Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + const char *theme = (const char *)data; + Evas_Object *win = elm_object_top_widget_get(obj); + + evas_object_data_set(win, "icon_theme", theme); +} + +static Eina_Bool +_icon_theme_valid(const char *theme) +{ + const char *icon_path; + + icon_path = efreet_icon_path_find(theme, "folder", 48); + return !!icon_path; +} + +static int +_icon_theme_list_sort(const void *data1, const void *data2) +{ + const Efreet_Icon_Theme *t1, *t2; + + t1 = data1; + t2 = data2; + + if (!t1->name.name) return 1; + if (!t2->name.name) return -1; + + return strcmp(t1->name.name, t2->name.name); +} + static void _status_config_sizing(Evas_Object *win, Evas_Object *naviframe) @@ -2164,6 +2217,112 @@ _status_config_themes(Evas_Object *win, elm_naviframe_item_simple_push(naviframe, tb); } +static void +_status_config_icons(Evas_Object *win, + Evas_Object *naviframe) +{ + Evas_Object *tb, *rc, *sp, *li, *ic, *pd, *fr, *bt; + Eina_List *list, *l; + const Efreet_Icon_Theme *th; + Elm_Object_Item *list_it, *def_it; + + tb = elm_table_add(win); + evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); + + rc = evas_object_rectangle_add(evas_object_evas_get(win)); + evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_min_set(rc, 0, 130); + elm_table_pack(tb, rc, 0, 0, 1, 1); + + rc = evas_object_rectangle_add(evas_object_evas_get(win)); + evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_min_set(rc, 0, 200); + elm_table_pack(tb, rc, 0, 1, 1, 1); + + ///////////////////////////////////////////// + + pd = elm_frame_add(win); + elm_object_style_set(pd, "pad_medium"); + evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(tb, pd, 0, 0, 1, 1); + evas_object_show(pd); + + li = elm_list_add(win); + elm_list_multi_select_set(li, EINA_FALSE); + evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_content_set(pd, li); + evas_object_show(li); + + evas_object_data_set(win, "icon_theme", elm_config_icon_theme_get()); + ic = elm_icon_add(li); + def_it = elm_list_item_append(li, "Elementary", ic, NULL, _icon_theme_sel, + ELM_CONFIG_ICON_THEME_ELEMENTARY); + + list = efreet_icon_theme_list_get(); + list = eina_list_sort(list, eina_list_count(list), _icon_theme_list_sort); + EINA_LIST_FOREACH(list, l, th) + { + if (!_icon_theme_valid(th->name.internal)) + continue; + + ic = elm_icon_add(li); + elm_image_file_set(ic, efreet_icon_path_find(th->name.internal, "folder", 48), NULL); + list_it = elm_list_item_append(li, th->name.name, ic, NULL, + _icon_theme_sel, th->name.internal); + + if (!strcmp(elm_config_icon_theme_get(), th->name.name)) + elm_list_item_selected_set(list_it, EINA_TRUE); + } + if (!elm_list_selected_items_get(li)) + elm_list_item_selected_set(def_it, EINA_TRUE); + + elm_list_go(li); + + pd = elm_frame_add(win); + elm_object_style_set(pd, "pad_medium"); + evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_table_pack(tb, pd, 0, 1, 1, 1); + evas_object_show(pd); + + fr = elm_frame_add(win); + elm_object_text_set(fr, "Preview"); + evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_content_set(pd, fr); + evas_object_show(fr); + + ///////////////////////////////////////////// + sp = elm_separator_add(win); + elm_separator_horizontal_set(sp, EINA_TRUE); + evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5); + elm_table_pack(tb, sp, 0, 2, 1, 1); + evas_object_show(sp); + + pd = elm_frame_add(win); + elm_object_style_set(pd, "pad_medium"); + evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(pd, 0.5, 0.5); + elm_table_pack(tb, pd, 0, 3, 1, 1); + evas_object_show(pd); + + bt = elm_button_add(win); + evas_object_smart_callback_add(bt, "clicked", _icon_theme_use, win); + elm_object_text_set(bt, "Use Icon Theme"); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bt, 0.5, 0.5); + elm_object_content_set(pd, bt); + evas_object_show(bt); + + evas_object_data_set(win, "icons", tb); + elm_naviframe_item_simple_push(naviframe, tb); +} + + static void _font_preview_update(Evas_Object *win) { @@ -3941,6 +4100,10 @@ _status_config_full(Evas_Object *win, _cf_themes, win); elm_toolbar_item_priority_set(tb_it, 90); + tb_it = elm_toolbar_item_append(tb, "preferences-desktop-theme", "Icons", + _cf_icons, win); + elm_toolbar_item_priority_set(tb_it, 90); + elm_toolbar_item_append(tb, "preferences-desktop-font", "Fonts", _cf_fonts, win); @@ -3965,6 +4128,7 @@ _status_config_full(Evas_Object *win, evas_object_data_set(win, "naviframe", naviframe); _status_config_themes(win, naviframe); + _status_config_icons(win, naviframe); _status_config_fonts(win, naviframe); _status_config_profiles(win, naviframe); _status_config_rendering(win, naviframe); diff --git a/src/lib/elementary/elm_icon.c b/src/lib/elementary/elm_icon.c index 55fc2d9414..0e3fc43ac0 100644 --- a/src/lib/elementary/elm_icon.c +++ b/src/lib/elementary/elm_icon.c @@ -276,7 +276,7 @@ _icon_freedesktop_set(Evas_Object *obj, { Efreet_Icon_Theme *theme; /* TODO: Listen for EFREET_EVENT_ICON_CACHE_UPDATE */ - theme = efreet_icon_theme_find(getenv("E_ICON_THEME")); + theme = efreet_icon_theme_find(elm_config_icon_theme_get()); if (!theme) { const char **itr;