Elm: Fix a couple more deprecation warnings and use elm_object_text_set/get.
[framework/uifw/elementary.git] / src / lib / elc_hoversel.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 /**
5  * @defgroup Hoversel
6  *
7  * A hoversel is a button that pops up a list of items (automatically
8  * choosing the direction to display) that have a lable and/or an icon to
9  * select from. It is a convenience widget to avoid the need to do all the
10  * piecing together yourself. It is intended for a small number of items in
11  * the hoversel menu (no more than 8), though is capable of many more.
12  *
13  * Signals that you can add callbacks for are:
14  *
15  * "clicked" - the user clicked the hoversel button and popped up the sel
16  * "selected" - an item in the hoversel list is selected. event_info is the item
17  * "dismissed" - the hover is dismissed
18  */
19 typedef struct _Widget_Data Widget_Data;
20
21 struct _Widget_Data
22 {
23    Evas_Object *btn, *hover;
24    Evas_Object *hover_parent;
25    Eina_List *items;
26    Eina_Bool horizontal : 1;
27    Eina_Bool expanded   : 1;
28 };
29
30 struct _Elm_Hoversel_Item
31 {
32    Elm_Widget_Item base;
33    const char *label;
34    const char *icon_file;
35    const char *icon_group;
36    Elm_Icon_Type icon_type;
37    Evas_Smart_Cb func;
38 };
39
40 static const char *widtype = NULL;
41 static void _del_pre_hook(Evas_Object *obj);
42 static void _del_hook(Evas_Object *obj);
43 static void _activate(Evas_Object *obj);
44 static void _activate_hook(Evas_Object *obj);
45 static void _disable_hook(Evas_Object *obj);
46 static void _sizing_eval(Evas_Object *obj);
47 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
48 static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
49
50 static const char SIG_CLICKED[] = "clicked";
51 static const char SIG_SELECTED[] = "selected";
52 static const char SIG_DISMISSED[] = "dismissed";
53
54 static const Evas_Smart_Cb_Description _signals[] = {
55    {SIG_CLICKED, ""},
56    {SIG_SELECTED, ""},
57    {SIG_DISMISSED, ""},
58    {NULL, NULL}
59 };
60
61 static void
62 _del_pre_hook(Evas_Object *obj)
63 {
64    Elm_Hoversel_Item *item;
65    Widget_Data *wd = elm_widget_data_get(obj);
66    if (!wd) return;
67    elm_hoversel_hover_end(obj);
68    elm_hoversel_hover_parent_set(obj, NULL);
69    EINA_LIST_FREE(wd->items, item)
70      {
71         elm_widget_item_pre_notify_del(item);
72         eina_stringshare_del(item->label);
73         eina_stringshare_del(item->icon_file);
74         eina_stringshare_del(item->icon_group);
75         elm_widget_item_del(item);
76      }
77 }
78
79 static void
80 _del_hook(Evas_Object *obj)
81 {
82    Widget_Data *wd = elm_widget_data_get(obj);
83    if (!wd) return;
84    free(wd);
85 }
86
87 static void
88 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
89 {
90    Widget_Data *wd = elm_widget_data_get(obj);
91    if (!wd) return;
92    elm_widget_mirrored_set(wd->btn, rtl);
93    elm_widget_mirrored_set(wd->hover, rtl);
94 }
95
96 static void
97 _theme_hook(Evas_Object *obj)
98 {
99    Widget_Data *wd = elm_widget_data_get(obj);
100    char buf[4096];
101    if (!wd) return;
102    _elm_widget_mirrored_reload(obj);
103
104    elm_hoversel_hover_end(obj);
105    if (wd->horizontal)
106      snprintf(buf, sizeof(buf), "hoversel_horizontal/%s", elm_widget_style_get(obj));
107    else
108      snprintf(buf, sizeof(buf), "hoversel_vertical/%s", elm_widget_style_get(obj));
109    elm_object_style_set(wd->btn, buf);
110    elm_object_disabled_set(wd->btn, elm_widget_disabled_get(obj));
111    _mirrored_set(obj, elm_widget_mirrored_get(obj));
112 }
113
114 static void
115 _disable_hook(Evas_Object *obj)
116 {
117    Widget_Data *wd = elm_widget_data_get(obj);
118    if (!wd) return;
119    elm_object_disabled_set(wd->btn, elm_widget_disabled_get(obj));
120 }
121
122 static void
123 _sizing_eval(Evas_Object *obj)
124 {
125    Widget_Data *wd = elm_widget_data_get(obj);
126    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
127    if (!wd) return;
128    evas_object_size_hint_min_get(wd->btn, &minw, &minh);
129    evas_object_size_hint_max_get(wd->btn, &maxw, &maxh);
130    evas_object_size_hint_min_set(obj, minw, minh);
131    evas_object_size_hint_max_set(obj, maxw, maxh);
132 }
133
134 static void
135 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
136 {
137    Widget_Data *wd = elm_widget_data_get(obj);
138    if (!wd) return;
139    if (elm_widget_focus_get(obj))
140      elm_widget_focus_steal(wd->btn);
141 }
142
143 static void
144 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
145 {
146    _sizing_eval(data);
147 }
148
149 static void
150 _hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
151 {
152    elm_hoversel_hover_end(data);
153 }
154
155 static void
156 _item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
157 {
158    Elm_Hoversel_Item *item = data;
159    Evas_Object *obj2 = item->base.widget;
160
161    elm_hoversel_hover_end(obj2);
162    if (item->func) item->func((void *)item->base.data, obj2, item);
163    evas_object_smart_callback_call(obj2, SIG_SELECTED, item);
164 }
165
166 static void
167 _activate(Evas_Object *obj)
168 {
169    Widget_Data *wd = elm_widget_data_get(obj);
170    Evas_Object *bt, *bx, *ic;
171    const Eina_List *l;
172    const Elm_Hoversel_Item *item;
173    char buf[4096];
174
175    if (!wd) return;
176    if (wd->expanded)
177      {
178         elm_hoversel_hover_end(obj);
179         return;
180      }
181    wd->expanded = EINA_TRUE;
182
183    if (elm_widget_disabled_get(obj)) return;
184    wd->hover = elm_hover_add(obj);
185    elm_widget_mirrored_automatic_set(wd->hover, EINA_FALSE);
186    if (wd->horizontal)
187      snprintf(buf, sizeof(buf), "hoversel_horizontal/%s", elm_widget_style_get(obj));
188    else
189      snprintf(buf, sizeof(buf), "hoversel_vertical/%s", elm_widget_style_get(obj));
190    elm_object_style_set(wd->hover, buf);
191    evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, obj);
192    elm_hover_parent_set(wd->hover, wd->hover_parent);
193    elm_hover_target_set(wd->hover, wd->btn);
194
195    bx = elm_box_add(wd->hover);
196    elm_widget_mirrored_automatic_set(bx, EINA_FALSE);
197    elm_box_homogeneous_set(bx, 1);
198
199    elm_box_horizontal_set(bx, wd->horizontal);
200
201    if (wd->horizontal)
202      snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s",
203               elm_widget_style_get(obj));
204    else
205      snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s",
206               elm_widget_style_get(obj));
207    EINA_LIST_FOREACH(wd->items, l, item)
208      {
209         bt = elm_button_add(wd->hover);
210         elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
211         elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj));
212         elm_object_style_set(bt, buf);
213         elm_object_text_set(bt, item->label);
214         if (item->icon_file)
215           {
216              ic = elm_icon_add(obj);
217              elm_icon_scale_set(ic, 0, 1);
218              if (item->icon_type == ELM_ICON_FILE)
219                elm_icon_file_set(ic, item->icon_file, item->icon_group);
220              else if (item->icon_type == ELM_ICON_STANDARD)
221                elm_icon_standard_set(ic, item->icon_file);
222              elm_button_icon_set(bt, ic);
223              evas_object_show(ic);
224           }
225         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
226         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
227         elm_box_pack_end(bx, bt);
228         evas_object_smart_callback_add(bt, "clicked", _item_clicked, item);
229         evas_object_show(bt);
230      }
231
232    if (wd->horizontal)
233      elm_hover_content_set(wd->hover,
234                            elm_hover_best_content_location_get(wd->hover,
235                                                                ELM_HOVER_AXIS_HORIZONTAL),
236                            bx);
237    else
238      elm_hover_content_set(wd->hover,
239                            elm_hover_best_content_location_get(wd->hover,
240                                                                ELM_HOVER_AXIS_VERTICAL),
241                            bx);
242    evas_object_show(bx);
243
244    evas_object_show(wd->hover);
245    evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
246
247    //   if (wd->horizontal) evas_object_hide(wd->btn);
248 }
249
250 static void
251 _activate_hook(Evas_Object *obj)
252 {
253    _activate(obj);
254 }
255
256 static void
257 _button_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
258 {
259    _activate(data);
260 }
261
262 static void
263 _parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
264 {
265    Widget_Data *wd = elm_widget_data_get(data);
266    if (!wd) return;
267    wd->hover_parent = NULL;
268 }
269
270 /**
271  * Add a new Hoversel object
272  *
273  * @param parent The parent object
274  * @return The new object or NULL if it cannot be created
275  *
276  * @ingroup Hoversel
277  */
278 EAPI Evas_Object *
279 elm_hoversel_add(Evas_Object *parent)
280 {
281    Evas_Object *obj;
282    Evas *e;
283    Widget_Data *wd;
284
285    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
286
287    ELM_SET_WIDTYPE(widtype, "hoversel");
288    elm_widget_type_set(obj, "hoversel");
289    elm_widget_sub_object_add(parent, obj);
290    elm_widget_data_set(obj, wd);
291    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
292    elm_widget_del_hook_set(obj, _del_hook);
293    elm_widget_theme_hook_set(obj, _theme_hook);
294    elm_widget_disable_hook_set(obj, _disable_hook);
295    elm_widget_activate_hook_set(obj, _activate_hook);
296    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
297    elm_widget_can_focus_set(obj, EINA_TRUE);
298
299    wd->btn = elm_button_add(parent);
300    elm_widget_mirrored_automatic_set(wd->btn, EINA_FALSE);
301    wd->expanded = EINA_FALSE;
302    elm_widget_resize_object_set(obj, wd->btn);
303    evas_object_event_callback_add(wd->btn, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
304                                   _changed_size_hints, obj);
305    evas_object_smart_callback_add(wd->btn, "clicked", _button_clicked, obj);
306    evas_object_smart_callbacks_descriptions_set(obj, _signals);
307
308    elm_widget_sub_object_add(obj, wd->btn);
309
310    elm_hoversel_hover_parent_set(obj, parent);
311    _theme_hook(obj);
312
313    return obj;
314 }
315
316 /**
317  * Set the Hover parent
318  *
319  * Sets the hover parent object. Should probably be the window that the hoversel
320  * is in.  See Hover objects for more information.
321  *
322  * @param obj The hoversel object
323  * @param parent The parent to use
324  *
325  * @ingroup Hoversel
326  */
327 EAPI void
328 elm_hoversel_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
329 {
330    ELM_CHECK_WIDTYPE(obj, widtype);
331    Widget_Data *wd = elm_widget_data_get(obj);
332    if (!wd) return;
333    if (wd->hover_parent)
334      evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_DEL,
335                                          _parent_del, obj);
336    wd->hover_parent = parent;
337    if (wd->hover_parent)
338      evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_DEL,
339                                     _parent_del, obj);
340 }
341
342 /**
343  * Get the Hover parent
344  *
345  * Gets the hover parent object. Should probably be the window that the hoversel
346  * is in.  See Hover objects for more information.
347  *
348  * @param obj The hoversel object
349  * @return The used parent
350  *
351  * @ingroup Hoversel
352  */
353 EAPI Evas_Object *
354 elm_hoversel_hover_parent_get(const Evas_Object *obj)
355 {
356    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
357    Widget_Data *wd = elm_widget_data_get(obj);
358    if (!wd) return NULL;
359    return wd->hover_parent;
360 }
361
362 /**
363  * Set the hoversel button label
364  *
365  * This sets the label of the button that is always visible (before it is
366  * clicked and expanded). Also see elm_object_text_set().
367  *
368  * @param obj The hoversel object
369  * @param label The label text.
370  *
371  * @ingroup Hoversel
372  */
373 EAPI void
374 elm_hoversel_label_set(Evas_Object *obj, const char *label)
375 {
376    ELM_CHECK_WIDTYPE(obj, widtype);
377    Widget_Data *wd = elm_widget_data_get(obj);
378    if (!wd) return;
379    elm_object_text_set(wd->btn, label);
380 }
381
382 /**
383  * Get the hoversel button label
384  *
385  * @param obj The hoversel object
386  * @return The label text.
387  *
388  * @ingroup Hoversel
389  */
390 EAPI const char *
391 elm_hoversel_label_get(const Evas_Object *obj)
392 {
393    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
394    Widget_Data *wd = elm_widget_data_get(obj);
395    if ((!wd) || (!wd->btn)) return NULL;
396    return elm_object_text_get(wd->btn);
397 }
398
399 /**
400  * This sets the hoversel to expand horizontally.  The initial button
401  * will display horizontally regardless of this setting.
402  *
403  * @param obj The hoversel object
404  * @param horizontal If true, the hover will expand horizontally to the right.
405  *
406  * @ingroup Hoversel
407  */
408 EAPI void
409 elm_hoversel_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
410 {
411    ELM_CHECK_WIDTYPE(obj, widtype);
412    Widget_Data *wd = elm_widget_data_get(obj);
413    if (!wd) return;
414    wd->horizontal = !!horizontal;
415 }
416
417
418 /**
419  * This returns whether the hoversel is set to expand horizontally.
420  *
421  * @param obj The hoversel object
422  * @return If true, the hover will expand horizontally to the right.
423  *
424  * @ingroup Hoversel
425  */
426 EAPI Eina_Bool
427 elm_hoversel_horizontal_get(const Evas_Object *obj)
428 {
429    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
430    Widget_Data *wd = elm_widget_data_get(obj);
431    if (!wd) return EINA_FALSE;
432    return wd->horizontal;
433 }
434
435 /**
436  * Set the icon of the hoversel button
437  *
438  * Sets the icon of the button that is always visible (before it is clicked
439  * and expanded). Also see elm_button_icon_set().
440  * Once the icon object is set, a previously set one will be deleted
441  * If you want to keep that old content object, use the
442  * elm_hoversel_icon_unset() function.
443  *
444  * @param obj The hoversel object
445  * @param icon The icon object
446  *
447  * @ingroup Hoversel
448  */
449 EAPI void
450 elm_hoversel_icon_set(Evas_Object *obj, Evas_Object *icon)
451 {
452    ELM_CHECK_WIDTYPE(obj, widtype);
453    Widget_Data *wd = elm_widget_data_get(obj);
454    if (!wd) return;
455    elm_button_icon_set(wd->btn, icon);
456 }
457
458 /**
459  * Get the icon of the hoversel button
460  *
461  * Get the icon of the button that is always visible (before it is clicked
462  * and expanded). Also see elm_button_icon_get().
463  *
464  * @param obj The hoversel object
465  * @return The icon object
466  *
467  * @ingroup Hoversel
468  */
469 EAPI Evas_Object *
470 elm_hoversel_icon_get(const Evas_Object *obj)
471 {
472    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
473    Widget_Data *wd = elm_widget_data_get(obj);
474    if ((!wd) || (!wd->btn)) return NULL;
475    return elm_button_icon_get(wd->btn);
476 }
477
478 /**
479  * Get the icon of the hoversel button
480  *
481  * Unparent and return the icon of the button that is always visible
482  * (before it is clicked and expanded). Also see elm_button_icon_unset().
483  *
484  * @param obj The hoversel object
485  * @return The icon object that was being used
486  *
487  * @ingroup Hoversel
488  */
489 EAPI Evas_Object *
490 elm_hoversel_icon_unset(Evas_Object *obj)
491 {
492    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
493    Widget_Data *wd = elm_widget_data_get(obj);
494    if ((!wd) || (!wd->btn)) return NULL;
495    return elm_button_icon_unset(wd->btn);
496 }
497
498 /**
499  * This triggers the hoversel popup from code, the same as though the
500  * user clicked the button.
501  *
502  * @param obj The hoversel object
503  *
504  * @ingroup Hoversel
505  */
506 EAPI void
507 elm_hoversel_hover_begin(Evas_Object *obj)
508 {
509    ELM_CHECK_WIDTYPE(obj, widtype);
510    Widget_Data *wd = elm_widget_data_get(obj);
511    if (!wd) return;
512    if (wd->hover) return;
513    _activate(obj);
514 }
515
516 /**
517  * This ends the hoversel popup as though the user clicked outside the hover.
518  *
519  * @param obj The hoversel object
520  *
521  * @ingroup Hoversel
522  */
523 EAPI void
524 elm_hoversel_hover_end(Evas_Object *obj)
525 {
526    ELM_CHECK_WIDTYPE(obj, widtype);
527    Widget_Data *wd = elm_widget_data_get(obj);
528    if (!wd) return;
529    if (!wd->hover) return;
530    wd->expanded = EINA_FALSE;
531    evas_object_del(wd->hover);
532    wd->hover = NULL;
533    evas_object_smart_callback_call(obj, SIG_DISMISSED, NULL);
534 }
535
536 /**
537  * Returns whether the hoversel is expanded.
538  *
539  * @param obj The hoversel object
540  * @return  This will return EINA_TRUE if the hoversel
541  * is expanded or EINA_FALSE if it is not expanded.
542  *
543  * @ingroup Hoversel
544  */
545 EAPI Eina_Bool
546 elm_hoversel_expanded_get(const Evas_Object *obj)
547 {
548    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
549    Widget_Data *wd = elm_widget_data_get(obj);
550    if (!wd) return EINA_FALSE;
551    return (wd->hover) ? EINA_TRUE : EINA_FALSE;
552 }
553
554 /**
555  * This will remove all the children items from the hoversel. (should not be
556  * called while the hoversel is active; use elm_hoversel_expanded_get()
557  * to check first).
558  *
559  * @param obj The hoversel object
560  *
561  * @ingroup Hoversel
562  */
563 EAPI void
564 elm_hoversel_clear(Evas_Object *obj)
565 {
566    Elm_Hoversel_Item *item;
567    Eina_List *l, *ll;
568    ELM_CHECK_WIDTYPE(obj, widtype);
569    Widget_Data *wd = elm_widget_data_get(obj);
570    if (!wd) return;
571    EINA_LIST_FOREACH_SAFE(wd->items, l, ll, item) elm_hoversel_item_del(item);
572 }
573
574 /**
575  * Get the list of items within the given hoversel.
576  *
577  * @param obj The hoversel object
578  * @return Returns a list of Elm_Hoversel_Item*
579  *
580  * @ingroup Hoversel
581  */
582 EAPI const Eina_List *
583 elm_hoversel_items_get(const Evas_Object *obj)
584 {
585    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
586    Widget_Data *wd = elm_widget_data_get(obj);
587    if (!wd) return NULL;
588    return wd->items;
589 }
590
591 /**
592  * Add an item to the hoversel button
593  *
594  * This adds an item to the hoversel to show when it is clicked. Note: if you
595  * need to use an icon from an edje file then use elm_hoversel_item_icon_set()
596  * right after the this function, and set icon_file to NULL here.
597  *
598  * @param obj The hoversel object
599  * @param label The text label to use for the item (NULL if not desired)
600  * @param icon_file An image file path on disk to use for the icon or standard
601  * icon name (NULL if not desired)
602  * @param icon_type The icon type if relevant
603  * @param func Convenience function to call when this item is selected
604  * @param data Data to pass to item-related functions
605  * @return A handle to the item added.
606  *
607  * @ingroup Hoversel
608  */
609 EAPI Elm_Hoversel_Item *
610 elm_hoversel_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
611 {
612    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
613    Widget_Data *wd = elm_widget_data_get(obj);
614    if (!wd) return NULL;
615    Elm_Hoversel_Item *item = elm_widget_item_new(obj, Elm_Hoversel_Item);
616    if (!item) return NULL;
617    wd->items = eina_list_append(wd->items, item);
618    item->label = eina_stringshare_add(label);
619    item->icon_file = eina_stringshare_add(icon_file);
620    item->icon_type = icon_type;
621    item->func = func;
622    item->base.data = data;
623    return item;
624 }
625
626 /**
627  * Delete an item from the hoversel
628  *
629  * This deletes the item from the hoversel (should not be called while the
630  * hoversel is active; use elm_hoversel_expanded_get()
631  * to check first).
632  *
633  * @param item The item to delete
634  *
635  * @ingroup Hoversel
636  */
637 EAPI void
638 elm_hoversel_item_del(Elm_Hoversel_Item *item)
639 {
640    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
641    Widget_Data *wd = elm_widget_data_get(item->base.widget);
642    if (!wd) return;
643    elm_hoversel_hover_end(item->base.widget);
644    wd->items = eina_list_remove(wd->items, item);
645    elm_widget_item_pre_notify_del(item);
646    eina_stringshare_del(item->label);
647    eina_stringshare_del(item->icon_file);
648    eina_stringshare_del(item->icon_group);
649    elm_widget_item_del(item);
650 }
651
652 /**
653  * Set the function called when an item within the hoversel
654  * is freed. That function will receive these parameters:
655  *
656  * void *item_data
657  * Evas_Object *the_item_object
658  * Elm_Hoversel_Item *the_object_struct
659  *
660  * @param item The item to set the callback on
661  * @param func The function called
662  *
663  * @ingroup Hoversel
664  */
665 EAPI void
666 elm_hoversel_item_del_cb_set(Elm_Hoversel_Item *item, Evas_Smart_Cb func)
667 {
668    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
669    elm_widget_item_del_cb_set(item, func);
670 }
671
672 /**
673  * This returns the data pointer supplied with elm_hoversel_item_add() that
674  * will be passed to associated function callbacks.
675  *
676  * @param item The item to get the data from
677  * @return The data pointer set with elm_hoversel_item_add()
678  *
679  * @ingroup Hoversel
680  */
681 EAPI void *
682 elm_hoversel_item_data_get(const Elm_Hoversel_Item *item)
683 {
684    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
685    return elm_widget_item_data_get(item);
686 }
687
688 /**
689  * This returns the label text of the given hoversel item.
690  *
691  * @param item The item to get the label
692  * @return The label text of the hoversel item
693  *
694  * @ingroup Hoversel
695  */
696 EAPI const char *
697 elm_hoversel_item_label_get(const Elm_Hoversel_Item *item)
698 {
699    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
700    return item->label;
701 }
702
703 /**
704  * This sets the icon for the given hoversel item. The icon can be loaded from
705  * the standard set, from an image file, or from an edje file.
706  *
707  * @param item The item to set the icon
708  * @param icon_file An image file path on disk to use for the icon or standard
709  * icon name
710  * @param icon_group The edje group to use if @p icon_file is an edje file. Set this
711  * to NULL if the icon is not an edje file
712  * @param icon_type The icon type
713  *
714  * @ingroup Hoversel
715  */
716 EAPI void
717 elm_hoversel_item_icon_set(Elm_Hoversel_Item *item, const char *icon_file, const char *icon_group, Elm_Icon_Type icon_type)
718 {
719    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
720    eina_stringshare_replace(&item->icon_file, icon_file);
721    eina_stringshare_replace(&item->icon_group, icon_group);
722    item->icon_type = icon_type;
723 }
724
725 /**
726  * Get the icon object of the hoversel item
727  *
728  * @param item The item to get the icon from
729  * @param icon_file The image file path on disk used for the icon or standard
730  * icon name
731  * @param icon_group The edje group used if @p icon_file is an edje file. NULL
732  * if the icon is not an edje file
733  * @param icon_type The icon type
734  *
735  * @ingroup Hoversel
736  */
737 EAPI void
738 elm_hoversel_item_icon_get(const Elm_Hoversel_Item *item, const char **icon_file, const char **icon_group, Elm_Icon_Type *icon_type)
739 {
740    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
741    if (icon_file) *icon_file = item->icon_file;
742    if (icon_group) *icon_group = item->icon_group;
743    if (icon_type) *icon_type = item->icon_type;
744 }
745