{
Evas_Object *ctxpopup;
Evas_Coord x,y;
+ Elm_Object_Item *item;
if (list_mouse_down > 0) return;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
evas_object_smart_callback_add(ctxpopup, "geometry,update", _geometry_update, NULL);
- elm_ctxpopup_item_append(ctxpopup, "Disable this item", NULL, _ctxpopup_item_disable_cb, ctxpopup);
- elm_ctxpopup_item_append(ctxpopup, "Delete this ctxpopup", NULL, _ctxpopup_item_delete_cb, ctxpopup);
- elm_ctxpopup_item_append(ctxpopup, "Another item", NULL, _ctxpopup_item_cb, NULL);
+ item = elm_ctxpopup_item_prepend(ctxpopup, "Disable this item", NULL, _ctxpopup_item_disable_cb, ctxpopup);
+ elm_ctxpopup_item_insert_before(ctxpopup, item, "Delete this ctxpopup", NULL, _ctxpopup_item_delete_cb, ctxpopup);
+ elm_ctxpopup_item_insert_after(ctxpopup, item, "Another item", NULL, _ctxpopup_item_cb, NULL);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
}
EOLIAN static Elm_Object_Item*
+_elm_ctxpopup_item_insert_before(Eo *obj, Elm_Ctxpopup_Data *sd, Elm_Object_Item *eo_before, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
+{
+ Eo *eo_item;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(eo_before, NULL);
+ ELM_CTXPOPUP_ITEM_DATA_GET(eo_before, before_it);
+ ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(before_it, NULL);
+
+ if (!before_it->list_item) return NULL;
+
+ eo_item = efl_add(ELM_CTXPOPUP_ITEM_CLASS, obj, elm_obj_ctxpopup_item_init(efl_added, func, data));
+ if (!eo_item) return NULL;
+
+ ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
+
+ item->list_item =
+ elm_list_item_insert_before(sd->list, before_it->list_item, label, icon, NULL, _item_wrap_cb, item);
+ efl_ref(item->list_item);
+ sd->items = eina_list_prepend_relative(sd->items, eo_item, eo_before);
+
+ if (sd->visible) elm_layout_sizing_eval(obj);
+
+ return eo_item;
+}
+
+EOLIAN static Elm_Object_Item*
+_elm_ctxpopup_item_insert_after(Eo *obj, Elm_Ctxpopup_Data *sd, Elm_Object_Item *eo_after, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
+{
+ Eo *eo_item;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(eo_after, NULL);
+ ELM_CTXPOPUP_ITEM_DATA_GET(eo_after, after_it);
+ ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(after_it, NULL);
+
+ if (!after_it->list_item) return NULL;
+
+ eo_item = efl_add(ELM_CTXPOPUP_ITEM_CLASS, obj, elm_obj_ctxpopup_item_init(efl_added, func, data));
+ if (!eo_item) return NULL;
+
+ ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
+
+ item->list_item =
+ elm_list_item_insert_after(sd->list, after_it->list_item, label, icon, NULL, _item_wrap_cb, item);
+ efl_ref(item->list_item);
+ sd->items = eina_list_append_relative(sd->items, eo_item, eo_after);
+
+ if (sd->visible) elm_layout_sizing_eval(obj);
+
+ return eo_item;
+}
+
+EOLIAN static Elm_Object_Item*
_elm_ctxpopup_item_append(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
{
Eo *eo_item;
clear {
[[Clear all items in the given ctxpopup object.]]
}
+ item_insert_before {
+ [[Insert a new item to a ctxpopup object before item $before.
+
+ See also elm_object_content_set.
+
+ @since 1.21
+ ]]
+ return: Elm.Widget.Item; [[A handle to the item added or $null, on errors.]]
+
+ params {
+ @in before: Elm.Widget.Item; [[The ctxpopup item to insert before.]]
+ @in label: string; [[The Label of the new item]]
+ @in icon: Efl.Canvas.Object @optional; [[Icon to be set on new item]]
+ @in func: Evas_Smart_Cb @optional; [[Convenience function called when item selected]]
+ @in data: const(void_ptr) @optional; [[Data passed to $func]]
+ }
+ }
+ item_insert_after {
+ [[Insert a new item to a ctxpopup object after item $after.
+
+ See also elm_object_content_set.
+
+ @since 1.21
+ ]]
+ return: Elm.Widget.Item; [[A handle to the item added or $null, on errors.]]
+
+ params {
+ @in after: Elm.Widget.Item; [[The ctxpopup item to insert after.]]
+ @in label: string; [[The Label of the new item]]
+ @in icon: Efl.Canvas.Object @optional; [[Icon to be set on new item]]
+ @in func: Evas_Smart_Cb @optional; [[Convenience function called when item selected]]
+ @in data: const(void_ptr) @optional; [[Data passed to $func]]
+ }
+ }
item_append {
[[Add a new item to a ctxpopup object.
-
Warning:Ctxpopup can't hold both an item list and a content at the same
time. When an item is added, any previous content will be removed.