summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--elementary/elementary.c_elementary_popup.pxi10
-rw-r--r--include/elementary/c_elementary.pxd4
-rw-r--r--tests/test.py2
-rw-r--r--tests/test_popup.py243
5 files changed, 252 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am
index bb79585..9330beb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -124,6 +124,7 @@ examples_files = \
tests/test_panel.py \
tests/test_panes.py \
tests/test_photo.py \
+ tests/test_popup.py \
tests/test_progressbar.py \
tests/test_radio.py \
tests/test_scroller.py \
diff --git a/elementary/elementary.c_elementary_popup.pxi b/elementary/elementary.c_elementary_popup.pxi
index 51ae8f2..393c370 100644
--- a/elementary/elementary.c_elementary_popup.pxi
+++ b/elementary/elementary.c_elementary_popup.pxi
@@ -40,11 +40,9 @@ cdef class PopupItem(ObjectItem):
raise TypeError("func is not None or callable")
self.params = (func, args, kwargs)
- item = elm_popup_item_append( popup.obj,
- _cfruni(label) if not None else NULL,
- icon.obj if not None else NULL,
- cb if not None else NULL,
- <void *>self)
+ item = elm_popup_item_append(popup.obj, _cfruni(label),
+ icon.obj if icon else NULL,
+ cb, <void *>self)
if item != NULL:
self._set_obj(item)
@@ -146,7 +144,7 @@ cdef public class Popup(Object) [object PyElementaryPopup, type PyElementaryPopu
Object.__init__(self, parent.evas)
self._set_obj(elm_popup_add(parent.obj))
- def item_append(self, label, evasObject icon, func = None, *args, **kwargs):
+ def item_append(self, label = None, evasObject icon = None, func = None, *args, **kwargs):
"""item_append(label, icon, func, *args, **kwargs)
Add a new item to a Popup object
diff --git a/include/elementary/c_elementary.pxd b/include/elementary/c_elementary.pxd
index 3ac916a..1578587 100644
--- a/include/elementary/c_elementary.pxd
+++ b/include/elementary/c_elementary.pxd
@@ -1893,7 +1893,7 @@ cdef extern from "Elementary.h":
void elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
Eina_Bool elm_panes_horizontal_get(Evas_Object *obj)
- # Photo (api:DONE cb:DONE test:TODO doc:DONE py3:DONE)
+ # Photo (api:DONE cb:DONE test:DONE doc:DONE py3:DONE)
Evas_Object *elm_photo_add(Evas_Object *parent)
Eina_Bool elm_photo_file_set(Evas_Object *obj, const_char_ptr file)
void elm_photo_thumb_set(Evas_Object *obj, const_char_ptr file, const_char_ptr group)
@@ -1928,7 +1928,7 @@ cdef extern from "Elementary.h":
Eina_Bool elm_plug_connect(Evas_Object *obj, const_char_ptr svcname, int svcnum, Eina_Bool svcsys)
Evas_Object *elm_plug_image_object_get(Evas_Object *obj)
- # Popup (api:DONE cb:DONE test:TODO doc:DONE py3:DONE)
+ # Popup (api:DONE cb:DONE test:DONE doc:DONE py3:DONE)
Evas_Object *elm_popup_add(Evas_Object *parent)
Elm_Object_Item *elm_popup_item_append(Evas_Object *obj, const_char_ptr label, Evas_Object *icon, Evas_Smart_Cb func, void *data)
void elm_popup_content_text_wrap_type_set(Evas_Object *obj, Elm_Wrap_Type wrap)
diff --git a/tests/test.py b/tests/test.py
index d5c81e6..f365445 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -46,6 +46,7 @@ from test_notify import notify_clicked
from test_panel import panel_clicked
from test_panes import panes_clicked
from test_photo import photo_clicked
+from test_popup import popup_clicked
from test_progressbar import progressbar_clicked
from test_radio import radio_clicked
from test_scroller import scroller_clicked
@@ -131,6 +132,7 @@ items = [("3D", [
("Notify", notify_clicked),
("Tooltip", tooltip_clicked),
("Ctxpopup", ctxpopup_clicked),
+ ("Popup", popup_clicked),
]),
("Range Values", [
("Spinner", spinner_clicked),
diff --git a/tests/test_popup.py b/tests/test_popup.py
new file mode 100644
index 0000000..46f2c26
--- /dev/null
+++ b/tests/test_popup.py
@@ -0,0 +1,243 @@
+ #!/usr/bin/env python
+# encoding: utf-8
+import os
+import elementary
+import edje
+import ecore
+import evas
+
+
+#----- Pupup -{{{-
+def cb_bnt_close(btn, popup):
+ if "im" in popup.data:
+ popup.data["im"].delete()
+ popup.delete()
+
+def cb_btn_restack(btn, popup):
+ im = evas.FilledImage(popup.evas);
+ im.file = "images/mystrale_2.jpg"
+ im.move(40, 40)
+ im.resize(500, 320)
+ im.show()
+
+ popup.data["im"] = im
+ popup.raise_()
+
+def cb_popup_center_text(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.text = "This Popup has content area and timeout value is 3 seconds"
+ popup.timeout = 3.0
+ popup.show()
+
+def cb_popup_center_title_text_1button(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.text = "This Popup has content area and " \
+ "action area set, action area has one button Close"
+ bt = elementary.Button(win)
+ bt.text = "Close"
+ bt.callback_clicked_add(cb_bnt_close, popup)
+ popup.part_content_set("button1", bt)
+ popup.show()
+
+def cb_popup_center_title_text_1button(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.text = "This Popup has title area, content area and " \
+ "action area set, action area has one button Close"
+ popup.part_text_set("title,text", "Title")
+ bt = elementary.Button(win)
+ bt.text = "Close"
+ bt.callback_clicked_add(cb_bnt_close, popup)
+ popup.part_content_set("button1", bt)
+ popup.show()
+
+def cb_popup_center_title_text_block_clicked_event(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.text = "This Popup has title area and content area. " \
+ "When clicked on blocked event region, popup gets deleted"
+ popup.part_text_set("title,text", "Title")
+ popup.callback_block_clicked_add(cb_bnt_close, popup)
+ popup.show()
+
+def cb_popup_bottom_title_text_3button(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.text = "This Popup has title area, content area and " \
+ "action area set with content being character wrapped. " \
+ "action area has three buttons OK, Cancel and Close"
+ popup.content_text_wrap_type = elementary.ELM_WRAP_CHAR
+ popup.part_text_set("title,text", "Title")
+
+ ic = elementary.Icon(win)
+ ic.file = "images/logo_small.png"
+ popup.part_content_set("title,icon", ic)
+
+ bt = elementary.Button(win)
+ bt.text = "OK"
+ popup.part_content_set("button1", bt)
+
+ bt = elementary.Button(win)
+ bt.text = "Cancel"
+ popup.part_content_set("button2", bt)
+
+ bt = elementary.Button(win)
+ bt.text = "Close"
+ bt.callback_clicked_add(cb_bnt_close, popup)
+ popup.part_content_set("button3", bt)
+
+ popup.show()
+
+def cb_popup_center_title_content_3button(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.part_text_set("title,text", "Title")
+
+ ic = elementary.Icon(win)
+ ic.file = "images/logo_small.png"
+ bt = elementary.Button(win)
+ bt.text = "Content"
+ bt.content = ic
+ popup.content = bt
+
+ bt = elementary.Button(win)
+ bt.text = "OK"
+ popup.part_content_set("button1", bt)
+
+ bt = elementary.Button(win)
+ bt.text = "Cancel"
+ popup.part_content_set("button2", bt)
+
+ bt = elementary.Button(win)
+ bt.text = "Close"
+ bt.callback_clicked_add(cb_bnt_close, popup)
+ popup.part_content_set("button3", bt)
+
+ popup.show()
+
+def cb_popup_center_title_item_3button(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.part_text_set("title,text", "Title")
+
+ for i in range(1, 11):
+ if i in [3, 5, 6]:
+ ic = elementary.Icon(win)
+ ic.file = "images/logo_small.png"
+ popup.item_append("item"+str(i), ic)
+ else:
+ popup.item_append("item"+str(i))
+
+ bt = elementary.Button(win)
+ bt.text = "OK"
+ popup.part_content_set("button1", bt)
+
+ bt = elementary.Button(win)
+ bt.text = "Cancel"
+ popup.part_content_set("button2", bt)
+
+ bt = elementary.Button(win)
+ bt.text = "Close"
+ bt.callback_clicked_add(cb_bnt_close, popup)
+ popup.part_content_set("button3", bt)
+
+ popup.show()
+
+def cb_popup_center_title_text_2button_restack(li, item, win):
+ popup = elementary.Popup(win)
+ popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ popup.text = "When you click the 'Restack' button, " \
+ "an image will be located under this popup"
+ popup.part_text_set("title,text", "Title")
+
+ bt = elementary.Button(win)
+ bt.text = "Restack"
+ bt.callback_clicked_add(cb_btn_restack, popup)
+ popup.part_content_set("button1", bt)
+
+ bt = elementary.Button(win)
+ bt.text = "Close"
+ bt.callback_clicked_add(cb_bnt_close, popup)
+ popup.part_content_set("button3", bt)
+
+ popup.show()
+
+times = 0
+g_popup = None
+def cb_popup_center_text_1button_hide_show(li, item, win):
+ global times
+ global g_popup
+
+ times += 1
+
+ if g_popup is not None:
+ g_popup.text = "You have checked this popup %d times." % times
+ g_popup.show()
+ return
+
+ g_popup = elementary.Popup(win)
+ g_popup.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ g_popup.text = "Hide this popup by using the button." \
+ "When you click list item again, you will see this popup again."
+
+ bt = elementary.Button(win)
+ bt.text = "Hide"
+ bt.callback_clicked_add(lambda b: g_popup.hide())
+ g_popup.part_content_set("button1", bt)
+
+ g_popup.show()
+
+
+def popup_clicked(obj):
+ win = elementary.Window("popup", elementary.ELM_WIN_BASIC)
+ win.title_set("Popup test")
+ win.autodel_set(True)
+
+ bg = elementary.Background(win)
+ win.resize_object_add(bg)
+ bg.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bg.show()
+
+ li = elementary.List(win)
+ li.mode = elementary.ELM_LIST_LIMIT
+ li.size_hint_weight = (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ li.callback_selected_add(lambda li, it: it.selected_set(False))
+ win.resize_object_add(li)
+ li.show()
+
+ li.item_append("popup-center-text", None, None,
+ cb_popup_center_text, win)
+ li.item_append("popup-center-text + 1 button", None, None,
+ cb_popup_center_title_text_1button, win)
+ li.item_append("popup-center-title + text + 1 button", None, None,
+ cb_popup_center_title_text_1button, win)
+ li.item_append("popup-center-title + text (block,clicked handling)", None, None,
+ cb_popup_center_title_text_block_clicked_event, win)
+ li.item_append("popup-bottom-title + text + 3 buttons", None, None,
+ cb_popup_bottom_title_text_3button, win)
+ li.item_append("popup-center-title + content + 3 buttons", None, None,
+ cb_popup_center_title_content_3button, win)
+ li.item_append("popup-center-title + items + 3 buttons", None, None,
+ cb_popup_center_title_item_3button, win)
+ li.item_append("popup-center-title + text + 2 buttons (check restacking)", None, None,
+ cb_popup_center_title_text_2button_restack, win)
+ li.item_append("popup-center-text + 1 button (check hide, show)", None, None,
+ cb_popup_center_text_1button_hide_show, win)
+
+ li.go()
+ win.resize(480, 800)
+ win.show()
+# }}}
+
+#----- Main -{{{-
+if __name__ == "__main__":
+ elementary.init()
+
+ popup_clicked(None)
+
+ elementary.run()
+ elementary.shutdown()
+# }}}
+# vim:foldmethod=marker