kuuko pushed a commit to branch master.
commit 531b4ea3ac0f3fd4f2c695cdfd52a84dbdbb5bca
Author: Kai Huuhko <[email protected]>
Date: Mon Apr 15 12:43:36 2013 +0000
Elementary: Fix Toolbar menu_get and make the example/test more pythonic.
---
efl/elementary/toolbar.pyx | 8 +----
examples/elementary/test_toolbar.py | 70 +++++++++++++++++--------------------
2 files changed, 34 insertions(+), 44 deletions(-)
diff --git a/efl/elementary/toolbar.pyx b/efl/elementary/toolbar.pyx
index 6c05cbe..d601ad2 100644
--- a/efl/elementary/toolbar.pyx
+++ b/efl/elementary/toolbar.pyx
@@ -472,13 +472,7 @@ cdef class ToolbarItem(ObjectItem):
cpdef menu_set(self, menu):
elm_toolbar_item_menu_set(self.item, menu)
cpdef menu_get(self):
- # TODO: Improve this
- cdef Evas_Object *menu
- menu = elm_toolbar_item_menu_get(self.item)
- if menu == NULL:
- return None
- else:
- return Menu(None, <object>menu)
+ return object_from_instance(elm_toolbar_item_menu_get(self.item))
#TODO def state_add(self, icon, label, func, data):
diff --git a/examples/elementary/test_toolbar.py
b/examples/elementary/test_toolbar.py
index de318a6..1236d2b 100644
--- a/examples/elementary/test_toolbar.py
+++ b/examples/elementary/test_toolbar.py
@@ -12,41 +12,41 @@ from efl.elementary.toolbar import Toolbar
def tb_1(obj, it, ph):
- ph.file_set("images/panel_01.jpg")
+ ph.file = "images/panel_01.jpg"
def tb_2(obj, it, ph):
- ph.file_set("images/rock_01.jpg")
+ ph.file = "images/rock_01.jpg"
def tb_3(obj, it, ph):
- ph.file_set("images/wood_01.jpg")
+ ph.file = "images/wood_01.jpg"
def tb_4(obj, it, ph):
- ph.file_set("images/sky_03.jpg")
+ ph.file = "images/sky_03.jpg"
def tb_5(obj, it, ph):
- ph.file_set(None)
+ ph.file = None
def toolbar_clicked(obj):
win = Window("toolbar", elementary.ELM_WIN_BASIC)
- win.title_set("Toolbar")
- win.autodel_set(True)
+ win.title = "Toolbar"
+ win.autodel = True
if obj is None:
win.callback_delete_request_add(lambda o: elementary.exit())
bg = Background(win)
win.resize_object_add(bg)
- bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bg.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
bg.show()
bx = Box(win)
win.resize_object_add(bx)
- bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
+ bx.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
bx.show()
tb = Toolbar(win)
tb.homogeneous = False
- tb.size_hint_weight_set(0.0, 0.0)
- tb.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0)
+ tb.size_hint_weight = 0.0, 0.0
+ tb.size_hint_align = evas.EVAS_HINT_FILL, 0.0
ph1 = Photo(win)
ph2 = Photo(win)
@@ -57,58 +57,54 @@ def toolbar_clicked(obj):
item.disabled = True
item = tb.item_append("clock", "World,", tb_2, ph2)
- item.selected_set(True)
+ item.selected = True
tb.item_append("folder-new", "here", tb_3, ph4)
-
tb.item_append("clock", "comes", tb_4, ph4)
-
tb.item_append("folder-new", "python-elementary!", tb_5, ph4)
item = tb.item_append("clock", "Menu", tb_5, ph4)
- item.menu_set(True)
- tb.menu_parent_set(win)
- menu = item.menu_get()
+ item.menu = True
+ tb.menu_parent = win
- menu.item_add(None, "Here", "clock", tb_3, ph4)
+ menu = item.menu
+ menu.item_add(None, "Here", "clock", tb_3, ph4)
menu_item = menu.item_add(None, "Comes", "refresh", tb_4, ph4)
-
menu.item_add(menu_item, "hey ho", "folder-new", tb_4, ph4)
-
menu.item_add(None, "python-elementary", "document-print", tb_5, ph4)
bx.pack_end(tb)
tb.show()
tb = Table(win)
- tb.size_hint_weight_set(0.0, evas.EVAS_HINT_EXPAND)
- tb.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
+ tb.size_hint_weight = 0.0, evas.EVAS_HINT_EXPAND
+ tb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
- ph1.size_set(40)
- ph1.file_set("images/plant_01.jpg")
- ph1.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- ph1.size_hint_align_set(0.5, 0.5)
+ ph1.size = 40
+ ph1.file = "images/plant_01.jpg"
+ ph1.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
+ ph1.size_hint_align = 0.5, 0.5
tb.pack(ph1, 0, 0, 1, 1)
ph1.show()
- ph2.size_set(80)
- ph2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- ph2.size_hint_align_set(0.5, 0.5)
+ ph2.size = 80
+ ph2.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
+ ph2.size_hint_align = 0.5, 0.5
tb.pack(ph2, 1, 0, 1, 1)
ph2.show()
- ph3.size_set(40)
- ph3.file_set("images/sky_01.jpg")
- ph3.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- ph3.size_hint_align_set(0.5, 0.5)
+ ph3.size = 40
+ ph3.file = "images/sky_01.jpg"
+ ph3.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
+ ph3.size_hint_align = 0.5, 0.5
tb.pack(ph3, 0, 1, 1, 1)
ph3.show()
- ph4.size_set(60)
- ph4.file_set("images/sky_02.jpg")
- ph4.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND)
- ph4.size_hint_align_set(0.5, 0.5)
+ ph4.size = 60
+ ph4.file = "images/sky_02.jpg"
+ ph4.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
+ ph4.size_hint_align = 0.5, 0.5
tb.pack(ph4, 1, 1, 1, 1)
ph4.show()
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter