summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-07-16 20:00:50 +0200
committerDave Andreoli <dave@gurumeditation.it>2018-07-16 20:00:50 +0200
commit18ca98e66f9e9bec7a0048d44310f016ab2ee76c (patch)
tree8ec38b2d178352ead2d9536d722fb7abc4571b2e
parent006052543f3863fb0e4975476d0bc03e06099279 (diff)
New 1.21 API: Ctxpopup item_insert_before/after
with test
-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):
142 def __get__(self): 142 def __get__(self):
143 return _object_item_to_python(elm_ctxpopup_item_next_get(self.item)) 143 return _object_item_to_python(elm_ctxpopup_item_next_get(self.item))
144 144
145
145cdef class Ctxpopup(LayoutClass): 146cdef class Ctxpopup(LayoutClass):
146 147
147 """ 148 """
@@ -234,6 +235,86 @@ cdef class Ctxpopup(LayoutClass):
234 else: 235 else:
235 return None 236 return None
236 237
238 def item_insert_before(self, CtxpopupItem before, label, evasObject icon=None,
239 func=None, *args, **kwargs):
240 """Add a new item to the list before the indicated item
241
242 :param CtxpopupItem before: The item before which to add it
243 :param string label: The label of new item
244 :param evasObject icon: The icon of new item
245 :param func: The callback function to be invoked when this item is selected.
246 :param \*args: The data to be attached for callback
247 :param \*\*kwargs: The data to be attached for callback
248 :return: :class:`CtxpopupItem`
249
250 .. versionadded:: 1.21
251
252 """
253 cdef:
254 Elm_Object_Item *item
255 Evas_Smart_Cb cb = NULL
256 CtxpopupItem ret = CtxpopupItem.__new__(CtxpopupItem)
257
258 if func is not None and callable(func):
259 cb = _object_item_callback
260
261 if isinstance(label, unicode): label = PyUnicode_AsUTF8String(label)
262
263 item = elm_ctxpopup_item_insert_before(self.obj,
264 before.item if before is not None else NULL,
265 <const char *>label if label is not None else NULL,
266 icon.obj if icon is not None else NULL,
267 cb, <void*>ret)
268
269 if item != NULL:
270 ret._set_obj(item)
271 ret.cb_func = func
272 ret.args = args
273 ret.kwargs = kwargs
274 return ret
275 else:
276 return None
277
278 def item_insert_after(self, CtxpopupItem after, label, evasObject icon=None,
279 func=None, *args, **kwargs):
280 """Add a new item to the list after the indicated item
281
282 :param CtxpopupItem after: The item after which to add it
283 :param string label: The label of new item
284 :param evasObject icon: The icon of new item
285 :param func: The callback function to be invoked when this item is selected.
286 :param \*args: The data to be attached for callback
287 :param \*\*kwargs: The data to be attached for callback
288 :return: :class:`CtxpopupItem`
289
290 .. versionadded:: 1.21
291
292 """
293 cdef:
294 Elm_Object_Item *item
295 Evas_Smart_Cb cb = NULL
296 CtxpopupItem ret = CtxpopupItem.__new__(CtxpopupItem)
297
298 if func is not None and callable(func):
299 cb = _object_item_callback
300
301 if isinstance(label, unicode): label = PyUnicode_AsUTF8String(label)
302
303 item = elm_ctxpopup_item_insert_after(self.obj,
304 after.item if after is not None else NULL,
305 <const char *>label if label is not None else NULL,
306 icon.obj if icon is not None else NULL,
307 cb, <void*>ret)
308
309 if item != NULL:
310 ret._set_obj(item)
311 ret.cb_func = func
312 ret.args = args
313 ret.kwargs = kwargs
314 return ret
315 else:
316 return None
317
237 def item_prepend(self, label, evasObject icon=None, 318 def item_prepend(self, label, evasObject icon=None,
238 func=None, *args, **kwargs): 319 func=None, *args, **kwargs):
239 """A constructor for a :py:class:`CtxpopupItem`. 320 """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":
20 Elm_Object_Item *elm_ctxpopup_last_item_get(const Evas_Object *obj) 20 Elm_Object_Item *elm_ctxpopup_last_item_get(const Evas_Object *obj)
21 Elm_Object_Item *elm_ctxpopup_item_prev_get(const Elm_Object_Item *it) 21 Elm_Object_Item *elm_ctxpopup_item_prev_get(const Elm_Object_Item *it)
22 Elm_Object_Item *elm_ctxpopup_item_next_get(const Elm_Object_Item *it) 22 Elm_Object_Item *elm_ctxpopup_item_next_get(const Elm_Object_Item *it)
23 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)
24 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):
58 it = item_new(cp, "Delete file", "user-trash") 58 it = item_new(cp, "Delete file", "user-trash")
59 it = item_new(cp, "Navigate to folder", "folder") 59 it = item_new(cp, "Navigate to folder", "folder")
60 it.disabled = True 60 it.disabled = True
61 it = item_new(cp, "Edit entry", "list-add") 61 it = item_new(cp, "Edit entry", "document-edit")
62 it = item_new(cp, "Sate date and time", "list-remove") 62 it = item_new(cp, "Sate date and time", "list-remove")
63 it.disabled = True 63 it.disabled = True
64 64
65 ic = Icon(cp, standard="user-home", resizable=(False,False)) 65 ic = Icon(cp, standard="list-add", resizable=(False,False))
66 cp.item_prepend("Prepended item", ic, cb_items) 66 it2 = cp.item_prepend("Prepended item", ic, cb_items)
67
68 ic = Icon(cp, standard="list-add", resizable=(False,False))
69 cp.item_insert_before(it2, "Before the Prepended", ic)
70
71 ic = Icon(cp, standard="list-add", resizable=(False,False))
72 cp.item_insert_after(it2, "After the Prepended", ic)
67 73
68 (x, y) = li.evas.pointer_canvas_xy_get() 74 (x, y) = li.evas.pointer_canvas_xy_get()
69 cp.move(x, y) 75 cp.move(x, y)