summaryrefslogtreecommitdiff
path: root/legacy/elementary
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2012-03-29 10:08:37 +0000
committerDaniel Juyung Seo <seojuyung2@gmail.com>2012-03-29 10:08:37 +0000
commit3d15654faaab6c4d7e181a2ea3d36515788fa462 (patch)
tree0e632bfc25007b4d5986af9999c411c327c78ec2 /legacy/elementary
parent2101792842477ef9ef4ae31373bf809a02efdb4b (diff)
elm elm_object_item: Fixed item part content set hooks.
1. delete old content object 2. check whether new content object is same as old content object 3. rename internal content set hook function 4. elm_widget_sub_object_del will be followed by evas_object_del 5. added some doxygen description. SVN revision: 69738
Diffstat (limited to 'legacy/elementary')
-rw-r--r--legacy/elementary/src/lib/elc_popup.c1
-rw-r--r--legacy/elementary/src/lib/elm_diskselector.c3
-rw-r--r--legacy/elementary/src/lib/elm_genlist.c5
-rw-r--r--legacy/elementary/src/lib/elm_list.c16
-rw-r--r--legacy/elementary/src/lib/elm_menu.c12
-rw-r--r--legacy/elementary/src/lib/elm_object_item.h4
-rw-r--r--legacy/elementary/src/lib/elm_segment_control.c9
-rw-r--r--legacy/elementary/src/lib/elm_toolbar.c9
8 files changed, 30 insertions, 29 deletions
diff --git a/legacy/elementary/src/lib/elc_popup.c b/legacy/elementary/src/lib/elc_popup.c
index 47379f8acc..d1e21cccd7 100644
--- a/legacy/elementary/src/lib/elc_popup.c
+++ b/legacy/elementary/src/lib/elc_popup.c
@@ -1078,7 +1078,6 @@ _item_icon_set(Elm_Popup_Content_Item *item, Evas_Object *icon)
1078 if (item->icon == icon) return; 1078 if (item->icon == icon) return;
1079 if (item->icon) 1079 if (item->icon)
1080 { 1080 {
1081 elm_widget_sub_object_del(WIDGET(item), item->icon);
1082 evas_object_data_del(item->icon, "_popup_content_item"); 1081 evas_object_data_del(item->icon, "_popup_content_item");
1083 evas_object_del(item->icon); 1082 evas_object_del(item->icon);
1084 } 1083 }
diff --git a/legacy/elementary/src/lib/elm_diskselector.c b/legacy/elementary/src/lib/elm_diskselector.c
index e86927917d..3c4da2ea47 100644
--- a/legacy/elementary/src/lib/elm_diskselector.c
+++ b/legacy/elementary/src/lib/elm_diskselector.c
@@ -909,8 +909,7 @@ static void
909_item_icon_set(Elm_Diskselector_Item *it, Evas_Object *icon) 909_item_icon_set(Elm_Diskselector_Item *it, Evas_Object *icon)
910{ 910{
911 if (it->icon == icon) return; 911 if (it->icon == icon) return;
912 if (it->icon) 912 if (it->icon) evas_object_del(it->icon);
913 evas_object_del(it->icon);
914 it->icon = icon; 913 it->icon = icon;
915 if (VIEW(it)) 914 if (VIEW(it))
916 { 915 {
diff --git a/legacy/elementary/src/lib/elm_genlist.c b/legacy/elementary/src/lib/elm_genlist.c
index 8f0eeeba5d..0fc3e33ad8 100644
--- a/legacy/elementary/src/lib/elm_genlist.c
+++ b/legacy/elementary/src/lib/elm_genlist.c
@@ -3584,8 +3584,13 @@ _item_content_get_hook(Elm_Gen_Item *it, const char *part)
3584static void 3584static void
3585_item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content) 3585_item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
3586{ 3586{
3587 Evas_Object *prev_obj;
3588
3587 if (content && part) 3589 if (content && part)
3588 { 3590 {
3591 if (eina_list_data_find(it->content_objs, content)) return;
3592 prev_obj = edje_object_part_swallow_get(VIEW(it), part);
3593 if (prev_obj) evas_object_del(prev_obj);
3589 it->content_objs = eina_list_append(it->content_objs, content); 3594 it->content_objs = eina_list_append(it->content_objs, content);
3590 edje_object_part_swallow(VIEW(it), part, content); 3595 edje_object_part_swallow(VIEW(it), part, content);
3591 } 3596 }
diff --git a/legacy/elementary/src/lib/elm_list.c b/legacy/elementary/src/lib/elm_list.c
index f06bfe14de..2ab480ac5c 100644
--- a/legacy/elementary/src/lib/elm_list.c
+++ b/legacy/elementary/src/lib/elm_list.c
@@ -1050,7 +1050,7 @@ _item_disable(Elm_Object_Item *it)
1050} 1050}
1051 1051
1052static void 1052static void
1053_item_content_set(Elm_Object_Item *it, const char *part, Evas_Object *content) 1053_item_content_set_hook(Elm_Object_Item *it, const char *part, Evas_Object *content)
1054{ 1054{
1055 Elm_List_Item *item = (Elm_List_Item *)it; 1055 Elm_List_Item *item = (Elm_List_Item *)it;
1056 Evas_Object **icon_p = NULL; 1056 Evas_Object **icon_p = NULL;
@@ -1092,7 +1092,7 @@ _item_content_set(Elm_Object_Item *it, const char *part, Evas_Object *content)
1092} 1092}
1093 1093
1094static Evas_Object * 1094static Evas_Object *
1095_item_content_get(const Elm_Object_Item *it, const char *part) 1095_item_content_get_hook(const Elm_Object_Item *it, const char *part)
1096{ 1096{
1097 Elm_List_Item *item = (Elm_List_Item *)it; 1097 Elm_List_Item *item = (Elm_List_Item *)it;
1098 1098
@@ -1110,20 +1110,20 @@ _item_content_get(const Elm_Object_Item *it, const char *part)
1110} 1110}
1111 1111
1112static Evas_Object * 1112static Evas_Object *
1113_item_content_unset(const Elm_Object_Item *it, const char *part) 1113_item_content_unset_hook(const Elm_Object_Item *it, const char *part)
1114{ 1114{
1115 Elm_List_Item *item = (Elm_List_Item *)it; 1115 Elm_List_Item *item = (Elm_List_Item *)it;
1116 1116
1117 if ((!part) || (!strcmp(part, "start"))) 1117 if ((!part) || (!strcmp(part, "start")))
1118 { 1118 {
1119 Evas_Object *obj = item->icon; 1119 Evas_Object *obj = item->icon;
1120 _item_content_set((Elm_Object_Item *)it, part, NULL); 1120 _item_content_set_hook((Elm_Object_Item *)it, part, NULL);
1121 return obj; 1121 return obj;
1122 } 1122 }
1123 else if (!strcmp(part, "end")) 1123 else if (!strcmp(part, "end"))
1124 { 1124 {
1125 Evas_Object *obj = item->end; 1125 Evas_Object *obj = item->end;
1126 _item_content_set((Elm_Object_Item *)it, part, NULL); 1126 _item_content_set_hook((Elm_Object_Item *)it, part, NULL);
1127 return obj; 1127 return obj;
1128 } 1128 }
1129 return NULL; 1129 return NULL;
@@ -1214,9 +1214,9 @@ _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *e
1214 _changed_size_hints, obj); 1214 _changed_size_hints, obj);
1215 } 1215 }
1216 elm_widget_item_disable_hook_set(it, _item_disable); 1216 elm_widget_item_disable_hook_set(it, _item_disable);
1217 elm_widget_item_content_set_hook_set(it, _item_content_set); 1217 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
1218 elm_widget_item_content_get_hook_set(it, _item_content_get); 1218 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
1219 elm_widget_item_content_unset_hook_set(it, _item_content_unset); 1219 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
1220 elm_widget_item_text_set_hook_set(it, _item_text_set); 1220 elm_widget_item_text_set_hook_set(it, _item_text_set);
1221 elm_widget_item_text_get_hook_set(it, _item_text_get); 1221 elm_widget_item_text_get_hook_set(it, _item_text_get);
1222 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook); 1222 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
diff --git a/legacy/elementary/src/lib/elm_menu.c b/legacy/elementary/src/lib/elm_menu.c
index 22d846e605..0cb0da06ab 100644
--- a/legacy/elementary/src/lib/elm_menu.c
+++ b/legacy/elementary/src/lib/elm_menu.c
@@ -174,21 +174,17 @@ _item_content_set_hook(Elm_Object_Item *it,
174 Evas_Object *content) 174 Evas_Object *content)
175{ 175{
176 Elm_Menu_Item *item; 176 Elm_Menu_Item *item;
177
178 if (part && strcmp(part, "default")) return; 177 if (part && strcmp(part, "default")) return;
179 178
180 item = (Elm_Menu_Item *)it; 179 item = (Elm_Menu_Item *)it;
180 if (content == item->content) return;
181 181
182 if (item->content) 182 if (item->content) evas_object_del(item->content);
183 {
184 elm_widget_sub_object_del(WIDGET(item), item->content);
185 evas_object_del(item->content);
186 }
187 183
188 item->content = content; 184 item->content = content;
189
190 elm_widget_sub_object_add(WIDGET(item), item->content); 185 elm_widget_sub_object_add(WIDGET(item), item->content);
191 edje_object_part_swallow(VIEW(item), "elm.swallow.content", item->content); 186 if (item->content)
187 edje_object_part_swallow(VIEW(item), "elm.swallow.content", item->content);
192 _sizing_eval(WIDGET(item)); 188 _sizing_eval(WIDGET(item));
193} 189}
194 190
diff --git a/legacy/elementary/src/lib/elm_object_item.h b/legacy/elementary/src/lib/elm_object_item.h
index 5ad22f91eb..b7a8ea6b77 100644
--- a/legacy/elementary/src/lib/elm_object_item.h
+++ b/legacy/elementary/src/lib/elm_object_item.h
@@ -19,6 +19,10 @@ EAPI Evas_Object *elm_object_item_widget_get(const Elm_Object_It
19 * @param part The content part name to set (NULL for the default content) 19 * @param part The content part name to set (NULL for the default content)
20 * @param content The new content of the object item 20 * @param content The new content of the object item
21 * 21 *
22 * This sets a new object to an item as a content object. If any object was
23 * already set as a content object in the same part, previous object will be
24 * deleted automatically.
25 *
22 * @note Elementary object items may have many contents 26 * @note Elementary object items may have many contents
23 * 27 *
24 * @ingroup General 28 * @ingroup General
diff --git a/legacy/elementary/src/lib/elm_segment_control.c b/legacy/elementary/src/lib/elm_segment_control.c
index cb765cc9e2..4f381d35cb 100644
--- a/legacy/elementary/src/lib/elm_segment_control.c
+++ b/legacy/elementary/src/lib/elm_segment_control.c
@@ -469,18 +469,13 @@ _item_content_set_hook(Elm_Object_Item *it,
469 Evas_Object *content) 469 Evas_Object *content)
470{ 470{
471 Elm_Segment_Item *item; 471 Elm_Segment_Item *item;
472
473 if (part && strcmp(part, "icon")) return; 472 if (part && strcmp(part, "icon")) return;
474 473
475 item = (Elm_Segment_Item *)it; 474 item = (Elm_Segment_Item *)it;
475 if (content == item->icon) return;
476 476
477 //Remove the existing icon 477 //Remove the existing icon
478 if (item->icon) 478 if (item->icon) evas_object_del(item->icon);
479 {
480 edje_object_part_unswallow(VIEW(item), item->icon);
481 evas_object_del(item->icon);
482 item->icon = NULL;
483 }
484 item->icon = content; 479 item->icon = content;
485 if (item->icon) 480 if (item->icon)
486 { 481 {
diff --git a/legacy/elementary/src/lib/elm_toolbar.c b/legacy/elementary/src/lib/elm_toolbar.c
index 4e27e9142f..648a84c627 100644
--- a/legacy/elementary/src/lib/elm_toolbar.c
+++ b/legacy/elementary/src/lib/elm_toolbar.c
@@ -425,15 +425,18 @@ _item_content_set_hook(Elm_Object_Item *it,
425 Evas_Object *content) 425 Evas_Object *content)
426{ 426{
427 double scale; 427 double scale;
428
429 if (part && strcmp(part, "object")) return; 428 if (part && strcmp(part, "object")) return;
430 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; 429 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
431 Evas_Object *obj = WIDGET(item); 430 Evas_Object *obj = WIDGET(item);
432 Widget_Data *wd = elm_widget_data_get(obj); 431 Widget_Data *wd = elm_widget_data_get(obj);
433 432 if (!wd || !obj) return;
434 if (item->object == content) return; 433 if (item->object == content) return;
434
435 if (item->object) evas_object_del(item->object);
436
435 item->object = content; 437 item->object = content;
436 elm_widget_sub_object_add(obj, item->object); 438 if (item->object)
439 elm_widget_sub_object_add(obj, item->object);
437 scale = (elm_widget_scale_get(obj) * _elm_config->scale); 440 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
438 _theme_hook_item(obj, item, scale, wd->icon_size); 441 _theme_hook_item(obj, item, scale, wd->icon_size);
439} 442}