summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-06-02 20:16:12 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-06-04 20:28:42 +0300
commitdc664dd4c2c9e506a272d1c4f70e086abe4a9430 (patch)
treef8bc9940ab45a26a3c8dced591d9739dfc2d2737
parent4f1efb1ee1c5263f17dc74338fe4d191a39195f3 (diff)
Python bindings for ewe, built optionallydevs/kuuko/ewe
-rw-r--r--doc/ewe/ewe.rst34
-rw-r--r--doc/ewe/module-combobox.rst8
-rw-r--r--doc/ewe/module-entry.rst8
-rw-r--r--doc/ewe/module-ruler.rst8
-rw-r--r--doc/ewe/module-statusbar.rst8
-rw-r--r--doc/ewe/module-tabs.rst8
-rw-r--r--doc/index.rst7
-rw-r--r--efl/elementary/entry.pxd4
-rw-r--r--efl/ewe/__init__.pxd3
-rw-r--r--efl/ewe/__init__.py0
-rw-r--r--efl/ewe/__init__.pyx45
-rw-r--r--efl/ewe/combobox.pxd21
-rw-r--r--efl/ewe/combobox.pyx166
-rw-r--r--efl/ewe/entry.pxd15
-rw-r--r--efl/ewe/entry.pyx221
-rw-r--r--efl/ewe/enums.pxd35
-rw-r--r--efl/ewe/object_item.pxd2
-rw-r--r--efl/ewe/object_item.pyx9
-rw-r--r--efl/ewe/ruler.pxd13
-rw-r--r--efl/ewe/ruler.pyx84
-rw-r--r--efl/ewe/statusbar.pxd47
-rw-r--r--efl/ewe/statusbar.pyx394
-rw-r--r--efl/ewe/tabs.pxd32
-rw-r--r--efl/ewe/tabs.pyx278
-rw-r--r--examples/ewe/ruler_example.edc26
-rw-r--r--examples/ewe/ruler_example.edjbin0 -> 6668 bytes
-rw-r--r--examples/ewe/statusbar.edc53
-rw-r--r--examples/ewe/statusbar.edjbin0 -> 6970 bytes
-rwxr-xr-xexamples/ewe/test.py158
-rw-r--r--examples/ewe/test_combobox.py64
-rw-r--r--examples/ewe/test_entry.py94
-rw-r--r--examples/ewe/test_ruler.py97
-rw-r--r--examples/ewe/test_statusbar.py184
-rw-r--r--examples/ewe/test_tabs.py87
-rwxr-xr-xsetup.py30
35 files changed, 2243 insertions, 0 deletions
diff --git a/doc/ewe/ewe.rst b/doc/ewe/ewe.rst
new file mode 100644
index 0000000..8a0e72e
--- /dev/null
+++ b/doc/ewe/ewe.rst
@@ -0,0 +1,34 @@
1.. py:module:: efl.ewe
2
3:mod:`efl.ewe` Package
4=============================
5
6.. automodule::
7 efl.ewe.__init__
8
9Reference
10---------
11
12Modules
13^^^^^^^
14
15.. toctree::
16 :maxdepth: 4
17
18 module-combobox
19 module-entry
20 module-ruler
21 module-statusbar
22 module-tabs
23
24Inheritance diagram
25-------------------
26
27.. inheritance-diagram::
28 efl.ewe.__init__
29 efl.ewe.combobox
30 efl.ewe.entry
31 efl.ewe.ruler
32 efl.ewe.statusbar
33 efl.ewe.tabs
34 :parts: 3
diff --git a/doc/ewe/module-combobox.rst b/doc/ewe/module-combobox.rst
new file mode 100644
index 0000000..a8a4630
--- /dev/null
+++ b/doc/ewe/module-combobox.rst
@@ -0,0 +1,8 @@
1:mod:`combobox` Module
2--------------------------
3
4.. automodule:: efl.ewe.combobox
5
6.. inheritance-diagram::
7 efl.ewe.combobox
8 :parts: 3
diff --git a/doc/ewe/module-entry.rst b/doc/ewe/module-entry.rst
new file mode 100644
index 0000000..efa313f
--- /dev/null
+++ b/doc/ewe/module-entry.rst
@@ -0,0 +1,8 @@
1:mod:`entry` Module
2--------------------------
3
4.. automodule:: efl.ewe.entry
5
6.. inheritance-diagram::
7 efl.ewe.entry
8 :parts: 3
diff --git a/doc/ewe/module-ruler.rst b/doc/ewe/module-ruler.rst
new file mode 100644
index 0000000..f471567
--- /dev/null
+++ b/doc/ewe/module-ruler.rst
@@ -0,0 +1,8 @@
1:mod:`ruler` Module
2--------------------------
3
4.. automodule:: efl.ewe.ruler
5
6.. inheritance-diagram::
7 efl.ewe.ruler
8 :parts: 3
diff --git a/doc/ewe/module-statusbar.rst b/doc/ewe/module-statusbar.rst
new file mode 100644
index 0000000..a904e58
--- /dev/null
+++ b/doc/ewe/module-statusbar.rst
@@ -0,0 +1,8 @@
1:mod:`statusbar` Module
2--------------------------
3
4.. automodule:: efl.ewe.statusbar
5
6.. inheritance-diagram::
7 efl.ewe.statusbar
8 :parts: 3
diff --git a/doc/ewe/module-tabs.rst b/doc/ewe/module-tabs.rst
new file mode 100644
index 0000000..945ab16
--- /dev/null
+++ b/doc/ewe/module-tabs.rst
@@ -0,0 +1,8 @@
1:mod:`tabs` Module
2--------------------------
3
4.. automodule:: efl.ewe.tabs
5
6.. inheritance-diagram::
7 efl.ewe.tabs
8 :parts: 3
diff --git a/doc/index.rst b/doc/index.rst
index ac42901..63377b8 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -79,6 +79,13 @@ Elementary
79 :maxdepth: 4 79 :maxdepth: 4
80 80
81 81
82Ewe
83----------
84
85.. toctree:: ewe/ewe
86 :maxdepth: 4
87
88
82DBus integration 89DBus integration
83---------------- 90----------------
84 91
diff --git a/efl/elementary/entry.pxd b/efl/elementary/entry.pxd
index 0096f7d..4f9c4ef 100644
--- a/efl/elementary/entry.pxd
+++ b/efl/elementary/entry.pxd
@@ -5,6 +5,7 @@ from enums cimport Elm_Wrap_Type, Elm_Text_Format, Elm_Cnp_Mode, \
5 Elm_Input_Panel_Lang, Elm_Input_Panel_Return_Key_Type, \ 5 Elm_Input_Panel_Lang, Elm_Input_Panel_Return_Key_Type, \
6 Elm_Autocapital_Type, Elm_Icon_Type, Elm_Sel_Type, Elm_Sel_Format, \ 6 Elm_Autocapital_Type, Elm_Icon_Type, Elm_Sel_Type, Elm_Sel_Format, \
7 Elm_Xdnd_Action 7 Elm_Xdnd_Action
8from efl.elementary.layout_class cimport LayoutClass
8 9
9cdef extern from "Elementary.h": 10cdef extern from "Elementary.h":
10 ctypedef struct Elm_Entry_Anchor_Info: 11 ctypedef struct Elm_Entry_Anchor_Info:
@@ -151,3 +152,6 @@ cdef extern from "Elementary.h":
151 void elm_entry_context_menu_item_icon_get(const Elm_Entry_Context_Menu_Item *item, const char **icon_file, const char **icon_group, Elm_Icon_Type *icon_type) 152 void elm_entry_context_menu_item_icon_get(const Elm_Entry_Context_Menu_Item *item, const char **icon_file, const char **icon_group, Elm_Icon_Type *icon_type)
152 153
153 Eina_Bool elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type selection, Elm_Sel_Format format, Elm_Drop_Cb datacb, void *udata) 154 Eina_Bool elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type selection, Elm_Sel_Format format, Elm_Drop_Cb datacb, void *udata)
155
156cdef class Entry(LayoutClass):
157 pass
diff --git a/efl/ewe/__init__.pxd b/efl/ewe/__init__.pxd
new file mode 100644
index 0000000..44c0f7f
--- /dev/null
+++ b/efl/ewe/__init__.pxd
@@ -0,0 +1,3 @@
1cdef extern from "ewe.h":
2 int ewe_init(int argc, char **argv)
3 int ewe_shutdown()
diff --git a/efl/ewe/__init__.py b/efl/ewe/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/efl/ewe/__init__.py
diff --git a/efl/ewe/__init__.pyx b/efl/ewe/__init__.pyx
new file mode 100644
index 0000000..6bea8c9
--- /dev/null
+++ b/efl/ewe/__init__.pyx
@@ -0,0 +1,45 @@
1from libc.string cimport memcpy
2from cpython cimport PyMem_Malloc, PyUnicode_AsUTF8String
3
4import sys
5
6def init():
7 """Initialize Elementary Widget Extensions library
8
9 :return: The init counter value.
10 :rtype: int
11
12 This function initializes Ewe and increments a counter of
13 the number of calls to it. It returns the new counter's value.
14
15 """
16 cdef:
17 int argc, i, arg_len
18 char **argv
19 char *arg
20
21 argc = len(sys.argv)
22 argv = <char **>PyMem_Malloc(argc * sizeof(char *))
23 for i in range(argc):
24 t = sys.argv[i]
25 if isinstance(t, unicode): t = PyUnicode_AsUTF8String(t)
26 arg = t
27 arg_len = len(arg)
28 argv[i] = <char *>PyMem_Malloc(arg_len + 1)
29 memcpy(argv[i], arg, arg_len + 1)
30
31 return ewe_init(argc, argv)
32
33def shutdown():
34 """Shut down Elementary Widget Extensions library
35
36 :return: The init counter value.
37 :rtype: int
38
39 This should be called at the end of your application, just
40 before it ceases to do any more processing. This will clean up
41 any permanent resources your application may have allocated via
42 Ewe that would otherwise persist.
43
44 """
45 return ewe_shutdown()
diff --git a/efl/ewe/combobox.pxd b/efl/ewe/combobox.pxd
new file mode 100644
index 0000000..8f7a458
--- /dev/null
+++ b/efl/ewe/combobox.pxd
@@ -0,0 +1,21 @@
1from efl.eina cimport Eina_Bool, Eina_Stringshare, Eina_List
2from efl.evas cimport Evas_Object
3
4cdef extern from "ewe.h":
5 ctypedef struct Ewe_Combobox_Item:
6 Evas_Object *owner
7 Evas_Object *content
8 Eina_Stringshare *title
9 unsigned int index
10
11 Evas_Object * ewe_combobox_add(Evas_Object *parent)
12 Eina_Bool ewe_combobox_expanded_get(Evas_Object *obj)
13 Ewe_Combobox_Item * ewe_combobox_item_add(Evas_Object *obj, Eina_Stringshare *title)
14 Eina_Bool ewe_combobox_item_del(Evas_Object *obj, Ewe_Combobox_Item *item)
15 Eina_Bool ewe_combobox_items_list_free(Evas_Object *obj, Eina_Bool empty)
16 const Eina_List * ewe_combobox_items_list_get(const Evas_Object *obj)
17 Eina_Bool ewe_combobox_item_title_set(Evas_Object *obj, int index, Eina_Stringshare *title)
18 Eina_Bool ewe_combobox_text_set(Evas_Object *obj, Eina_Stringshare *title)
19 Eina_Stringshare * ewe_combobox_item_title_get(Evas_Object *obj, const int index)
20 Ewe_Combobox_Item * ewe_combobox_select_item_get(Evas_Object *obj)
21 Eina_Bool ewe_combobox_select_item_set(Evas_Object *obj, const int index)
diff --git a/efl/ewe/combobox.pyx b/efl/ewe/combobox.pyx
new file mode 100644
index 0000000..ea6021c
--- /dev/null
+++ b/efl/ewe/combobox.pyx
@@ -0,0 +1,166 @@
1from libc.stdint cimport uintptr_t
2from cpython cimport PyUnicode_AsUTF8String
3
4from efl.utils.conversions cimport _ctouni
5from efl.evas cimport Object as evasObject
6from efl.elementary.object cimport Object
7
8def _cb_combobox_item_conv(uintptr_t addr):
9 cdef ComboboxItem it = ComboboxItem.__new__(ComboboxItem)
10 it.item = <Ewe_Combobox_Item *>addr
11 return it
12
13cdef class ComboboxItem(object):
14
15 cdef Ewe_Combobox_Item *item
16
17 def __init__(self, evasObject parent not None, title):
18 """This adds an item to combobox object.
19
20 :param parent: The combobox object
21 :param title: The combobox title
22
23 """
24 if isinstance(title, unicode): title = PyUnicode_AsUTF8String(title)
25 self.item = ewe_combobox_item_add(parent.obj, title)
26
27 def delete(self):
28 """Delete combobox item.
29
30 :param item: The combobox item
31 :return: EINA_TRUE on success, EINA_FALSE otherwise
32
33 """
34 return bool(ewe_combobox_item_del(self.item.owner, self.item))
35
36cdef list eina_list_items_to_python_list(const Eina_List *lst):
37 cdef:
38 Ewe_Combobox_Item *item
39 list ret = []
40 Eina_List *itr = <Eina_List *>lst
41 ComboboxItem it
42 while itr:
43 it = ComboboxItem.__new__(ComboboxItem)
44 it.item = <Ewe_Combobox_Item *>itr.data
45 ret.append(it)
46 itr = itr.next
47 return ret
48
49cdef class Combobox(Object):
50
51 def __init__(self, evasObject parent not None, **kwargs):
52 """Add a new combobox to the parent
53
54 :param parent: The parent object
55
56 """
57 self._set_obj(ewe_combobox_add(parent.obj))
58 self._set_properties_from_keyword_args(kwargs)
59
60 property expanded:
61 """Returns whether the combobox is expanded.
62
63 :type: bool
64
65 """
66 def __get__(self):
67 return bool(ewe_combobox_expanded_get(self.obj))
68
69 def items_list_free(self, bint empty):
70 """Combobox items list free.
71
72 :param item: The combobox item
73 :return: True on success, False otherwise
74
75 """
76 return ewe_combobox_items_list_free(self.obj, empty)
77
78 def items_list_get(self):
79 """Get internal items list.
80
81 :return: list of items on success, None otherwise
82
83 """
84 return eina_list_items_to_python_list(
85 ewe_combobox_items_list_get(self.obj)
86 )
87
88 property text:
89 """This sets title for the combobox.
90
91 :param title: Text to be set as title of the combobox
92 :raise RuntimeError: True on success, False otherwise
93
94 """
95 def __set__(self, title):
96 if isinstance(title, unicode):
97 title = PyUnicode_AsUTF8String(title)
98 if not ewe_combobox_text_set(self.obj, title):
99 raise RuntimeError("Setting title text failed")
100
101 def selected_item_get(self):
102 """Gets the selected item from a combobox object.
103
104 :return: The selected combobox item object or None if it cannot be created
105
106 """
107 cdef ComboboxItem it = ComboboxItem.__new__(ComboboxItem)
108 it.item = ewe_combobox_select_item_get(self.obj)
109 return it
110
111 def selected_item_set(self, int index):
112 """Sets select combobox item.
113
114 :param index: The combobox index
115 :return: True on success, False otherwise
116
117 """
118 return bool(ewe_combobox_select_item_set(self.obj, index))
119
120 def item_title_set(self, int index, title):
121 """This sets title of the combobox item.
122
123 :param index: The combobox item index
124 :param title: Text to be setted as title of the combobox item
125 :rtype: bool
126
127 """
128 if isinstance(title, unicode): title = PyUnicode_AsUTF8String(title)
129 return ewe_combobox_item_title_set(
130 self.obj,
131 index,
132 <Eina_Stringshare *>title if title is not None else NULL
133 )
134 def item_title_get(self, int index):
135 """This sets title of the combobox item.
136
137 :param index: The combobox item index
138 :rtype: string
139
140 """
141 return _ctouni(ewe_combobox_item_title_get(
142 self.obj,
143 index
144 ))
145
146 def callback_collapsed_add(self, func, *args, **kwargs):
147 """Called when the menu is collapsed."""
148 self._callback_add("collapsed", func, *args, **kwargs)
149
150 def callback_collapsed_del(self, func):
151 self._callback_del("collapsed", func)
152
153 def callback_expanded_add(self, func, *args, **kwargs):
154 """Called when the menu is expanded."""
155 self._callback_add("expanded", func, *args, **kwargs)
156
157 def callback_expanded_del(self, func):
158 self._callback_del("expanded", func)
159
160 def callback_selected_add(self, func, *args, **kwargs):
161 """Called when user selects an item."""
162 self._callback_add_full("selected", _cb_combobox_item_conv, func,
163 *args, **kwargs)
164
165 def callback_selected_del(self, func):
166 self._callback_del_full("selected", _cb_combobox_item_conv, func)
diff --git a/efl/ewe/entry.pxd b/efl/ewe/entry.pxd
new file mode 100644
index 0000000..738afdc
--- /dev/null
+++ b/efl/ewe/entry.pxd
@@ -0,0 +1,15 @@
1from efl.eina cimport Eina_Bool
2from efl.evas cimport Evas_Object
3
4cdef extern from "ewe.h":
5 Evas_Object *ewe_entry_add(Evas_Object *parent)
6 Eina_Bool ewe_entry_regex_set(Evas_Object *obj, const char *regex_str, int flags)
7 Eina_Bool ewe_entry_regex_unset(Evas_Object *obj)
8 Eina_Bool ewe_entry_regex_check(Evas_Object *obj)
9 Eina_Bool ewe_entry_regex_glow_set(Evas_Object *obj, Eina_Bool glow)
10 Eina_Bool ewe_entry_regex_glow_get(const Evas_Object *obj)
11 int ewe_entry_regex_error_get(const Evas_Object *obj)
12 const char * ewe_entry_regex_error_text_get(const Evas_Object *obj)
13 Eina_Bool ewe_entry_regex_autocheck_set(Evas_Object *obj, Eina_Bool autocheck)
14 Eina_Bool ewe_entry_regex_autocheck_get(const Evas_Object *obj)
15 void ewe_entry_entry_set(Evas_Object *obj, const char *text)
diff --git a/efl/ewe/entry.pyx b/efl/ewe/entry.pyx
new file mode 100644
index 0000000..d4b6d10
--- /dev/null
+++ b/efl/ewe/entry.pyx
@@ -0,0 +1,221 @@
1"""
2
3Enumerations
4============
5
6.. _Ewe_Entry_Regex_Toggles:
7
8Regex Flags
9-------------
10
11.. data:: EWE_REG_EXTENDED
12
13 Regex check option: Use Extended Regular Expressions.
14
15.. data:: EWE_REG_ICASE
16
17 Regex check option: Ignore case in match.
18
19
20.. _Ewe_Entry_Regex_Status:
21
22Regex Status
23------------
24
25.. data:: EWE_REG_NOERROR
26
27 Regex Success: Regex maches to the Entrys text
28
29.. data:: EWE_REG_NOMATCH
30
31 Regex Error: regexec() failed to match.
32
33.. data:: EWE_REG_BADPAT
34
35 Regex Error: Invalid regular expression.
36
37.. data:: EWE_REG_ECOLLATE
38
39 Regex Error: Invalid collating element referenced.
40
41.. data:: EWE_REG_ECTYPE
42
43 Regex Error: Invalid character class type referenced.
44
45.. data:: EWE_REG_EESCAPE
46
47 Regex Error: Trailing \ in pattern.
48
49.. data:: EWE_REG_ESUBREG
50
51 Regex Error: Wrong back reference.
52
53.. data:: EWE_REG_EBRACK
54
55 Regex Error: [ ] imbalance.
56
57.. data:: EWE_REG_EPAREN
58
59 Regex Error: \( \) or ( ) imbalance.
60
61.. data:: EWE_REG_EBRACE
62
63 Regex Error: \{ \} imbalance.
64
65.. data:: EWE_REG_BADBR
66
67 Regex Error: Content of \{ \} invalid: not a number, number too large, more than two numbers, first larger than second.
68
69.. data:: EWE_REG_ERANGE
70
71 Regex Error: Invalid endpoint in range expression.
72
73.. data:: EWE_REG_ESPACE
74
75 Regex Error: Out of memory.
76
77.. data:: EWE_REG_BADRPT
78
79 Regex Error: ?, * or + not preceded by valid regular expression.
80
81"""
82
83from efl.elementary.entry cimport Entry as elmEntry
84from cpython cimport PyUnicode_AsUTF8String
85from efl.utils.conversions cimport _ctouni
86from efl.evas cimport Object as evasObject
87
88cimport enums
89
90EWE_REG_EXTENDED = enums.EWE_REG_EXTENDED
91EWE_REG_ICASE = enums.EWE_REG_ICASE
92
93EWE_REG_NOERROR = enums.EWE_REG_NOERROR
94EWE_REG_NOMATCH = enums.EWE_REG_NOMATCH
95EWE_REG_BADPAT = enums.EWE_REG_BADPAT
96EWE_REG_ECOLLATE = enums.EWE_REG_ECOLLATE
97EWE_REG_ECTYPE = enums.EWE_REG_ECTYPE
98EWE_REG_EESCAPE = enums.EWE_REG_EESCAPE
99EWE_REG_ESUBREG = enums.EWE_REG_ESUBREG
100EWE_REG_EBRACK = enums.EWE_REG_EBRACK
101EWE_REG_EPAREN = enums.EWE_REG_EPAREN
102EWE_REG_EBRACE = enums.EWE_REG_EBRACE
103EWE_REG_BADBR = enums.EWE_REG_BADBR
104EWE_REG_ERANGE = enums.EWE_REG_ERANGE
105EWE_REG_ESPACE = enums.EWE_REG_ESPACE
106EWE_REG_BADRPT = enums.EWE_REG_BADRPT
107
108cdef class Entry(elmEntry):
109
110 def __init__(self, evasObject parent not None, **kwargs):
111 """This adds an entry to @p parent object.
112
113 By default, entries are:
114
115 - not scrolled
116 - multi-line
117 - word wrapped
118 - autosave is enabled
119
120 :param parent: The parent object
121
122 """
123 self._set_obj(ewe_entry_add(parent.obj))
124 self._set_properties_from_keyword_args(kwargs)
125
126 def regex_set(self, regex_str not None, int flags):
127 """Set regular expresion to be compiled and used.
128
129 :param regex_str: The text of regular expresion
130 :param flags: Compile flags for regex
131 :type flags: int value from or'ed :ref:`Ewe_Entry_Regex_Toggles`
132 :return: True on success, otherwise returns False.
133
134 """
135 if isinstance(regex_str, unicode):
136 regex_str = PyUnicode_AsUTF8String(regex_str)
137 return bool(ewe_entry_regex_set(
138 self.obj,
139 <const char *>regex_str,
140 flags
141 ))
142
143 def regex_unset(self):
144 """Unset previoustly set regular expresion.
145
146 :return: True on success, otherwise returns False.
147
148 """
149 return bool(ewe_entry_regex_unset(self.obj))
150
151 def regex_check(self):
152 """Check current text of Entry with previoustly set regular expresion.
153
154 :return: True on success, otherwise returns False.
155
156 """
157 return bool(ewe_entry_regex_check(self.obj))
158
159 property regex_glow:
160 """Set if regex error signals for EDJE should be emitted.
161
162 :type: bool
163
164 """
165 def __set__(self, bint glow):
166 if not ewe_entry_regex_glow_set(self.obj, glow):
167 raise RuntimeError("glow could not be set")
168
169 def __get__(self):
170 return bool(ewe_entry_regex_glow_get(self.obj))
171
172 def regex_error_get(self):
173 """Returns last regex error
174
175 :return: The last regex error.
176
177 """
178 return ewe_entry_regex_error_get(self.obj)
179
180 def regex_error_text_get(self):
181 """Returns the string that contains last regex error.
182 This message updates on each regex setting and checking.
183 The string is deleted on Entry object deleteon.
184
185 :return: The last regex error. If regex is not set yet None would be returned.
186
187 """
188 return _ctouni(ewe_entry_regex_error_text_get(self.obj))
189
190 property regex_autocheck:
191 """Automatic regex check on "entry,changed".
192
193 Signals will be processed only for focused entry.
194
195 :type: bool
196
197 """
198 def __set__(self, bint autocheck):
199 if not ewe_entry_regex_autocheck_set(self.obj, autocheck):
200 raise RuntimeError("could not enable autocheck")
201
202 def __get__(self):
203 return bool(ewe_entry_regex_autocheck_get(self.obj))
204
205 property entry:
206 """This sets the text displayed within the entry to @p entry.
207
208 :param entry: The text to be displayed
209
210 .. note:: Using this function bypasses text filters
211
212 """
213 def __get__(self):
214 return elmEntry.entry.__get__(self)
215
216 def __set__(self, text):
217 if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
218 ewe_entry_entry_set(
219 self.obj,
220 <const char *>text if text is not None else NULL
221 )
diff --git a/efl/ewe/enums.pxd b/efl/ewe/enums.pxd
new file mode 100644
index 0000000..24eef4c
--- /dev/null
+++ b/efl/ewe/enums.pxd
@@ -0,0 +1,35 @@
1cdef extern from "ewe.h":
2 enum:
3 EWE_REG_EXTENDED
4 EWE_REG_ICASE
5
6 enum:
7 EWE_REG_NOERROR
8 EWE_REG_NOMATCH
9 EWE_REG_BADPAT
10 EWE_REG_ECOLLATE
11 EWE_REG_ECTYPE
12 EWE_REG_EESCAPE
13 EWE_REG_ESUBREG
14 EWE_REG_EBRACK
15 EWE_REG_EPAREN
16 EWE_REG_EBRACE
17 EWE_REG_BADBR
18 EWE_REG_ERANGE
19 EWE_REG_ESPACE
20 EWE_REG_BADRPT
21
22 ctypedef enum Ewe_Ruler_Orient:
23 EWE_RULER_ORIENT_WRONG # returned from get func if some error occured
24 EWE_RULER_ORIENT_HORIZONTAL # Ruler (dis)appears in horizontal mode
25 EWE_RULER_ORIENT_VERTICAL # Ruler (dis)appears in vertical mode
26
27 ctypedef enum Ewe_Statusbar_Items_Align:
28 EWE_STATUSBAR_ITEMS_ALIGN_RIGHT
29 EWE_STATUSBAR_ITEMS_ALIGN_CENTER
30 EWE_STATUSBAR_ITEMS_ALIGN_LEFT
31 EWE_STATUSBAR_ITEMS_ALIGN_LAST
32
33 ctypedef enum Ewe_Statusbar_Items_Type:
34 EWE_STATUSBAR_ITEM_TYPE_OBJECT # item with content
35 EWE_STATUSBAR_ITEM_TYPE_SEPARATOR # separate item
diff --git a/efl/ewe/object_item.pxd b/efl/ewe/object_item.pxd
new file mode 100644
index 0000000..f0b5938
--- /dev/null
+++ b/efl/ewe/object_item.pxd
@@ -0,0 +1,2 @@
1cdef class _ObjectItem(object):
2 cdef int _set_properties_from_keyword_args(self, dict kwargs) except 0
diff --git a/efl/ewe/object_item.pyx b/efl/ewe/object_item.pyx
new file mode 100644
index 0000000..0b0cb5d
--- /dev/null
+++ b/efl/ewe/object_item.pyx
@@ -0,0 +1,9 @@
1cdef class _ObjectItem(object):
2 cdef int _set_properties_from_keyword_args(self, dict kwargs) except 0:
3 if not kwargs:
4 return 1
5 cdef list cls_list = dir(self)
6 for k, v in kwargs.items():
7 assert k in cls_list, "%s has no attribute with the name %s." % (self, k)
8 setattr(self, k, v)
9 return 1
diff --git a/efl/ewe/ruler.pxd b/efl/ewe/ruler.pxd
new file mode 100644
index 0000000..67a91f4
--- /dev/null
+++ b/efl/ewe/ruler.pxd
@@ -0,0 +1,13 @@
1from efl.c_eo cimport Eo
2from efl.eina cimport Eina_Bool
3from efl.evas cimport Evas_Object
4from enums cimport Ewe_Ruler_Orient
5
6cdef extern from "ewe.h":
7 Evas_Object * ewe_ruler_add(Evas_Object *parent)
8 Eina_Bool ewe_ruler_orient_set(Evas_Object *obj, Ewe_Ruler_Orient orient)
9 Ewe_Ruler_Orient ewe_ruler_orient_get(const Eo *obj)
10 Eina_Bool ewe_ruler_step_set(Evas_Object *obj, unsigned int step)
11 unsigned int ewe_ruler_step_get(const Eo *obj)
12 Eina_Bool ewe_ruler_zero_offset_set(Evas_Object *obj, int pos)
13 int ewe_ruler_zero_offset_get(const Eo *obj)
diff --git a/efl/ewe/ruler.pyx b/efl/ewe/ruler.pyx
new file mode 100644
index 0000000..d630d84
--- /dev/null
+++ b/efl/ewe/ruler.pyx
@@ -0,0 +1,84 @@
1"""
2Enumerations
3============
4
5.. _Ewe_Ruler_Orient:
6
7Orientation
8-----------
9
10.. data:: EWE_RULER_ORIENT_WRONG
11
12 returned from get func if some error occured
13
14.. data:: EWE_RULER_ORIENT_HORIZONTAL
15
16 Ruler (dis)appears in horizontal mode
17
18.. data:: EWE_RULER_ORIENT_VERTICAL
19
20 Ruler (dis)appears in vertical mode
21
22"""
23
24from cpython cimport PyUnicode_AsUTF8String
25from efl.utils.conversions cimport _ctouni
26from efl.evas cimport Object as evasObject
27from efl.elementary.object cimport Object
28cimport enums
29
30EWE_RULER_ORIENT_WRONG = enums.EWE_RULER_ORIENT_WRONG
31EWE_RULER_ORIENT_HORIZONTAL = enums.EWE_RULER_ORIENT_HORIZONTAL
32EWE_RULER_ORIENT_VERTICAL = enums.EWE_RULER_ORIENT_VERTICAL
33
34
35cdef class Ruler(Object):
36 def __init__(self, evasObject parent not None, **kwargs):
37 """Add new ruler to the given parent object
38
39 :param parent: The parent object.
40
41 """
42 self._set_obj(ewe_ruler_add(parent.obj))
43 self._set_properties_from_keyword_args(kwargs)
44
45 property orient:
46 """Ruler orientation
47
48 :type: :ref:`Ewe_Ruler_Orient`
49
50 """
51 def __set__(self, Ewe_Ruler_Orient orient):
52 if not ewe_ruler_orient_set(self.obj, orient):
53 raise RuntimeError("Could not set ruler orientation")
54
55 def __get__(self):
56 return ewe_ruler_orient_get(self.obj)
57
58 property step:
59 """Step between marks of the ruler. If step is setting to 0, it would be
60 setting to 1.
61
62 :type: int
63
64 """
65 def __set__(self, unsigned int step):
66 if not ewe_ruler_step_set(self.obj, step):
67 raise RuntimeError("Could not set ruler step")
68
69 def __get__(self):
70 return ewe_ruler_step_get(self.obj)
71
72 property zero_offset:
73 """Change the ruler's "zero pointer" mark position in pixels relative to
74 start parent's layout
75
76 :type: int
77
78 """
79 def __set__(self, int pos):
80 if not ewe_ruler_zero_offset_set(self.obj, pos):
81 raise RuntimeError("Could not set ruler offset")
82
83 def __get__(self):
84 return ewe_ruler_zero_offset_get(self.obj)
diff --git a/efl/ewe/statusbar.pxd b/efl/ewe/statusbar.pxd
new file mode 100644
index 0000000..f258166
--- /dev/null
+++ b/efl/ewe/statusbar.pxd
@@ -0,0 +1,47 @@
1from efl.eina cimport Eina_Bool, Eina_List
2from efl.evas cimport Evas_Object, Evas_Smart_Cb
3from enums cimport Ewe_Statusbar_Items_Type, Ewe_Statusbar_Items_Align
4
5cdef extern from "ewe.h":
6
7 ctypedef struct Ewe_Statusbar_Item:
8 Evas_Object *parent # the pointer to parent statusbar object
9 Evas_Object *content # the object, which added into item
10 Evas_Object *markup # the object which load markup from edj file
11
12 Ewe_Statusbar_Items_Type type # item type: separator or item witch content
13
14 Evas_Smart_Cb func # callback function, which call when item clicked
15 void *cb_data # data, which will be sended into item callback
16
17
18 Eina_Bool disabled # the item disabled status: EINA_TRUE - enabled
19 int id # the item identificator
20 int width # the item width, if less that 0, then ulimited width will set
21
22
23 int ewe_statusbar_item_id_get(Ewe_Statusbar_Item *item)
24 int ewe_statusbar_item_width_get(Ewe_Statusbar_Item *item)
25 Eina_Bool ewe_statusbar_item_width_set(Ewe_Statusbar_Item *item, int width)
26 char * ewe_statusbar_item_label_get(Ewe_Statusbar_Item *item)
27 Eina_Bool ewe_statusbar_item_label_set(Ewe_Statusbar_Item *item, const char *label)
28 Evas_Object * ewe_statusbar_item_content_get(Ewe_Statusbar_Item *item)
29 Eina_Bool ewe_statusbar_item_content_set(Ewe_Statusbar_Item *item, Evas_Object *content)
30 Evas_Object * ewe_statusbar_item_content_unset(Ewe_Statusbar_Item *item)
31 Evas_Object * ewe_statusbar_item_statusbar_get(Ewe_Statusbar_Item *item)
32
33
34 Evas_Object * ewe_statusbar_add(Evas_Object *parent)
35 Eina_Bool ewe_statusbar_clear(Evas_Object *obj)
36 Ewe_Statusbar_Item * ewe_statusbar_item_append(Evas_Object *obj, Evas_Object *content, Ewe_Statusbar_Items_Type type, Evas_Smart_Cb func, void *func_data)
37 Ewe_Statusbar_Item * ewe_statusbar_item_prepend(Evas_Object *obj, Evas_Object *content, Ewe_Statusbar_Items_Type type, Evas_Smart_Cb func, void *func_data)
38 Eina_Bool ewe_statusbar_item_insert_before(Evas_Object *obj, Ewe_Statusbar_Item *item, Ewe_Statusbar_Item *before)
39 Eina_Bool ewe_statusbar_item_insert_after(Evas_Object *obj, Ewe_Statusbar_Item *item, Ewe_Statusbar_Item *after)
40 Eina_Bool ewe_statusbar_items_swap(Evas_Object *obj, Ewe_Statusbar_Item *item_first, Ewe_Statusbar_Item *item_second)
41 const Eina_List * ewe_statusbar_items_list_get(Evas_Object *obj)
42 void ewe_statusbar_items_padding_set(Evas_Object *obj, int padding)
43 int ewe_statusbar_items_padding_get(const Evas_Object *obj)
44 void ewe_statusbar_items_align_set(Evas_Object *obj, Ewe_Statusbar_Items_Align align)
45 Ewe_Statusbar_Items_Align ewe_statusbar_items_align_get(const Evas_Object *obj)
46 Eina_Bool ewe_statusbar_item_remove(Evas_Object *obj, Ewe_Statusbar_Item *item)
47
diff --git a/efl/ewe/statusbar.pyx b/efl/ewe/statusbar.pyx
new file mode 100644
index 0000000..c0d0a21
--- /dev/null
+++ b/efl/ewe/statusbar.pyx
@@ -0,0 +1,394 @@
1
2"""
3
4Enumerations
5============
6
7
8.. _Ewe_Statusbar_Items_Align:
9
10Item alignment
11--------------
12
13Defines items align into statusbar
14
15.. data:: EWE_STATUSBAR_ITEMS_ALIGN_RIGHT
16.. data:: EWE_STATUSBAR_ITEMS_ALIGN_CENTER
17.. data:: EWE_STATUSBAR_ITEMS_ALIGN_LEFT
18
19
20.. _Ewe_Statusbar_Items_Type:
21
22Item types
23----------
24
25Defines statusbar item types.
26
27.. data:: EWE_STATUSBAR_ITEM_TYPE_OBJECT
28
29 item with content
30
31.. data:: EWE_STATUSBAR_ITEM_TYPE_SEPARATOR
32
33 separator item
34
35"""
36
37from cpython cimport PyUnicode_AsUTF8String, Py_INCREF, Py_DECREF
38
39from efl.eo cimport object_from_instance
40from efl.utils.conversions cimport _touni
41from efl.evas cimport Object as evasObject
42from efl.elementary.object cimport Object
43from efl.ewe.object_item cimport _ObjectItem
44cimport enums
45
46import traceback
47
48EWE_STATUSBAR_ITEMS_ALIGN_RIGHT = enums.EWE_STATUSBAR_ITEMS_ALIGN_RIGHT
49EWE_STATUSBAR_ITEMS_ALIGN_CENTER = enums.EWE_STATUSBAR_ITEMS_ALIGN_CENTER
50EWE_STATUSBAR_ITEMS_ALIGN_LEFT = enums.EWE_STATUSBAR_ITEMS_ALIGN_LEFT
51EWE_STATUSBAR_ITEMS_ALIGN_LAST = enums.EWE_STATUSBAR_ITEMS_ALIGN_LAST
52
53EWE_STATUSBAR_ITEM_TYPE_OBJECT = enums.EWE_STATUSBAR_ITEM_TYPE_OBJECT
54EWE_STATUSBAR_ITEM_TYPE_SEPARATOR = enums.EWE_STATUSBAR_ITEM_TYPE_SEPARATOR
55
56cdef void _py_ewe_statusbar_item_cb(void *data, Evas_Object *obj, void *event_info) with gil:
57 cdef StatusbarItem item = <object>data
58 try:
59 o = object_from_instance(obj)
60 item.cb(o, item, item.cb_data)
61 except Exception:
62 traceback.print_exc()
63
64cdef _statusbar_item_to_python(Ewe_Statusbar_Item *it):
65 cdef:
66 void *data
67 StatusbarItem item
68
69 if it == NULL:
70 return None
71
72 data = it.cb_data
73
74 if data == NULL:
75 # Create a dummy statusbar item.
76 item = StatusbarItem.__new__(StatusbarItem)
77 item._set_obj(it)
78 else:
79 item = <object>data
80
81 return item
82
83cdef _statusbar_item_list_to_python(const Eina_List *lst):
84 cdef Ewe_Statusbar_Item *it
85 ret = []
86 while lst:
87 it = <Ewe_Statusbar_Item *>lst.data
88 lst = lst.next
89 o = _statusbar_item_to_python(it)
90 if o is not None:
91 ret.append(o)
92 return ret
93
94cdef class StatusbarItem(_ObjectItem):
95
96 cdef:
97 object cb
98 object cb_data
99 Ewe_Statusbar_Item *item
100
101 cdef int _set_obj(self, Ewe_Statusbar_Item *item) except 0:
102 assert self.item == NULL, "Object must be clean"
103 self.item = item
104 Py_INCREF(self)
105 return 1
106
107 cdef int _unset_obj(self) except 0:
108 assert self.item != NULL, "Object already deleted"
109 self.item = NULL
110 Py_DECREF(self)
111 return 1
112
113 def __init__(self, *args, **kwargs):
114 self.append(*args, **kwargs)
115
116 @classmethod
117 def append(cls,
118 Statusbar statusbar not None, evasObject content=None,
119 Ewe_Statusbar_Items_Type type=enums.EWE_STATUSBAR_ITEM_TYPE_OBJECT,
120 cb=None, cb_data=None, **kwargs):
121 """Append a new item in a given statusbar widget.
122
123 :param content: The object, which will be set into statusbar item as
124 content. Can be None, if planned set content with
125 :py:attr:`StatusbarItem.content`.
126 :param type: Item type.
127 :param func: Convenience function called when the item is clicked.
128 :param func_data: Data passed to func above.
129
130 :return: A handle to the item added or NULL if not possible
131
132 This adds the new item to the end of the list childrens in statusbar widget.
133
134 """
135 cdef:
136 void *func_data
137 StatusbarItem self
138
139 self = cls.__new__(cls)
140
141 if cb:
142 if not callable(cb):
143 raise TypeError("cb must be callable")
144 else:
145 self.cb = cb
146 self.cb_data = cb_data
147
148 self._set_obj(ewe_statusbar_item_append(
149 statusbar.obj, content.obj, type,
150 <Evas_Smart_Cb>_py_ewe_statusbar_item_cb if cb is not None else NULL,
151 <void *>self
152 ))
153
154 self._set_properties_from_keyword_args(kwargs)
155
156 return self
157
158 @classmethod
159 def prepend(cls,
160 Statusbar statusbar not None, evasObject content=None,
161 Ewe_Statusbar_Items_Type type=enums.EWE_STATUSBAR_ITEM_TYPE_OBJECT,
162 cb=None, cb_data=None, **kwargs):
163 """Prepend a new item in a given statusbar widget.
164
165 :param content: The object, which will be set into statusbar item as
166 content. Can be None, if planned set content with
167 :py:attr:`StatusbarItem.content`.
168 :param type: Item type.
169 :param func: Convenience function called when the item is clicked.
170 :param func_data: Data passed to func above.
171
172 :return: A handle to the item added or None if not possible
173
174 This adds the new item to the beginnig of the list childrens in statusbar widget.
175
176 """
177 cdef:
178 void *func_data
179 StatusbarItem self
180
181 self = cls.__new__(cls)
182
183 if cb:
184 if not callable(cb):
185 raise TypeError("cb must be callable")
186 else:
187 self.cb = cb
188 self.cb_data = cb_data
189
190 self._set_properties_from_keyword_args(kwargs)
191
192 self._set_obj(ewe_statusbar_item_prepend(
193 statusbar.obj, content.obj, type,
194 <Evas_Smart_Cb>_py_ewe_statusbar_item_cb if cb is not None else NULL,
195 <void *>self
196 ))
197
198 return self
199
200 def insert_before(self, StatusbarItem before not None):
201 """Insert this item before another in a given statusbar widget.
202
203 :param before: The item to place this one before.
204
205 :return: True if item inserted sucessful, or Flase in otherwise.
206
207 """
208 return bool(ewe_statusbar_item_insert_before(
209 ewe_statusbar_item_statusbar_get(self.item),
210 before.item,
211 self.item
212 ))
213
214 def insert_after(self, StatusbarItem after not None):
215 """Insert a existent item after another in a given statusbar widget.
216
217 :param after: The item to place this one before.
218
219 :return: True if item inserted sucessful, or False in otherwise.
220
221 """
222 return bool(ewe_statusbar_item_insert_after(
223 ewe_statusbar_item_statusbar_get(self.item),
224 after.item,
225 self.item
226 ))
227
228 def items_swap(self, StatusbarItem item_second not None):
229 """Swap statusbar items positions into statusbar widgets.
230
231 :param item_first: The item, which will be swapped.
232 :param item_second: The item, which will be swapped.
233
234 :return: True if swap is sucessful, or False in otherwise.
235
236 """
237 return bool(ewe_statusbar_items_swap(
238 ewe_statusbar_item_statusbar_get(self.item),
239 self.item,
240 item_second.item
241 ))
242
243 property index:
244 """Get the index of the statusbar item.
245
246 :type: int
247
248 """
249 def __get__(self):
250 return ewe_statusbar_item_id_get(self.item)
251
252 property width:
253 """The width of the statusbar item.
254
255 A width, which will be set as fixed for statusbar item. If
256 param equal -1, then width of statusbar item will be unlimited.
257
258 :type: int
259
260 """
261 def __get__(self):
262 return ewe_statusbar_item_width_get(self.item)
263
264 def __set__(self, int width):
265 if not ewe_statusbar_item_width_set(self.item, width):
266 raise RuntimeError("Width could not be set")
267
268 property label:
269 """Item label.
270
271 :type: string
272
273 """
274 def __get__(self):
275 return _touni(ewe_statusbar_item_label_get(self.item))
276
277 def __set__(self, label):
278 if isinstance(label, unicode):
279 label = PyUnicode_AsUTF8String(label)
280
281 if not ewe_statusbar_item_label_set(
282 self.item,
283 <const char *>label if label is not None else NULL
284 ):
285 raise RuntimeError("Could not set item label")
286
287 property content:
288 """Get the object, which stored into statusbar item.
289
290 :type: :py:class:`efl.evas.Object`
291
292 """
293 def __get__(self):
294 return object_from_instance(
295 ewe_statusbar_item_content_get(self.item)
296 )
297
298 def __set__(self, evasObject content):
299 if not ewe_statusbar_item_content_set(self.item, content.obj):
300 raise RuntimeError("Content could not be set")
301
302 def __del__(self):
303 ewe_statusbar_item_content_unset(self.item)
304
305 property statusbar:
306 """Get the statusbar object from statusbar item.
307
308 :type: :py:class:`Statusbar`
309
310 """
311 def __get__(self):
312 return object_from_instance(
313 ewe_statusbar_item_statusbar_get(self.item)
314 )
315
316 def delete(self):
317 """Remove item from statusbar widget.
318
319 :return: True if item removed sucessful, or False in otherwise.
320
321 """
322 cdef bint ret
323 ret = ewe_statusbar_item_remove(
324 ewe_statusbar_item_statusbar_get(self.item),
325 self.item
326 )
327 self._unset_obj()
328 return ret
329
330
331cdef class Statusbar(Object):
332 def __init__(self, evasObject parent not None, **kwargs):
333 """Add a new statusbar widget to the given parent object.
334
335 :param parent: The parent object
336
337 """
338 self._set_obj(ewe_statusbar_add(parent.obj))
339 self._set_properties_from_keyword_args(kwargs)
340
341 def clear(self):
342 """Remove all items from a given statusbar widget.
343
344 :return: True if items clear sucessful, or False in otherwise.
345
346 This removes (and deletes) all items in given statusbar, leaving it
347 empty.
348
349 """
350 return bool(ewe_statusbar_clear(self.obj))
351
352 property items:
353 """Retrieve a list of the items, which exist into the statusbar.
354
355 :return: a new Eina_List with a pointer to Ewe_Statusbar_Item in its
356 nodes, or None on errors.
357
358 """
359 def __get__(self):
360 return _statusbar_item_list_to_python(
361 ewe_statusbar_items_list_get(self.obj)
362 )
363
364 property padding:
365 """Set the padding between the statusbar items.
366
367 :type: int
368
369 Extra space in pixels that will be added between a statusbar items.
370 This padding is set for all items in the statusbar widget.
371
372 """
373 def __set__(self, int padding):
374 ewe_statusbar_items_padding_set(self.obj, padding)
375
376 def __get__(self):
377 return ewe_statusbar_items_padding_get(self.obj)
378
379 property align:
380 """Alignment of the whole bounding statusbar of items.
381
382 :type: :ref:`Ewe_Statusbar_Items_Align`
383
384 How the bounding box containing all the items of the statusbar, after
385 their sizes and position has been calculated, will be aligned within
386 the space given for the whole statusbar widget.
387
388 """
389 def __set__(self, Ewe_Statusbar_Items_Align align):
390 ewe_statusbar_items_align_set(self.obj, align)
391
392 def __get__(self):
393 return ewe_statusbar_items_align_get(self.obj)
394
diff --git a/efl/ewe/tabs.pxd b/efl/ewe/tabs.pxd
new file mode 100644
index 0000000..47455ac
--- /dev/null
+++ b/efl/ewe/tabs.pxd
@@ -0,0 +1,32 @@
1from efl.eina cimport Eina_Bool, Eina_List, Eina_Stringshare
2from efl.evas cimport Evas_Object, Evas_Smart_Cb
3from enums cimport Ewe_Statusbar_Items_Type, Ewe_Statusbar_Items_Align
4
5
6cdef extern from "ewe.h":
7 ctypedef struct Ewe_Tabs_Item:
8 Evas_Object *owner
9 Evas_Object *head
10 Evas_Object *content
11 Eina_Stringshare *title
12 Eina_Stringshare *style
13 Eina_Bool disabled
14
15 Evas_Object * ewe_tabs_add(Evas_Object *parent)
16 Ewe_Tabs_Item * ewe_tabs_item_append(Evas_Object *obj, Ewe_Tabs_Item *item, Eina_Stringshare *title, Eina_Stringshare *style)
17 Ewe_Tabs_Item * ewe_tabs_item_prepend(Evas_Object *obj, Ewe_Tabs_Item *item, Eina_Stringshare *title, Eina_Stringshare *style)
18 Eina_Bool ewe_tabs_item_del(Evas_Object *obj, Ewe_Tabs_Item *item)
19 const Eina_List * ewe_tabs_items_list_get(const Evas_Object *obj)
20 Eina_Bool ewe_tabs_item_content_set(Evas_Object *obj, Ewe_Tabs_Item *item, Evas_Object *content)
21 Evas_Object * ewe_tabs_item_content_unset(Evas_Object *obj, Ewe_Tabs_Item *item)
22 const Evas_Object * ewe_tabs_item_content_get(Evas_Object *obj, Ewe_Tabs_Item *item)
23 Eina_Bool ewe_tabs_item_icon_set(Evas_Object *obj, Ewe_Tabs_Item *item, Evas_Object *icon)
24 Evas_Object * ewe_tabs_item_icon_unset(Evas_Object *obj, Ewe_Tabs_Item *item)
25 Eina_Bool ewe_tabs_item_button_set(Evas_Object *obj, Ewe_Tabs_Item *item, Evas_Object *button)
26 Evas_Object * ewe_tabs_item_button_unset(Evas_Object *obj, Ewe_Tabs_Item *item)
27 Eina_Bool ewe_tabs_active_item_set(Evas_Object *obj, Ewe_Tabs_Item *item)
28 Ewe_Tabs_Item * ewe_tabs_active_item_get(const Evas_Object *obj)
29 Eina_Bool ewe_tabs_item_title_set(Evas_Object *obj, Ewe_Tabs_Item *item, Eina_Stringshare *title)
30 Eina_Stringshare * ewe_tabs_item_title_get(const Evas_Object *obj, Ewe_Tabs_Item *item)
31 Eina_Bool ewe_tabs_item_disabled_set(Evas_Object *obj, Ewe_Tabs_Item *item, Eina_Bool disabled)
32 Eina_Bool ewe_tabs_item_disabled_get(const Evas_Object *obj, Ewe_Tabs_Item *item)
diff --git a/efl/ewe/tabs.pyx b/efl/ewe/tabs.pyx
new file mode 100644
index 0000000..207f77a
--- /dev/null
+++ b/efl/ewe/tabs.pyx
@@ -0,0 +1,278 @@
1from libc.stdint cimport uintptr_t
2from cpython cimport PyUnicode_AsUTF8String, Py_INCREF, Py_DECREF
3
4from efl.eo cimport object_from_instance
5from efl.utils.conversions cimport _ctouni
6from efl.evas cimport Object as evasObject
7from efl.elementary.object cimport Object
8from efl.ewe.object_item cimport _ObjectItem
9cimport enums
10
11import traceback
12
13
14def _cb_tabs_item_conv(uintptr_t addr):
15 cdef TabsItem it = TabsItem.__new__(TabsItem)
16 it.item = <Ewe_Tabs_Item *>addr
17 return it
18
19cdef _tabs_item_to_python(Ewe_Tabs_Item *it):
20 cdef:
21 TabsItem item
22
23 if it == NULL:
24 return None
25
26 # Create a dummy tabs item.
27 item = TabsItem.__new__(TabsItem)
28 item._set_obj(it)
29
30 return item
31
32cdef _tabs_item_list_to_python(const Eina_List *lst):
33 cdef Ewe_Tabs_Item *it
34 ret = []
35 while lst:
36 it = <Ewe_Tabs_Item *>lst.data
37 lst = lst.next
38 o = _tabs_item_to_python(it)
39 if o is not None:
40 ret.append(o)
41 return ret
42
43
44cdef class TabsItem(_ObjectItem):
45 cdef:
46 Ewe_Tabs_Item *item
47
48 cdef int _set_obj(self, Ewe_Tabs_Item *item) except 0:
49 assert self.item == NULL, "Object must be clean"
50 self.item = item
51 Py_INCREF(self)
52 return 1
53
54 def __richcmp__(TabsItem self, TabsItem y, op):
55 if op == 2:
56 return self.item == y.item
57 elif op == 3:
58 return self.item != y.item
59 else:
60 return NotImplemented
61
62 def __init__(self, *args, **kwargs):
63 self.append(*args, **kwargs)
64
65 @classmethod
66 def append(cls,
67 Tabs tabs not None, TabsItem after=None,
68 title=None, style=None, **kwargs
69 ):
70 """This adds an item after specified item.
71 If no item specified adds as last.
72
73 :param item: The tabs item
74 :param title: The tabs title
75 :param style: The tabs style
76 :return: The new tabs item object or NULL if it cannot be created
77
78 """
79 cdef:
80 void *func_data
81 TabsItem self
82
83 self = cls.__new__(cls)
84
85 if isinstance(title, unicode): title = PyUnicode_AsUTF8String(title)
86 if isinstance(style, unicode): style = PyUnicode_AsUTF8String(style)
87
88 self._set_obj(ewe_tabs_item_append(
89 tabs.obj,
90 <Ewe_Tabs_Item *>after.item if after is not None else NULL,
91 <Eina_Stringshare *>title if title is not None else NULL,
92 <Eina_Stringshare *>style if style is not None else NULL
93 ))
94
95 self._set_properties_from_keyword_args(kwargs)
96
97 return self
98
99 @classmethod
100 def prepend(cls,
101 Tabs tabs not None, TabsItem before=None,
102 title=None, style=None, **kwargs
103 ):
104 """This adds an item before specified item.
105 If no item specified adds as first.
106
107 :param item: The tabs item
108 :param title: The tabs title
109 :param style: The tabs style
110 :return: The new tabs item object or NULL if it cannot be created
111
112 """
113 cdef:
114 void *func_data
115 TabsItem self
116
117 self = cls.__new__(cls)
118
119 if isinstance(title, unicode): title = PyUnicode_AsUTF8String(title)
120 if isinstance(style, unicode): style = PyUnicode_AsUTF8String(style)
121
122 self._set_obj(ewe_tabs_item_prepend(
123 tabs.obj,
124 <Ewe_Tabs_Item *>before.item if before is not None else NULL,
125 <Eina_Stringshare *>title if title is not None else NULL,
126 <Eina_Stringshare *>style if style is not None else NULL
127 ))
128
129 self._set_properties_from_keyword_args(kwargs)
130
131 return self
132
133 def delete(self):
134 """Delete tabs item.
135
136 :param item: The tabs item
137 :return: EINA_TRUE on success, EINA_FALSE otherwise
138
139 """
140 return bool(ewe_tabs_item_del(self.item.owner, self.item))
141
142 property content:
143 """Content of tabs item
144
145 :type: :py:class:`efl.evas.Object`
146
147 """
148 def __set__(self, evasObject content):
149 if not ewe_tabs_item_content_set(
150 self.item.owner, self.item, content.obj
151 ):
152 raise RuntimeError
153
154 def __del__(self):
155 ewe_tabs_item_content_unset(self.item.owner, self.item)
156
157 def __get__(self):
158 return object_from_instance(ewe_tabs_item_content_get(
159 self.item.owner, self.item
160 ))
161
162
163 property icon:
164 """Icon of tabs item
165
166 :type: :py:class:`efl.evas.Object`
167
168 """
169 def __set__(self, evasObject icon not None):
170 if not ewe_tabs_item_icon_set(self.item.owner, self.item, icon.obj):
171 raise RuntimeError
172
173 def __del__(self):
174 ewe_tabs_item_icon_unset(self.item.owner, self.item)
175
176 property button:
177 """Button of tabs item.
178
179 :type: :py:class:`efl.evas.Object`
180
181 """
182 def __set__(self, evasObject button not None):
183 if not ewe_tabs_item_button_set(self.item.owner, self.item, button.obj):
184 raise RuntimeError
185
186 def __del__(self):
187 ewe_tabs_item_button_unset(self.item.owner, self.item)
188
189 def activate(self):
190 """This activates tabs item.
191
192 :param item: The tabs item
193 :return: EINA_TRUE on success, EINA_FALSE otherwise
194
195 """
196 return bool(ewe_tabs_active_item_set(self.item.owner, self.item))
197
198 property title:
199 """Title of the tabs item.
200
201 :type: string
202
203 """
204 def __set__(self, title):
205 if isinstance(title, unicode):
206 title = PyUnicode_AsUTF8String(title)
207 if not ewe_tabs_item_title_set(
208 self.item.owner, self.item, title
209 ):
210 raise RuntimeError
211
212 def __get__(self):
213 return _ctouni(ewe_tabs_item_title_get(self.item.owner, self.item))
214
215 property disabled:
216 """This enables or disables tabs item.
217
218 Notes: user cannot switch to disabled tabs item.
219 If it is active allready or is activated from code
220 items content will be also rendered disabled.
221
222 :param item: The tabs item
223 :param disabled: EINA_TRUE to disable, EINA_FALSE to enable tabs item
224 :return: EINA_TRUE on success, EINA_FALSE otherwise
225
226 """
227 def __set__(self, bint disabled):
228 if not ewe_tabs_item_disabled_set(self.item.owner, self.item, disabled):
229 raise RuntimeError
230
231 def __get__(self):
232 return bool(ewe_tabs_item_disabled_get(self.item.owner, self.item))
233
234cdef class Tabs(Object):
235 def __init__(self, evasObject parent not None, **kwargs):
236 """This adds tabs to @p parent object.
237
238 :param parent: The parent object
239 :return: The new object or NULL if it cannot be created
240
241 """
242 self._set_obj(ewe_tabs_add(parent.obj))
243 self._set_properties_from_keyword_args(kwargs)
244
245 property items:
246 """Get internal items list.
247
248 :param obj: The tabs object
249 :return: list of items on success, NULL otherwise
250
251 """
252 def __get__(self):
253 return _tabs_item_list_to_python(ewe_tabs_items_list_get(self.obj))
254
255 property active_item:
256 """Get active item item.
257
258 :return: Ewe_Tabs_Item* on success, NULL otherwise
259
260 """
261 def __get__(self):
262 return _tabs_item_to_python(ewe_tabs_active_item_get(self.obj))
263
264 def callback_item_activated_add(self, func, *args, **kwargs):
265 self._callback_add_full("ewe,tabs,item,activated", _cb_tabs_item_conv,
266 func, *args, **kwargs)
267
268 def callback_item_activated_del(self, func):
269 self._callback_del_full("ewe,tabs,item,activated", _cb_tabs_item_conv,
270 func)
271
272 def callback_item_deactivated_add(self, func, *args, **kwargs):
273 self._callback_add_full("ewe,tabs,item,deactivated", _cb_tabs_item_conv,
274 func, *args, **kwargs)
275
276 def callback_item_deactivated_del(self, func):
277 self._callback_del_full("ewe,tabs,item,deactivated", _cb_tabs_item_conv,
278 func)
diff --git a/examples/ewe/ruler_example.edc b/examples/ewe/ruler_example.edc
new file mode 100644
index 0000000..02df06d
--- /dev/null
+++ b/examples/ewe/ruler_example.edc
@@ -0,0 +1,26 @@
1collections {
2 group { name: "view";
3 parts {
4 part { name: "ruler_hor";
5 type: SWALLOW;
6 description {
7 state: "default 0.0";
8 align: 0.5 0.0;
9 max: -1 60;
10 rel1.offset: 80 20;
11 rel2.offset: -20 -20;
12 }
13 }
14 part { name: "ruler_ver";
15 type: SWALLOW;
16 description {
17 state: "default 0.0";
18 align: 0.0 0.5;
19 max: 60 -1;
20 rel1.offset: 20 80;
21 rel2.offset: 20 -20;
22 }
23 }
24 }
25 }
26}
diff --git a/examples/ewe/ruler_example.edj b/examples/ewe/ruler_example.edj
new file mode 100644
index 0000000..bd0f7de
--- /dev/null
+++ b/examples/ewe/ruler_example.edj
Binary files differ
diff --git a/examples/ewe/statusbar.edc b/examples/ewe/statusbar.edc
new file mode 100644
index 0000000..b39ed54
--- /dev/null
+++ b/examples/ewe/statusbar.edc
@@ -0,0 +1,53 @@
1collections {
2 group { name: "window";
3 parts {
4 part { name: "background";
5 type: RECT;
6 description { state: "default" 0.0;
7 color: 64 64 64 255;
8 }
9 }
10 part { name: "ewe.swallow.content";
11 type: SWALLOW;
12 description { state: "default" 0.0;
13 rel2 {
14 relative: 1 0;
15 offset: -1 -2;
16 to: "ewe.swallow.statusbar";
17 }
18 }
19 }
20 part { name: "ewe.swallow.statusbar";
21 type: SWALLOW;
22 description { state: "default" 0.0;
23 align: 0 1;
24 min: 0 29;
25 max: -1 29;
26 rel2 {
27 offset: 0 0;
28 }
29 }
30 }
31 part { name: "bevel";
32 type: RECT;
33 description { state: "default" 0.0;
34 align: 0.5 1;
35 min: 0 2;
36 max: -1 2;
37 fixed: 1 1;
38 color: 255 90 0 255;
39 rel1 {
40 to_y: "ewe.swallow.statusbar";
41 }
42 rel2 {
43 relative: 1 0;
44 offset: 0 0;
45 to_y: "ewe.swallow.statusbar";
46 }
47 }
48 }
49 }
50 }
51}
52
53
diff --git a/examples/ewe/statusbar.edj b/examples/ewe/statusbar.edj
new file mode 100644
index 0000000..747d81e
--- /dev/null
+++ b/examples/ewe/statusbar.edj
Binary files differ
diff --git a/examples/ewe/test.py b/examples/ewe/test.py
new file mode 100755
index 0000000..3284c14
--- /dev/null
+++ b/examples/ewe/test.py
@@ -0,0 +1,158 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4import logging
5elog = logging.getLogger("efl")
6elog.setLevel(logging.INFO)
7
8elog_form = logging.Formatter(
9 "[%(name)s] %(levelname)s in %(funcName)s:%(lineno)d - %(message)s"
10 )
11elog_hdlr = logging.StreamHandler()
12elog_hdlr.setFormatter(elog_form)
13
14elog.addHandler(elog_hdlr)
15
16eolog = logging.getLogger("efl.eo")
17eolog.setLevel(logging.INFO)
18
19evaslog = logging.getLogger("efl.evas")
20evaslog.setLevel(logging.INFO)
21
22from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
23from efl import elementary
24from efl.elementary.window import StandardWindow
25from efl.elementary.box import Box, ELM_BOX_LAYOUT_FLOW_HORIZONTAL
26from efl.elementary.button import Button
27from efl.elementary.frame import Frame
28from efl.elementary.label import Label
29from efl.elementary.check import Check
30from efl.elementary.entry import Entry
31from efl.elementary.scroller import Scroller
32
33from efl.elementary.configuration import Configuration
34elm_conf = Configuration()
35
36elog.setLevel(logging.DEBUG)
37
38EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
39FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
40
41items = [
42 ("Combobox", [
43 ("Combobox", "test_combobox", "combobox_clicked"),
44 ]),
45 ("Entry", [
46 ("Entry", "test_entry", "entry_clicked"),
47 ]),
48 ("Ruler", [
49 ("Ruler", "test_ruler", "ruler_clicked"),
50 ]),
51 ("Statusbar", [
52 ("Statusbar", "test_statusbar", "statusbar_clicked"),
53 ]),
54 ("Tabs", [
55 ("Tabs", "test_tabs", "tabs_clicked"),
56 ])
57 ]
58
59
60def selected_cb(o, mod, func):
61 exec("from {0} import {1}; {1}(o)".format(mod, func))
62
63
64def menu_create(search, win):
65 tbx.clear()
66 for category in items:
67 frame = Frame(win, size_hint_weight=EXPAND_BOTH,
68 size_hint_align=FILL_BOTH, text=category[0])
69 frame.show()
70 tbx.pack_end(frame)
71
72 tbx2 = Box(win, layout=ELM_BOX_LAYOUT_FLOW_HORIZONTAL,
73 size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
74 size_hint_align=(EVAS_HINT_FILL, 0.0))
75 frame.content_set(tbx2)
76 tbx2.show()
77
78 cnt = 0
79 for test in category[1]:
80 if search is None or test[0].lower().find(search.lower()) > -1:
81 bt = Button(win, text=test[0])
82 bt.callback_clicked_add(selected_cb, test[1], test[2])
83 bt.show()
84 tbx2.pack_end(bt)
85 cnt += 1
86
87 if cnt < 1:
88 frame.delete()
89
90
91def destroy(obj, str1, str2, str3, str4):
92 elementary.exit()
93
94
95def cb_mirroring(toggle):
96 elm_conf.mirrored = toggle.state
97
98
99def cb_filter(en, win):
100 menu_create(en.text_get(), win)
101
102if __name__ == "__main__":
103 elementary.init()
104 win = StandardWindow("test", "Python EFL test application")
105 win.callback_delete_request_add(destroy, "test1", "test2",
106 str3="test3", str4="test4")
107
108 box0 = Box(win, size_hint_weight=EXPAND_BOTH)
109 win.resize_object_add(box0)
110 box0.show()
111
112 lb = Label(win)
113 lb.text = ("Please select a test from the list below by clicking<br>"
114 "the test button to show the test window.")
115 lb.show()
116
117 fr = Frame(win, text="Information", content=lb)
118 box0.pack_end(fr)
119 fr.show()
120
121 tg = Check(win, style="toggle", text="UI-Mirroring:")
122 tg.callback_changed_add(cb_mirroring)
123 box0.pack_end(tg)
124 tg.show()
125
126 bx1 = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
127 size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True)
128 box0.pack_end(bx1)
129 bx1.show()
130
131 lb = Label(win, text="Filter:")
132 bx1.pack_end(lb)
133 lb.show()
134
135 en = Entry(win, single_line=True, scrollable=True,
136 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
137 en.part_text_set("guide", "Type widget name here to search.")
138 en.callback_changed_add(cb_filter, win)
139 bx1.pack_end(en)
140 en.show()
141 en.focus_set(True)
142
143 sc = Scroller(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
144 bounce=(False, True))
145 sc.show()
146 box0.pack_end(sc)
147
148 tbx = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0),
149 size_hint_align=(EVAS_HINT_FILL, 0.0))
150 sc.content_set(tbx)
151 tbx.show()
152
153 menu_create(None, win)
154
155 win.resize(480, 480)
156 win.show()
157 elementary.run()
158 elementary.shutdown()
diff --git a/examples/ewe/test_combobox.py b/examples/ewe/test_combobox.py
new file mode 100644
index 0000000..ed11132
--- /dev/null
+++ b/examples/ewe/test_combobox.py
@@ -0,0 +1,64 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary
6from efl import ewe
7from efl.ewe.combobox import Combobox, ComboboxItem
8from efl.elementary.box import Box
9from efl.elementary.window import StandardWindow
10
11EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
12EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
13FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
14FILL_HORIZ = EVAS_HINT_FILL, 0.5
15
16
17def collapsed(obj):
18 print("collapsed")
19
20
21def expanded(obj):
22 print("expanded")
23
24
25def selected(obj, item):
26 print(item)
27
28
29def combobox_clicked(obj):
30 win = StandardWindow(
31 "combobox", "Combobox", autodel=True,
32 size=(320, 200)
33 )
34 if obj is None:
35 win.callback_delete_request_add(lambda o: elementary.exit())
36
37 bx = Box(win, size_hint_weight=EXPAND_BOTH)
38 win.resize_object_add(bx)
39 bx.show()
40
41 cb = Combobox(
42 win, size_hint_weight=EXPAND_BOTH,
43 size_hint_align=FILL_BOTH,
44 )
45
46 cb.callback_collapsed_add(collapsed)
47 cb.callback_expanded_add(expanded)
48 cb.callback_selected_add(selected)
49
50 for i in range(5):
51 ComboboxItem(cb, str(i))
52
53 bx.pack_end(cb)
54 cb.show()
55
56 win.show()
57
58if __name__ == "__main__":
59 ewe.init()
60
61 combobox_clicked(None)
62
63 elementary.run()
64 ewe.shutdown()
diff --git a/examples/ewe/test_entry.py b/examples/ewe/test_entry.py
new file mode 100644
index 0000000..70bec1e
--- /dev/null
+++ b/examples/ewe/test_entry.py
@@ -0,0 +1,94 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary
6from efl import ewe
7from efl.elementary.box import Box
8from efl.elementary.label import Label
9from efl.elementary.window import StandardWindow
10from efl.ewe.entry import Entry
11
12EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
13EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
14FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
15FILL_HORIZ = EVAS_HINT_FILL, 0.5
16
17
18def on_changed(obj, entry2, entry3):
19 entry = entry2.entry
20 if entry and entry2.regex_set(entry, 0):
21 entry3.regex_set(entry, 0)
22 entry3.editable = True
23 entry3.regex_autocheck = True
24 entry3.regex_check()
25 entry3.regex_glow = True
26 else:
27 print("Error Message: %s" % entry2.regex_error_text_get())
28 entry3.regex_unset()
29 entry3.editable = False
30 entry3.regex_autocheck = False
31 entry3.entry = ""
32 entry3.regex_glow = False
33
34
35def entry_clicked(obj):
36 win = StandardWindow(
37 "entry", "Entry", autodel=True,
38 size=(400, 400)
39 )
40 if obj is None:
41 win.callback_delete_request_add(lambda o: elementary.exit())
42
43 box = Box(win, size_hint_weight=EXPAND_BOTH)
44 win.resize_object_add(box)
45
46 # Entry to enter regex
47 ebox = Box(box, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
48
49 entry2 = Entry(
50 box, scrollable=True, single_line=True,
51 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH
52 )
53
54 entry2.show()
55
56 label = Label(box, text="Enter regex:")
57 label.show()
58
59 ebox.pack_end(label)
60 ebox.pack_end(entry2)
61 ebox.show()
62 box.pack_end(ebox)
63
64 # Entry to check regex
65 ebox = Box(box, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
66
67 entry3 = Entry(
68 ebox, scrollable=True, single_line=True, editable=False,
69 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH
70 )
71 entry3.show()
72
73 label = Label(box, text="Check regex:")
74 label.show()
75
76 ebox.pack_end(label)
77 ebox.pack_end(entry3)
78
79 ebox.show()
80 box.pack_end(ebox)
81
82 entry2.callback_changed_add(on_changed, entry2, entry3)
83
84 box.show()
85 win.show()
86
87
88if __name__ == "__main__":
89 ewe.init()
90
91 entry_clicked(None)
92
93 elementary.run()
94 ewe.shutdown()
diff --git a/examples/ewe/test_ruler.py b/examples/ewe/test_ruler.py
new file mode 100644
index 0000000..7d29f57
--- /dev/null
+++ b/examples/ewe/test_ruler.py
@@ -0,0 +1,97 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary
6from efl import ewe
7from efl.ewe.ruler import Ruler, EWE_RULER_ORIENT_VERTICAL
8from efl.elementary.layout import Layout
9from efl.elementary.spinner import Spinner
10from efl.elementary.window import StandardWindow
11
12EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
13EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
14FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
15FILL_HORIZ = EVAS_HINT_FILL, 0.5
16
17
18RULER_HOR = "ruler_hor"
19RULER_VER = "ruler_ver"
20
21
22def offset_cb(obj):
23 val = obj.value
24 obj.data[RULER_HOR].zero_offset = val
25 obj.data[RULER_VER].zero_offset = val
26 print("Zero offset changed to %d" % val)
27
28
29def step_cb(obj):
30 val = obj.value
31 obj.data[RULER_HOR].step = val
32 obj.data[RULER_VER].step = val
33 print("Step between marks of the ruler has changed to %d" % val)
34
35
36def ruler_clicked(obj):
37 win = StandardWindow(
38 "ruler", "Ruler", autodel=True,
39 size=(740, 740)
40 )
41 if obj is None:
42 win.callback_delete_request_add(lambda o: elementary.exit())
43
44 step = 100
45
46 layout = Layout(win, size_hint_weight=EXPAND_BOTH)
47 win.resize_object_add(layout)
48 layout.file_set("ruler_example.edj", "view")
49 layout.show()
50
51 ruler_hor = Ruler(win)
52 layout.content_set("ruler_hor", ruler_hor)
53 ruler_hor.step = step
54 ruler_hor.show()
55
56 layout = Layout(win, size_hint_weight=EXPAND_BOTH)
57 win.resize_object_add(layout)
58 layout.file_set("ruler_example.edj", "view")
59 layout.show()
60
61 ruler_ver = Ruler(win)
62 layout.content_set("ruler_ver", ruler_ver)
63 ruler_ver.orient = EWE_RULER_ORIENT_VERTICAL
64 ruler_ver.step = step
65 ruler_ver.show()
66
67 spinner1 = Spinner(
68 win, step=10, min_max=(-10000.0, 10000.0), editable=True,
69 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ,
70 geometry=(350, 350, 210, 25)
71 )
72 spinner1.label_format = "Zero offset is %1.0f"
73 spinner1.show()
74 spinner1.data[RULER_HOR] = ruler_hor
75 spinner1.data[RULER_VER] = ruler_ver
76 spinner1.callback_changed_add(offset_cb)
77
78 spinner2 = Spinner(
79 win, step=5, min_max=(0, 1000.0), value=100, editable=True,
80 size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_BOTH,
81 geometry=(350, 390, 210, 25)
82 )
83 spinner2.label_format = "Step between marks is %1.0f"
84 spinner2.show()
85 spinner2.data[RULER_HOR] = ruler_hor
86 spinner2.data[RULER_VER] = ruler_ver
87 spinner2.callback_changed_add(step_cb)
88
89 win.show()
90
91if __name__ == "__main__":
92 ewe.init()
93
94 ruler_clicked(None)
95
96 elementary.run()
97 ewe.shutdown()
diff --git a/examples/ewe/test_statusbar.py b/examples/ewe/test_statusbar.py
new file mode 100644
index 0000000..c315e2d
--- /dev/null
+++ b/examples/ewe/test_statusbar.py
@@ -0,0 +1,184 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary
6from efl import ewe
7from efl.ewe.statusbar import Statusbar, StatusbarItem, \
8 EWE_STATUSBAR_ITEM_TYPE_OBJECT, EWE_STATUSBAR_ITEM_TYPE_SEPARATOR
9from efl.elementary.entry import Entry
10from efl.elementary.window import Window, ELM_WIN_BASIC
11from efl.elementary.background import Background
12from efl.elementary.label import Label
13from efl.elementary.button import Button
14from efl.elementary.layout import Layout
15from efl.elementary.progressbar import Progressbar
16from efl.elementary.clock import Clock
17
18EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
19EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
20FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
21FILL_HORIZ = EVAS_HINT_FILL, 0.5
22
23checked = False
24
25
26def item_cb(obj, item, data):
27 progressbar = data
28 if progressbar.value >= 1:
29 progressbar.value += 0.1
30 else:
31 progressbar.value += 0.1
32
33
34def item_del_cb(obj, item, data):
35 label = data
36 print("item deleted: " + str(item.delete()))
37 count = len(obj.items)
38 label.text = str(count)
39
40
41def unswallow_cb(obj, data):
42 item = data
43
44 content = item.content
45 del item.content
46
47 if not content:
48 print("Unset object is None")
49 try:
50 item.content = obj
51 except RuntimeError:
52 pass
53 else:
54 obj.text = "UnSet me"
55 item.label = "Unset"
56 item.width = 220
57 return
58
59 if content is not obj:
60 print("Unsetted object not equal to button")
61 return
62
63 obj.text = "Set me"
64 item.label = "Unset"
65 item.width = 120
66 content.move(50, 50)
67
68
69def reorder_cb(obj, data):
70 item = obj.data["tst"]
71 before = obj.data["tst2"]
72 after = data
73 #it_index = item.index
74 global checked
75
76 if checked:
77 item.insert_after(after)
78 else:
79 item.insert_before(before)
80
81 checked = not checked
82
83
84def statusbar_clicked(obj):
85 win = Window(
86 "statusbar", ELM_WIN_BASIC, title="Statusbar", autodel=True,
87 size=(1200, 300)
88 )
89 if obj is None:
90 win.callback_delete_request_add(lambda o: elementary.exit())
91
92 bg = Background(
93 win, size_hint_weight=EXPAND_BOTH, color=(90, 255, 255)
94 )
95 bg.show()
96
97 markup = Layout(win, size_hint_weight=EXPAND_BOTH)
98 win.resize_object_add(markup)
99
100 try:
101 markup.file = ("statusbar.edj", "window")
102 except RuntimeError:
103 print("Something wrong with layout file st")
104
105 statusbar = Statusbar(markup)
106 statusbar.show()
107
108 markup.content_set("ewe.swallow.statusbar", statusbar)
109 markup.content_set("ewe.swallow.content", bg)
110 markup.show()
111
112 progressbar = Progressbar(markup)
113 progressbar.show()
114 reorder_button = Button(statusbar)
115
116 obj = Entry(statusbar, single_line=True, entry="Testing")
117
118 item = StatusbarItem.append(
119 statusbar, progressbar, EWE_STATUSBAR_ITEM_TYPE_OBJECT, label="PB: "
120 )
121
122 item = StatusbarItem.append(
123 statusbar, reorder_button, EWE_STATUSBAR_ITEM_TYPE_OBJECT,
124 item_cb, progressbar, label="Reorder: "
125 )
126 reorder_button.data["tst"] = item
127
128 button = Button(statusbar)
129 item = StatusbarItem.append(
130 statusbar, button, EWE_STATUSBAR_ITEM_TYPE_OBJECT, label="Unset"
131 )
132 button.callback_clicked_add(unswallow_cb, item)
133 reorder_button.callback_clicked_add(reorder_cb, item)
134
135 StatusbarItem.append(statusbar, button, EWE_STATUSBAR_ITEM_TYPE_SEPARATOR)
136 StatusbarItem.append(
137 statusbar, obj, EWE_STATUSBAR_ITEM_TYPE_OBJECT, label="Entry: "
138 )
139
140 StatusbarItem.append(
141 statusbar, type=EWE_STATUSBAR_ITEM_TYPE_OBJECT, label="None: "
142 )
143
144 label = Label(statusbar)
145
146 button = Button(statusbar)
147 item = StatusbarItem.append(
148 statusbar, button, EWE_STATUSBAR_ITEM_TYPE_OBJECT, item_del_cb, label,
149 label="Delete me "
150 )
151
152 StatusbarItem.append(statusbar, button, EWE_STATUSBAR_ITEM_TYPE_SEPARATOR)
153
154 obj = Clock(statusbar)
155 item = StatusbarItem.append(
156 statusbar, obj, EWE_STATUSBAR_ITEM_TYPE_OBJECT
157 )
158 item.label = " "
159
160 item = StatusbarItem.append(
161 statusbar, label, EWE_STATUSBAR_ITEM_TYPE_OBJECT, width=100,
162 label="Count"
163 )
164 reorder_button.data["tst2"] = item
165
166 item = StatusbarItem.append(
167 statusbar, button, EWE_STATUSBAR_ITEM_TYPE_SEPARATOR
168 )
169 items = statusbar.items
170 count = len(items)
171 label.text = str(count)
172
173 print("Items count %d" % count)
174
175 win.show()
176
177
178if __name__ == "__main__":
179 ewe.init()
180
181 statusbar_clicked(None)
182
183 elementary.run()
184 ewe.shutdown()
diff --git a/examples/ewe/test_tabs.py b/examples/ewe/test_tabs.py
new file mode 100644
index 0000000..4542715
--- /dev/null
+++ b/examples/ewe/test_tabs.py
@@ -0,0 +1,87 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
5from efl import elementary
6from efl import ewe
7from efl.ewe.tabs import Tabs, TabsItem
8from efl.elementary.label import Label
9from efl.elementary.button import Button
10from efl.elementary.window import StandardWindow
11
12EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
13EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
14FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
15FILL_HORIZ = EVAS_HINT_FILL, 0.5
16
17
18def on_click(obj, data):
19 it = data
20 it.delete()
21
22
23def on_activate(obj, it):
24 print("Activated item: [%s]" % it.title)
25
26
27def on_deactivate(obj, it):
28 print("Deactivated item: [%s]" % it.title)
29
30
31def tabs_clicked(obj):
32 win = StandardWindow(
33 "tabs", "Tabs", autodel=True, size=(1000, 600)
34 )
35 if obj is None:
36 win.callback_delete_request_add(lambda o: elementary.exit())
37
38 tabs = Tabs(win)
39 tabs.callback_item_activated_add(on_activate)
40 tabs.callback_item_deactivated_add(on_deactivate)
41
42 lbl = Label(win, text="TEXT 1")
43 lbl2 = Label(win, text="TEXT 2")
44 lbl3 = Label(win, text="TEXT 3")
45
46 it = TabsItem.append(tabs, title="test_tabs")
47 it.content = lbl
48 it = TabsItem.append(tabs, title="test_tabs")
49 it.disabled = True
50 it_cannot_del = TabsItem.append(tabs, title="Can't delete me :P")
51 btn = Button(tabs)
52 btn.callback_clicked_add(on_click, it_cannot_del)
53 it_cannot_del.icon = btn
54 it = TabsItem.append(tabs, title="test_tabs")
55 it = TabsItem.append(tabs, None, "test_tabs2 with long text", "red")
56 it = TabsItem.prepend(tabs, it, "test_tabs2 with long text", "green")
57 it.title = "tabs item 2 with resetted title"
58 it.content = lbl2
59
60 del it.content
61
62 it = TabsItem.append(tabs, style="blue")
63 it.title = "tabs item 3 :)"
64 it.content = lbl3
65
66 items = tabs.items
67 for it in items:
68 if it == it_cannot_del:
69 continue
70 btn = Button(tabs)
71 btn.callback_clicked_add(on_click, it)
72 it.button = btn
73
74 win.resize_object_add(tabs)
75 lbl3.show()
76
77 tabs.show()
78
79 win.show()
80
81if __name__ == "__main__":
82 ewe.init()
83
84 tabs_clicked(None)
85
86 elementary.run()
87 ewe.shutdown()
diff --git a/setup.py b/setup.py
index dee9e17..e88e3a1 100755
--- a/setup.py
+++ b/setup.py
@@ -29,6 +29,7 @@ if RELEASE.split(".")[2] == "99":
29CYTHON_MIN_VERSION = "0.19" 29CYTHON_MIN_VERSION = "0.19"
30EFL_MIN_VERSION = "1.10.99" 30EFL_MIN_VERSION = "1.10.99"
31ELM_MIN_VERSION = "1.10.99" 31ELM_MIN_VERSION = "1.10.99"
32EWE_MIN_VERSION = "0.1.0"
32 33
33 34
34# XXX: Force default visibility. See phab T504 35# XXX: Force default visibility. See phab T504
@@ -415,6 +416,35 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
415 416
416 packages.append("efl.elementary") 417 packages.append("efl.elementary")
417 418
419 # === Ewe ===
420 try:
421 ewe_cflags, ewe_libs = pkg_config(
422 'Ewe', 'ewe', EWE_MIN_VERSION
423 )
424 except SystemExit:
425 pass
426 else:
427 ewe_mods = (
428 "__init__",
429 "object_item",
430 "combobox",
431 "entry",
432 "ruler",
433 "statusbar",
434 "tabs"
435 )
436
437 for m in ewe_mods:
438 e = Extension(
439 "ewe." + m,
440 ["efl/ewe/" + m + module_suffix],
441 include_dirs=["include/"],
442 extra_compile_args=ewe_cflags,
443 extra_link_args=ewe_libs + eina_libs + evas_libs,
444 )
445 modules.append(e)
446
447 packages.append("efl.ewe")
418 448
419setup( 449setup(
420 name="python-efl", 450 name="python-efl",