diff options
author | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2015-02-16 11:34:50 +0100 |
---|---|---|
committer | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2015-10-05 12:54:39 +0200 |
commit | e32225568ddbee9301f07c4d062ed977abcb14ac (patch) | |
tree | f9d690f65c76c5f874703835a4020091ad372e42 | |
parent | 6f00127d444213a2a3b2fc4788ef5cb3b9882be9 (diff) | |
download | elementary-e32225568ddbee9301f07c4d062ed977abcb14ac.tar.gz |
settingswidget: pass group and file instead of a evas_object
-rw-r--r-- | src/bin/test_settingspane.c | 26 | ||||
-rw-r--r-- | src/lib/elc_settingspane.c | 47 | ||||
-rw-r--r-- | src/lib/elm_settingspane.eo | 6 |
3 files changed, 52 insertions, 27 deletions
diff --git a/src/bin/test_settingspane.c b/src/bin/test_settingspane.c index 832b5c3e1..9edab693c 100644 --- a/src/bin/test_settingspane.c +++ b/src/bin/test_settingspane.c @@ -217,7 +217,7 @@ recreate_focused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info E void test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - Evas_Object *win, *o, *box, *sw, *btnbox, *ic, *swallow; + Evas_Object *win, *o, *box, *sw, *btnbox, *swallow; Elm_Settingspane_Item *it, *it2; char buf[PATH_MAX]; @@ -246,37 +246,25 @@ test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev { snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), simple_menu[i][2]); - ic = elm_icon_add(win); - elm_image_file_set(ic, buf, NULL); - evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL); - it = elm_settingspane_item_append(sw, ic, simple_menu[i][0], - simple_menu[i][1], ic, NULL); + it = elm_settingspane_item_append(sw, buf, simple_menu[i][0], + simple_menu[i][1], buf, NULL, NULL); elm_settingspane_item_attach_panel(it, content_cb[i], reset_cb, apply_cb); } /* A complex item! */ - ic = elm_icon_add(win); snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), "icon_09.png"); - elm_image_file_set(ic, buf, NULL); - evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL); - it = elm_settingspane_item_append(sw, ic, "Complex", + it = elm_settingspane_item_append(sw, NULL, "Complex", "No we are not going to jump here into<br>complex numbers,<br>this is just a complex menu item,<br>this means it has childrens!", - ic, NULL); + buf, NULL, NULL); elm_settingspane_item_keywords_set(it, eina_stringshare_add("Hardone,second")); - ic = elm_icon_add(win); snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), "bubble.png"); - elm_image_file_set(ic, buf, NULL); - evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL); - it2 = elm_settingspane_item_append(sw, ic, "Child", + it2 = elm_settingspane_item_append(sw, NULL, "Child", "This is a children entry", - ic, it); + buf, NULL, it); elm_settingspane_item_keywords_set(it2, eina_stringshare_add("Heavyone,Third,")); elm_settingspane_item_attach_panel(it2, content_cb[3], reset_cb, apply_cb); diff --git a/src/lib/elc_settingspane.c b/src/lib/elc_settingspane.c index 5debafcb7..2110270c4 100644 --- a/src/lib/elc_settingspane.c +++ b/src/lib/elc_settingspane.c @@ -1409,14 +1409,49 @@ _elm_settingspane_eo_base_constructor(Eo *obj, Elm_Settingspane_Data *pd) pd->itcc->func.content_get = _elm_settingspane_ii_content_cb; } +static Evas_Object* +_elm_settingspane_icon_gen(Evas_Object *par, const char *file, const char *group) +{ + Evas_Object *ic; + + ic = elm_icon_add(par); + + if (group && file) + { + //we have a edje file + elm_image_file_set(ic, file, group); + } + else if (!group && file) + { + //we have a normal file + elm_image_file_set(ic, file, group); + } + else if (group && !file) + { + //we have a standart icon + elm_icon_standard_set(ic, group); + } + else + { + evas_object_del(ic); + return NULL; + } + evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(ic, EVAS_HINT_FILL, EVAS_HINT_FILL); + return ic; +} + static Elm_Settingspane_Item * _elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, const char *description, - Evas_Object *icon, Elm_Settingspane_Item *par, - Elm_Settingspane_Item *rel) + const char *file, const char *group, + Elm_Settingspane_Item *par, Elm_Settingspane_Item *rel) { Elm_Settingspane_Item *new_child = NULL; Elm_Settingspane_Item_Data *data_par; + Evas_Object *icon; + + icon = _elm_settingspane_icon_gen(obj, file, group); /* * Append to the zero level @@ -1445,17 +1480,17 @@ _elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *dat } EOLIAN static Elm_Settingspane_Item * -_elm_settingspane_item_append(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, const char *description, Evas_Object *icon, Elm_Settingspane_Item *par) +_elm_settingspane_item_append(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, const char *description, const char *file, const char *group, Elm_Settingspane_Item *par) { - return _elm_settingspane_item_append_full(obj, pd, data, name, description, icon, par, NULL); + return _elm_settingspane_item_append_full(obj, pd, data, name, description, file, group, par, NULL); } EOLIAN static Elm_Settingspane_Item * -_elm_settingspane_item_append_relative(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, const char *description, Evas_Object *icon, Elm_Settingspane_Item *rel) +_elm_settingspane_item_append_relative(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, const char *description, const char *file, const char *group, Elm_Settingspane_Item *rel) { EINA_SAFETY_ON_NULL_RETURN_VAL(rel, NULL); Elm_Settingspane_Item_Data *id = eo_data_scope_get(rel, ELM_SETTINGSPANE_ITEM_CLASS); - return _elm_settingspane_item_append_full(obj, pd, data, name, description, icon, id->par, rel); + return _elm_settingspane_item_append_full(obj, pd, data, name, description, file, group, id->par, rel); } /* Item implement */ diff --git a/src/lib/elm_settingspane.eo b/src/lib/elm_settingspane.eo index 87184860e..1efb9d820 100644 --- a/src/lib/elm_settingspane.eo +++ b/src/lib/elm_settingspane.eo @@ -47,7 +47,8 @@ class Elm_Settingspane(Elm_Layout) @in const(char) *name; /*@ name of the item */ @in const(char) *description; /*@ the description of the item */ - @in Evas_Object *icon; /*@ the icon to show in the menu */ + @in const(char) *file; /*@ The file of the icon to display, NULL if it is a standart fdo icon.*/ + @in const(char) *group; /*@ The group of the icon to display, NULL if it is a png file, or the name of a standart fdo icon to use. */ @in Elm_Settingspane_Item *par; /*@ parent of this item, it will be shown when the parent item is selected. If NULL it will be appended to the 0 lvl */ } } @@ -70,7 +71,8 @@ class Elm_Settingspane(Elm_Layout) @in void *data; /*@ data to attach to the item which gets passed to the callback */ @in const(char) *name; /*@ name of the item */ @in const(char) *description; /*@ the description of the item */ - @in Evas_Object *icon; /*@ the icon to show in the menu */ + @in const(char) *file; /*@ The file of the icon to display, NULL if it is a standart fdo icon.*/ + @in const(char) *group; /*@ The group of the icon to display, NULL if it is a png file, or the name of a standart fdo icon to use. */ @in Elm_Settingspane_Item *rel; /*@ the item after which the current one will be appended, if NULL the call will fail!*/ } } |