aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--efl/elementary/ctxpopup.pxi81
-rw-r--r--efl/elementary/ctxpopup_cdef.pxi2
-rw-r--r--examples/elementary/test_ctxpopup.py12
3 files changed, 92 insertions, 3 deletions
diff --git a/efl/elementary/ctxpopup.pxi b/efl/elementary/ctxpopup.pxi
index 30d1495..1de93f7 100644
--- a/efl/elementary/ctxpopup.pxi
+++ b/efl/elementary/ctxpopup.pxi
@@ -142,6 +142,7 @@ cdef class CtxpopupItem(ObjectItem):
def __get__(self):
return _object_item_to_python(elm_ctxpopup_item_next_get(self.item))
+
cdef class Ctxpopup(LayoutClass):
"""
@@ -234,6 +235,86 @@ cdef class Ctxpopup(LayoutClass):
else:
return None
+ def item_insert_before(self, CtxpopupItem before, label, evasObject icon=None,
+ func=None, *args, **kwargs):
+ """Add a new item to the list before the indicated item
+
+ :param CtxpopupItem before: The item before which to add it
+ :param string label: The label of new item
+ :param evasObject icon: The icon of new item
+ :param func: The callback function to be invoked when this item is selected.
+ :param \*args: The data to be attached for callback
+ :param \*\*kwargs: The data to be attached for callback
+ :return: :class:`CtxpopupItem`
+
+ .. versionadded:: 1.21
+
+ """
+ cdef:
+ Elm_Object_Item *item
+ Evas_Smart_Cb cb = NULL
+ CtxpopupItem ret = CtxpopupItem.__new__(CtxpopupItem)
+
+ if func is not None and callable(func):
+ cb = _object_item_callback
+
+ if isinstance(label, unicode): label = PyUnicode_AsUTF8String(label)
+
+ item = elm_ctxpopup_item_insert_before(self.obj,
+ before.item if before is not None else NULL,
+ <const char *>label if label is not None else NULL,
+ icon.obj if icon is not None else NULL,
+ cb, <void*>ret)
+
+ if item != NULL:
+ ret._set_obj(item)
+ ret.cb_func = func
+ ret.args = args
+ ret.kwargs = kwargs
+ return ret
+ else:
+ return None
+
+ def item_insert_after(self, CtxpopupItem after, label, evasObject icon=None,
+ func=None, *args, **kwargs):
+ """Add a new item to the list after the indicated item
+
+ :param CtxpopupItem after: The item after which to add it
+ :param string label: The label of new item
+ :param evasObject icon: The icon of new item
+ :param func: The callback function to be invoked when this item is selected.
+ :param \*args: The data to be attached for callback
+ :param \*\*kwargs: The data to be attached for callback
+ :return: :class:`CtxpopupItem`
+
+ .. versionadded:: 1.21
+
+ """
+ cdef:
+ Elm_Object_Item *item
+ Evas_Smart_Cb cb = NULL
+ CtxpopupItem ret = CtxpopupItem.__new__(CtxpopupItem)
+
+ if func is not None and callable(func):
+ cb = _object_item_callback
+
+ if isinstance(label, unicode): label = PyUnicode_AsUTF8String(label)
+
+ item = elm_ctxpopup_item_insert_after(self.obj,
+ after.item if after is not None else NULL,
+ <const char *>label if label is not None else NULL,
+ icon.obj if icon is not None else NULL,
+ cb, <void*>ret)
+
+ if item != NULL:
+ ret._set_obj(item)
+ ret.cb_func = func
+ ret.args = args
+ ret.kwargs = kwargs
+ return ret
+ else:
+ return None
+
def item_prepend(self, label, evasObject icon=None,
func=None, *args, **kwargs):
"""A constructor for a :py:class:`CtxpopupItem`.
diff --git a/efl/elementary/ctxpopup_cdef.pxi b/efl/elementary/ctxpopup_cdef.pxi
index bf8916e..65a2f51 100644
--- a/efl/elementary/ctxpopup_cdef.pxi
+++ b/efl/elementary/ctxpopup_cdef.pxi
@@ -20,3 +20,5 @@ cdef extern from "Elementary.h":
Elm_Object_Item *elm_ctxpopup_last_item_get(const Evas_Object *obj)
Elm_Object_Item *elm_ctxpopup_item_prev_get(const Elm_Object_Item *it)
Elm_Object_Item *elm_ctxpopup_item_next_get(const Elm_Object_Item *it)
+ Elm_Object_Item *elm_ctxpopup_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
+ Elm_Object_Item *elm_ctxpopup_item_insert_after(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
diff --git a/examples/elementary/test_ctxpopup.py b/examples/elementary/test_ctxpopup.py
index cb00e53..b6aa8d2 100644
--- a/examples/elementary/test_ctxpopup.py
+++ b/examples/elementary/test_ctxpopup.py
@@ -58,12 +58,18 @@ def cb_item1(li, item):
it = item_new(cp, "Delete file", "user-trash")
it = item_new(cp, "Navigate to folder", "folder")
it.disabled = True
- it = item_new(cp, "Edit entry", "list-add")
+ it = item_new(cp, "Edit entry", "document-edit")
it = item_new(cp, "Sate date and time", "list-remove")
it.disabled = True
- ic = Icon(cp, standard="user-home", resizable=(False,False))
- cp.item_prepend("Prepended item", ic, cb_items)
+ ic = Icon(cp, standard="list-add", resizable=(False,False))
+ it2 = cp.item_prepend("Prepended item", ic, cb_items)
+
+ ic = Icon(cp, standard="list-add", resizable=(False,False))
+ cp.item_insert_before(it2, "Before the Prepended", ic)
+
+ ic = Icon(cp, standard="list-add", resizable=(False,False))
+ cp.item_insert_after(it2, "After the Prepended", ic)
(x, y) = li.evas.pointer_canvas_xy_get()
cp.move(x, y)