efl.ecore: Return of ecore.x (from python-ecore)
Made some corrections to make it compile and fixed doc formatting.
This commit is contained in:
parent
d98cd27107
commit
1466ea7207
|
@ -89,6 +89,7 @@ API Reference
|
|||
:maxdepth: 4
|
||||
|
||||
ecore_module
|
||||
x
|
||||
timer
|
||||
animator
|
||||
poller
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
:mod:`efl.ecore.x` Module
|
||||
--------------------------
|
||||
|
||||
.. automodule:: efl.ecore.x
|
||||
|
||||
.. inheritance-diagram::
|
||||
efl.ecore.x
|
||||
:parts: 2
|
|
@ -346,3 +346,6 @@ cdef class FileMonitor:
|
|||
cdef readonly object kargs
|
||||
|
||||
cdef object _exec_monitor(self, Ecore_File_Event event, const char *path)
|
||||
|
||||
cdef object _event_mapping_register(int type, cls)
|
||||
cdef object _event_mapping_unregister(int type)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
cdef object _event_type_mapping = dict()
|
||||
|
||||
def _event_mapping_register(int type, cls):
|
||||
cdef object _event_mapping_register(int type, cls):
|
||||
if type in _event_type_mapping:
|
||||
raise ValueError("event type '%d' already registered." % type)
|
||||
if not issubclass(cls, Event):
|
||||
|
@ -26,7 +26,7 @@ def _event_mapping_register(int type, cls):
|
|||
_event_type_mapping[type] = cls
|
||||
|
||||
|
||||
def _event_mapping_unregister(int type):
|
||||
cdef object _event_mapping_unregister(int type):
|
||||
_event_type_mapping.pop(type)
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,237 @@
|
|||
# Copyright (C) 2007-2014 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/>.
|
||||
|
||||
#from cpython cimport PyObject, Py_INCREF, Py_DECREF
|
||||
from cpython cimport PyMem_Malloc, PyMem_Free
|
||||
|
||||
|
||||
def init(name=None):
|
||||
"""Initialize the X display connection to the given display.
|
||||
|
||||
:param name: display target name, if None, default will be used.
|
||||
:rtype: int
|
||||
"""
|
||||
cdef char *s
|
||||
cdef int i
|
||||
if name is None:
|
||||
s = NULL
|
||||
else:
|
||||
s = name
|
||||
i = ecore_x_init(s)
|
||||
x_events_register()
|
||||
return i
|
||||
|
||||
|
||||
def shutdown():
|
||||
"""Shuts down the Ecore X library.
|
||||
|
||||
In shutting down the library, the X display connection is terminated
|
||||
and any event handlers for it are removed.
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
return ecore_x_shutdown()
|
||||
|
||||
|
||||
def disconnect():
|
||||
"""Shuts down the Ecore X library.
|
||||
|
||||
As ecore_x_shutdown, except do not close Display, only connection.
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
return ecore_x_disconnect()
|
||||
|
||||
|
||||
def fd_get():
|
||||
"""Retrieves the X display file descriptor.
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
return ecore_x_fd_get()
|
||||
|
||||
|
||||
def double_click_time_set(double t):
|
||||
"""Sets the timeout for a double and triple clicks to be flagged.
|
||||
|
||||
This sets the time between clicks before the double_click flag is
|
||||
set in a button down event. If 3 clicks occur within double this
|
||||
time, the triple_click flag is also set.
|
||||
"""
|
||||
ecore_x_double_click_time_set(t)
|
||||
|
||||
def double_click_time_get():
|
||||
":rtype: float"
|
||||
return ecore_x_double_click_time_get()
|
||||
|
||||
|
||||
def flush():
|
||||
"Sends all X commands in the X Display buffer."
|
||||
ecore_x_flush()
|
||||
|
||||
|
||||
def sync():
|
||||
"Flushes the command buffer and waits until all requests have been"
|
||||
ecore_x_sync()
|
||||
|
||||
|
||||
def current_time_get():
|
||||
"Return the last event time."
|
||||
return ecore_x_current_time_get()
|
||||
|
||||
|
||||
def error_request_get():
|
||||
"""Get the request code that caused the error.
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
return ecore_x_error_request_get()
|
||||
|
||||
|
||||
def error_code_get():
|
||||
"""Get the error code from the error.
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
return ecore_x_error_code_get()
|
||||
|
||||
|
||||
def window_focus_get():
|
||||
"""Returns the window that has the focus.
|
||||
|
||||
:rtype: L{Window}
|
||||
"""
|
||||
cdef Ecore_X_Window xid
|
||||
xid = ecore_x_window_focus_get()
|
||||
return Window_from_xid(xid)
|
||||
|
||||
|
||||
cdef int _skip_list_build(skip_list, Ecore_X_Window **pskips, int *pskip_num) except 0:
|
||||
cdef Window win
|
||||
cdef int i
|
||||
|
||||
if skip_list:
|
||||
pskip_num[0] = len(skip_list)
|
||||
else:
|
||||
pskip_num[0] = 0
|
||||
|
||||
if pskip_num[0] == 0:
|
||||
pskips[0] = NULL
|
||||
return 1
|
||||
else:
|
||||
pskips[0] = <Ecore_X_Window *>PyMem_Malloc(pskip_num[0] * sizeof(Ecore_X_Window))
|
||||
i = 0
|
||||
try:
|
||||
for w in skip_list:
|
||||
win = w
|
||||
pskips[0][i] = win.xid
|
||||
i += 1
|
||||
except:
|
||||
pskip_num[0] = 0
|
||||
PyMem_Free(<void*>pskips[0])
|
||||
raise
|
||||
return 1
|
||||
|
||||
|
||||
def window_shadow_tree_at_xy_with_skip_get(Window base, int x, int y, skip_list=None):
|
||||
"""Retrieves the top, visible window at the given location,
|
||||
but skips the windows in the list. This uses a shadow tree built from the
|
||||
window tree that is only updated the first time
|
||||
L{window_shadow_tree_at_xy_with_skip_get()} is called, or the next time
|
||||
it is called after a L{window_shadow_tree_flush()}.
|
||||
|
||||
:param base: Window to use as base, or None to use root window.
|
||||
:param x: The given X position.
|
||||
:param y: The given Y position.
|
||||
:rtype: Window
|
||||
"""
|
||||
cdef:
|
||||
Ecore_X_Window base_xid, ret_xid
|
||||
Ecore_X_Window *skips
|
||||
int skip_num
|
||||
if base is <Window>None:
|
||||
base_xid = 0
|
||||
else:
|
||||
base_xid = base.xid
|
||||
|
||||
_skip_list_build(skip_list, &skips, &skip_num)
|
||||
ret_xid = ecore_x_window_shadow_tree_at_xy_with_skip_get(base_xid, x, y,
|
||||
skips, skip_num)
|
||||
if skips != NULL:
|
||||
PyMem_Free(<void*>skips)
|
||||
|
||||
return Window_from_xid(ret_xid)
|
||||
|
||||
|
||||
def window_shadow_tree_flush():
|
||||
"Flushes the window shadow tree so nothing is stored."
|
||||
ecore_x_window_shadow_tree_flush()
|
||||
|
||||
|
||||
def window_at_xy_get(int x, int y):
|
||||
"""Retrieves the top, visible window at the given location.
|
||||
|
||||
:param x: horizontal position.
|
||||
:param y: vertical position.
|
||||
:rtype: Window
|
||||
"""
|
||||
cdef Ecore_X_Window xid
|
||||
xid = ecore_x_window_at_xy_get(x, y)
|
||||
return Window_from_xid(xid)
|
||||
|
||||
|
||||
def window_at_xy_with_skip_get(int x, int y, skip_list=None):
|
||||
"""Retrieves the top, visible window at the given location.
|
||||
|
||||
:param x: horizontal position.
|
||||
:param y: vertical position.
|
||||
:rtype: Window
|
||||
"""
|
||||
cdef:
|
||||
Ecore_X_Window xid
|
||||
Ecore_X_Window *skips
|
||||
int skip_num
|
||||
|
||||
_skip_list_build(skip_list, &skips, &skip_num)
|
||||
xid = ecore_x_window_at_xy_with_skip_get(x, y, skips, skip_num)
|
||||
|
||||
if skips != NULL:
|
||||
PyMem_Free(<void*>skips)
|
||||
|
||||
return Window_from_xid(xid)
|
||||
|
||||
|
||||
def window_at_xy_begin_get(Window begin, int x, int y):
|
||||
"""Retrieves the top, visible window at the given location, starting from
|
||||
begin.
|
||||
|
||||
:param begin: Window to start at.
|
||||
:param x: horizontal position.
|
||||
:param y: vertical position.
|
||||
:rtype: Window
|
||||
"""
|
||||
cdef Ecore_X_Window xid, begin_xid
|
||||
if begin is <Window>None:
|
||||
begin_xid = 0
|
||||
else:
|
||||
begin_xid = begin.xid
|
||||
xid = ecore_x_window_at_xy_begin_get(begin_xid, x, y)
|
||||
return Window_from_xid(xid)
|
||||
|
||||
|
||||
include "x_window.pxi"
|
||||
include "x_events.pxi"
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,463 @@
|
|||
# Copyright (C) 2007-2014 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/>.
|
||||
|
||||
cdef class Window:
|
||||
def __init__(self, Window parent=None, int x=0, int y=0, int w=1, int h=1,
|
||||
input=False, argb=False, override_redirect=False):
|
||||
"""Create a new X window.
|
||||
|
||||
:param parent: window to use as parent, or None to use the
|
||||
root window.
|
||||
:param x: horizontal position.
|
||||
:param y: vertical position.
|
||||
:param w: horizontal size.
|
||||
:param h: vertical size.
|
||||
:param input: if should be an input-only window or not.
|
||||
:param argb: if window should be ARGB.
|
||||
:param override_redirect: if override redirect attribute must be set.
|
||||
"""
|
||||
cdef Ecore_X_Window p_xid, xid
|
||||
if parent is <Window>None:
|
||||
p_xid = 0
|
||||
else:
|
||||
p_xid = parent.xid
|
||||
|
||||
if not input and not argb and not override_redirect:
|
||||
xid = ecore_x_window_new(p_xid, x, y, w, h)
|
||||
elif argb:
|
||||
if not override_redirect:
|
||||
xid = ecore_x_window_argb_new(p_xid, x, y, w, h)
|
||||
else:
|
||||
xid = ecore_x_window_override_argb_new(p_xid, x, y, w, h)
|
||||
elif input:
|
||||
xid = ecore_x_window_input_new(p_xid, x, y, w, h)
|
||||
elif override_redirect:
|
||||
xid = ecore_x_window_override_new(p_xid, x, y, w, h)
|
||||
else:
|
||||
raise ValueError("not able to create window!")
|
||||
|
||||
self._set_xid(xid)
|
||||
|
||||
cdef int _set_xid(self, Ecore_X_Window xid) except 0:
|
||||
if self.xid == 0:
|
||||
self.xid = xid
|
||||
return 1
|
||||
else:
|
||||
raise ValueError("object already wraps an X Window.")
|
||||
|
||||
def __str__(self):
|
||||
cdef int x, y, w, h, visible
|
||||
cdef unsigned int parent
|
||||
|
||||
ecore_x_window_geometry_get(self.xid, &x, &y, &w, &h)
|
||||
parent = ecore_x_window_parent_get(self.xid)
|
||||
visible = ecore_x_window_visible_get(self.xid)
|
||||
return "%s(xid=%#x, parent=%#x, x=%d, y=%d, w=%d, h=%d, visible=%s)" % \
|
||||
(self.__class__.__name__, self.xid, parent, x, y, w, h,
|
||||
bool(visible))
|
||||
|
||||
def __repr__(self):
|
||||
cdef int x, y, w, h
|
||||
cdef unsigned int parent
|
||||
|
||||
ecore_x_window_geometry_get(self.xid, &x, &y, &w, &h)
|
||||
parent = ecore_x_window_parent_get(self.xid)
|
||||
return "%s(%#x, xid=%#x, parent=%#x, x=%d, y=%d, w=%d, h=%d)" % \
|
||||
(self.__class__.__name__, <unsigned long><void *>self,
|
||||
self.xid, parent, x, y, w, h)
|
||||
|
||||
def __richcmp__(self, other, int op):
|
||||
if op == 2: # equal
|
||||
if self is other:
|
||||
return 1
|
||||
else:
|
||||
return self.xid == int(other)
|
||||
else:
|
||||
return 0
|
||||
|
||||
def __int__(self):
|
||||
return self.xid
|
||||
|
||||
def __long__(self):
|
||||
return self.xid
|
||||
|
||||
def delete(self):
|
||||
"Deletes the current window."
|
||||
if self.xid != 0:
|
||||
ecore_x_window_free(self.xid)
|
||||
self.xid = 0
|
||||
|
||||
def delete_request_send(self):
|
||||
"Sends a delete request to this window."
|
||||
ecore_x_window_delete_request_send(self.xid)
|
||||
|
||||
def root_get(self):
|
||||
":rtype: Window"
|
||||
cdef Ecore_X_Window xid
|
||||
xid = ecore_x_window_root_get(self.xid)
|
||||
return Window_from_xid(xid)
|
||||
|
||||
def reparent(self, Window new_parent=None, int x=0, int y=0):
|
||||
"""Moves this window to within another window at a given position.
|
||||
|
||||
:param new_parent: window to use as parent, or None to use the root
|
||||
window.
|
||||
:param x: horizontal position within the new parent.
|
||||
:param y: vertical position within the new parent.
|
||||
"""
|
||||
cdef Ecore_X_Window p_xid
|
||||
if new_parent is <Window>None:
|
||||
p_xid = 0
|
||||
else:
|
||||
p_xid = new_parent.xid
|
||||
ecore_x_window_reparent(self.xid, p_xid, x, y)
|
||||
|
||||
def parent_set(self, Window new_parent=None):
|
||||
"""Set window parent.
|
||||
|
||||
:param new_parent: window to use as parent, or None to use the root
|
||||
window.
|
||||
:see: same as :py:meth:`reparent` with both x and y being 0.
|
||||
"""
|
||||
cdef Ecore_X_Window p_xid
|
||||
if new_parent is <Window>None:
|
||||
p_xid = 0
|
||||
else:
|
||||
p_xid = new_parent.xid
|
||||
ecore_x_window_reparent(self.xid, p_xid, 0, 0)
|
||||
|
||||
def parent_get(self):
|
||||
":rtype: Window"
|
||||
cdef Ecore_X_Window xid
|
||||
xid = ecore_x_window_parent_get(self.xid)
|
||||
return Window_from_xid(xid)
|
||||
|
||||
property parent:
|
||||
def __set__(self, value):
|
||||
self.parent_set(value)
|
||||
|
||||
def __get__(self):
|
||||
return self.parent_get()
|
||||
|
||||
def show(self):
|
||||
"""Shows this window.
|
||||
|
||||
Synonymous to "mapping" a window in X Window System terminology.
|
||||
"""
|
||||
ecore_x_window_show(self.xid)
|
||||
|
||||
def hide(self):
|
||||
"""Hides a window.
|
||||
|
||||
Synonymous to "unmapping" a window in X Window System terminology.
|
||||
"""
|
||||
ecore_x_window_hide(self.xid)
|
||||
|
||||
def visible_set(self, value):
|
||||
if value:
|
||||
self.show()
|
||||
else:
|
||||
self.hide()
|
||||
|
||||
def visible_get(self):
|
||||
":rtype: bool"
|
||||
return bool(ecore_x_window_visible_get(self.xid))
|
||||
|
||||
def focus(self):
|
||||
"Give focus to this windows."
|
||||
ecore_x_window_focus(self.xid)
|
||||
|
||||
def focus_at_time(self, Ecore_X_Time time):
|
||||
"""Sets the focus this window at a specific time.
|
||||
|
||||
:param time: time specification, see :py:meth:`current_time_get`.
|
||||
"""
|
||||
ecore_x_window_focus_at_time(self.xid, time)
|
||||
|
||||
def ignore_set(self, int setting):
|
||||
ecore_x_window_ignore_set(self.xid, bool(setting))
|
||||
|
||||
def raise_(self):
|
||||
"Raises this window."
|
||||
ecore_x_window_raise(self.xid)
|
||||
|
||||
def lower(self):
|
||||
"Lowers this window."
|
||||
ecore_x_window_lower(self.xid)
|
||||
|
||||
def move(self, int x, int y):
|
||||
"""Set window position.
|
||||
|
||||
:param x: horizontal.
|
||||
:param y: vertical.
|
||||
"""
|
||||
ecore_x_window_move(self.xid, x, y)
|
||||
|
||||
def pos_set(self, int x, int y):
|
||||
"""Set window position.
|
||||
|
||||
:param x: horizontal.
|
||||
:param y: vertical.
|
||||
|
||||
.. note:: alias for :py:meth:`move`
|
||||
"""
|
||||
ecore_x_window_move(self.xid, x, y)
|
||||
|
||||
def pos_get(self):
|
||||
":rtype: tuple of int"
|
||||
cdef int x, y, w, h
|
||||
ecore_x_window_geometry_get(self.xid, &x, &y, &w, &h)
|
||||
return (x, y)
|
||||
|
||||
property pos:
|
||||
def __set__(self, spec):
|
||||
self.pos_set(*spec)
|
||||
|
||||
def __get__(self):
|
||||
return self.pos_get()
|
||||
|
||||
def resize(self, int w, int h):
|
||||
"""Set window size.
|
||||
|
||||
:param w: horizontal.
|
||||
:param h: vertical.
|
||||
"""
|
||||
ecore_x_window_resize(self.xid, w, h)
|
||||
|
||||
def size_set(self, int w, int h):
|
||||
"""Set window size.
|
||||
|
||||
:param w: horizontal.
|
||||
:param h: vertical.
|
||||
|
||||
.. note:: alias for :py:meth:`resize`
|
||||
"""
|
||||
ecore_x_window_resize(self.xid, w, h)
|
||||
|
||||
def size_get(self):
|
||||
":rtype: tuple of int"
|
||||
cdef int w, h
|
||||
ecore_x_window_size_get(self.xid, &w, &h)
|
||||
return (w, h)
|
||||
|
||||
property size:
|
||||
def __set__(self, spec):
|
||||
self.size_set(*spec)
|
||||
|
||||
def __get__(self):
|
||||
return self.size_get()
|
||||
|
||||
def move_resize(self, int x, int y, int w, int h):
|
||||
"""Set both position and size.
|
||||
|
||||
:param x: horizontal position.
|
||||
:param y: vertical position.
|
||||
:param w: horizontal size.
|
||||
:param h: vertical size.
|
||||
"""
|
||||
ecore_x_window_move_resize(self.xid, x, y, w, h)
|
||||
|
||||
def geometry_set(self, int x, int y, int w, int h):
|
||||
"""Set both position and size.
|
||||
|
||||
:param x: horizontal position.
|
||||
:param y: vertical position.
|
||||
:param w: horizontal size.
|
||||
:param h: vertical size.
|
||||
"""
|
||||
ecore_x_window_move_resize(self.xid, x, y, w, h)
|
||||
|
||||
def geometry_get(self):
|
||||
":rtype: tuple of int"
|
||||
cdef int x, y, w, h
|
||||
ecore_x_window_geometry_get(self.xid, &x, &y, &w, &h)
|
||||
return (x, y, w, h)
|
||||
|
||||
property geometry:
|
||||
def __set__(self, spec):
|
||||
self.geometry_set(*spec)
|
||||
|
||||
def __get__(self):
|
||||
return self.geometry_get()
|
||||
|
||||
def border_width_set(self, int width):
|
||||
"""Sets the width of the border of this window.
|
||||
|
||||
:param width: border width, in pixels.
|
||||
"""
|
||||
ecore_x_window_border_width_set(self.xid, width)
|
||||
|
||||
def border_width_get(self):
|
||||
":rtype: int"
|
||||
return ecore_x_window_border_width_get(self.xid)
|
||||
|
||||
property border_width:
|
||||
def __set__(self, spec):
|
||||
self.border_width_set(*spec)
|
||||
|
||||
def __get__(self):
|
||||
return self.border_width_get()
|
||||
|
||||
def depth_get(self):
|
||||
":rtype: int"
|
||||
return ecore_x_window_depth_get(self.xid)
|
||||
|
||||
property depth:
|
||||
def __get__(self):
|
||||
return self.depth_get()
|
||||
|
||||
def configure(self, int mask, int x, int y, int w, int h, int border_width,
|
||||
Window sibling, int stack_mode):
|
||||
cdef Ecore_X_Window sibling_xid
|
||||
if sibling is <Window>None:
|
||||
sibling_xid = 0
|
||||
else:
|
||||
sibling_xid = sibling.xid
|
||||
ecore_x_window_configure(self.xid, <Ecore_X_Window_Configure_Mask>mask,
|
||||
x, y, w, h, border_width, sibling_xid,
|
||||
stack_mode)
|
||||
|
||||
def cursor_show(self):
|
||||
ecore_x_window_cursor_show(self.xid, 1)
|
||||
|
||||
def cursor_hide(self):
|
||||
ecore_x_window_cursor_show(self.xid, 0)
|
||||
|
||||
def cursor_set(self, Ecore_X_Cursor cursor):
|
||||
ecore_x_window_cursor_set(self.xid, cursor)
|
||||
|
||||
def pointer_warp(self, int x, int y):
|
||||
ecore_x_pointer_warp(self.xid, x, y)
|
||||
|
||||
def pointer_xy_get(self):
|
||||
cdef int x, y
|
||||
ecore_x_pointer_xy_get(self.xid, &x, &y);
|
||||
return (x, y)
|
||||
|
||||
def defaults_set(self):
|
||||
"""Sets the default properties for the given window.
|
||||
|
||||
The default properties set for the window are WM_CLIENT_MACHINE and
|
||||
_NET_WM_PID.
|
||||
"""
|
||||
ecore_x_window_defaults_set(self.xid)
|
||||
|
||||
def killall_children(self):
|
||||
"Kill all clients with subwindows under this window."
|
||||
ecore_x_killall(self.xid)
|
||||
|
||||
def kill(self):
|
||||
"Kill this specific client"
|
||||
ecore_x_kill(self.xid)
|
||||
|
||||
def background_color_set(self, int r, int g, int b):
|
||||
"""Set background color.
|
||||
|
||||
:param r: red (0...65536, 16 bits)
|
||||
:param g: green (0...65536, 16 bits)
|
||||
:param b: blue (0...65536, 16 bits)
|
||||
"""
|
||||
ecore_x_window_background_color_set(self.xid, r, g, b)
|
||||
|
||||
def area_clear(self, int x, int y, int w, int h):
|
||||
"Paints the specified area with background's color or pixmap."
|
||||
ecore_x_window_area_clear(self.xid, x, y, w, h)
|
||||
|
||||
def area_expose(self, int x, int y, int w, int h):
|
||||
"Like :py:meth:`area_clear`, but generates exposures."
|
||||
ecore_x_window_area_expose(self.xid, x, y, w, h)
|
||||
|
||||
def override_set(self, int setting):
|
||||
ecore_x_window_override_set(self.xid, bool(setting))
|
||||
|
||||
def argb_get(self):
|
||||
":rtype: bool"
|
||||
return bool(ecore_x_window_argb_get(self.xid))
|
||||
|
||||
def gravity_set(self, int gravity):
|
||||
ecore_x_window_gravity_set(self.xid, <Ecore_X_Gravity>gravity)
|
||||
|
||||
def pixel_gravity_set(self, int gravity):
|
||||
ecore_x_window_pixel_gravity_set(self.xid, <Ecore_X_Gravity>gravity)
|
||||
|
||||
def event_mask_set(self, int mask):
|
||||
ecore_x_event_mask_set(self.xid, <Ecore_X_Event_Mask>mask)
|
||||
|
||||
def event_mask_unset(self, int mask):
|
||||
ecore_x_event_mask_unset(self.xid, <Ecore_X_Event_Mask>mask)
|
||||
|
||||
def icccm_hints_set(self, int accepts_focus, int initial_state,
|
||||
int icon_pixmap, int icon_mask, int icon_window,
|
||||
int window_group, int is_urgent):
|
||||
"""Set ICCCM window hints.
|
||||
|
||||
:param accepts_focus: if window accepts focus or not.
|
||||
:param initial_state: one of ECORE_X_WINDOW_STATE_HINT_*.
|
||||
:param icon_pixmap: pixmap id to be used as icon.
|
||||
:param icon_mask: pixmap id to be used as icon mask.
|
||||
:param icon_window: window id to be used as icon.
|
||||
:param window_group: window id representing the group.
|
||||
:param is_urgent: if window is urgent or not.
|
||||
"""
|
||||
ecore_x_icccm_hints_set(self.xid, accepts_focus,
|
||||
<Ecore_X_Window_State_Hint>initial_state,
|
||||
icon_pixmap, icon_mask, icon_window,
|
||||
window_group, is_urgent)
|
||||
|
||||
def icccm_hints_get(self):
|
||||
"""Get ICCCM window hints.
|
||||
|
||||
:see: :py:meth:`icccm_hints_set`
|
||||
:return: tuple with: accepts_focus, initial_state, icon_pixmap,
|
||||
icon_mask, icon_window, window_group, is_urgent
|
||||
"""
|
||||
cdef Eina_Bool accepts_focus, is_urgent
|
||||
cdef int initial_state, icon_pixmap, icon_mask, \
|
||||
icon_window, window_group
|
||||
ecore_x_icccm_hints_get(self.xid, &accepts_focus,
|
||||
<Ecore_X_Window_State_Hint *>&initial_state,
|
||||
<Ecore_X_Pixmap *>&icon_pixmap,
|
||||
<Ecore_X_Pixmap *>&icon_mask,
|
||||
<Ecore_X_Window *>&icon_window,
|
||||
<Ecore_X_Window *>&window_group,
|
||||
&is_urgent)
|
||||
return (bool(accepts_focus), initial_state, icon_pixmap, icon_mask,
|
||||
icon_window, window_group, bool(is_urgent))
|
||||
|
||||
def type_set(self, int type):
|
||||
ecore_x_netwm_window_type_set(self.xid, <Ecore_X_Window_Type>type)
|
||||
|
||||
def state_set(self, states):
|
||||
# building list
|
||||
cdef Ecore_X_Window_State *_states
|
||||
_states = <Ecore_X_Window_State *>PyMem_Malloc(len(states) * sizeof(Ecore_X_Window_State))
|
||||
for i in xrange(len(states)):
|
||||
_states[i] = states[i]
|
||||
|
||||
ecore_x_netwm_window_state_set(self.xid, _states, len(states))
|
||||
PyMem_Free(<void*>_states)
|
||||
|
||||
def Window_from_xid(unsigned long xid):
|
||||
"""Create a Python wrapper for given window id.
|
||||
|
||||
:param xid: window id.
|
||||
:rtype: L{Window}
|
||||
"""
|
||||
cdef Window w
|
||||
w = Window.__new__(Window)
|
||||
w._set_xid(xid)
|
||||
return w
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import efl.ecore
|
||||
from efl.ecore.x import init, Window, on_window_configure_add
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
init()
|
||||
|
||||
try:
|
||||
filename = sys.argv[1]
|
||||
except IndexError, e:
|
||||
raise SystemExit("Usage: %s <filename>" % sys.argv[0])
|
||||
|
||||
main_window = Window(w=800, h=600)
|
||||
main_window.background_color_set(0xffff, 0, 0)
|
||||
main_window.show()
|
||||
|
||||
sub_window = Window(main_window, 10, 10, 780, 580)
|
||||
sub_window.background_color_set(0, 0, 0xffff)
|
||||
sub_window.show()
|
||||
|
||||
cmd = ["/usr/bin/mplayer", "-slave", "-nomouseinput", "-quiet",
|
||||
"-wid", str(sub_window.xid), filename]
|
||||
p = Popen(cmd, stdin=PIPE, stdout=PIPE, close_fds=True)
|
||||
|
||||
|
||||
def handle_read(fd_handler, file):
|
||||
line = file.read(1)
|
||||
r = bool(line and not fd_handler.has_error())
|
||||
if not r:
|
||||
efl.ecore.main_loop_quit()
|
||||
return r
|
||||
|
||||
|
||||
def on_configure(event, main_window, sub_window):
|
||||
if event.win == main_window:
|
||||
sub_window.resize(event.w - 20, event.h - 20)
|
||||
return True
|
||||
on_window_configure_add(on_configure, main_window, sub_window)
|
||||
|
||||
efl.ecore.fd_handler_add(
|
||||
p.stdout, efl.ecore.ECORE_FD_ALL, handle_read, p.stdout)
|
||||
efl.ecore.main_loop_begin()
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import efl.ecore
|
||||
from efl.ecore.x import init, Window, on_window_configure_add
|
||||
|
||||
init()
|
||||
|
||||
# method 1
|
||||
main_window = Window(w=800, h=600)
|
||||
main_window.background_color_set(0xffff, 0, 0)
|
||||
main_window.show()
|
||||
|
||||
sub_window = Window(main_window, 10, 10, 780, 580)
|
||||
sub_window.background_color_set(0, 0, 0xffff)
|
||||
sub_window.show()
|
||||
|
||||
|
||||
def cb_on_configure(event, main_window, sub_window):
|
||||
if event.win == main_window:
|
||||
sub_window.resize(event.w - 20, event.h - 20)
|
||||
return True
|
||||
on_window_configure_add(cb_on_configure, main_window, sub_window)
|
||||
|
||||
|
||||
# method 2: inheritance
|
||||
class MyWindow(Window):
|
||||
def __init__(self, w, h):
|
||||
Window.__init__(self, w=w, h=h)
|
||||
self.background_color_set(0xffff, 0, 0)
|
||||
self.sub_window = Window(self, 10, 10, w - 20, h - 20)
|
||||
self.sub_window.background_color_set(0, 0, 0xffff)
|
||||
self.sub_window.show()
|
||||
on_window_configure_add(self._cb_on_configure)
|
||||
|
||||
def _cb_on_configure(self, event):
|
||||
if event.win == self:
|
||||
self.sub_window.resize(event.w - 20, event.h - 20)
|
||||
return True
|
||||
|
||||
other_window = MyWindow(400, 300)
|
||||
other_window.show()
|
||||
|
||||
efl.ecore.main_loop_begin()
|
33
setup.py
33
setup.py
|
@ -232,13 +232,32 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
ecore_cflags, ecore_libs = pkg_config('Ecore', 'ecore', EFL_MIN_VERSION)
|
||||
ecore_file_cflags, ecore_file_libs = pkg_config(
|
||||
'EcoreFile', 'ecore-file', EFL_MIN_VERSION)
|
||||
ecore_ext = Extension(
|
||||
"ecore.__init__", ["efl/ecore/__init__" + module_suffix],
|
||||
include_dirs=['include/'],
|
||||
extra_compile_args=list(set(ecore_cflags + ecore_file_cflags)),
|
||||
extra_link_args=ecore_libs + ecore_file_libs + eina_libs + evas_libs,
|
||||
)
|
||||
modules.append(ecore_ext)
|
||||
ecore_input_cflags, ecore_input_libs = pkg_config(
|
||||
'EcoreInput', 'ecore-input', EFL_MIN_VERSION)
|
||||
ecore_x_cflags, ecore_x_libs = pkg_config(
|
||||
'EcoreX', 'ecore-x', EFL_MIN_VERSION)
|
||||
ecore_exts = (
|
||||
Extension(
|
||||
"ecore.__init__", ["efl/ecore/__init__" + module_suffix],
|
||||
include_dirs=['include/'],
|
||||
extra_compile_args=list(set(ecore_cflags + ecore_file_cflags)),
|
||||
extra_link_args=ecore_libs + ecore_file_libs + eina_libs +
|
||||
evas_libs
|
||||
),
|
||||
Extension(
|
||||
"ecore.x", ["efl/ecore/x" + module_suffix],
|
||||
include_dirs=['include/'],
|
||||
extra_compile_args=
|
||||
list(set(
|
||||
ecore_cflags + ecore_file_cflags + ecore_x_cflags +
|
||||
ecore_input_cflags
|
||||
)),
|
||||
extra_link_args=
|
||||
ecore_libs + ecore_file_libs + ecore_x_libs + ecore_input_libs +
|
||||
eina_libs + evas_libs,
|
||||
)
|
||||
)
|
||||
modules += ecore_exts
|
||||
packages.append("efl.ecore")
|
||||
|
||||
# compatibility
|
||||
|
|
Loading…
Reference in New Issue