Elementary: Add module systray
Test/example needs more work
This commit is contained in:
parent
d141a912e5
commit
2ce228be96
|
@ -120,6 +120,7 @@ Inheritance diagram
|
|||
efl.elementary.slider
|
||||
efl.elementary.slideshow
|
||||
efl.elementary.spinner
|
||||
efl.elementary.systray
|
||||
efl.elementary.table
|
||||
efl.elementary.theme
|
||||
efl.elementary.thumb
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
.. automodule:: efl.elementary.systray
|
|
@ -34,10 +34,10 @@ cdef Eina_Bool event_handler_cb(void *data, int type, void *event) with gil:
|
|||
cdef EventHandler handler
|
||||
cdef Eina_Bool r
|
||||
|
||||
assert event != NULL
|
||||
assert data != NULL
|
||||
#assert event != NULL
|
||||
assert data != NULL, "data should not be NULL!"
|
||||
handler = <EventHandler>data
|
||||
assert type == handler.type
|
||||
assert type == handler.type, "handler type isn't the same as event type!"
|
||||
|
||||
try:
|
||||
r = handler._exec(event)
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
from efl.eina cimport Eina_Bool, Eina_List
|
||||
from efl.evas cimport Evas_Object, Evas_Coord
|
||||
from efl.c_eo cimport Eo, Eo_Class
|
||||
|
||||
cdef extern from "Elementary.h":
|
||||
|
||||
ctypedef Eo Elm_Systray
|
||||
|
||||
cpdef enum:
|
||||
ELM_EVENT_SYSTRAY_READY
|
||||
|
||||
cpdef enum _Elm_Systray_Category:
|
||||
ELM_SYSTRAY_CATEGORY_APP_STATUS
|
||||
ELM_SYSTRAY_CATEGORY_COMMUNICATIONS
|
||||
ELM_SYSTRAY_CATEGORY_SYS_SERVICES
|
||||
ELM_SYSTRAY_CATEGORY_HARDWARE
|
||||
ELM_SYSTRAY_CATEGORY_OTHER
|
||||
ctypedef _Elm_Systray_Category Elm_Systray_Category
|
||||
|
||||
cpdef enum _Elm_Systray_Status:
|
||||
ELM_SYSTRAY_STATUS_PASSIVE
|
||||
ELM_SYSTRAY_STATUS_ACTIVE
|
||||
ELM_SYSTRAY_STATUS_ATTENTION
|
||||
ctypedef _Elm_Systray_Status Elm_Systray_Status
|
||||
|
||||
const Eo_Class *elm_systray_class_get()
|
||||
|
||||
void elm_obj_systray_id_set(const char *id)
|
||||
const char * elm_obj_systray_id_get()
|
||||
void elm_obj_systray_category_set(Elm_Systray_Category cat)
|
||||
Elm_Systray_Category elm_obj_systray_category_get()
|
||||
void elm_obj_systray_icon_theme_path_set(const char *icon_theme_path)
|
||||
const char * elm_obj_systray_icon_theme_path_get()
|
||||
void elm_obj_systray_menu_set(const Eo *menu)
|
||||
const Eo * elm_obj_systray_menu_get()
|
||||
void elm_obj_systray_att_icon_name_set(const char *att_icon_name)
|
||||
const char * elm_obj_systray_att_icon_name_get()
|
||||
void elm_obj_systray_status_set(Elm_Systray_Status st)
|
||||
Elm_Systray_Status elm_obj_systray_status_get()
|
||||
void elm_obj_systray_icon_name_set(const char *icon_name)
|
||||
const char * elm_obj_systray_icon_name_get()
|
||||
void elm_obj_systray_title_set(const char *title)
|
||||
const char * elm_obj_systray_title_get()
|
||||
Eina_Bool elm_obj_systray_register()
|
|
@ -0,0 +1,304 @@
|
|||
# Copyright (C) 2007-2015 various contributors (see AUTHORS)
|
||||
#
|
||||
# This file is part of Python-EFL.
|
||||
#
|
||||
# Python-EFL is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
# Python-EFL is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
:mod:`systray` Module
|
||||
##########################
|
||||
|
||||
.. versionadded:: 1.14
|
||||
|
||||
|
||||
Enumerations
|
||||
============
|
||||
|
||||
.. _Elm_Systray_Category:
|
||||
|
||||
Category of the Status Notifier Item.
|
||||
-------------------------------------
|
||||
|
||||
.. data:: ELM_SYSTRAY_CATEGORY_APP_STATUS
|
||||
|
||||
Indicators of application status
|
||||
|
||||
.. data:: ELM_SYSTRAY_CATEGORY_COMMUNICATIONS
|
||||
|
||||
Communications apps
|
||||
|
||||
.. data:: ELM_SYSTRAY_CATEGORY_SYS_SERVICES
|
||||
|
||||
System Service apps
|
||||
|
||||
.. data:: ELM_SYSTRAY_CATEGORY_HARDWARE
|
||||
|
||||
Hardware indicators
|
||||
|
||||
.. data:: ELM_SYSTRAY_CATEGORY_OTHER
|
||||
|
||||
Undefined category
|
||||
|
||||
|
||||
.. _Elm_Systray_Status:
|
||||
|
||||
Application status information.
|
||||
-------------------------------
|
||||
|
||||
.. data:: ELM_SYSTRAY_STATUS_PASSIVE
|
||||
|
||||
Passive (normal)
|
||||
|
||||
.. data:: ELM_SYSTRAY_STATUS_ACTIVE
|
||||
|
||||
Active
|
||||
|
||||
.. data:: ELM_SYSTRAY_STATUS_ATTENTION
|
||||
|
||||
Needs Attention
|
||||
|
||||
Inheritance diagram
|
||||
===================
|
||||
|
||||
.. inheritance-diagram:: efl.elementary.systray
|
||||
:parts: 2
|
||||
|
||||
"""
|
||||
|
||||
from cpython cimport PyUnicode_AsUTF8String, Py_INCREF
|
||||
|
||||
from efl.c_eo cimport eo_do, eo_add, Eo as cEo
|
||||
from efl.eo cimport Eo, object_from_instance
|
||||
from object cimport Object
|
||||
from efl.ecore cimport Event, EventHandler, _event_mapping_register
|
||||
from efl.utils.conversions cimport _ctouni
|
||||
|
||||
|
||||
cdef class EventSystrayReady(Event):
|
||||
cdef int _set_obj(self, void *o) except 0:
|
||||
return 1
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s()>" % (self.__class__.__name__,)
|
||||
|
||||
_event_mapping_register(ELM_EVENT_SYSTRAY_READY, EventSystrayReady)
|
||||
|
||||
|
||||
cdef class Systray(Object):
|
||||
|
||||
"""
|
||||
|
||||
This is the class that actually implements the widget.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, Eo parent not None, *args, **kwargs):
|
||||
self._set_obj(eo_add(elm_systray_class_get(), parent.obj))
|
||||
self._set_properties_from_keyword_args(kwargs)
|
||||
|
||||
property id:
|
||||
"""The id of the Status Notifier Item.
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __set__(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_id_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def __get__(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_id_get()))
|
||||
|
||||
def id_set(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_id_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def id_get(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_id_get()))
|
||||
|
||||
property category:
|
||||
"""
|
||||
|
||||
The category of the Status Notifier Item.
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __set__(self, Elm_Systray_Category value):
|
||||
eo_do(self.obj, elm_obj_systray_category_set(value))
|
||||
|
||||
def __get__(self):
|
||||
return <Elm_Systray_Category>eo_do(self.obj, elm_obj_systray_category_get())
|
||||
|
||||
def category_set(self, Elm_Systray_Category value):
|
||||
eo_do(self.obj, elm_obj_systray_category_set(value))
|
||||
|
||||
def category_get(self):
|
||||
return <Elm_Systray_Category>eo_do(self.obj, elm_obj_systray_category_get())
|
||||
|
||||
property icon_theme_path:
|
||||
"""The path to the theme where the icons can be found.
|
||||
|
||||
Set this value to "" to use the default path.
|
||||
|
||||
:type: string
|
||||
"""
|
||||
def __set__(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_icon_theme_path_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def __get__(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_icon_theme_path_get()))
|
||||
|
||||
def icon_theme_path_set(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_icon_theme_path_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def icon_theme_path_get(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_icon_theme_path_get()))
|
||||
|
||||
property menu:
|
||||
"""The object path of the D-Bus Menu to be shown when the Status Notifier Item is activated by the user.
|
||||
|
||||
:type: Eo
|
||||
"""
|
||||
def __set__(self, Eo value):
|
||||
eo_do(self.obj, elm_obj_systray_menu_set(value.obj))
|
||||
|
||||
def __get__(self):
|
||||
return object_from_instance(<cEo *>eo_do(self.obj, elm_obj_systray_menu_get()))
|
||||
|
||||
def menu_set(self, Eo value):
|
||||
eo_do(self.obj, elm_obj_systray_menu_set(value.obj))
|
||||
|
||||
def menu_get(self):
|
||||
return object_from_instance(<cEo *>eo_do(self.obj, elm_obj_systray_menu_get()))
|
||||
|
||||
property att_icon_name:
|
||||
"""The name of the attention icon to be used by the Status Notifier Item.
|
||||
|
||||
:type: string
|
||||
"""
|
||||
def __set__(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_att_icon_name_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def __get__(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_att_icon_name_get()))
|
||||
|
||||
def att_icon_name_set(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_att_icon_name_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def att_icon_name_get(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_att_icon_name_get()))
|
||||
|
||||
property status:
|
||||
"""The status of the Status Notifier Item.
|
||||
|
||||
:type: Elm_Systray_Status
|
||||
"""
|
||||
def __set__(self, Elm_Systray_Status value):
|
||||
eo_do(self.obj, elm_obj_systray_status_set(value))
|
||||
|
||||
def __get__(self):
|
||||
return <Elm_Systray_Status>eo_do(self.obj, elm_obj_systray_status_get())
|
||||
|
||||
def status_set(self, Elm_Systray_Status value):
|
||||
eo_do(self.obj, elm_obj_systray_status_set(value))
|
||||
|
||||
def status_get(self):
|
||||
return <Elm_Systray_Status>eo_do(self.obj, elm_obj_systray_status_get())
|
||||
|
||||
property icon_name:
|
||||
"""The name of the icon to be used by the Status Notifier Item.
|
||||
|
||||
:type: string
|
||||
"""
|
||||
def __set__(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_icon_name_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def __get__(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_icon_name_get()))
|
||||
|
||||
def icon_name_set(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_icon_name_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def icon_name_get(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_icon_name_get()))
|
||||
|
||||
property title:
|
||||
"""The title of the Status Notifier Item.
|
||||
|
||||
:type: string
|
||||
"""
|
||||
def __set__(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_title_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def __get__(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_title_get()))
|
||||
|
||||
def title_set(self, value):
|
||||
if isinstance(value, unicode): value = PyUnicode_AsUTF8String(value)
|
||||
eo_do(self.obj, elm_obj_systray_title_set(
|
||||
<const char *>value if value is not None else NULL
|
||||
)
|
||||
)
|
||||
|
||||
def title_get(self):
|
||||
return _ctouni(<const char *>eo_do(self.obj, elm_obj_systray_title_get()))
|
||||
|
||||
def register(self):
|
||||
"""Register this Status Notifier Item in the System Tray Watcher.
|
||||
|
||||
This function should only be called after the event
|
||||
#ELM_EVENT_SYSTRAY_READY is emitted.
|
||||
|
||||
"""
|
||||
return bool(<Eina_Bool>eo_do(self.obj, elm_obj_systray_register()))
|
||||
|
||||
|
||||
def on_systray_ready(func, *args, **kwargs):
|
||||
"""Use this to set a handler for the systray ready event."""
|
||||
return EventHandler(ELM_EVENT_SYSTRAY_READY, func, *args, **kwargs)
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from efl.ecore import ECORE_CALLBACK_DONE
|
||||
import efl.elementary as elm
|
||||
elm.init()
|
||||
if not elm.need_systray():
|
||||
raise SystemExit("systray support missing")
|
||||
|
||||
from efl.elementary.window import StandardWindow
|
||||
from efl.elementary.systray import Systray, on_systray_ready
|
||||
from efl.elementary.menu import Menu
|
||||
|
||||
|
||||
def ready_cb(event):
|
||||
print(tray.register())
|
||||
|
||||
return ECORE_CALLBACK_DONE
|
||||
|
||||
|
||||
win = StandardWindow("test", "systray test", size=(400, 400))
|
||||
win.callback_delete_request_add(lambda x: elm.exit())
|
||||
|
||||
on_systray_ready(ready_cb)
|
||||
|
||||
menu = Menu(win)
|
||||
menu.item_add(None, "it works!")
|
||||
|
||||
tray = Systray(win)
|
||||
tray.icon_name = "elementary"
|
||||
tray.att_icon_name = "elementary"
|
||||
tray.menu = menu
|
||||
|
||||
win.show()
|
||||
|
||||
elm.run()
|
||||
elm.shutdown()
|
12
setup.py
12
setup.py
|
@ -251,7 +251,10 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
# === Eo ===
|
||||
eo_cflags, eo_libs = pkg_config('Eo', 'eo', EFL_MIN_VER)
|
||||
eo_ext = Extension("eo", ["efl/eo/efl.eo" + module_suffix],
|
||||
define_macros=[('EFL_BETA_API_SUPPORT', None)],
|
||||
define_macros=[
|
||||
('EFL_BETA_API_SUPPORT', 1),
|
||||
('EFL_EO_API_SUPPORT', 1)
|
||||
],
|
||||
include_dirs=['include/'],
|
||||
extra_compile_args=eo_cflags,
|
||||
extra_link_args=eo_libs + eina_libs
|
||||
|
@ -437,6 +440,7 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
"slideshow",
|
||||
"spinner",
|
||||
#"store",
|
||||
"systray",
|
||||
"table",
|
||||
"theme",
|
||||
"thumb",
|
||||
|
@ -451,9 +455,13 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
for m in elm_mods:
|
||||
e = Extension("elementary." + m,
|
||||
["efl/elementary/" + m + module_suffix],
|
||||
define_macros=[
|
||||
('EFL_BETA_API_SUPPORT', 1),
|
||||
('EFL_EO_API_SUPPORT', 1)
|
||||
],
|
||||
include_dirs=["include/"],
|
||||
extra_compile_args=elm_cflags,
|
||||
extra_link_args=elm_libs + eina_libs + evas_libs)
|
||||
extra_link_args=elm_libs + eina_libs + eo_libs + evas_libs)
|
||||
ext_modules.append(e)
|
||||
|
||||
packages.append("efl.elementary")
|
||||
|
|
Loading…
Reference in New Issue