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