summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-03-22 14:41:41 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-10-05 12:56:26 +0200
commitb7d8d91a825c5bf83a8b848ad73227c9bf56d005 (patch)
treeac92a854fbd4cefcdd1ed5861b2497af838f9892
parent52ce4835a1bca6854b846ebab60f0018713522c6 (diff)
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.c20
-rw-r--r--src/lib/elc_settingspane.c65
-rw-r--r--src/lib/elm_settingspane.eo6
-rw-r--r--src/lib/elm_settingspane_item.eo18
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
237 snprintf(buf, sizeof(buf), "%s/images/%s", 237 snprintf(buf, sizeof(buf), "%s/images/%s",
238 elm_app_data_dir_get(), simple_menu[i][2]); 238 elm_app_data_dir_get(), simple_menu[i][2]);
239 239
240 it = elm_settingspane_item_append(sw, buf, simple_menu[i][0], 240 it = elm_settingspane_item_append(sw, buf, simple_menu[i][0], NULL);
241 simple_menu[i][1], buf, NULL, NULL); 241 elm_settingspane_item_description_set(it, simple_menu[i][1]);
242 elm_settingspane_item_image_set(it, buf, NULL);
242 elm_settingspane_item_attach_panel(it, content_cb[i], reset_cb, apply_cb); 243 elm_settingspane_item_attach_panel(it, content_cb[i], reset_cb, apply_cb);
243 } 244 }
244 245
@@ -246,15 +247,18 @@ test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
246 snprintf(buf, sizeof(buf), "%s/images/%s", 247 snprintf(buf, sizeof(buf), "%s/images/%s",
247 elm_app_data_dir_get(), "icon_09.png"); 248 elm_app_data_dir_get(), "icon_09.png");
248 249
249 it = elm_settingspane_item_append(sw, NULL, "Complex", 250 it = elm_settingspane_item_append(sw, NULL, "Complex", NULL);
250 "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!", 251 elm_settingspane_item_description_set(it,
251 buf, NULL, NULL); 252 "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!");
253 elm_settingspane_item_image_set(it, buf, NULL);
252 elm_settingspane_item_keywords_set(it, "Hardone,second"); 254 elm_settingspane_item_keywords_set(it, "Hardone,second");
253 snprintf(buf, sizeof(buf), "%s/images/%s", 255 snprintf(buf, sizeof(buf), "%s/images/%s",
254 elm_app_data_dir_get(), "bubble.png"); 256 elm_app_data_dir_get(), "bubble.png");
255 it2 = elm_settingspane_item_append(sw, NULL, "Child", 257 it2 = elm_settingspane_item_append(sw, NULL, "Child", it);
256 "This is a children entry", 258 elm_settingspane_item_description_set(it2,
257 buf, NULL, it); 259 "This is a children entry");
260 elm_settingspane_item_image_set(it2, buf, NULL);
261
258 elm_settingspane_item_keywords_set(it2, "Heavyone,Third,"); 262 elm_settingspane_item_keywords_set(it2, "Heavyone,Third,");
259 elm_settingspane_item_attach_panel(it2, content_cb[3], reset_cb, apply_cb); 263 elm_settingspane_item_attach_panel(it2, content_cb[3], reset_cb, apply_cb);
260 264
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
76 76
77 const char *name; 77 const char *name;
78 const char *description; 78 const char *description;
79 const char *group;
80 const char *file;
79 void *data; 81 void *data;
80 82
81 Evas_Object *sw; //< widget where this is created 83 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)
312} 314}
313 315
314static Elm_Settingspane_Item* 316static Elm_Settingspane_Item*
315_item_new(Evas_Object *obj, Elm_Settingspane_Item *par, void *usr_data, const char *name, const char *description, Evas_Object *icon) 317_item_new(Evas_Object *obj, Elm_Settingspane_Item *par,
318 void *usr_data,
319 const char *name)
316{ 320{
317 Elm_Settingspane_Item *item = eo_add(ELM_SETTINGSPANE_ITEM_CLASS, obj); 321 Elm_Settingspane_Item *item = eo_add(ELM_SETTINGSPANE_ITEM_CLASS, obj);
318 Elm_Settingspane_Item_Data *data = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS); 322 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
321 data->sw = obj; 325 data->sw = obj;
322 data->par = par; 326 data->par = par;
323 data->name = name; 327 data->name = name;
324 data->description = description;
325 data->icon = icon;
326 data->key_words = NULL; 328 data->key_words = NULL;
327 data->key_words = eina_list_append(data->key_words, eina_stringshare_add(name)); 329 data->key_words = eina_list_append(data->key_words, eina_stringshare_add(name));
328 //we need to ref this item, so elm_genlist_clear will not delete it!
329 eo_ref(icon);
330 return item; 330 return item;
331} 331}
332 332
@@ -929,7 +929,7 @@ _elm_settingspane_evas_object_smart_add(Eo *obj, Elm_Settingspane_Data *pd)
929 evas_object_show(tb2); 929 evas_object_show(tb2);
930 pd->table_menu = tb2; 930 pd->table_menu = tb2;
931 931
932 pd->zero = _item_new(obj, NULL, NULL, eina_stringshare_add("root"), eina_stringshare_add(""), NULL); 932 pd->zero = _item_new(obj, NULL, NULL, eina_stringshare_add("root"));
933 } 933 }
934 934
935EOLIAN static void 935EOLIAN static void
@@ -991,22 +991,18 @@ _elm_settingspane_icon_gen(Evas_Object *par, const char *file, const char *group
991 991
992static Elm_Settingspane_Item * 992static Elm_Settingspane_Item *
993_elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *data, 993_elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *data,
994 const char *name, const char *description, 994 const char *name,
995 const char *file, const char *group,
996 Elm_Settingspane_Item *par, Elm_Settingspane_Item *rel) 995 Elm_Settingspane_Item *par, Elm_Settingspane_Item *rel)
997{ 996{
998 Elm_Settingspane_Item *new_child = NULL; 997 Elm_Settingspane_Item *new_child = NULL;
999 Elm_Settingspane_Item_Data *data_par; 998 Elm_Settingspane_Item_Data *data_par;
1000 Evas_Object *icon;
1001
1002 icon = _elm_settingspane_icon_gen(obj, file, group);
1003 999
1004 /* 1000 /*
1005 * Append to the zero level 1001 * Append to the zero level
1006 */ 1002 */
1007 if (!par) 1003 if (!par)
1008 { 1004 {
1009 new_child = _item_new(obj, pd->zero, data, name, description, icon); 1005 new_child = _item_new(obj, pd->zero, data, name);
1010 _item_append(pd->zero, new_child, rel); 1006 _item_append(pd->zero, new_child, rel);
1011 return new_child; 1007 return new_child;
1012 } 1008 }
@@ -1021,24 +1017,55 @@ _elm_settingspane_item_append_full(Eo *obj, Elm_Settingspane_Data *pd, void *dat
1021 } 1017 }
1022 else 1018 else
1023 { 1019 {
1024 new_child = _item_new(obj, par, data, name, description, icon); 1020 new_child = _item_new(obj, par, data, name);
1025 _item_append(par, new_child, rel); 1021 _item_append(par, new_child, rel);
1026 } 1022 }
1027 return new_child; 1023 return new_child;
1028} 1024}
1029 1025
1026EOLIAN static void
1027_elm_settingspane_item_description_set(Eo *obj, Elm_Settingspane_Item_Data *pd, const char *description)
1028{
1029 pd->description = description;
1030 _item_menu_refresh(obj, pd);
1031}
1032
1033EOLIAN static void
1034_elm_settingspane_item_image_set(Eo *obj, Elm_Settingspane_Item_Data *pd, const char *file, const char *group)
1035{
1036 pd->file = file;
1037 pd->group = group;
1038
1039 if (pd->icon)
1040 {
1041 eo_unref(pd->icon);
1042 evas_object_del(pd->icon);
1043 }
1044
1045 pd->icon = _elm_settingspane_icon_gen(pd->sw, file, group);
1046 eo_ref(pd->icon);
1047 _item_menu_refresh(obj, pd);
1048}
1049
1050EOLIAN static void
1051_elm_settingspane_item_image_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, const char **file, const char **group)
1052{
1053 *file = pd->file;
1054 *group = pd->group;
1055}
1056
1030EOLIAN static Elm_Settingspane_Item * 1057EOLIAN static Elm_Settingspane_Item *
1031_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) 1058_elm_settingspane_item_append(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, Elm_Settingspane_Item *par)
1032{ 1059{
1033 return _elm_settingspane_item_append_full(obj, pd, data, name, description, file, group, par, NULL); 1060 return _elm_settingspane_item_append_full(obj, pd, data, name, par, NULL);
1034} 1061}
1035 1062
1036EOLIAN static Elm_Settingspane_Item * 1063EOLIAN static Elm_Settingspane_Item *
1037_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) 1064_elm_settingspane_item_append_relative(Eo *obj, Elm_Settingspane_Data *pd, void *data, const char *name, Elm_Settingspane_Item *rel)
1038{ 1065{
1039 EINA_SAFETY_ON_NULL_RETURN_VAL(rel, NULL); 1066 EINA_SAFETY_ON_NULL_RETURN_VAL(rel, NULL);
1040 Elm_Settingspane_Item_Data *id = eo_data_scope_get(rel, ELM_SETTINGSPANE_ITEM_CLASS); 1067 Elm_Settingspane_Item_Data *id = eo_data_scope_get(rel, ELM_SETTINGSPANE_ITEM_CLASS);
1041 return _elm_settingspane_item_append_full(obj, pd, data, name, description, file, group, id->par, rel); 1068 return _elm_settingspane_item_append_full(obj, pd, data, name, id->par, rel);
1042} 1069}
1043 1070
1044/* Item implement */ 1071/* Item implement */
@@ -1390,8 +1417,8 @@ _elm_settingspane_item_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_Settingspane_
1390{ 1417{
1391 if (pd->panel) 1418 if (pd->panel)
1392 eo_unref(pd->panel->layout); 1419 eo_unref(pd->panel->layout);
1393 //unref the icon, 1420 if (pd->icon)
1394 eo_unref(pd->icon); 1421 eo_unref(pd->icon);
1395 eo_do_super(obj, ELM_SETTINGSPANE_ITEM_CLASS, eo_destructor()); 1422 eo_do_super(obj, ELM_SETTINGSPANE_ITEM_CLASS, eo_destructor());
1396} 1423}
1397 1424
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)
46 @in void *data; /*@ data to attach to the item which gets passed to the callback */ 46 @in void *data; /*@ data to attach to the item which gets passed to the callback */
47 47
48 @in const(char) *name; /*@ name of the item */ 48 @in const(char) *name; /*@ name of the item */
49 @in const(char) *description; /*@ the description of the item */
50 @in const(char) *file; /*@ The file of the icon to display, NULL if it is a standart fdo icon.*/
51 @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. */
52 @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 */ 49 @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 */
53 } 50 }
54 } 51 }
@@ -70,9 +67,6 @@ class Elm_Settingspane(Elm_Layout)
70 params { 67 params {
71 @in void *data; /*@ data to attach to the item which gets passed to the callback */ 68 @in void *data; /*@ data to attach to the item which gets passed to the callback */
72 @in const(char) *name; /*@ name of the item */ 69 @in const(char) *name; /*@ name of the item */
73 @in const(char) *description; /*@ the description of the item */
74 @in const(char) *file; /*@ The file of the icon to display, NULL if it is a standart fdo icon.*/
75 @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. */
76 @in Elm_Settingspane_Item *rel; /*@ the item after which the current one will be appended, if NULL the call will fail!*/ 70 @in Elm_Settingspane_Item *rel; /*@ the item after which the current one will be appended, if NULL the call will fail!*/
77 } 71 }
78 } 72 }
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){
20 } 20 }
21 } 21 }
22 description{ 22 description{
23 set {
24 /*@
25 Will set the desrciption for the item.
26
27 It will be displayed when you hover the item.
28 @ingroup Settingspane
29 */
30 }
23 get { 31 get {
24 /*@ 32 /*@
25 Return the description of the item 33 Return the description of the item
@@ -36,6 +44,16 @@ class Elm_Settingspane_Item(Eo.Base){
36 const (char) *description; 44 const (char) *description;
37 } 45 }
38 } 46 }
47 image {
48 set {
49 }
50 get {
51 }
52 values {
53 const (char) *file;
54 const (char) *group;
55 }
56 }
39 parent { 57 parent {
40 get { 58 get {
41 /*@ 59 /*@