summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-07-22 17:24:06 +0200
committerDave Andreoli <dave@gurumeditation.it>2017-07-22 17:24:06 +0200
commit5bbaba2a6ebad92aa2309ca546d774977201527f (patch)
tree06acb922529e4308236e5fbd7c3763e30d6aac67
parent74ed9e86a48a3375c316c359e4305500890cb206 (diff)
New 1.20 API: elm.Genlist.multi_select_mode
with test
-rw-r--r--efl/elementary/genlist_cdef.pxi2
-rw-r--r--efl/elementary/genlist_widget.pxi20
-rwxr-xr-xexamples/elementary/test.py1
-rw-r--r--examples/elementary/test_genlist_multiselect.py81
4 files changed, 104 insertions, 0 deletions
diff --git a/efl/elementary/genlist_cdef.pxi b/efl/elementary/genlist_cdef.pxi
index 17190ce..c4da09b 100644
--- a/efl/elementary/genlist_cdef.pxi
+++ b/efl/elementary/genlist_cdef.pxi
@@ -28,6 +28,8 @@ cdef extern from "Elementary.h":
28 void elm_genlist_clear(Evas_Object *obj) 28 void elm_genlist_clear(Evas_Object *obj)
29 void elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi) 29 void elm_genlist_multi_select_set(Evas_Object *obj, Eina_Bool multi)
30 Eina_Bool elm_genlist_multi_select_get(const Evas_Object *obj) 30 Eina_Bool elm_genlist_multi_select_get(const Evas_Object *obj)
31 void elm_genlist_multi_select_mode_set(Evas_Object *obj, Elm_Object_Multi_Select_Mode mode)
32 Elm_Object_Multi_Select_Mode elm_genlist_multi_select_mode_get(const Evas_Object *obj)
31 void elm_genlist_mode_set(Evas_Object *obj, Elm_List_Mode mode) 33 void elm_genlist_mode_set(Evas_Object *obj, Elm_List_Mode mode)
32 Elm_List_Mode elm_genlist_mode_get(const Evas_Object *obj) 34 Elm_List_Mode elm_genlist_mode_get(const Evas_Object *obj)
33 Elm_Object_Item * elm_genlist_item_append(Evas_Object *obj, Elm_Genlist_Item_Class *itc, void *data, Elm_Object_Item *parent, Elm_Genlist_Item_Type flags, Evas_Smart_Cb func, void *func_data) 35 Elm_Object_Item * elm_genlist_item_append(Evas_Object *obj, Elm_Genlist_Item_Class *itc, void *data, Elm_Object_Item *parent, Elm_Genlist_Item_Type flags, Evas_Smart_Cb func, void *func_data)
diff --git a/efl/elementary/genlist_widget.pxi b/efl/elementary/genlist_widget.pxi
index 49a9fb7..3c89d14 100644
--- a/efl/elementary/genlist_widget.pxi
+++ b/efl/elementary/genlist_widget.pxi
@@ -64,6 +64,26 @@ cdef class Genlist(Object):
64 def multi_select_get(self): 64 def multi_select_get(self):
65 return bool(elm_genlist_multi_select_get(self.obj)) 65 return bool(elm_genlist_multi_select_get(self.obj))
66 66
67 property multi_select_mode:
68 """The genlist multi select mode.
69
70 Whenever the user need to pres Ctrl to perform multiselect or not.
71
72 :type: :ref:`Elm_Object_Multi_Select_Mode`
73
74 .. versionadded:: 1.20
75
76 """
77 def __set__(self, mode):
78 elm_genlist_multi_select_mode_set(self.obj, mode)
79 def __get__(self):
80 return elm_genlist_multi_select_mode_get(self.obj)
81
82 def multi_select_mode_set(self, mode):
83 elm_genlist_multi_select_mode_set(self.obj, mode)
84 def multi_select_mode_get(self):
85 return elm_genlist_multi_select_mode_get(self.obj)
86
67 property mode: 87 property mode:
68 """The mode used for sizing items horizontally. 88 """The mode used for sizing items horizontally.
69 89
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index bf87b9b..3c01007 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -174,6 +174,7 @@ items = [
174 ("Lists - Genlist", [ 174 ("Lists - Genlist", [
175 ("Genlist 1", "test_genlist_1", "test_genlist_1"), 175 ("Genlist 1", "test_genlist_1", "test_genlist_1"),
176 ("Genlist 2", "test_genlist_2", "test_genlist_2"), 176 ("Genlist 2", "test_genlist_2", "test_genlist_2"),
177 ("Genlist Multi Select", "test_genlist_multiselect", "test_genlist_multiselect"),
177 ("Genlist Tree", "test_genlist_tree", "test_genlist_tree"), 178 ("Genlist Tree", "test_genlist_tree", "test_genlist_tree"),
178 ("Genlist Group", "test_genlist_group", "test_genlist_group"), 179 ("Genlist Group", "test_genlist_group", "test_genlist_group"),
179 ("Genlist Filter", "test_genlist_filter", "test_genlist_filter"), 180 ("Genlist Filter", "test_genlist_filter", "test_genlist_filter"),
diff --git a/examples/elementary/test_genlist_multiselect.py b/examples/elementary/test_genlist_multiselect.py
new file mode 100644
index 0000000..457d937
--- /dev/null
+++ b/examples/elementary/test_genlist_multiselect.py
@@ -0,0 +1,81 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4import os
5
6from efl.evas import EXPAND_BOTH, FILL_BOTH, EXPAND_HORIZ, FILL_HORIZ
7from efl import elementary as elm
8
9
10script_path = os.path.dirname(os.path.abspath(__file__))
11img_path = os.path.join(script_path, "images")
12
13
14class MyItemClass(elm.GenlistItemClass):
15 def __init__(self):
16 elm.GenlistItemClass.__init__(self, item_style="tree_effect")
17
18 def text_get(self, obj, part, item_data):
19 return "Item # %i" % item_data
20
21 def content_get(self, obj, part, item_data):
22 icon = "logo_small.png" if part == "elm.swallow.icon" else "bubble.png"
23 return elm.Icon(obj, file=os.path.join(img_path, icon))
24
25itc = MyItemClass()
26
27
28def test_genlist_multiselect(parent):
29 win = elm.StandardWindow("Genlist", "Genlist Multi Select",
30 size=(320, 500), autodel=True)
31
32 # vertical box + options frame
33 box = elm.Box(win, size_hint_expand=EXPAND_BOTH)
34 win.resize_object_add(box)
35 box.show()
36
37 fr = elm.Frame(win, text='Multi Select Options',
38 size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
39 box.pack_end(fr)
40 fr.show()
41
42 hbox = elm.Box(win, horizontal=True, homogeneous=False,
43 size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
44 fr.content = hbox
45 hbox.show()
46
47 # Genlist
48 gl = elm.Genlist(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
49 box.pack_end(gl)
50 gl.show()
51
52 for i in range(100):
53 gl.item_append(itc, i)
54
55 # Options
56 ck = elm.Check(win, style="toggle", text="Multi Select Enable")
57 ck.callback_changed_add(lambda o: setattr(gl, "multi_select", o.state))
58 hbox.pack_end(ck)
59 ck.show()
60
61 rdg = rd = elm.Radio(win, text="Default mode", state_value=0)
62 rd.callback_changed_add(lambda o: setattr(gl, "multi_select_mode",
63 elm.ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT))
64 hbox.pack_end(rd)
65 rd.show()
66
67 rd = elm.Radio(win, text="With Control mode", state_value=1)
68 rd.callback_changed_add(lambda o: setattr(gl, "multi_select_mode",
69 elm.ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL))
70 rdg.group_add(rd)
71 hbox.pack_end(rd)
72 rd.show()
73
74 # show the window
75 win.show()
76
77
78if __name__ == "__main__":
79 elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
80 test_genlist_multiselect(None)
81 elm.run()