Merge branch 'intefl/svn_merge' of ssh://165.213.149.219:21922/slp/pkgs/e/elementary...
[framework/uifw/elementary.git] / src / lib / elm_diskselector.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include "els_scroller.h"
4
5 #ifndef MAX
6 # define MAX(a, b) (((a) > (b)) ? (a) : (b))
7 #endif
8
9 #ifndef CEIL
10 #define CEIL(a) (((a) % 2 != 0) ? ((a) / 2 + 1) : ((a) / 2))
11 #endif
12
13 #define DISPLAY_ITEM_NUM_MIN 3
14
15 typedef struct _Widget_Data Widget_Data;
16 typedef struct _Elm_Diskselector_Item Elm_Diskselector_Item;
17
18 struct _Widget_Data
19 {
20    Evas_Object *self;
21    Evas_Object *scroller;
22    Evas_Object *main_box;
23    Evas_Object *left_blank;
24    Evas_Object *right_blank;
25    Elm_Diskselector_Item *selected_item;
26    Elm_Diskselector_Item *first;
27    Elm_Diskselector_Item *second;
28    Elm_Diskselector_Item *s_last;
29    Elm_Diskselector_Item *last;
30    Eina_List *items;
31    Eina_List *r_items;
32    Eina_List *over_items;
33    Eina_List *under_items;
34    int item_count, len_threshold, len_side, display_item_num;
35    Ecore_Idle_Enterer *idler;
36    Ecore_Idle_Enterer *check_idler;
37    Evas_Coord minw, minh;
38    Eina_Bool init:1;
39    Eina_Bool round:1;
40    Eina_Bool display_item_num_by_api:1;
41 };
42
43 struct _Elm_Diskselector_Item
44 {
45    ELM_WIDGET_ITEM;
46    Eina_List *node;
47    Evas_Object *icon;
48    const char *label;
49    Evas_Smart_Cb func;
50 };
51
52 static const char *widtype = NULL;
53
54 static Eina_Bool _move_scroller(void *data);
55 static void _del_hook(Evas_Object * obj);
56 static void _del_pre_hook(Evas_Object * obj);
57 static void _sizing_eval(Evas_Object * obj);
58 static void _theme_hook(Evas_Object * obj);
59 static void _on_focus_hook(void *data, Evas_Object *obj);
60 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
61 static void _sub_del(void *data, Evas_Object * obj, void *event_info);
62 static void _round_items_del(Widget_Data *wd);
63 static void _scroller_move_cb(void *data, Evas_Object *obj, void *event_info);
64 static void _item_click_cb(void *data, Evas_Object *obj __UNUSED__,
65                            const char *emission __UNUSED__,
66                            const char *source __UNUSED__);
67 static void _selected_item_indicate(Elm_Diskselector_Item *it);
68 static void _item_text_set_hook(Elm_Object_Item *it,
69                                 const char *part,
70                                 const char *label);
71 static const char * _item_text_get_hook(const Elm_Object_Item *it,
72                                         const char *part);
73 static void _item_content_set_hook(Elm_Object_Item *it,
74                                    const char *part,
75                                    Evas_Object *content);
76 static Evas_Object * _item_content_get_hook(const Elm_Object_Item *it,
77                                             const char *part);
78
79 static const char SIG_SELECTED[] = "selected";
80 static const Evas_Smart_Cb_Description _signals[] = {
81        {SIG_SELECTED, ""},
82        {NULL, NULL}
83 };
84
85 static void
86 _diskselector_object_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
87 {
88    Widget_Data *wd;
89    Evas_Coord w, h;
90
91    wd = elm_widget_data_get(data);
92    if (!wd) return;
93
94    if ((wd->minw == -1) && (wd->minh == -1))
95       elm_coords_finger_size_adjust(6, &wd->minw, 1, &wd->minh);
96    edje_object_size_min_restricted_calc
97       (elm_smart_scroller_edje_object_get
98           (wd->scroller), &wd->minw, &wd->minh, wd->minw, wd->minh);
99    evas_object_size_hint_min_set(obj, wd->minw, wd->minh);
100    evas_object_size_hint_max_set(obj, -1, -1);
101
102    evas_object_geometry_get(wd->scroller, NULL, NULL, &w, &h);
103    if (wd->round)
104      evas_object_resize(wd->main_box, (w / wd->display_item_num) * (wd->item_count + (CEIL(wd->display_item_num) * 2)), h);
105    else
106      evas_object_resize(wd->main_box, (w / wd->display_item_num) * (wd->item_count + CEIL(wd->display_item_num)), h);
107
108    elm_smart_scroller_paging_set(wd->scroller, 0, 0,
109                                  (int)(w / wd->display_item_num), 0);
110
111    if (!wd->idler)
112      wd->idler = ecore_idle_enterer_before_add(_move_scroller, data);
113 }
114
115 static void
116 _item_del(Elm_Diskselector_Item *item)
117 {
118    if (!item) return;
119    eina_stringshare_del(item->label);
120    if (item->icon)
121      evas_object_del(item->icon);
122 }
123
124 static int
125 _count_letter(const char *str)
126 {
127    int pos = 0;
128    int code = 0, chnum;
129
130    for (chnum = 0; ; chnum++)
131      {
132         pos = evas_string_char_next_get(str, pos, &code);
133         if (code == 0) break;
134      }
135    return chnum;
136 }
137
138 static int
139 _check_letter(const char *str, int length)
140 {
141    int pos = 0;
142    int code = 0, chnum;
143
144    for (chnum = 0; ; chnum++)
145      {
146         if (chnum == length) break;
147         pos = evas_string_char_next_get(str, pos, &code);
148         if (code == 0) break;
149      }
150    return pos;
151 }
152
153 static Eina_Bool
154 _check_string(void *data)
155 {
156    int mid, steps, length, diff;
157    Elm_Diskselector_Item *it;
158    Eina_List *list, *l;
159    Evas_Coord ox, ow;
160    char buf[1024];
161    Widget_Data *wd = data;
162
163    evas_object_geometry_get(wd->scroller, &ox, NULL, &ow, NULL);
164    if (ow <= 0)
165      return EINA_FALSE;
166    if (!wd->init)
167      return EINA_FALSE;
168    if (!wd->round)
169      list = wd->items;
170    else
171      list = wd->r_items;
172
173    EINA_LIST_FOREACH(list, l, it)
174      {
175         Evas_Coord x, w;
176         int len;
177         evas_object_geometry_get(VIEW(it), &x, NULL, &w, NULL);
178         /* item not visible */
179         if ((x + w <= ox) || (x >= ox + ow))
180           continue;
181
182         len = _count_letter(it->label);
183 //        // FIXME: len should be # of ut8f letters. ie count using utf8 string walk, not stringshare len
184 //        len = eina_stringshare_strlen(it->label);
185
186         if (x <= ox + 5)
187           edje_object_signal_emit(VIEW(it), "elm,state,left_side",
188                                   "elm");
189         else if (x + w >= ox + ow - 5)
190           edje_object_signal_emit(VIEW(it), "elm,state,right_side",
191                                   "elm");
192         else
193           {
194              if ((wd->len_threshold) && (len > wd->len_threshold))
195                edje_object_signal_emit(VIEW(it), "elm,state,center_small",
196                                        "elm");
197              else
198                edje_object_signal_emit(VIEW(it), "elm,state,center",
199                                        "elm");
200           }
201
202         // if len is les that the limit len, skip anyway
203         if (len <= wd->len_side)
204           continue;
205
206         steps = len - wd->len_side + 1;
207         mid = x + w / 2;
208         if (mid <= ox + ow / 2)
209           diff = (ox + ow / 2) - mid;
210         else
211           diff = mid - (ox + ow / 2);
212
213         length = len - (int)(diff * steps / (ow / 3));
214         length = MAX(length, wd->len_side);
215         // limit string len to "length" ut8f chars
216         length = _check_letter(it->label, length);
217         // cut it off at byte mark returned form _check_letter
218         strncpy(buf, it->label, length);
219         buf[length] = '\0';
220         edje_object_part_text_set(VIEW(it), "elm.text", buf);
221      }
222
223    if (wd->check_idler)
224      ecore_idle_enterer_del(wd->check_idler);
225    wd->check_idler = NULL;
226    return EINA_FALSE;
227 }
228
229 static Eina_Bool
230 _item_del_pre_hook(Elm_Object_Item *it)
231 {
232 <<<<<<< HEAD
233    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
234 =======
235 >>>>>>> remotes/origin/upstream
236    Elm_Diskselector_Item *item, *item2, *dit;
237    Eina_List *l;
238    int i = 0;
239    Widget_Data *wd;
240 <<<<<<< HEAD
241    item = (Elm_Diskselector_Item *) it;
242 =======
243    item = (Elm_Diskselector_Item *)it;
244 >>>>>>> remotes/origin/upstream
245    wd = elm_widget_data_get(WIDGET(item));
246    if (!wd) return EINA_FALSE;
247
248    elm_box_unpack(wd->main_box, VIEW(item));
249
250    if (wd->round)
251      wd->r_items = eina_list_remove(wd->r_items, item);
252
253    wd->items = eina_list_remove(wd->items, item);
254
255    if (wd->selected_item == item)
256      {
257         dit = (Elm_Diskselector_Item *) eina_list_nth(wd->items, 0);
258         if (dit != item)
259           wd->selected_item = dit;
260         else
261           wd->selected_item = eina_list_nth(wd->items, 1);
262
263         _selected_item_indicate(wd->selected_item);
264      }
265
266    _item_del(item);
267    wd->item_count -= 1;
268
269    if (wd->round)
270      {
271         if (!wd->item_count)
272           {
273              evas_object_hide(wd->VIEW(first));
274              evas_object_hide(wd->VIEW(second));
275              evas_object_hide(wd->VIEW(last));
276              evas_object_hide(wd->VIEW(s_last));
277
278              EINA_LIST_FOREACH(wd->under_items, l, item2)
279                evas_object_hide(VIEW(item2));
280
281              EINA_LIST_FOREACH(wd->over_items, l, item2)
282                evas_object_hide(VIEW(item2));
283           }
284         else
285           {
286              dit = eina_list_nth(wd->items, 0);
287              if (dit)
288                {
289                   eina_stringshare_replace(&wd->first->label, dit->label);
290                   edje_object_part_text_set(wd->VIEW(first), "elm.text",
291                                             wd->first->label);
292                }
293              dit = eina_list_nth(wd->items, 1);
294              if (dit)
295                {
296                   eina_stringshare_replace(&wd->second->label, dit->label);
297                   edje_object_part_text_set(wd->VIEW(second), "elm.text",
298                                             wd->second->label);
299                }
300              // if more than 3 itmes should be displayed
301              for (i = 2; i < CEIL(wd->display_item_num); i++)
302                {
303                   dit = eina_list_nth(wd->items, i);
304                   item2 = eina_list_nth(wd->over_items, i - 2);
305                   eina_stringshare_replace(&item2->label, dit->label);
306                   edje_object_part_text_set(VIEW(item2), "elm.text", item2->label);
307                }
308
309              dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 1);
310              if (dit)
311                {
312                   eina_stringshare_replace(&wd->last->label, dit->label);
313                   edje_object_part_text_set(wd->VIEW(last), "elm.text",
314                                             wd->last->label);
315                }
316              dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 2);
317              if (dit)
318                {
319                   eina_stringshare_replace(&wd->s_last->label, dit->label);
320                   edje_object_part_text_set(wd->VIEW(s_last), "elm.text",
321                                             wd->s_last->label);
322                }
323              // if more than 3 itmes should be displayed
324              for (i = 3; i <= CEIL(wd->display_item_num); i++)
325                {
326                   dit = eina_list_nth(wd->items, wd->item_count - i);
327                   item2 = eina_list_nth(wd->under_items, i - 3);
328                   eina_stringshare_replace(&item2->label, dit->label);
329                   edje_object_part_text_set(VIEW(item2), "elm.text",
330                                             item2->label);
331                }
332           }
333      }
334    wd->check_idler = ecore_idle_enterer_before_add(_check_string, wd);
335    _sizing_eval(wd->self);
336
337    return EINA_TRUE;
338 }
339
340 static Elm_Diskselector_Item *
341 _item_new(Evas_Object *obj, Evas_Object *icon, const char *label, Evas_Smart_Cb func, const void *data)
342 {
343    Elm_Diskselector_Item *it;
344    const char *style = elm_widget_style_get(obj);
345
346    it = elm_widget_item_new(obj, Elm_Diskselector_Item);
347    if (!it) return NULL;
348
349    elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
350    elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
351    elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
352    elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
353    elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
354
355    it->label = eina_stringshare_add(label);
356    it->icon = icon;
357    it->func = func;
358    it->base.data = data;
359    VIEW(it) = edje_object_add(evas_object_evas_get(obj));
360    _elm_theme_object_set(obj, VIEW(it), "diskselector", "item", style);
361    evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND,
362                                     EVAS_HINT_EXPAND);
363    evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL,
364                                    EVAS_HINT_FILL);
365    evas_object_show(VIEW(it));
366
367    if (it->label)
368      {
369         edje_object_part_text_set(VIEW(it), "elm.text", it->label);
370         edje_object_signal_callback_add(VIEW(it), "elm,action,click", "", _item_click_cb, it);
371      }
372    if (it->icon)
373      {
374         evas_object_size_hint_min_set(it->icon, 24, 24);
375         evas_object_size_hint_max_set(it->icon, 40, 40);
376         edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
377         evas_object_show(it->icon);
378         elm_widget_sub_object_add(obj, it->icon);
379      }
380    return it;
381 }
382
383 static void
384 _theme_data_get(Widget_Data *wd)
385 {
386    const char* str;
387 <<<<<<< HEAD
388    Evas_Object *parent;
389 =======
390 >>>>>>> remotes/origin/upstream
391    str = edje_object_data_get(wd->right_blank, "len_threshold");
392    if (str) wd->len_threshold = MAX(0, atoi(str));
393    else wd->len_threshold = 0;
394
395    if (!wd->display_item_num_by_api)
396      {
397         str = edje_object_data_get(wd->right_blank, "display_item_num");
398         if (str) wd->display_item_num = MAX(DISPLAY_ITEM_NUM_MIN, atoi(str));
399         else wd->display_item_num = DISPLAY_ITEM_NUM_MIN;
400      }
401
402    str = edje_object_data_get(wd->right_blank, "min_width");
403 <<<<<<< HEAD
404    if (str) wd->minw = MAX(-1, atoi(str)) * elm_scale_get();
405    else
406      {
407         parent = elm_widget_parent_widget_get(wd->self);
408         if (!parent) wd->minw = -1;
409         else evas_object_geometry_get(parent, NULL, NULL, &wd->minw, NULL);
410      }
411
412    str = edje_object_data_get(wd->right_blank, "min_height");
413    if (str) wd->minh = MAX(-1, atoi(str)) * elm_scale_get();
414 =======
415    if (str) wd->minw = MAX(-1, atoi(str));
416    else wd->minw = -1;
417
418    str = edje_object_data_get(wd->right_blank, "min_height");
419    if (str) wd->minh = MAX(-1, atoi(str));
420 >>>>>>> remotes/origin/upstream
421    else wd->minh = -1;
422 }
423
424 static void
425 _del_hook(Evas_Object * obj)
426 {
427    Widget_Data *wd = elm_widget_data_get(obj);
428    if (!wd) return;
429    free(wd);
430 }
431
432 static void
433 _del_pre_hook(Evas_Object * obj)
434 {
435    Elm_Diskselector_Item *it;
436    Eina_List *l;
437
438    Widget_Data *wd = elm_widget_data_get(obj);
439    if (!wd) return;
440
441    if (wd->left_blank)
442      evas_object_del(wd->left_blank);
443    if (wd->right_blank)
444      evas_object_del(wd->right_blank);
445    if (wd->last)
446      {
447         eina_stringshare_del(wd->last->label);
448         evas_object_del(wd->VIEW(last));
449         free(wd->last);
450      }
451    if (wd->s_last)
452      {
453         eina_stringshare_del(wd->s_last->label);
454         evas_object_del(wd->VIEW(s_last));
455         free(wd->s_last);
456      }
457    if (wd->second)
458      {
459         eina_stringshare_del(wd->second->label);
460         evas_object_del(wd->VIEW(second));
461         free(wd->second);
462      }
463    if (wd->first)
464      {
465         eina_stringshare_del(wd->first->label);
466         evas_object_del(wd->VIEW(first));
467         free(wd->first);
468      }
469
470    EINA_LIST_FOREACH(wd->under_items, l, it)
471      {
472         if (it)
473           {
474              eina_stringshare_del(it->label);
475              evas_object_del(VIEW(it));
476              free(it);
477           }
478      }
479
480    EINA_LIST_FOREACH(wd->over_items, l, it)
481    {
482      if (it)
483         {
484            eina_stringshare_del(it->label);
485            evas_object_del(VIEW(it));
486            free(it);
487         }
488    }
489
490    EINA_LIST_FREE(wd->items, it)
491      {
492         _item_del(it);
493         elm_widget_item_free(it);
494      }
495    eina_list_free(wd->r_items);
496 }
497
498 static void
499 _sizing_eval(Evas_Object * obj)
500 {
501    Widget_Data *wd = elm_widget_data_get(obj);
502    if (!wd) return;
503    _diskselector_object_resize(obj, NULL, obj, NULL);
504 }
505
506 static void
507 _theme_hook(Evas_Object * obj)
508 {
509    Eina_List *l;
510    Elm_Diskselector_Item *it;
511    Widget_Data *wd = elm_widget_data_get(obj);
512    if (!wd) return;
513
514    if (wd->scroller)
515      elm_smart_scroller_object_theme_set(obj, wd->scroller, "diskselector",
516                                          "base", elm_widget_style_get(obj));
517    if (wd->round)
518      {
519         EINA_LIST_FOREACH(wd->r_items, l, it)
520           {
521              _elm_theme_object_set(obj, VIEW(it), "diskselector", "item",
522                                    elm_widget_style_get(obj));
523              edje_object_part_text_set(VIEW(it), "elm.text", it->label);
524           }
525      }
526    else
527      {
528         EINA_LIST_FOREACH(wd->items, l, it)
529           {
530              _elm_theme_object_set(obj, VIEW(it), "diskselector", "item",
531                                    elm_widget_style_get(obj));
532              edje_object_part_text_set(VIEW(it), "elm.text", it->label);
533           }
534      }
535    _elm_theme_object_set(obj, wd->right_blank, "diskselector", "item",
536                                    elm_widget_style_get(obj));
537    _theme_data_get(wd);
538    _sizing_eval(obj);
539 }
540
541 static void
542 _sub_del(void *data __UNUSED__, Evas_Object * obj, void *event_info)
543 {
544    Widget_Data *wd = elm_widget_data_get(obj);
545    Evas_Object *sub = event_info;
546    Elm_Diskselector_Item *it;
547    const Eina_List *l;
548
549    if (!wd) return;
550    if (!sub) abort();
551    if (sub == wd->scroller)
552      wd->scroller = NULL;
553    else
554      {
555         EINA_LIST_FOREACH(wd->items, l, it)
556           {
557              if (sub == it->icon)
558                {
559                   it->icon = NULL;
560                   _sizing_eval(obj);
561                   break;
562                }
563           }
564      }
565 }
566
567 static void
568 _select_item(Elm_Diskselector_Item *it)
569 {
570    if (!it) return;
571    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
572    wd->selected_item = it;
573    _selected_item_indicate(wd->selected_item);
574    if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
575    evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
576 }
577
578 static void
579 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
580 {
581    Widget_Data *wd = elm_widget_data_get(obj);
582    if (!wd)
583      return;
584
585    if (elm_widget_focus_get(obj))
586      {
587         edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
588         evas_object_focus_set(wd->self, EINA_TRUE);
589      }
590    else
591      {
592         edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
593         evas_object_focus_set(wd->self, EINA_FALSE);
594      }
595 }
596
597 static Eina_Bool
598 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
599 {
600    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
601    Evas_Event_Key_Down *ev = event_info;
602    Widget_Data *wd = elm_widget_data_get(obj);
603    if (!wd) return EINA_FALSE;
604    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
605    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
606
607    Elm_Diskselector_Item *it = NULL;
608    Eina_List *l;
609
610    if (!wd->selected_item) {
611         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
612         return EINA_TRUE;
613    }
614
615    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")) ||
616        (!strcmp(ev->keyname, "Up"))  || (!strcmp(ev->keyname, "KP_Up")))
617      {
618         l = wd->selected_item->node->prev;
619         if ((!l) && (wd->round))
620           l = eina_list_last(wd->items);
621      }
622    else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")) ||
623             (!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
624      {
625         l = wd->selected_item->node->next;
626         if ((!l) && (wd->round))
627           l = wd->items;
628      }
629    else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
630      l = wd->items;
631    else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
632      l = eina_list_last(wd->items);
633    else return EINA_FALSE;
634
635    if (l)
636      it = eina_list_data_get(l);
637
638    if (it)
639      {
640         wd->selected_item = it;
641         if (!wd->idler)
642           wd->idler = ecore_idle_enterer_before_add(_move_scroller, obj);
643      }
644
645    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
646    return EINA_TRUE;
647 }
648
649 static void
650 _selected_item_indicate(Elm_Diskselector_Item *it)
651 {
652    Elm_Diskselector_Item *item;
653    Eina_List *l;
654    Widget_Data *wd;
655    wd = elm_widget_data_get(WIDGET(it));
656
657    if (!wd) return;
658
659    EINA_LIST_FOREACH(wd->r_items, l, item)
660      {
661         if (!strcmp(item->label, it->label)) edje_object_signal_emit(VIEW(item), "elm,state,selected", "elm");
662         else
663            edje_object_signal_emit(VIEW(item), "elm,state,default", "elm");
664      }
665 }
666
667 static void
668 _item_click_cb(void *data, Evas_Object *obj __UNUSED__,
669                const char *emission __UNUSED__, const char *source __UNUSED__)
670 {
671    Elm_Diskselector_Item *it = data;
672
673    if (!it) return;
674
675    Widget_Data *wd;
676    wd = elm_widget_data_get(WIDGET(it));
677
678    if (!wd) return;
679
680    if (wd->selected_item != it)
681      {
682         wd->selected_item = it;
683         _selected_item_indicate(wd->selected_item);
684      }
685
686    if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
687 }
688
689 static void
690 _scroller_move_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
691 {
692    Evas_Coord x, y, w, h, bw;
693    Widget_Data *wd = data;
694
695    _check_string(wd);
696    elm_smart_scroller_child_pos_get(obj, &x, &y);
697    elm_smart_scroller_child_viewport_size_get(obj, &w, &h);
698    if (wd->round)
699      {
700         evas_object_geometry_get(wd->main_box, NULL, NULL, &bw, NULL);
701         if (x > ((w / wd->display_item_num) * (wd->item_count + (wd->display_item_num % 2))))
702            elm_smart_scroller_child_region_show(wd->scroller,
703                                                x - ((w / wd->display_item_num) * wd->item_count),
704                                                y, w, h);
705         else if (x < 0)
706            elm_smart_scroller_child_region_show(wd->scroller,
707                                                x + ((w / wd->display_item_num) * wd->item_count),
708                                                y, w, h);
709      }
710 }
711
712 static void
713 _scroller_stop_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
714 {
715    Elm_Diskselector_Item *it;
716    Widget_Data *wd = data;
717    Evas_Coord x, w, ow;
718    Eina_List *l, *list;
719
720    if (wd->idler) return;
721
722    if (!wd->round)
723      list = wd->items;
724    else
725      list = wd->r_items;
726
727    evas_object_geometry_get(wd->scroller, NULL, NULL, &ow, NULL);
728    EINA_LIST_FOREACH(list, l, it)
729      {
730         evas_object_geometry_get(VIEW(it), &x, NULL, &w, NULL);
731         if (abs((int)(ow / 2 - (int)(x + w / 2))) < 10) break;
732      }
733
734    if (!it) return;
735    _select_item(it);
736 }
737
738 static Eina_Bool
739 _move_scroller(void *data)
740 {
741    Evas_Object *obj = data;
742    Widget_Data *wd;
743    Eina_List *list, *l;
744    Elm_Diskselector_Item *dit;
745    Evas_Coord y, w, h;
746    int i;
747
748    wd = elm_widget_data_get(obj);
749    if (!wd) return EINA_FALSE;
750
751    if (!wd->round)
752      {
753         i = 0;
754         list = wd->items;
755      }
756    else
757      {
758         i = 1;
759         list = wd->r_items;
760      }
761
762    EINA_LIST_FOREACH(list, l, dit)
763      {
764         if (wd->selected_item == dit)
765            break;
766         i++;
767      }
768
769    if (wd->round) i -= CEIL(wd->display_item_num);
770
771    if (!dit)
772      {
773         wd->selected_item =
774            (Elm_Diskselector_Item *) eina_list_nth(wd->items, 0);
775         return EINA_FALSE;
776      }
777
778    evas_object_geometry_get(wd->scroller, NULL, &y, &w, &h);
779 <<<<<<< HEAD
780    //move scroller in two steps for getting smooth launching effect.
781    if (i > 2)
782      elm_smart_scroller_child_region_show(wd->scroller, w / wd->display_item_num * (i-2), y, w, h);
783    elm_smart_scroller_region_bring_in(wd->scroller, w / wd->display_item_num * i, y, w, h);
784
785 =======
786    elm_smart_scroller_child_region_show(wd->scroller, w / wd->display_item_num * i, y, w, h);
787 >>>>>>> remotes/origin/upstream
788    _select_item(dit);
789    if (wd->idler)
790      {
791         ecore_idle_enterer_del(wd->idler);
792         wd->idler = NULL;
793      }
794    wd->init = EINA_TRUE;
795    _check_string(wd);
796
797    return EINA_TRUE;
798 }
799
800 static void
801 _round_item_del(Widget_Data *wd, Elm_Diskselector_Item *it)
802 {
803    if (!it) return;
804    elm_box_unpack(wd->main_box, VIEW(it));
805    wd->r_items = eina_list_remove(wd->r_items, it);
806    eina_stringshare_del(it->label);
807    elm_widget_item_free(it);
808 }
809
810 static void
811 _round_items_del(Widget_Data *wd)
812 {
813    Eina_List *l;
814    Elm_Diskselector_Item * it;
815
816    _round_item_del(wd, wd->last);
817    wd->last = NULL;
818    _round_item_del(wd, wd->s_last);
819    wd->s_last = NULL;
820    _round_item_del(wd, wd->second);
821    wd->second = NULL;
822    _round_item_del(wd, wd->first);
823    wd->first = NULL;
824
825    EINA_LIST_FOREACH(wd->under_items, l, it)
826      {
827         _round_item_del(wd, it);
828      }
829    wd->under_items = eina_list_free(wd->under_items);
830
831    EINA_LIST_FOREACH(wd->over_items, l, it)
832      {
833         _round_item_del(wd, it);
834      }
835    wd->over_items = eina_list_free(wd->over_items);
836 }
837
838 static void
839 _round_items_add(Widget_Data *wd)
840 {
841    Elm_Diskselector_Item *dit;
842    Elm_Diskselector_Item *it;
843    Elm_Diskselector_Item *temp_it;
844    int i = 0;
845    dit = it = eina_list_nth(wd->items, 0);
846    if (!dit) return;
847
848    if (!wd->first)
849      {
850         wd->first = _item_new(WIDGET(it), it->icon, it->label, it->func,
851                               it->base.data);
852         wd->first->node = it->node;
853         wd->r_items = eina_list_append(wd->r_items, wd->first);
854      }
855
856    it = eina_list_nth(wd->items, 1);
857    if (!it)
858      it = dit;
859    if (!wd->second)
860      {
861         wd->second = _item_new(WIDGET(it), it->icon, it->label, it->func,
862                                it->base.data);
863         wd->second->node = it->node;
864         wd->r_items = eina_list_append(wd->r_items, wd->second);
865      }
866
867    // if more than 3 itmes should be displayed
868    for (i = 2; i < CEIL(wd->display_item_num); i++)
869      {
870         it = eina_list_nth(wd->items, i);
871         if (!it) it = dit;
872         temp_it = _item_new(WIDGET(it), it->icon, it->label, it->func, it->base.data);
873         wd->over_items = eina_list_append(wd->over_items, temp_it);
874         wd->r_items = eina_list_append(wd->r_items, temp_it);
875      }
876
877    it = eina_list_nth(wd->items, wd->item_count - 1);
878    if (!it)
879      it = dit;
880    if (!wd->last)
881      {
882         wd->last = _item_new(WIDGET(it), it->icon, it->label, it->func,
883                              it->base.data);
884         wd->last->node = it->node;
885         wd->r_items = eina_list_prepend(wd->r_items, wd->last);
886      }
887
888    it = eina_list_nth(wd->items, wd->item_count - 2);
889    if (!it)
890      it = dit;
891    if (!wd->s_last)
892      {
893         wd->s_last = _item_new(WIDGET(it), it->icon, it->label, it->func,
894                                it->base.data);
895         wd->s_last->node = it->node;
896         wd->r_items = eina_list_prepend(wd->r_items, wd->s_last);
897      }
898
899    // if more than 3 itmes should be displayed
900    for (i = 3; i <= CEIL(wd->display_item_num); i++)
901      {
902         it = eina_list_nth(wd->items, wd->item_count - i);
903         if (!it) it = dit;
904         temp_it = _item_new(WIDGET(it), it->icon, it->label, it->func, it->base.data);
905         wd->under_items = eina_list_append(wd->under_items, temp_it);
906         wd->r_items = eina_list_prepend(wd->r_items, temp_it);
907      }
908 }
909
910 static void
911 _item_icon_set(Elm_Diskselector_Item *it, Evas_Object *icon)
912 {
913    if (it->icon == icon) return;
914    if (it->icon)
915      evas_object_del(it->icon);
916    it->icon = icon;
917    if (VIEW(it))
918      {
919         evas_object_size_hint_min_set(it->icon, 24, 24);
920         evas_object_size_hint_max_set(it->icon, 40, 40);
921         edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
922         evas_object_show(it->icon);
923         elm_widget_sub_object_add(WIDGET(it), it->icon);
924      }
925 }
926
927 static void
928 _check_identical_item(Elm_Diskselector_Item *it, Evas_Object *icon)
929 {
930    Widget_Data *wd;
931    Elm_Diskselector_Item *dit;
932    Eina_List *l;
933    int idx = 0;
934    int ic = 0;
935    int ac = 0;
936
937    wd = elm_widget_data_get(WIDGET(it));
938    if (!wd) return;
939
940    if (wd->round)
941      {
942         // Get index from indentical item from round items
943         EINA_LIST_FOREACH(wd->r_items, l, dit)
944           {
945              if (it == dit) break;
946              idx++;
947           }
948
949         // No item to match
950         ic = eina_list_count(wd->r_items);
951         if (idx >= ic) return;
952         dit = NULL;
953
954         // Number of added items: CEIL(wd->display_item_num)
955         ac = CEIL(wd->display_item_num);
956
957         if (((idx >= 0) && (idx < ac)) ||
958             ((idx >= ac) && (idx < (2 * ac))))
959           {
960               // Selected item: under, low region
961              dit = eina_list_nth(wd->r_items,
962                                  idx + ic - (2 * ac));
963           }
964         else if (((idx >= (ic - ac)) && (idx < ic)) ||
965                  ((idx >= (ic - (2 * ac))) && (idx < ic - ac)))
966           {
967               // Selected item: over, high region
968               dit = eina_list_nth(wd->r_items,
969                                   idx - ic + (2 * ac));
970           }
971
972         if(dit) _item_icon_set(dit, icon);
973         _sizing_eval(wd->self);
974      }
975 }
976
977 static void
978 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
979 {
980 <<<<<<< HEAD
981    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
982    Elm_Diskselector_Item *item;
983    if (part && strcmp(part, "default")) return;
984    item = (Elm_Diskselector_Item *) it;
985 =======
986    Elm_Diskselector_Item *item;
987    if (part && strcmp(part, "default")) return;
988    item = (Elm_Diskselector_Item *)it;
989 >>>>>>> remotes/origin/upstream
990    eina_stringshare_replace(&item->label, label);
991    edje_object_part_text_set(VIEW(item), "elm.text", item->label);
992 }
993
994 static const char *
995 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
996 {
997 <<<<<<< HEAD
998    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
999    if (part && strcmp(part, "default")) return NULL;
1000    return ((Elm_Diskselector_Item *) it)->label;
1001 =======
1002    if (part && strcmp(part, "default")) return NULL;
1003    return ((Elm_Diskselector_Item *)it)->label;
1004 >>>>>>> remotes/origin/upstream
1005 }
1006
1007 static void
1008 _item_content_set_hook(Elm_Object_Item *it,
1009                        const char *part,
1010                        Evas_Object *content)
1011 {
1012 <<<<<<< HEAD
1013    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1014    if (part && strcmp(part, "icon")) return;
1015    _item_icon_set((Elm_Diskselector_Item *) it, content);
1016    _check_identical_item((Elm_Diskselector_Item *) it, content);
1017 =======
1018    if (part && strcmp(part, "icon")) return;
1019    _item_icon_set((Elm_Diskselector_Item *)it, content);
1020    _check_identical_item((Elm_Diskselector_Item *)it, content);
1021 >>>>>>> remotes/origin/upstream
1022 }
1023
1024 static Evas_Object *
1025 _item_content_get_hook(const Elm_Object_Item *it, const char *part)
1026 {
1027 <<<<<<< HEAD
1028    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1029    if (part && strcmp(part, "icon")) return NULL;
1030    return ((Elm_Diskselector_Item *) it)->icon;
1031 }
1032
1033 =======
1034    if (part && strcmp(part, "icon")) return NULL;
1035    return ((Elm_Diskselector_Item *)it)->icon;
1036 }
1037
1038
1039 >>>>>>> remotes/origin/upstream
1040 EAPI Evas_Object *
1041 elm_diskselector_add(Evas_Object *parent)
1042 {
1043    Evas *e;
1044    Evas_Object *obj;
1045    Widget_Data *wd;
1046
1047    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1048
1049    ELM_SET_WIDTYPE(widtype, "diskselector");
1050    elm_widget_type_set(obj, "diskselector");
1051    elm_widget_sub_object_add(parent, obj);
1052    elm_widget_data_set(obj, wd);
1053    elm_widget_del_hook_set(obj, _del_hook);
1054    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1055    elm_widget_theme_hook_set(obj, _theme_hook);
1056    elm_widget_can_focus_set(obj, EINA_TRUE);
1057    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1058    elm_widget_event_hook_set(obj, _event_hook);
1059
1060    wd->self = obj;
1061    wd->item_count = 0;
1062    wd->round = EINA_FALSE;
1063    wd->init = EINA_FALSE;
1064    wd->len_side = 3;
1065    wd->display_item_num_by_api = EINA_FALSE;
1066
1067    wd->scroller = elm_smart_scroller_add(e);
1068    elm_smart_scroller_widget_set(wd->scroller, obj);
1069    _theme_hook(obj);
1070    elm_widget_resize_object_set(obj, wd->scroller);
1071    elm_smart_scroller_policy_set(wd->scroller, ELM_SMART_SCROLLER_POLICY_OFF,
1072                                  ELM_SMART_SCROLLER_POLICY_OFF);
1073    elm_smart_scroller_bounce_allow_set(wd->scroller, EINA_TRUE, EINA_FALSE);
1074    evas_object_smart_callback_add(wd->scroller, "scroll", _scroller_move_cb,
1075                                   wd);
1076    evas_object_smart_callback_add(wd->scroller, "animate,stop",
1077                                   _scroller_stop_cb, wd);
1078    _elm_theme_object_set(obj, wd->scroller, "diskselector", "base",
1079                          "default");
1080    evas_object_event_callback_add(wd->scroller, EVAS_CALLBACK_RESIZE,
1081                                   _diskselector_object_resize, obj);
1082
1083    wd->main_box = elm_box_add(parent);
1084    elm_box_horizontal_set(wd->main_box, EINA_TRUE);
1085    elm_box_homogeneous_set(wd->main_box, EINA_TRUE);
1086    evas_object_size_hint_weight_set(wd->main_box, EVAS_HINT_EXPAND,
1087                                     EVAS_HINT_EXPAND);
1088    evas_object_size_hint_align_set(wd->main_box, EVAS_HINT_FILL,
1089                                    EVAS_HINT_FILL);
1090    _elm_theme_object_set(obj, wd->main_box, "diskselector", "base",
1091                          "default");
1092    elm_widget_sub_object_add(obj, wd->main_box);
1093
1094    elm_smart_scroller_child_set(wd->scroller, wd->main_box);
1095
1096    wd->left_blank = edje_object_add(evas_object_evas_get(obj));
1097    _elm_theme_object_set(obj, wd->left_blank, "diskselector", "item",
1098                          "default");
1099    evas_object_size_hint_weight_set(wd->left_blank, EVAS_HINT_EXPAND,
1100                                     EVAS_HINT_EXPAND);
1101    evas_object_size_hint_align_set(wd->left_blank, EVAS_HINT_FILL,
1102                                    EVAS_HINT_FILL);
1103    elm_box_pack_end(wd->main_box, wd->left_blank);
1104    evas_object_show(wd->left_blank);
1105
1106    wd->right_blank = edje_object_add(evas_object_evas_get(obj));
1107    _elm_theme_object_set(obj, wd->right_blank, "diskselector", "item",
1108                          "default");
1109    evas_object_size_hint_weight_set(wd->right_blank, EVAS_HINT_EXPAND,
1110                                     EVAS_HINT_EXPAND);
1111    evas_object_size_hint_align_set(wd->right_blank, EVAS_HINT_FILL,
1112                                    EVAS_HINT_FILL);
1113    elm_box_pack_end(wd->main_box, wd->right_blank);
1114    evas_object_show(wd->right_blank);
1115
1116    _theme_data_get(wd);
1117
1118    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1119    evas_object_smart_callbacks_descriptions_set(obj, _signals);
1120    _sizing_eval(obj);
1121    return obj;
1122 }
1123
1124 EAPI Eina_Bool
1125 <<<<<<< HEAD
1126 elm_diskselector_round_get(const Evas_Object *obj)
1127 =======
1128 elm_diskselector_round_enabled_get(const Evas_Object *obj)
1129 >>>>>>> remotes/origin/upstream
1130 {
1131    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1132    Widget_Data *wd = elm_widget_data_get(obj);
1133    if (!wd) return EINA_FALSE;
1134    return wd->round;
1135 }
1136
1137 EAPI void
1138 <<<<<<< HEAD
1139 elm_diskselector_round_set(Evas_Object * obj, Eina_Bool round)
1140 =======
1141 elm_diskselector_round_enabled_set(Evas_Object * obj, Eina_Bool enabled)
1142 >>>>>>> remotes/origin/upstream
1143 {
1144    Eina_List *elist;
1145    Elm_Diskselector_Item *it;
1146
1147    ELM_CHECK_WIDTYPE(obj, widtype);
1148    Widget_Data *wd = elm_widget_data_get(obj);
1149    if (!wd) return;
1150
1151 <<<<<<< HEAD
1152    if (wd->round == round)
1153      return;
1154
1155    wd->round = round;
1156    if (round)
1157 =======
1158    if (wd->round == enabled)
1159      return;
1160
1161    wd->round = !!enabled;
1162    if (enabled)
1163 >>>>>>> remotes/origin/upstream
1164      {
1165         wd->r_items = eina_list_clone(wd->items);
1166         elm_box_unpack(wd->main_box, wd->left_blank);
1167         evas_object_hide(wd->left_blank);
1168         elm_box_unpack(wd->main_box, wd->right_blank);
1169         evas_object_hide(wd->right_blank);
1170         if (!wd->items)
1171           return;
1172
1173         _round_items_add(wd);
1174
1175         if (wd->last)
1176           elm_box_pack_start(wd->main_box, wd->VIEW(last));
1177         if (wd->s_last)
1178           elm_box_pack_start(wd->main_box, wd->VIEW(s_last));
1179
1180         // if more than 3 items should be displayed
1181         EINA_LIST_FOREACH(wd->under_items, elist, it)
1182            elm_box_pack_start(wd->main_box, VIEW(it));
1183
1184         if (wd->first)
1185           elm_box_pack_end(wd->main_box, wd->VIEW(first));
1186         if (wd->second)
1187           elm_box_pack_end(wd->main_box, wd->VIEW(second));
1188
1189         // if more than 3 items should be displayed
1190         EINA_LIST_FOREACH(wd->over_items, elist, it)
1191            elm_box_pack_end(wd->main_box, VIEW(it));
1192      }
1193    else
1194      {
1195         _round_items_del(wd);
1196         elm_box_pack_start(wd->main_box, wd->left_blank);
1197         elm_box_pack_end(wd->main_box, wd->right_blank);
1198         eina_list_free(wd->r_items);
1199         wd->r_items = NULL;
1200      }
1201
1202    _selected_item_indicate(wd->selected_item);
1203    _sizing_eval(obj);
1204 }
1205
1206 EAPI int
1207 <<<<<<< HEAD
1208 elm_diskselector_side_label_length_get(const Evas_Object *obj)
1209 =======
1210 elm_diskselector_side_text_max_length_get(const Evas_Object *obj)
1211 >>>>>>> remotes/origin/upstream
1212 {
1213    ELM_CHECK_WIDTYPE(obj, widtype) 0;
1214    Widget_Data *wd = elm_widget_data_get(obj);
1215    if (!wd) return 0;
1216    return wd->len_side;
1217 }
1218
1219 EAPI void
1220 <<<<<<< HEAD
1221 elm_diskselector_side_label_length_set(Evas_Object *obj, int len)
1222 =======
1223 elm_diskselector_side_text_max_length_set(Evas_Object *obj, int len)
1224 >>>>>>> remotes/origin/upstream
1225 {
1226    ELM_CHECK_WIDTYPE(obj, widtype);
1227    Widget_Data *wd = elm_widget_data_get(obj);
1228    if (!wd) return;
1229    wd->len_side = len;
1230 }
1231
1232 EAPI void
1233 <<<<<<< HEAD
1234 elm_diskselector_side_label_lenght_set(Evas_Object *obj, int len)
1235 {
1236    return elm_diskselector_side_label_length_set(obj, len);
1237 }
1238
1239 EAPI int
1240 elm_diskselector_side_label_lenght_get(const Evas_Object *obj)
1241 {
1242    return elm_diskselector_side_label_length_get(obj);
1243 }
1244
1245 EAPI void
1246 =======
1247 >>>>>>> remotes/origin/upstream
1248 elm_diskselector_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1249 {
1250    ELM_CHECK_WIDTYPE(obj, widtype);
1251    Widget_Data *wd = elm_widget_data_get(obj);
1252    if (!wd) return;
1253    if (wd->scroller)
1254      elm_smart_scroller_bounce_allow_set(wd->scroller, h_bounce, v_bounce);
1255 }
1256
1257 EAPI void
1258 elm_diskselector_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1259 {
1260    ELM_CHECK_WIDTYPE(obj, widtype);
1261    Widget_Data *wd = elm_widget_data_get(obj);
1262    if (!wd) return;
1263    elm_smart_scroller_bounce_allow_get(wd->scroller, h_bounce, v_bounce);
1264 }
1265
1266 EAPI void
1267 elm_diskselector_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
1268 {
1269    ELM_CHECK_WIDTYPE(obj, widtype);
1270    Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
1271    Widget_Data *wd = elm_widget_data_get(obj);
1272    if ((!wd) || (!wd->scroller)) return;
1273    elm_smart_scroller_policy_get(wd->scroller, &s_policy_h, &s_policy_v);
1274    *policy_h = (Elm_Scroller_Policy) s_policy_h;
1275    *policy_v = (Elm_Scroller_Policy) s_policy_v;
1276 }
1277
1278 EAPI void
1279 elm_diskselector_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
1280 {
1281    ELM_CHECK_WIDTYPE(obj, widtype);
1282    Widget_Data *wd = elm_widget_data_get(obj);
1283    if ((!wd) || (!wd->scroller)) return;
1284    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
1285        (policy_v >= ELM_SCROLLER_POLICY_LAST))
1286      return;
1287    elm_smart_scroller_policy_set(wd->scroller, policy_h, policy_v);
1288 }
1289
1290 EAPI void
1291 elm_diskselector_clear(Evas_Object *obj)
1292 {
1293    ELM_CHECK_WIDTYPE(obj, widtype);
1294    Widget_Data *wd = elm_widget_data_get(obj);
1295    Elm_Diskselector_Item *it;
1296
1297    if (!wd) return;
1298    if (!wd->items) return;
1299
1300    wd->selected_item = NULL;
1301    EINA_LIST_FREE(wd->items, it)
1302      {
1303         _item_del(it);
1304         elm_widget_item_free(it);
1305      }
1306    _round_items_del(wd);
1307    _sizing_eval(obj);
1308 }
1309
1310 EAPI const Eina_List *
1311 elm_diskselector_items_get(const Evas_Object *obj)
1312 {
1313    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1314    Widget_Data *wd = elm_widget_data_get(obj);
1315    if (!wd) return NULL;
1316    return wd->items;
1317 }
1318
1319 EAPI Elm_Object_Item *
1320 elm_diskselector_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1321 {
1322    Elm_Diskselector_Item *it;
1323    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1324    Widget_Data *wd = elm_widget_data_get(obj);
1325    if (!wd) return NULL;
1326
1327    it = _item_new(obj, icon, label, func, data);
1328    wd->items = eina_list_append(wd->items, it);
1329    it->node = eina_list_last(wd->items);
1330    wd->item_count++;
1331    if (wd->round)
1332      {
1333         _round_items_del(wd);
1334         wd->r_items = eina_list_append(wd->r_items, it);
1335         _round_items_add(wd);
1336         if (wd->last)
1337           elm_box_pack_start(wd->main_box, wd->VIEW(last));
1338         if (wd->s_last)
1339           elm_box_pack_start(wd->main_box, wd->VIEW(s_last));
1340         elm_box_pack_end(wd->main_box, VIEW(it));
1341         if (wd->first)
1342           elm_box_pack_end(wd->main_box, wd->VIEW(first));
1343         if (wd->second)
1344           elm_box_pack_end(wd->main_box, wd->VIEW(second));
1345      }
1346    else
1347      {
1348         elm_box_unpack(wd->main_box, wd->right_blank);
1349         elm_box_pack_end(wd->main_box, VIEW(it));
1350         elm_box_pack_end(wd->main_box, wd->right_blank);
1351      }
1352    if (!wd->selected_item)
1353      wd->selected_item = it;
1354    if (!wd->idler)
1355      wd->idler = ecore_idle_enterer_before_add(_move_scroller, obj);
1356    _sizing_eval(obj);
1357 <<<<<<< HEAD
1358    return (Elm_Object_Item *) it;
1359 }
1360
1361 EAPI void
1362 elm_diskselector_item_del(Elm_Object_Item * it)
1363 {
1364    elm_object_item_del(it);
1365 }
1366
1367 EAPI const char *
1368 elm_diskselector_item_label_get(const Elm_Object_Item * it)
1369 {
1370    return _item_text_get_hook(it, NULL);
1371 }
1372
1373 EAPI void
1374 elm_diskselector_item_label_set(Elm_Object_Item * it, const char *label)
1375 {
1376    _item_text_set_hook(it, NULL, label);
1377 =======
1378    return (Elm_Object_Item *)it;
1379 >>>>>>> remotes/origin/upstream
1380 }
1381
1382 EAPI Elm_Object_Item *
1383 elm_diskselector_selected_item_get(const Evas_Object *obj)
1384 {
1385    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1386    Widget_Data *wd = elm_widget_data_get(obj);
1387    if (!wd) return NULL;
1388    return (Elm_Object_Item *) wd->selected_item;
1389 }
1390
1391 EAPI void
1392 elm_diskselector_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1393 {
1394    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1395    Widget_Data *wd;
1396 <<<<<<< HEAD
1397    Elm_Diskselector_Item *item = (Elm_Diskselector_Item *) it;
1398 =======
1399    Elm_Diskselector_Item *item = (Elm_Diskselector_Item *)it;
1400 >>>>>>> remotes/origin/upstream
1401    wd = elm_widget_data_get(WIDGET(item));
1402    if (!wd) return;
1403
1404    if ((wd->selected_item == item) && (selected))
1405      return;
1406
1407    if ((wd->selected_item == item) && (!selected))
1408      wd->selected_item = eina_list_data_get(wd->items);
1409    else
1410      {
1411         wd->selected_item = item;
1412         _selected_item_indicate(wd->selected_item);
1413      }
1414
1415    if (!wd->idler)
1416      wd->idler = ecore_idle_enterer_before_add(_move_scroller, WIDGET(item));
1417 }
1418
1419 EAPI Eina_Bool
1420 elm_diskselector_item_selected_get(const Elm_Object_Item *it)
1421 {
1422    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1423    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1424    if (!wd) return EINA_FALSE;
1425 <<<<<<< HEAD
1426    return (wd->selected_item == ((Elm_Diskselector_Item *) it));
1427 }
1428
1429 EAPI void
1430 elm_diskselector_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
1431 {
1432    elm_object_item_del_cb_set(it, func);
1433 }
1434
1435 EAPI void *
1436 elm_diskselector_item_data_get(const Elm_Object_Item *it)
1437 {
1438    return elm_object_item_data_get(it);
1439 }
1440
1441 EAPI Evas_Object *
1442 elm_diskselector_item_icon_get(const Elm_Object_Item *it)
1443 {
1444    return _item_content_get_hook(it, NULL);
1445 }
1446
1447 EAPI void
1448 elm_diskselector_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
1449 {
1450    _item_content_set_hook(it, NULL, icon);
1451 =======
1452    return (wd->selected_item == ((Elm_Diskselector_Item *)it));
1453 >>>>>>> remotes/origin/upstream
1454 }
1455
1456 EAPI Elm_Object_Item *
1457 elm_diskselector_item_prev_get(const Elm_Object_Item *it)
1458 {
1459    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1460 <<<<<<< HEAD
1461    Elm_Diskselector_Item *item = (Elm_Diskselector_Item *) it;
1462 =======
1463    Elm_Diskselector_Item *item = (Elm_Diskselector_Item *)it;
1464 >>>>>>> remotes/origin/upstream
1465    if (item->node->prev) return item->node->prev->data;
1466    else return NULL;
1467 }
1468
1469 EAPI Elm_Object_Item *
1470 elm_diskselector_item_next_get(const Elm_Object_Item *it)
1471 {
1472    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1473 <<<<<<< HEAD
1474    Elm_Diskselector_Item *item = (Elm_Diskselector_Item *) it;
1475 =======
1476    Elm_Diskselector_Item *item = (Elm_Diskselector_Item *)it;
1477 >>>>>>> remotes/origin/upstream
1478    if (item->node->next) return item->node->next->data;
1479    else return NULL;
1480 }
1481
1482 EAPI Elm_Object_Item *
1483 elm_diskselector_first_item_get(const Evas_Object *obj)
1484 {
1485    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1486    Widget_Data *wd = elm_widget_data_get(obj);
1487    if (!wd || !wd->items) return NULL;
1488    return eina_list_data_get(wd->items);
1489 }
1490
1491 EAPI Elm_Object_Item *
1492 elm_diskselector_last_item_get(const Evas_Object *obj)
1493 {
1494    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1495    Widget_Data *wd = elm_widget_data_get(obj);
1496    if (!wd || !wd->items) return NULL;
1497    return eina_list_data_get(eina_list_last(wd->items));
1498 }
1499
1500 EAPI void
1501 <<<<<<< HEAD
1502 elm_diskselector_item_tooltip_text_set(Elm_Object_Item *it, const char *text)
1503 {
1504    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1505    elm_widget_item_tooltip_text_set(it, text);
1506 }
1507
1508 EAPI void
1509 elm_diskselector_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
1510 {
1511    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1512    elm_widget_item_tooltip_content_cb_set(it, func, data, del_cb);
1513 }
1514
1515 EAPI void
1516 elm_diskselector_item_tooltip_unset(Elm_Object_Item *it)
1517 {
1518    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1519    elm_widget_item_tooltip_unset(it);
1520 }
1521
1522 EAPI void
1523 elm_diskselector_item_tooltip_style_set(Elm_Object_Item *it, const char *style)
1524 {
1525    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1526    elm_widget_item_tooltip_style_set(it, style);
1527 }
1528
1529 EAPI const char *
1530 elm_diskselector_item_tooltip_style_get(const Elm_Object_Item *it)
1531 {
1532    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1533    return elm_widget_item_tooltip_style_get(it);
1534 }
1535
1536 EAPI void
1537 elm_diskselector_item_cursor_set(Elm_Object_Item *it, const char *cursor)
1538 {
1539    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1540    elm_widget_item_cursor_set(it, cursor);
1541 }
1542
1543 EAPI const char *
1544 elm_diskselector_item_cursor_get(const Elm_Object_Item *it)
1545 {
1546    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1547    return elm_widget_item_cursor_get(it);
1548 }
1549
1550 EAPI void
1551 elm_diskselector_item_cursor_unset(Elm_Object_Item *it)
1552 {
1553    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1554    elm_widget_item_cursor_unset(it);
1555 }
1556
1557 EAPI void
1558 elm_diskselector_item_cursor_style_set(Elm_Object_Item *it, const char *style)
1559 {
1560    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1561    elm_widget_item_cursor_style_set(it, style);
1562 }
1563
1564 EAPI const char *
1565 elm_diskselector_item_cursor_style_get(const Elm_Object_Item *it)
1566 {
1567    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1568    return elm_widget_item_cursor_style_get(it);
1569 }
1570
1571 EAPI void
1572 elm_diskselector_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only)
1573 {
1574    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1575    elm_widget_item_cursor_engine_only_set(it, engine_only);
1576 }
1577
1578 EAPI Eina_Bool
1579 elm_diskselector_item_cursor_engine_only_get(const Elm_Object_Item *it)
1580 {
1581    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1582    return elm_widget_item_cursor_engine_only_get(it);
1583 }
1584
1585 EAPI void
1586 =======
1587 >>>>>>> remotes/origin/upstream
1588 elm_diskselector_display_item_num_set(Evas_Object *obj, int num)
1589 {
1590    ELM_CHECK_WIDTYPE(obj, widtype);
1591    Widget_Data *wd = elm_widget_data_get(obj);
1592    if (!wd) return;
1593    if (num < DISPLAY_ITEM_NUM_MIN) num = DISPLAY_ITEM_NUM_MIN;
1594    wd->display_item_num = num;
1595    wd->display_item_num_by_api = EINA_TRUE;
1596 }
1597
1598 EAPI int
1599 elm_diskselector_display_item_num_get(const Evas_Object *item)
1600 {
1601    ELM_CHECK_WIDTYPE(item, widtype) (-1);
1602    Widget_Data *wd = elm_widget_data_get(item);
1603    if (!wd) return -1;
1604    return wd->display_item_num;
1605 }