summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--NEWS1
-rw-r--r--src/lib/elm_segment_control.c50
3 files changed, 9 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 08bba5918..1075538ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -254,3 +254,4 @@
2542012-07-01 Gustavo Sverzut Barbieri (k-s) 2542012-07-01 Gustavo Sverzut Barbieri (k-s)
255 255
256 * Add and use elm_widget_item_widget_get() 256 * Add and use elm_widget_item_widget_get()
257 * Fix elm_segment_control to not abuse user's data from item.
diff --git a/NEWS b/NEWS
index 1534bb2a6..ab4d22828 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,7 @@ Fixes:
23 * Genlist : Realize move items during tree effect only when the item is not in the queue. 23 * Genlist : Realize move items during tree effect only when the item is not in the queue.
24 * Add missing files in the tarball. 24 * Add missing files in the tarball.
25 * Fileselector : honor the folder_only option when using EIO 25 * Fileselector : honor the folder_only option when using EIO
26 * Segment Selector : do not abuse user object item data.
26 27
27Improvements: 28Improvements:
28 29
diff --git a/src/lib/elm_segment_control.c b/src/lib/elm_segment_control.c
index 8b9182510..949cf7fcc 100644
--- a/src/lib/elm_segment_control.c
+++ b/src/lib/elm_segment_control.c
@@ -99,12 +99,7 @@ _elm_segment_control_smart_sizing_eval(Evas_Object *obj)
99static void 99static void
100_item_free(Elm_Segment_Item *it) 100_item_free(Elm_Segment_Item *it)
101{ 101{
102 Elm_Segment_Control_Smart_Data *sd; 102 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
103
104 if (!it) return;
105
106 sd = elm_widget_item_data_get(it);
107 if (!sd) return;
108 103
109 if (sd->selected_item == it) sd->selected_item = NULL; 104 if (sd->selected_item == it) sd->selected_item = NULL;
110 if (sd->items) sd->items = eina_list_remove(sd->items, it); 105 if (sd->items) sd->items = eina_list_remove(sd->items, it);
@@ -335,12 +330,7 @@ _elm_segment_control_smart_focus_next(const Evas_Object *obj,
335static void 330static void
336_segment_off(Elm_Segment_Item *it) 331_segment_off(Elm_Segment_Item *it)
337{ 332{
338 Elm_Segment_Control_Smart_Data *sd; 333 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
339
340 if (!it) return;
341
342 sd = elm_widget_item_data_get(it);
343 if (!sd) return;
344 334
345 edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm"); 335 edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm");
346 336
@@ -350,12 +340,7 @@ _segment_off(Elm_Segment_Item *it)
350static void 340static void
351_segment_on(Elm_Segment_Item *it) 341_segment_on(Elm_Segment_Item *it)
352{ 342{
353 Elm_Segment_Control_Smart_Data *sd; 343 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
354
355 if (!it) return;
356
357 sd = elm_widget_item_data_get(it);
358 if (!sd) return;
359 344
360 if (it == sd->selected_item) return; 345 if (it == sd->selected_item) return;
361 346
@@ -383,16 +368,12 @@ _on_mouse_up(void *data,
383 Evas_Object *obj __UNUSED__, 368 Evas_Object *obj __UNUSED__,
384 void *event_info) 369 void *event_info)
385{ 370{
386 Elm_Segment_Control_Smart_Data *sd;
387 Elm_Segment_Item *it; 371 Elm_Segment_Item *it;
388 Evas_Event_Mouse_Up *ev; 372 Evas_Event_Mouse_Up *ev;
389 Evas_Coord x, y, w, h; 373 Evas_Coord x, y, w, h;
390 374
391 it = data; 375 it = data;
392 if (!it) return; 376 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
393
394 sd = elm_widget_item_data_get(it);
395 if (!sd) return;
396 377
397 if (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj)) return; 378 if (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj)) return;
398 379
@@ -414,14 +395,10 @@ _on_mouse_down(void *data,
414 Evas_Object *obj __UNUSED__, 395 Evas_Object *obj __UNUSED__,
415 void *event_info __UNUSED__) 396 void *event_info __UNUSED__)
416{ 397{
417 Elm_Segment_Control_Smart_Data *sd;
418 Elm_Segment_Item *it; 398 Elm_Segment_Item *it;
419 399
420 it = data; 400 it = data;
421 if (!it) return; 401 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
422
423 sd = elm_widget_item_data_get(it);
424 if (!sd) return;
425 402
426 if (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj)) return; 403 if (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj)) return;
427 404
@@ -447,15 +424,11 @@ _item_text_set_hook(Elm_Object_Item *it,
447 const char *part, 424 const char *part,
448 const char *label) 425 const char *label)
449{ 426{
450 Elm_Segment_Control_Smart_Data *sd;
451 Elm_Segment_Item *item; 427 Elm_Segment_Item *item;
452 428
453 if (part && strcmp(part, "default")) return; 429 if (part && strcmp(part, "default")) return;
454 430
455 item = (Elm_Segment_Item *)it; 431 item = (Elm_Segment_Item *)it;
456 sd = elm_widget_item_data_get(item);
457 if (!sd) return;
458
459 eina_stringshare_replace(&item->label, label); 432 eina_stringshare_replace(&item->label, label);
460 if (item->label) 433 if (item->label)
461 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm"); 434 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
@@ -512,11 +485,8 @@ _item_content_get_hook(const Elm_Object_Item *it,
512static Eina_Bool 485static Eina_Bool
513_item_del_pre_hook(Elm_Object_Item *it) 486_item_del_pre_hook(Elm_Object_Item *it)
514{ 487{
515 Elm_Segment_Control_Smart_Data *sd;
516 Elm_Segment_Item *item = (Elm_Segment_Item *)it; 488 Elm_Segment_Item *item = (Elm_Segment_Item *)it;
517 489 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
518 sd = elm_widget_item_data_get(item);
519 if (!sd) return EINA_FALSE;
520 490
521 _item_free(item); 491 _item_free(item);
522 _update_list(sd); 492 _update_list(sd);
@@ -531,12 +501,9 @@ _item_new(Evas_Object *obj,
531{ 501{
532 Elm_Segment_Item *it; 502 Elm_Segment_Item *it;
533 503
534 ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
535
536 it = elm_widget_item_new(obj, Elm_Segment_Item); 504 it = elm_widget_item_new(obj, Elm_Segment_Item);
537 if (!it) return NULL; 505 if (!it) return NULL;
538 506
539 elm_widget_item_data_set(it, sd);
540 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook); 507 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
541 elm_widget_item_text_set_hook_set(it, _item_text_set_hook); 508 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
542 elm_widget_item_text_get_hook_set(it, _item_text_get_hook); 509 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
@@ -759,13 +726,10 @@ EAPI void
759elm_segment_control_item_selected_set(Elm_Object_Item *it, 726elm_segment_control_item_selected_set(Elm_Object_Item *it,
760 Eina_Bool selected) 727 Eina_Bool selected)
761{ 728{
762 Elm_Segment_Control_Smart_Data *sd;
763 Elm_Segment_Item *item = (Elm_Segment_Item *)it; 729 Elm_Segment_Item *item = (Elm_Segment_Item *)it;
764 730
765 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it); 731 ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it);
766 732 ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
767 sd = elm_widget_item_data_get(item);
768 if (!sd) return;
769 733
770 if (item == sd->selected_item) 734 if (item == sd->selected_item)
771 { 735 {