diff options
author | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2015-03-22 14:41:41 +0100 |
---|---|---|
committer | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2015-10-05 12:56:26 +0200 |
commit | b7d8d91a825c5bf83a8b848ad73227c9bf56d005 (patch) | |
tree | ac92a854fbd4cefcdd1ed5861b2497af838f9892 | |
parent | 52ce4835a1bca6854b846ebab60f0018713522c6 (diff) | |
download | elementary-b7d8d91a825c5bf83a8b848ad73227c9bf56d005.tar.gz |
settingspane: shorted append method
The append method is now shorter, and you can add the image and
description when you want and need to do.
-rw-r--r-- | src/bin/test_settingspane.c | 20 | ||||
-rw-r--r-- | src/lib/elc_settingspane.c | 65 | ||||
-rw-r--r-- | src/lib/elm_settingspane.eo | 6 | ||||
-rw-r--r-- | src/lib/elm_settingspane_item.eo | 18 |
4 files changed, 76 insertions, 33 deletions
diff --git a/src/bin/test_settingspane.c b/src/bin/test_settingspane.c index 60be9efa1..973b90690 100644 --- a/src/bin/test_settingspane.c +++ b/src/bin/test_settingspane.c @@ -237,8 +237,9 @@ 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]); - it = elm_settingspane_item_append(sw, buf, simple_menu[i][0], - simple_menu[i][1], buf, NULL, NULL); + it = elm_settingspane_item_append(sw, buf, simple_menu[i][0], NULL); + elm_settingspane_item_description_set(it, simple_menu[i][1]); + elm_settingspane_item_image_set(it, buf, NULL); elm_settingspane_item_attach_panel(it, content_cb[i], reset_cb, apply_cb); } @@ -246,15 +247,18 @@ 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(), "icon_09.png"); - 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!", - buf, NULL, NULL); + it = elm_settingspane_item_append(sw, NULL, "Complex", NULL); + elm_settingspane_item_description_set(it, + "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!"); + elm_settingspane_item_image_set(it, buf, NULL); elm_settingspane_item_keywords_set(it, "Hardone,second"); snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), "bubble.png"); - it2 = elm_settingspane_item_append(sw, NULL, "Child", - "This is a children entry", - buf, NULL, it); + it2 = elm_settingspane_item_append(sw, NULL, "Child", it); + elm_settingspane_item_description_set(it2, + "This is a children entry"); + elm_settingspane_item_image_set(it2, buf, NULL); + elm_settingspane_item_keywords_set(it2, "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 b584f509e..03f0a33bb 100644 --- a/src/lib/elc_settingspane.c +++ b/src/lib/elc_settingspane.c @@ -76,6 +76,8 @@ typedef struct const char *name; const char *description; + const char *group; + const char *file; void *data; Evas_Object *sw; //< widget where this is created @@ -312,7 +314,9 @@ _elm_settingspane_ii_content_cb(void *data, Evas_Object *obj, const char *part) } static Elm_Settingspane_Item* -_item_new(Evas_Object *obj, Elm_Settingspane_Item *par, void *usr_data, const char *name, const char *description, Evas_Object *icon) +_item_new(Evas_Object *obj, Elm_Settingspane_Item *par, + void *usr_data, + const char *name) { Elm_Settingspane_Item *item = eo_add(ELM_SETTINGSPANE_ITEM_CLASS, obj); Elm_Settingspane_Item_Data *data = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS); @@ -321,12 +325,8 @@ _item_new(Evas_Object *obj, Elm_Settingspane_Item *par, void *usr_data, const ch data->sw = obj; data->par = par; data->name = name; - data->description = description; - data->icon = icon; data->key_words = NULL; data->key_words = eina_list_append(data->key_words, eina_stringshare_add(name)); - //we need to ref this item, so elm_genlist_clear will not delete it! - eo_ref(icon); return item; } @@ -929,7 +929,7 @@ _elm_settingspane_evas_object_smart_add(Eo *obj, Elm_Settingspane_Data *pd) evas_object_show(tb2); pd->table_menu = tb2; - pd->zero = _item_new(obj, NULL, NULL, eina_stringshare_add("root"), eina_stringshare_add(""), NULL); + pd->zero = _item_new(obj, NULL, NULL, eina_stringshare_add("root")); } EOLIAN static void @@ -991,22 +991,18 @@ _elm_settingspane_icon_gen(Evas_Object *par, const char *file, const char *group static Elm_Settingspane_Item * _elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *data, - const char *name, const char *description, - const char *file, const char *group, + const char *name, 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 */ if (!par) { - new_child = _item_new(obj, pd->zero, data, name, description, icon); + new_child = _item_new(obj, pd->zero, data, name); _item_append(pd->zero, new_child, rel); return new_child; } @@ -1021,24 +1017,55 @@ _elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *dat } else { - new_child = _item_new(obj, par, data, name, description, icon); + new_child = _item_new(obj, par, data, name); _item_append(par, new_child, rel); } return new_child; } +EOLIAN static void +_elm_settingspane_item_description_set(Eo *obj, Elm_Settingspane_Item_Data *pd, const char *description) +{ + pd->description = description; + _item_menu_refresh(obj, pd); +} + +EOLIAN static void +_elm_settingspane_item_image_set(Eo *obj, Elm_Settingspane_Item_Data *pd, const char *file, const char *group) +{ + pd->file = file; + pd->group = group; + + if (pd->icon) + { + eo_unref(pd->icon); + evas_object_del(pd->icon); + } + + pd->icon = _elm_settingspane_icon_gen(pd->sw, file, group); + eo_ref(pd->icon); + _item_menu_refresh(obj, pd); +} + +EOLIAN static void +_elm_settingspane_item_image_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, const char **file, const char **group) +{ + *file = pd->file; + *group = pd->group; +} + EOLIAN static Elm_Settingspane_Item * -_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) +_elm_settingspane_item_append(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, Elm_Settingspane_Item *par) { - return _elm_settingspane_item_append_full(obj, pd, data, name, description, file, group, par, NULL); + return _elm_settingspane_item_append_full(obj, pd, data, name, 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, const char *file, const char *group, Elm_Settingspane_Item *rel) +_elm_settingspane_item_append_relative(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, 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, file, group, id->par, rel); + return _elm_settingspane_item_append_full(obj, pd, data, name, id->par, rel); } /* Item implement */ @@ -1390,8 +1417,8 @@ _elm_settingspane_item_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_Settingspane_ { if (pd->panel) eo_unref(pd->panel->layout); - //unref the icon, - eo_unref(pd->icon); + if (pd->icon) + eo_unref(pd->icon); eo_do_super(obj, ELM_SETTINGSPANE_ITEM_CLASS, eo_destructor()); } diff --git a/src/lib/elm_settingspane.eo b/src/lib/elm_settingspane.eo index ada8d2e72..bcfaa47ac 100644 --- a/src/lib/elm_settingspane.eo +++ b/src/lib/elm_settingspane.eo @@ -46,9 +46,6 @@ 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 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,9 +67,6 @@ class Elm_Settingspane(Elm_Layout) params { @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 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!*/ } } diff --git a/src/lib/elm_settingspane_item.eo b/src/lib/elm_settingspane_item.eo index 860e7ac4c..296d34430 100644 --- a/src/lib/elm_settingspane_item.eo +++ b/src/lib/elm_settingspane_item.eo @@ -20,6 +20,14 @@ class Elm_Settingspane_Item(Eo.Base){ } } description{ + set { + /*@ + Will set the desrciption for the item. + + It will be displayed when you hover the item. + @ingroup Settingspane + */ + } get { /*@ Return the description of the item @@ -36,6 +44,16 @@ class Elm_Settingspane_Item(Eo.Base){ const (char) *description; } } + image { + set { + } + get { + } + values { + const (char) *file; + const (char) *group; + } + } parent { get { /*@ |