summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-02-27 20:52:10 +0100
committerdavemds <dave@gurumeditation.it>2014-02-27 20:52:10 +0100
commitc2a34f20ad2ba457b768b66d2730617a1e0d7279 (patch)
treec866fc2fc17334055245300b4b0c9e9148dea177
parent1bfb4d8922201821e5054e073e544ab6603cd046 (diff)
Python-EFL: Colorselector new 1.9 API
Diffstat (limited to '')
-rw-r--r--efl/elementary/colorselector.pxd7
-rw-r--r--efl/elementary/colorselector.pyx44
-rw-r--r--examples/elementary/test_colorselector.py26
3 files changed, 66 insertions, 11 deletions
diff --git a/efl/elementary/colorselector.pxd b/efl/elementary/colorselector.pxd
index c0f814a..8f6b018 100644
--- a/efl/elementary/colorselector.pxd
+++ b/efl/elementary/colorselector.pxd
@@ -1,5 +1,5 @@
1from efl.evas cimport Evas_Object, const_Evas_Object, const_Eina_List 1from efl.evas cimport Evas_Object, const_Evas_Object, const_Eina_List, Eina_Bool
2from object_item cimport Elm_Object_Item 2from object_item cimport Elm_Object_Item, const_Elm_Object_Item
3from enums cimport Elm_Colorselector_Mode 3from enums cimport Elm_Colorselector_Mode
4from libc.string cimport const_char 4from libc.string cimport const_char
5 5
@@ -16,3 +16,6 @@ cdef extern from "Elementary.h":
16 void elm_colorselector_palette_name_set(Evas_Object *obj, const_char *palette_name) 16 void elm_colorselector_palette_name_set(Evas_Object *obj, const_char *palette_name)
17 const_char * elm_colorselector_palette_name_get(Evas_Object *obj) 17 const_char * elm_colorselector_palette_name_get(Evas_Object *obj)
18 const_Eina_List * elm_colorselector_palette_items_get(const_Evas_Object *obj) 18 const_Eina_List * elm_colorselector_palette_items_get(const_Evas_Object *obj)
19 Eina_Bool elm_colorselector_palette_item_selected_get(const_Elm_Object_Item *it)
20 void elm_colorselector_palette_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
21 Elm_Object_Item * elm_colorselector_palette_selected_item_get(const_Evas_Object *obj)
diff --git a/efl/elementary/colorselector.pyx b/efl/elementary/colorselector.pyx
index 1d25540..f75817b 100644
--- a/efl/elementary/colorselector.pyx
+++ b/efl/elementary/colorselector.pyx
@@ -131,6 +131,26 @@ cdef class ColorselectorPaletteItem(ObjectItem):
131 def color_set(self, r, g, b, a): 131 def color_set(self, r, g, b, a):
132 elm_colorselector_palette_item_color_set(self.item, r, g, b, a) 132 elm_colorselector_palette_item_color_set(self.item, r, g, b, a)
133 133
134 property selected:
135 """Whenever the palette item is selected or not.
136
137 :type: bool
138
139 .. versionadded:: 1.9
140
141 """
142 def __get__(self):
143 return bool(elm_colorselector_palette_item_selected_get(self.item))
144
145 def __set__(self, bint selected):
146 elm_colorselector_palette_item_selected_set(self.item, selected)
147
148 def selected_get(self):
149 return bool(elm_colorselector_palette_item_selected_get(self.item))
150 def selected_set(self, bint selected):
151 elm_colorselector_palette_item_selected_set(self.item, selected)
152
153
134cdef class Colorselector(LayoutClass): 154cdef class Colorselector(LayoutClass):
135 155
136 """This is the class that actually implements the widget.""" 156 """This is the class that actually implements the widget."""
@@ -242,22 +262,28 @@ cdef class Colorselector(LayoutClass):
242 262
243 """ 263 """
244 cdef: 264 cdef:
245 const_Eina_List *lst = elm_colorselector_palette_items_get(self.obj)
246 Elm_Object_Item *obj_item
247 int r, g, b, a
248 list ret = list() 265 list ret = list()
249 ColorselectorPaletteItem item 266 const_Eina_List *lst = elm_colorselector_palette_items_get(self.obj)
250 267
251 while lst: 268 while lst:
252 obj_item = <Elm_Object_Item *>lst.data 269 ret.append(_object_item_to_python(<Elm_Object_Item *>lst.data))
253 elm_colorselector_palette_item_color_get(obj_item, &r, &g, &b, &a)
254 item = ColorselectorPaletteItem(r, g, b, a)
255 item._set_obj(obj_item)
256 ret.append(item)
257 lst = lst.next 270 lst = lst.next
258 271
259 return ret 272 return ret
260 273
274 def palette_selected_item_get(self):
275 """palette_selected_item_get()
276
277 Get the selected item in the palette.
278
279 :return: the selected item.
280 :rtype: list of :py:class:`ColorselectorPaletteItem`
281
282 .. versionadded:: 1.9
283
284 """
285 cdef Elm_Object_Item *it = elm_colorselector_palette_selected_item_get(self.obj)
286 return _object_item_to_python(it)
261 287
262 def callback_changed_add(self, func, *args, **kwargs): 288 def callback_changed_add(self, func, *args, **kwargs):
263 """When the color value changes on selector""" 289 """When the color value changes on selector"""
diff --git a/examples/elementary/test_colorselector.py b/examples/elementary/test_colorselector.py
index 2021c31..becc14c 100644
--- a/examples/elementary/test_colorselector.py
+++ b/examples/elementary/test_colorselector.py
@@ -40,6 +40,15 @@ def cb_cs_item_lp(cs, item, rect):
40 b = (b * a) / 255 40 b = (b * a) / 255
41 rect.color = (r, g, b, a) 41 rect.color = (r, g, b, a)
42 42
43def selected_item_get(bt, cs):
44 item = cs.palette_selected_item_get()
45 print("Selected: {}".format(item.color if item is not None else None))
46
47def palette_items(bt, cs):
48 for item in cs.palette_items_get():
49 print("Item: {} {}".format(item.color, "<- selected" if item.selected else ""))
50
51
43def colorselector_clicked(obj): 52def colorselector_clicked(obj):
44 win = StandardWindow("colorselector", "ColorSelector test", 53 win = StandardWindow("colorselector", "ColorSelector test",
45 autodel=True, size=(350,350)) 54 autodel=True, size=(350,350))
@@ -111,6 +120,23 @@ def colorselector_clicked(obj):
111 hbox.pack_end(bt) 120 hbox.pack_end(bt)
112 bt.show() 121 bt.show()
113 122
123 hbox = Box(win, horizontal=True, size_hint_align=FILL_BOTH,
124 size_hint_weight=EXPAND_HORIZ)
125 vbox.pack_end(hbox)
126 hbox.show()
127
128 bt = Button(win, text="palette items", size_hint_align=FILL_BOTH,
129 size_hint_weight=EXPAND_HORIZ)
130 bt.callback_clicked_add(palette_items, cs)
131 hbox.pack_end(bt)
132 bt.show()
133
134 bt = Button(win, text="palette selected item", size_hint_align=FILL_BOTH,
135 size_hint_weight=EXPAND_HORIZ)
136 bt.callback_clicked_add(selected_item_get, cs)
137 hbox.pack_end(bt)
138 bt.show()
139
114 win.show() 140 win.show()
115 141
116 142