Move ecore_x out of the ecore extension

Now ecore do not more looks like an alien with his __init__
hack and his different module/package structure

This broke ecore.x users as the extension is now efl.ecore_x

Sorry to bother but I still think that ecore_x should not be
implemented in python, if this hurt you please let me know
This commit is contained in:
Davide Andreoli 2015-01-04 12:47:40 +01:00
parent 1910563604
commit 863efc19eb
7 changed files with 4219 additions and 27 deletions

404
efl/ecore/efl.ecore.pyx Normal file
View File

@ -0,0 +1,404 @@
# 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/>.
"""
.. _Ecore_Fd_Handler_Flags:
Fd handler flags
================
What to monitor the file descriptor for: reading, writing or error.
.. data:: ECORE_FD_READ
Fd Read mask
.. data:: ECORE_FD_WRITE
Fd Write mask
.. data:: ECORE_FD_ERROR
Fd Error mask
.. _Ecore_Exe_Flags:
Exe flags
=========
Flags for executing a child with its stdin and/or stdout piped back.
.. data:: ECORE_EXE_NONE
No exe flags at all
.. data:: ECORE_EXE_PIPE_READ
Exe Pipe Read mask
.. data:: ECORE_EXE_PIPE_WRITE
Exe Pipe Write mask
.. data:: ECORE_EXE_PIPE_ERROR
Exe Pipe error mask
.. data:: ECORE_EXE_PIPE_READ_LINE_BUFFERED
Reads are buffered until a newline and split 1 line per Ecore_Exe_Event_Data_Line
.. data:: ECORE_EXE_PIPE_ERROR_LINE_BUFFERED
Errors are buffered until a newline and split 1 line per Ecore_Exe_Event_Data_Line
.. data:: ECORE_EXE_PIPE_AUTO
stdout and stderr are buffered automatically
.. data:: ECORE_EXE_RESPAWN
FIXME: Exe is restarted if it dies
.. data:: ECORE_EXE_USE_SH
Use /bin/sh to run the command
.. data:: ECORE_EXE_NOT_LEADER
Do not use setsid() to have the executed process be its own session leader
.. data:: ECORE_EXE_TERM_WITH_PARENT
Makes child receive SIGTERM when parent dies
Callback return values
======================
.. data:: ECORE_CALLBACK_CANCEL
Return value to remove a callback, it will not be called again
.. data:: ECORE_CALLBACK_RENEW
Return value to keep a callback
Event return values
===================
.. data:: ECORE_CALLBACK_PASS_ON
Return value to pass event to next handler
.. data:: ECORE_CALLBACK_DONE
Return value to stop event handling
.. _Ecore_Pos_Map:
Position mappings for the animation
===================================
.. data:: ECORE_POS_MAP_LINEAR
Linear 0.0 -> 1.0
.. data:: ECORE_POS_MAP_ACCELERATE
Start slow then speed up
.. data:: ECORE_POS_MAP_DECELERATE
Start fast then slow down
.. data:: ECORE_POS_MAP_SINUSOIDAL
Start slow, speed up then slow down at end
.. data:: ECORE_POS_MAP_ACCELERATE_FACTOR
Start slow then speed up, v1 being a power factor, 0.0 being linear, 1.0 being normal accelerate, 2.0 being much more pronounced accelerate (squared), 3.0 being cubed, etc.
.. data:: ECORE_POS_MAP_DECELERATE_FACTOR
Start fast then slow down, v1 being a power factor, 0.0 being linear, 1.0 being normal decelerate, 2.0 being much more pronounced decelerate (squared), 3.0 being cubed, etc.
.. data:: ECORE_POS_MAP_SINUSOIDAL_FACTOR
Start slow, speed up then slow down at end, v1 being a power factor, 0.0 being linear, 1.0 being normal sinusoidal, 2.0 being much more pronounced sinusoidal (squared), 3.0 being cubed, etc.
.. data:: ECORE_POS_MAP_DIVISOR_INTERP
Start at gradient * v1, interpolated via power of v2 curve
.. data:: ECORE_POS_MAP_BOUNCE
Start at 0.0 then "drop" like a ball bouncing to the ground at 1.0, and bounce v2 times, with decay factor of v1
.. data:: ECORE_POS_MAP_SPRING
Start at 0.0 then "wobble" like a spring rest position 1.0, and wobble v2 times, with decay factor of v1
.. _Ecore_Animator_Source:
Timing sources for animators
============================
.. data:: ECORE_ANIMATOR_SOURCE_TIMER
The default system clock/timer based animator that ticks every "frametime" seconds
.. data:: ECORE_ANIMATOR_SOURCE_CUSTOM
A custom animator trigger that you need to call ecore_animator_trigger() to make it tick
.. Ecore_File_Event:
File monitor events
===================
.. data:: ECORE_FILE_EVENT_NONE
No event
.. data:: ECORE_FILE_EVENT_CREATED_FILE
A file has been created
.. data:: ECORE_FILE_EVENT_CREATED_DIRECTORY
A directory has been created
.. data:: ECORE_FILE_EVENT_DELETED_FILE
A file has been deleted
.. data:: ECORE_FILE_EVENT_DELETED_DIRECTORY
A directory has been deleted
.. data:: ECORE_FILE_EVENT_DELETED_SELF
The monitored path itself has been deleted
.. data:: ECORE_FILE_EVENT_MODIFIED
A file has changed
.. data:: ECORE_FILE_EVENT_CLOSED
A file has been closed
"""
from libc.stdint cimport uintptr_t
import traceback
from efl.eo cimport Eo, PY_REFCOUNT
from efl.utils.conversions cimport _ctouni
from cpython cimport Py_INCREF, Py_DECREF
cimport efl.ecore.enums as enums
ECORE_CALLBACK_CANCEL = enums.ECORE_CALLBACK_CANCEL
ECORE_CALLBACK_RENEW = enums.ECORE_CALLBACK_RENEW
ECORE_CALLBACK_PASS_ON = enums.ECORE_CALLBACK_PASS_ON
ECORE_CALLBACK_DONE = enums.ECORE_CALLBACK_DONE
# Ecore_Fd_Handler_Flags:
ECORE_FD_READ = enums.ECORE_FD_READ
ECORE_FD_WRITE = enums.ECORE_FD_WRITE
ECORE_FD_ERROR = enums.ECORE_FD_ERROR
ECORE_FD_ALL = 7
# Ecore_Exe_Flags:
ECORE_EXE_PIPE_READ = enums.ECORE_EXE_PIPE_READ
ECORE_EXE_PIPE_WRITE = enums.ECORE_EXE_PIPE_WRITE
ECORE_EXE_PIPE_ERROR = enums.ECORE_EXE_PIPE_ERROR
ECORE_EXE_PIPE_READ_LINE_BUFFERED = enums.ECORE_EXE_PIPE_READ_LINE_BUFFERED
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = enums.ECORE_EXE_PIPE_ERROR_LINE_BUFFERED
ECORE_EXE_PIPE_AUTO = enums.ECORE_EXE_PIPE_AUTO
ECORE_EXE_RESPAWN = enums.ECORE_EXE_RESPAWN
ECORE_EXE_USE_SH = enums.ECORE_EXE_USE_SH
ECORE_EXE_NOT_LEADER = enums.ECORE_EXE_NOT_LEADER
ECORE_EXE_TERM_WITH_PARENT = enums.ECORE_EXE_TERM_WITH_PARENT
ECORE_EXE_PRIORITY_INHERIT = 9999
# Ecore_File_Progress_Return:
ECORE_FILE_PROGRESS_CONTINUE = 0
ECORE_FILE_PROGRESS_ABORT = 1
# Ecore_File_Event
ECORE_FILE_EVENT_NONE = enums.ECORE_FILE_EVENT_NONE
ECORE_FILE_EVENT_CREATED_FILE = enums.ECORE_FILE_EVENT_CREATED_FILE
ECORE_FILE_EVENT_CREATED_DIRECTORY = enums.ECORE_FILE_EVENT_CREATED_DIRECTORY
ECORE_FILE_EVENT_DELETED_FILE = enums.ECORE_FILE_EVENT_DELETED_FILE
ECORE_FILE_EVENT_DELETED_DIRECTORY = enums.ECORE_FILE_EVENT_DELETED_DIRECTORY
ECORE_FILE_EVENT_DELETED_SELF = enums.ECORE_FILE_EVENT_DELETED_SELF
ECORE_FILE_EVENT_MODIFIED = enums.ECORE_FILE_EVENT_MODIFIED
ECORE_FILE_EVENT_CLOSED = enums.ECORE_FILE_EVENT_CLOSED
# Ecore_Poller_Type:
ECORE_POLLER_CORE = enums.ECORE_POLLER_CORE
cdef Eina_Bool _ecore_task_cb(void *data) with gil:
cdef Eo obj = <Eo>data
cdef Eina_Bool ret
try:
ret = obj._task_exec()
except Exception:
traceback.print_exc()
ret = 0
if not ret:
obj.delete()
return ret
cdef int _ecore_events_registered = 0
def init():
global _ecore_events_registered
r = ecore_init()
if r > 0 and _ecore_events_registered == 0:
_ecore_events_registered = 1
global _event_type_mapping
_event_type_mapping = {
enums.ECORE_EVENT_SIGNAL_USER: EventSignalUser,
enums.ECORE_EVENT_SIGNAL_HUP: EventSignalHup,
enums.ECORE_EVENT_SIGNAL_EXIT: EventSignalExit,
enums.ECORE_EVENT_SIGNAL_POWER: EventSignalPower,
enums.ECORE_EVENT_SIGNAL_REALTIME: EventSignalRealtime,
enums.ECORE_EXE_EVENT_ADD: EventExeAdd,
enums.ECORE_EXE_EVENT_DEL: EventExeDel,
enums.ECORE_EXE_EVENT_DATA: EventExeData,
enums.ECORE_EXE_EVENT_ERROR: EventExeData,
}
ecore_file_init()
return r
def shutdown():
ecore_file_shutdown()
return ecore_shutdown()
def main_loop_quit():
ecore_main_loop_quit()
def main_loop_begin():
with nogil:
ecore_main_loop_begin()
def main_loop_iterate():
with nogil:
ecore_main_loop_iterate()
def main_loop_glib_integrate():
if not ecore_main_loop_glib_integrate():
raise SystemError("failed to integrate GLib main loop into ecore.")
def main_loop_glib_always_integrate_disable():
ecore_main_loop_glib_always_integrate_disable()
def time_get():
return ecore_time_get()
def loop_time_get():
return ecore_loop_time_get()
include "efl.ecore_animator.pxi"
include "efl.ecore_timer.pxi"
include "efl.ecore_poller.pxi"
include "efl.ecore_idler.pxi"
include "efl.ecore_fd_handler.pxi"
include "efl.ecore_events.pxi"
include "efl.ecore_exe.pxi"
include "efl.ecore_file_download.pxi"
include "efl.ecore_file_monitor.pxi"
init()
#---------------------------------------------------------------------------
# let's try to warn users that ecore conflicts with subprocess module
import subprocess
_orig_subprocess = None
def subprocess_warning(*a, **ka):
print(""" DEVELOPER WARNING:
Using subprocess (Popen and derivatives) with Ecore is a bad idea.
Ecore will set some signal handlers subprocess module depends and this
may cause this module to operate unexpectedly.
Instead of using subprocess.Popen(), please consider using Ecore's
Exe() class.
""")
return _orig_subprocess(*a, **ka)
if subprocess.Popen is not subprocess_warning:
_orig_subprocess = subprocess.Popen
subprocess.Popen = subprocess_warning
#---------------------------------------------------------------------------
# also try to warn that ecore conflicts with signal module
import signal
_orig_signal = None
def signal_warning(sig, action):
if sig in (signal.SIGPIPE, signal.SIGALRM, signal.SIGCHLD, signal.SIGUSR1,
signal.SIGUSR2, signal.SIGHUP, signal.SIGQUIT, signal.SIGINT,
signal.SIGTERM, signal.SIGPWR):
print(""" DEVELOPER WARNING:
Ecore already defines signal handlers for:
SIGPIPE, SIGALRM, SIGCHLD, SIGUSR1, SIGUSR2
SIGHUP, SIGQUIT, SIGINT, SIGTERM, SIGPWR, SIGRT*
Since you're defining a new signal handler, you might collide with
Ecore and bad things may happen!
""")
return _orig_signal(sig, action)
if signal.signal is not signal_warning:
_orig_signal = signal.signal
signal.signal = signal_warning

1629
efl/ecore_x/efl.ecore_x.pxd Normal file

File diff suppressed because it is too large Load Diff

302
efl/ecore_x/efl.ecore_x.pyx Normal file
View File

@ -0,0 +1,302 @@
# 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/>.
#from cpython cimport PyObject, Py_INCREF, Py_DECREF
from cpython cimport PyMem_Malloc, PyMem_Free, PyUnicode_AsUTF8String
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 int i
if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name)
i = ecore_x_init(<char *>name if name is not None else NULL)
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)
def keyboard_ungrab():
ecore_x_keyboard_ungrab()
def screensaver_event_available_get():
""" .. versionadded:: 1.11 """
return bool(ecore_x_screensaver_event_available_get())
def screensaver_idle_time_get():
""" .. versionadded:: 1.11 """
return ecore_x_screensaver_idle_time_get()
def screensaver_set(int timeout, int interval, int prefer_blanking, int allow_exposures):
""" .. versionadded:: 1.11 """
ecore_x_screensaver_set(timeout, interval, prefer_blanking, allow_exposures)
def screensaver_timeout_set(int timeout):
""" .. versionadded:: 1.11 """
ecore_x_screensaver_timeout_set(timeout)
def screensaver_timeout_get():
""" .. versionadded:: 1.11 """
return ecore_x_screensaver_timeout_get()
def screensaver_blank_set(int timeout):
""" .. versionadded:: 1.11 """
ecore_x_screensaver_blank_set(timeout)
def screensaver_blank_get():
""" .. versionadded:: 1.11 """
return ecore_x_screensaver_blank_get()
def screensaver_expose_set(int timeout):
""" .. versionadded:: 1.11 """
ecore_x_screensaver_expose_set(timeout)
def screensaver_expose_get():
""" .. versionadded:: 1.11 """
return ecore_x_screensaver_expose_get()
def screensaver_interval_set(int timeout):
""" .. versionadded:: 1.11 """
ecore_x_screensaver_interval_set(timeout)
def screensaver_interval_get():
""" .. versionadded:: 1.11 """
return ecore_x_screensaver_interval_get()
def screensaver_event_listen_set(Eina_Bool on):
""" .. versionadded:: 1.11 """
ecore_x_screensaver_event_listen_set(on)
def screensaver_custom_blanking_enable():
""" .. versionadded:: 1.11 """
return bool(ecore_x_screensaver_custom_blanking_enable())
def screensaver_custom_blanking_disable():
""" .. versionadded:: 1.11 """
return bool(ecore_x_screensaver_custom_blanking_disable())
def screensaver_supend():
""" .. versionadded:: 1.11 """
ecore_x_screensaver_supend()
def screensaver_resume():
""" .. versionadded:: 1.11 """
ecore_x_screensaver_resume()
include "efl.ecore_x_window.pxi"
include "efl.ecore_x_events.pxi"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,466 @@
# 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/>.
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 keyboard_grab(self):
return bool(ecore_x_keyboard_grab(self.xid))
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

351
include/efl.ecore.pxd Normal file
View File

@ -0,0 +1,351 @@
# 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/>.
from efl.eina cimport *
from efl.c_eo cimport Eo as cEo
from efl.eo cimport Eo
from efl.ecore.enums cimport Ecore_Fd_Handler_Flags, Ecore_Exe_Flags, \
Ecore_File_Event, Ecore_Poller_Type
cdef extern from "Ecore.h":
####################################################################
# Basic Types
#
ctypedef cEo Ecore_Timer
ctypedef cEo Ecore_Animator
ctypedef cEo Ecore_Poller
ctypedef cEo Ecore_Idler
ctypedef cEo Ecore_Idle_Enterer
ctypedef cEo Ecore_Idle_Exiter
ctypedef struct Ecore_Event_Handler
ctypedef struct Ecore_Event
ctypedef struct Ecore_Event_Signal_User:
int number
ctypedef struct Ecore_Event_Signal_Exit:
unsigned int interrupt
unsigned int quit
unsigned int terminate
ctypedef struct Ecore_Event_Signal_Realtime:
int num
ctypedef struct Ecore_Exe_Event_Add:
Ecore_Exe *exe
void *ext_data
ctypedef struct Ecore_Exe_Event_Del:
int pid
int exit_code
Ecore_Exe *exe
int exit_signal
unsigned int exited
unsigned int signalled
void *ext_data
ctypedef struct Ecore_Exe_Event_Data:
Ecore_Exe *exe
void *data
int size
Ecore_Exe_Event_Data_Line *lines
ctypedef struct Ecore_Exe_Event_Data_Line:
char *line
int size
ctypedef struct Ecore_Fd_Handler
ctypedef struct Ecore_Exe
####################################################################
# Other typedefs
#
ctypedef void (*Ecore_Cb)(void *data)
ctypedef Eina_Bool (*Ecore_Task_Cb)(void *data)
ctypedef Eina_Bool (*Ecore_Fd_Cb)(void *data, Ecore_Fd_Handler *fd_handler)
ctypedef void (*Ecore_Fd_Prep_Cb)(void *data, Ecore_Fd_Handler *fd_handler)
ctypedef Eina_Bool (*Ecore_Event_Handler_Cb)(void *data, int type, void *event)
ctypedef void (*Ecore_End_Cb)(void *user_data, void *func_data)
ctypedef void (*Ecore_Exe_Cb)(void *data, const Ecore_Exe *exe)
ctypedef Eina_Bool (*Ecore_Timeline_Cb)(void *data, double pos)
####################################################################
# Functions
#
int ecore_init()
int ecore_shutdown()
void ecore_main_loop_iterate() nogil
void ecore_main_loop_begin() nogil
void ecore_main_loop_quit()
int ecore_main_loop_glib_integrate()
void ecore_main_loop_glib_always_integrate_disable()
double ecore_time_get()
double ecore_loop_time_get()
Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, void *data)
Ecore_Animator *ecore_animator_timeline_add(double runtime, Ecore_Timeline_Cb func, void *data)
void *ecore_animator_del(Ecore_Animator *animator)
void ecore_animator_frametime_set(double frametime)
double ecore_animator_frametime_get()
Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data)
void *ecore_poller_del(Ecore_Poller *poller)
Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval)
int ecore_poller_poller_interval_get(Ecore_Poller *poller)
Ecore_Timer *ecore_timer_add(double t, Ecore_Task_Cb func, void *data)
void *ecore_timer_del(Ecore_Timer *timer)
void ecore_timer_freeze(Ecore_Timer *timer)
void ecore_timer_thaw(Ecore_Timer *timer)
void ecore_timer_interval_set(Ecore_Timer *timer, double t)
double ecore_timer_interval_get(Ecore_Timer *timer)
void ecore_timer_delay(Ecore_Timer *timer, double add)
void ecore_timer_reset(Ecore_Timer *timer)
double ecore_timer_pending_get(Ecore_Timer *timer)
double ecore_timer_precision_get()
double ecore_timer_precision_set(double value)
Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func, void *data)
void *ecore_idler_del(Ecore_Idler *idler)
Ecore_Idler *ecore_idle_enterer_add(Ecore_Task_Cb func, void *data)
void *ecore_idle_enterer_del(Ecore_Idler *idler)
Ecore_Idler *ecore_idle_exiter_add(Ecore_Task_Cb func, void *data)
void *ecore_idle_exiter_del(Ecore_Idler *idler)
Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func, void *data, Ecore_Fd_Cb buf_func, void *buf_data)
void ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, void *data)
void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler)
int ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
Ecore_Event_Handler *ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, void *data)
void *ecore_event_handler_del(Ecore_Event_Handler *event_handler)
int ecore_event_type_new()
Ecore_Event *ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data)
void *ecore_event_del(Ecore_Event *ev)
void ecore_exe_run_priority_set(int pri)
int ecore_exe_run_priority_get()
Ecore_Exe *ecore_exe_pipe_run(char *exe_cmd, Ecore_Exe_Flags flags, void *data)
void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func)
int ecore_exe_send(Ecore_Exe *exe, const void *data, int size)
void ecore_exe_close_stdin(Ecore_Exe *exe)
void ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines)
Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
void ecore_exe_event_data_free(Ecore_Exe_Event_Data *data)
void *ecore_exe_free(Ecore_Exe *exe)
int ecore_exe_pid_get(Ecore_Exe *exe)
void ecore_exe_tag_set(Ecore_Exe *exe, char *tag)
const char * ecore_exe_tag_get(Ecore_Exe *exe)
const char * ecore_exe_cmd_get(Ecore_Exe *exe)
void *ecore_exe_data_get(Ecore_Exe *exe)
Ecore_Exe_Flags ecore_exe_flags_get(Ecore_Exe *exe)
void ecore_exe_pause(Ecore_Exe *exe)
void ecore_exe_continue(Ecore_Exe *exe)
void ecore_exe_interrupt(Ecore_Exe *exe)
void ecore_exe_quit(Ecore_Exe *exe)
void ecore_exe_terminate(Ecore_Exe *exe)
void ecore_exe_kill(Ecore_Exe *exe)
void ecore_exe_signal(Ecore_Exe *exe, int num)
void ecore_exe_hup(Ecore_Exe *exe)
cdef extern from "Ecore_File.h":
ctypedef struct Ecore_File_Download_Job
ctypedef struct Ecore_File_Monitor
ctypedef void (*Ecore_File_Download_Completion_Cb)(void *data, const char *file, int status)
ctypedef int (*Ecore_File_Download_Progress_Cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow)
ctypedef void (*Ecore_File_Monitor_Cb)(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path)
int ecore_file_init()
int ecore_file_shutdown()
void ecore_file_download_abort(Ecore_File_Download_Job *job)
void ecore_file_download_abort_all()
Eina_Bool ecore_file_download_protocol_available(const char *protocol)
Eina_Bool ecore_file_download(const char *url, const char *dst,
Ecore_File_Download_Completion_Cb completion_cb,
Ecore_File_Download_Progress_Cb progress_cb,
void *data,
Ecore_File_Download_Job **job_ret)
Ecore_File_Monitor *ecore_file_monitor_add(const char *path, Ecore_File_Monitor_Cb func, void *data)
void ecore_file_monitor_del(Ecore_File_Monitor *ecore_file_monitor)
const char *ecore_file_monitor_path_get(Ecore_File_Monitor *ecore_file_monitor)
####################################################################
# Python classes
#
cdef class Timer(Eo):
cdef double _interval
cdef readonly object func, args, kargs
cpdef bint _task_exec(self) except *
cdef class Animator(Eo):
cdef readonly object func
cdef readonly tuple args
cdef readonly dict kargs
cpdef bint _task_exec(self) except *
cdef class Poller(Eo):
cdef readonly object func
cdef readonly tuple args
cdef readonly dict kargs
cpdef bint _task_exec(self) except *
cdef class Idler(Eo):
cdef readonly object func, args, kargs
cpdef bint _task_exec(self) except *
cdef class IdleEnterer(Idler):
pass
cdef class IdleExiter(Idler):
pass
cdef class FdHandler(object):
cdef Ecore_Fd_Handler *obj
cdef readonly object func
cdef readonly object args
cdef readonly object kargs
cdef readonly object _prepare_callback
cdef object _exec(self)
cdef class Exe(object):
cdef Ecore_Exe *exe
cdef readonly object __data
cdef object __callbacks
cdef int _set_obj(self, char *exe_cmd, int flags) except 0
cdef int _unset_obj(self) except 0
cdef class ExeEventFilter(object):
cdef Ecore_Exe *exe
cdef Ecore_Event_Handler *handler
cdef readonly object owner
cdef readonly int event_type
cdef object callbacks
cdef class EventHandler(object):
cdef Ecore_Event_Handler *obj
cdef readonly int type
cdef readonly object event_cls
cdef readonly object func
cdef readonly object args
cdef readonly object kargs
cdef int _set_obj(self, Ecore_Event_Handler *obj) except 0
cdef int _unset_obj(self) except 0
cdef Eina_Bool _exec(self, void *event) except 2
cdef class Event(object):
cdef int _set_obj(self, void *obj) except 0
cdef class EventSignalUser(Event):
cdef readonly object number
cdef class EventSignalHup(Event):
pass
cdef class EventSignalExit(Event):
cdef readonly object interrupt
cdef readonly object quit
cdef readonly object terminate
cdef class EventSignalPower(Event):
pass
cdef class CustomEvent(Event):
cdef readonly object obj
cdef class QueuedEvent:
cdef Ecore_Event *obj
cdef readonly object args
cdef int _set_obj(self, Ecore_Event *ev) except 0
cdef int _unset_obj(self) except 0
cdef class EventExeAdd(Event):
cdef readonly object exe
cdef class EventExeDel(Event):
cdef readonly object exe
cdef readonly object pid
cdef readonly object exit_code
cdef readonly object exit_signal
cdef readonly object exited
cdef readonly object signalled
cdef class EventExeData(Event):
cdef readonly object exe
cdef readonly object data
cdef readonly object size
cdef readonly object lines
cdef class FileDownload:
cdef Ecore_File_Download_Job *job
cdef readonly object completion_cb
cdef readonly object progress_cb
cdef readonly object args
cdef readonly object kargs
cdef object _exec_completion(self, const char *file, int status)
cdef object _exec_progress(self, const char *file,
long int dltotal, long int dlnow,
long int ultotal, long int ulnow)
cdef class FileMonitor:
cdef Ecore_File_Monitor *mon
cdef readonly object monitor_cb
cdef readonly object args
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)

View File

@ -227,36 +227,37 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
# === Ecore ===
ecore_cflags, ecore_libs = pkg_config('Ecore', 'ecore', EFL_MIN_VER)
ecore_file_cflags, ecore_file_libs = pkg_config(
'EcoreFile', 'ecore-file', EFL_MIN_VER)
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),
]
ecore_file_cflags, ecore_file_libs = pkg_config('EcoreFile', 'ecore-file',
EFL_MIN_VER)
ecore_ext = Extension("ecore", ["efl/ecore/efl.ecore" + 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)
ext_modules.append(ecore_ext)
# === Ecore X ===
try:
ecore_input_cflags, ecore_input_libs = pkg_config(
'EcoreInput', 'ecore-input', EFL_MIN_VER)
ecore_x_cflags, ecore_x_libs = pkg_config(
'EcoreX', 'ecore-x', EFL_MIN_VER)
ecore_input_cflags, ecore_input_libs = pkg_config('EcoreInput',
'ecore-input',
EFL_MIN_VER)
ecore_x_cflags, ecore_x_libs = pkg_config('EcoreX', 'ecore-x',