summaryrefslogtreecommitdiff
path: root/efl/elementary/need.pyx
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-04-20 06:25:43 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2015-04-20 06:27:10 +0300
commitc08888239f30f8bc8f4707650cedd819a9a09b00 (patch)
treed9462accc1ed0c0fb2f43030054cbacc6934a023 /efl/elementary/need.pyx
parent6532ef85f6ef2118b0fcf59edbf7417ed17aceed (diff)
Elm: Move ecore events registration out of init
Diffstat (limited to 'efl/elementary/need.pyx')
-rw-r--r--efl/elementary/need.pyx111
1 files changed, 108 insertions, 3 deletions
diff --git a/efl/elementary/need.pyx b/efl/elementary/need.pyx
index 52eeea0..bb9f4dd 100644
--- a/efl/elementary/need.pyx
+++ b/efl/elementary/need.pyx
@@ -29,6 +29,87 @@ This functions are used to tell elementary of optionals modules usage.
29 29
30 30
31from efl.utils.deprecated cimport DEPRECATED 31from efl.utils.deprecated cimport DEPRECATED
32from efl.utils.conversions cimport _touni
33from efl.ecore cimport Event, _event_mapping_register
34
35
36cdef class SysNotifyNotificationClosed(Event):
37
38 cdef Elm_Sys_Notify_Notification_Closed *obj
39
40 cdef int _set_obj(self, void *o) except 0:
41 self.obj = <Elm_Sys_Notify_Notification_Closed*>o
42 return 1
43
44 def __repr__(self):
45 # TODO: int -> string for 'reason'
46 return "<%s(id=%d, reason=%s)>" % \
47 (type(self).__name__, self.id, self.reason)
48
49 property id:
50 """ID of the notification.
51
52 :type: int
53
54 """
55 def __get__(self):
56 return self.obj.id
57
58 property reason:
59 """The Reason the notification was closed.
60
61 :type: :ref:`Elm_Sys_Notify_Closed_Reason`
62
63 """
64 def __get__(self):
65 return self.obj.reason
66
67
68cdef class SysNotifyActionInvoked(Event):
69
70 cdef Elm_Sys_Notify_Action_Invoked *obj
71
72 cdef int _set_obj(self, void *o) except 0:
73 self.obj = <Elm_Sys_Notify_Action_Invoked*>o
74 return 1
75
76 def __repr__(self):
77 return "<%s(id=%d, action_key=%s)>" % \
78 (type(self).__name__, self.id, self.action_key)
79
80 property id:
81 """ID of the notification.
82
83 :type: int
84
85 """
86 def __get__(self):
87 return self.obj.id
88
89 property action_key:
90 """The key of the action invoked. These match the keys sent over in the
91 list of actions.
92
93 :type: string
94
95 """
96 def __get__(self):
97 return _touni(self.obj.action_key)
98
99
100cdef class EthumbConnect(Event):
101 cdef int _set_obj(self, void *o) except 0:
102 return 1
103
104 def __repr__(self):
105 return "<%s()>" % (self.__class__.__name__,)
106
107cdef class EventSystrayReady(Event):
108 cdef int _set_obj(self, void *o) except 0:
109 return 1
110
111 def __repr__(self):
112 return "<%s()>" % (self.__class__.__name__,)
32 113
33 114
34def need_efreet(): 115def need_efreet():
@@ -57,7 +138,13 @@ def need_systray():
57 .. versionadded:: 1.8 138 .. versionadded:: 1.8
58 139
59 """ 140 """
60 return bool(elm_need_systray()) 141 cdef bint ret = elm_need_systray()
142 if ret:
143 try:
144 _event_mapping_register(ELM_EVENT_SYSTRAY_READY, EventSystrayReady)
145 except ValueError:
146 pass
147 return ret
61 148
62def need_sys_notify(): 149def need_sys_notify():
63 """Request that your elementary application needs Elm_Sys_Notify 150 """Request that your elementary application needs Elm_Sys_Notify
@@ -72,7 +159,20 @@ def need_sys_notify():
72 .. versionadded:: 1.8 159 .. versionadded:: 1.8
73 160
74 """ 161 """
75 return bool(elm_need_sys_notify()) 162 cdef bint ret = elm_need_sys_notify()
163 if ret:
164 try:
165 _event_mapping_register(
166 ELM_EVENT_SYS_NOTIFY_NOTIFICATION_CLOSED,
167 SysNotifyNotificationClosed
168 )
169 _event_mapping_register(
170 ELM_EVENT_SYS_NOTIFY_ACTION_INVOKED,
171 SysNotifyActionInvoked
172 )
173 except ValueError:
174 pass
175 return ret
76 176
77@DEPRECATED("1.8", "Use :py:func:`need_eldbus` for eldbus (v2) support. Old API is deprecated.") 177@DEPRECATED("1.8", "Use :py:func:`need_eldbus` for eldbus (v2) support. Old API is deprecated.")
78def need_e_dbus(): 178def need_e_dbus():
@@ -131,7 +231,12 @@ def need_ethumb():
131 :rtype: bool 231 :rtype: bool
132 232
133 """ 233 """
134 return bool(elm_need_ethumb()) 234 cdef bint ret = elm_need_ethumb()
235 try:
236 _event_mapping_register(ELM_ECORE_EVENT_ETHUMB_CONNECT, EthumbConnect)
237 except ValueError:
238 pass
239 return ret
135 240
136def need_web(): 241def need_web():
137 """Request that your elementary application needs web support 242 """Request that your elementary application needs web support