summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-01-29 21:47:53 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-10-05 12:54:39 +0200
commit09c5d0cc396b84b88c38d44acf247c7308792553 (patch)
tree144c2265c41728cb03db71f9a57f5533a5767d55
parentad0d966e3388327b8d135ae550e77057ac3a2357 (diff)
Settingspane: made the api more usable
adding a string "bal,bla2,bla2" makes it easier for translations than adding single words.
-rw-r--r--src/bin/test_settingspane.c5
-rw-r--r--src/lib/elc_settingspane.c37
-rw-r--r--src/lib/elm_settingspane_item.eo37
3 files changed, 54 insertions, 25 deletions
diff --git a/src/bin/test_settingspane.c b/src/bin/test_settingspane.c
index 67a9d9c1e..93d9f6df7 100644
--- a/src/bin/test_settingspane.c
+++ b/src/bin/test_settingspane.c
@@ -253,8 +253,7 @@ test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
253 it = elm_settingspane_item_append(sw, ic, "Complex", 253 it = elm_settingspane_item_append(sw, ic, "Complex",
254 "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!", 254 "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!",
255 ic, NULL); 255 ic, NULL);
256 elm_settingspane_item_keyword_add(it, eina_stringshare_add("Hardone")); 256 elm_settingspane_item_keywords_set(it, eina_stringshare_add("Hardone,second"));
257 elm_settingspane_item_keyword_add(it, eina_stringshare_add("second"));
258 ic = elm_icon_add(win); 257 ic = elm_icon_add(win);
259 snprintf(buf, sizeof(buf), "%s/images/%s", 258 snprintf(buf, sizeof(buf), "%s/images/%s",
260 elm_app_data_dir_get(), "bubble.png"); 259 elm_app_data_dir_get(), "bubble.png");
@@ -264,7 +263,7 @@ test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
264 it2 = elm_settingspane_item_append(sw, ic, "Child", 263 it2 = elm_settingspane_item_append(sw, ic, "Child",
265 "This is a children entry", 264 "This is a children entry",
266 ic, it); 265 ic, it);
267 elm_settingspane_item_keyword_add(it2, eina_stringshare_add("Heavyone")); 266 elm_settingspane_item_keywords_set(it2, eina_stringshare_add("Heavyone,Third,"));
268 elm_settingspane_item_attach_panel(it2, content_cb[3], reset_cb, apply_cb); 267 elm_settingspane_item_attach_panel(it2, content_cb[3], reset_cb, apply_cb);
269 268
270 evas_object_show(sw); 269 evas_object_show(sw);
diff --git a/src/lib/elc_settingspane.c b/src/lib/elc_settingspane.c
index 9340316e9..6ee5e727f 100644
--- a/src/lib/elc_settingspane.c
+++ b/src/lib/elc_settingspane.c
@@ -48,6 +48,7 @@ typedef struct
48 48
49 Eina_List *childs; //list of Elm_Settingspane_Item* 49 Eina_List *childs; //list of Elm_Settingspane_Item*
50 50
51 const char *key_word; //< the original string which was given
51 Eina_List *key_words; //< list of strdupĀ“ed strings to match searching 52 Eina_List *key_words; //< list of strdupĀ“ed strings to match searching
52 53
53 const char *name; 54 const char *name;
@@ -1515,17 +1516,43 @@ _elm_settingspane_item_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_Settingspane_
1515 1516
1516 1517
1517EOLIAN static void 1518EOLIAN static void
1518_elm_settingspane_item_keyword_add(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, Eina_Stringshare *str) 1519_elm_settingspane_item_keywords_set(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, Eina_Stringshare *str)
1519{ 1520{
1521 char **splits;
1522 char *split;
1523 const char *word;
1524 int i = 0;
1525
1526 /* save the original string */
1520 eina_stringshare_ref(str); 1527 eina_stringshare_ref(str);
1528 if (pd->key_word)
1529 eina_stringshare_del(pd->key_word);
1530
1531 pd->key_word = str;
1532
1533 /* free the existing list */
1534 EINA_LIST_FREE(pd->key_words, word)
1535 {
1536 eina_stringshare_del(word);
1537 }
1538 /* parse out the single words */
1539 splits = eina_str_split(pd->key_word, ",", -1);
1540
1541 if (!splits) return;
1542
1543 for(i = 0; splits[i]; i++)
1544 {
1545 split = splits[i];
1546 pd->key_words = eina_list_append(pd->key_words, eina_stringshare_add(split));
1547 }
1548
1521 pd->key_words = eina_list_append(pd->key_words, str); 1549 pd->key_words = eina_list_append(pd->key_words, str);
1522} 1550}
1523 1551
1524EOLIAN static void 1552EOLIAN static Eina_Stringshare *
1525_elm_settingspane_item_keyword_delete(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, Eina_Stringshare *str) 1553_elm_settingspane_item_keywords_get(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd)
1526{ 1554{
1527 eina_stringshare_del(str); 1555 return pd->key_word;
1528 pd->key_words = eina_list_remove(pd->key_words, str);
1529} 1556}
1530 1557
1531/* widget api calls */ 1558/* widget api calls */
diff --git a/src/lib/elm_settingspane_item.eo b/src/lib/elm_settingspane_item.eo
index 7711c14c0..9ad8bc894 100644
--- a/src/lib/elm_settingspane_item.eo
+++ b/src/lib/elm_settingspane_item.eo
@@ -91,25 +91,28 @@ class Elm_Settingspane_Item(Eo.Base){
91 Eina_Bool changed; 91 Eina_Bool changed;
92 } 92 }
93 } 93 }
94 keywords {
95 get {
96 /*@
97 Returns the keywords
98 */
99 }
100 set {
101 /*@
102 Set the keywords
103
104 This is the string for the search of a item
105
106 The string should be from the form word[,word2]
107 The value of the searchentry will be compared against the values seperated by a ","
108 */
109 }
110 values {
111 Eina_Stringshare *word;
112 }
113 }
94 } 114 }
95 methods { 115 methods {
96 keyword_add {
97 /*@
98 Append a string to the internal search list.
99 If items are searched the keyword is checked against the elements of this stringlist.
100 */
101 params {
102 @in Eina_Stringshare* str; /*@ The String to append to the list*/
103 }
104 }
105 keyword_delete {
106 /*@
107 Delete a string from the internal search list.
108 */
109 params {
110 @in Eina_Stringshare* str; /*@ The String to remove from the internal list*/
111 }
112 }
113 attach_panel { 116 attach_panel {
114 /*@ 117 /*@
115 Attach a panel to the item 118 Attach a panel to the item