Python-EFL: Cleanup and enable compilation of emotion, cleaned also the test.

SVN revision: 83931
This commit is contained in:
Davide Andreoli 2013-02-14 23:05:55 +00:00
parent 85272ee9e2
commit 454d967f84
6 changed files with 100 additions and 170 deletions

View File

@ -55,5 +55,5 @@
You can run individual tests or use the 00_run_all_tests.py in each folder or
even in the tests/ base dir to run all the tests at once.
The tests in elementary are not unittest and are meant to be run by the user
as they usually require some sort of interaction.
The tests in elementary and emotion are not unittest and are meant to be
run by the user as they usually require some sort of interaction.

3
TODO
View File

@ -3,7 +3,6 @@ BUGS:
* Evas: smart object doesn't work
* test_core_evas_canvas_callbacks.py have 2 lines commented out
* test_emotion.py loop on shutdown (parent issue)
* edje.color_class_list() is broken in C (disabled in edje/test_01_basics.py)
* edje.text_class_list() is broken in C (disabled out in edje/test_01_basics.py)
@ -26,6 +25,7 @@ TODO:
* elm.Conformant need a test
* include python-ethumb
* include python-e_dbus (or make edbus2 ??)
* check emotion api completness
TODO FOR PYTHON 3:
@ -52,3 +52,4 @@ CHANGES FROM 1.7 to 1.8:
* added efl container package
* ecore.file.Download => efl.ecore.FileDownload
* Emotion(module_filename="xxx") => Emotion(module_name="xxx")

View File

@ -23,40 +23,63 @@ from efl.evas cimport evas_object_smart_callback_add
from efl.evas cimport evas_object_smart_callback_del
__extra_epydoc_fields__ = (
("parm", "Parameter", "Parameters"), # epydoc don't support pyrex properly
)
EMOTION_EVENT_MENU1 = 0
EMOTION_EVENT_MENU2 = 1
EMOTION_EVENT_MENU3 = 2
EMOTION_EVENT_MENU4 = 3
EMOTION_EVENT_MENU5 = 4
EMOTION_EVENT_MENU6 = 5
EMOTION_EVENT_MENU7 = 6
EMOTION_EVENT_UP = 7
EMOTION_EVENT_DOWN = 8
EMOTION_EVENT_LEFT = 9
EMOTION_EVENT_RIGHT = 10
EMOTION_EVENT_SELECT = 11
EMOTION_EVENT_NEXT = 12
EMOTION_EVENT_PREV = 13
# Emotion_Event:
EMOTION_EVENT_MENU1 = 0
EMOTION_EVENT_MENU2 = 1
EMOTION_EVENT_MENU3 = 2
EMOTION_EVENT_MENU4 = 3
EMOTION_EVENT_MENU5 = 4
EMOTION_EVENT_MENU6 = 5
EMOTION_EVENT_MENU7 = 6
EMOTION_EVENT_UP = 7
EMOTION_EVENT_DOWN = 8
EMOTION_EVENT_LEFT = 9
EMOTION_EVENT_RIGHT = 10
EMOTION_EVENT_SELECT = 11
EMOTION_EVENT_NEXT = 12
EMOTION_EVENT_PREV = 13
EMOTION_EVENT_ANGLE_NEXT = 14
EMOTION_EVENT_ANGLE_PREV = 15
EMOTION_EVENT_FORCE = 16
EMOTION_EVENT_0 = 17
EMOTION_EVENT_1 = 18
EMOTION_EVENT_2 = 19
EMOTION_EVENT_3 = 20
EMOTION_EVENT_4 = 21
EMOTION_EVENT_5 = 22
EMOTION_EVENT_6 = 23
EMOTION_EVENT_7 = 24
EMOTION_EVENT_8 = 25
EMOTION_EVENT_9 = 26
EMOTION_EVENT_10 = 27
EMOTION_EVENT_FORCE = 16
EMOTION_EVENT_0 = 17
EMOTION_EVENT_1 = 18
EMOTION_EVENT_2 = 19
EMOTION_EVENT_3 = 20
EMOTION_EVENT_4 = 21
EMOTION_EVENT_5 = 22
EMOTION_EVENT_6 = 23
EMOTION_EVENT_7 = 24
EMOTION_EVENT_8 = 25
EMOTION_EVENT_9 = 26
EMOTION_EVENT_10 = 27
# Emotion_Meta_Info:
EMOTION_META_INFO_TRACK_TITLE = 0
EMOTION_META_INFO_TRACK_ARTIST = 1
EMOTION_META_INFO_TRACK_ALBUM = 2
EMOTION_META_INFO_TRACK_YEAR = 3
EMOTION_META_INFO_TRACK_GENRE = 4
EMOTION_META_INFO_TRACK_COMMENT = 5
EMOTION_META_INFO_TRACK_DISC_ID = 6
EMOTION_META_INFO_TRACK_COUNT = 7
# Emotion_Channel_Settings:
EMOTION_CHANNEL_AUTO = -1
EMOTION_CHANNEL_DEFAULT = 0
# Emotion_Aspect:
EMOTION_ASPECT_KEEP_NONE = 0
EMOTION_ASPECT_KEEP_WIDTH = 1
EMOTION_ASPECT_KEEP_HEIGHT = 2
EMOTION_ASPECT_KEEP_BOTH = 3
EMOTION_ASPECT_CROP = 4
EMOTION_ASPECT_CUSTOM = 5
# Emotion_Suspend:
EMOTION_WAKEUP = 0
EMOTION_SLEEP = 1
EMOTION_DEEP_SLEEP = 2
EMOTION_HIBERNATE = 3
cdef void _emotion_callback(void *data, Evas_Object *o, void *ei) with gil:
@ -90,20 +113,18 @@ cdef class Emotion(evasObject):
self._emotion_callbacks = {}
def __init__(self, Canvas canvas not None, **kargs):
if self.obj == NULL:
self._set_obj(emotion_object_add(canvas.obj))
# self._add_obj(emotion_object_class_get(), canvas.obj)
self._set_obj(emotion_object_add(canvas.obj))
self._set_common_params(**kargs)
def _set_common_params(self,
char *module_filename="gstreamer",
char *module_name="gstreamer",
module_params=None, size=None, pos=None,
geometry=None, color=None, name=None):
evasObject._set_common_params(self, size=size, pos=pos, name=name,
geometry=geometry, color=color)
if emotion_object_init(self.obj, module_filename) == 0:
if emotion_object_init(self.obj, module_name) == 0:
raise EmotionModuleInitError("failed to initialize module '%s'" %
module_filename)
module_name)
if isinstance(module_params, (tuple, list)):
module_params = dict(module_params)
@ -489,13 +510,6 @@ cdef class Emotion(evasObject):
return self.meta_info_dict_get()
def callback_add(self, char *event, func, *args, **kargs):
"""Add callback to given emotion event.
Signature: C{function(object, *args, **kargs)}
@parm: B{event} event to listen, like "frame_decode".
@parm: B{func} callable to use.
"""
e = intern(event)
lst = self._emotion_callbacks.setdefault(e, [])
if not lst:
@ -504,11 +518,6 @@ cdef class Emotion(evasObject):
lst.append((func, args, kargs))
def callback_del(self, char *event, func):
"""Remove previously connected callback.
@parm: B{event}
@parm: B{func}
"""
try:
lst = self._emotion_callbacks[event]
except KeyError, e:
@ -603,4 +612,5 @@ cdef class Emotion(evasObject):
_object_mapping_register("Emotion_Object", Emotion)
init()

View File

@ -21,54 +21,18 @@ from efl.evas cimport Object as evasObject
cdef extern from "Emotion.h":
ctypedef enum Emotion_Module:
EMOTION_MODULE_XINE = 0
EMOTION_MODULE_GSTREAMER
ctypedef enum Emotion_Event:
pass
# EMOTION_EVENT_MENU1 = 0
# EMOTION_EVENT_MENU2
# EMOTION_EVENT_MENU3
# EMOTION_EVENT_MENU4
# EMOTION_EVENT_MENU5
# EMOTION_EVENT_MENU6
# EMOTION_EVENT_MENU7
# EMOTION_EVENT_UP
# EMOTION_EVENT_DOWN
# EMOTION_EVENT_LEFT
# EMOTION_EVENT_RIGHT
# EMOTION_EVENT_SELECT
# EMOTION_EVENT_NEXT
# EMOTION_EVENT_PREV
# EMOTION_EVENT_ANGLE_NEXT
# EMOTION_EVENT_ANGLE_PREV
# EMOTION_EVENT_FORCE
# EMOTION_EVENT_0
# EMOTION_EVENT_1
# EMOTION_EVENT_2
# EMOTION_EVENT_3
# EMOTION_EVENT_4
# EMOTION_EVENT_5
# EMOTION_EVENT_6
# EMOTION_EVENT_7
# EMOTION_EVENT_8
# EMOTION_EVENT_9
# EMOTION_EVENT_10
ctypedef enum Emotion_Meta_Info:
EMOTION_META_INFO_TRACK_TITLE
EMOTION_META_INFO_TRACK_ARTIST
EMOTION_META_INFO_TRACK_ALBUM
EMOTION_META_INFO_TRACK_YEAR
EMOTION_META_INFO_TRACK_GENRE
EMOTION_META_INFO_TRACK_COMMENT
EMOTION_META_INFO_TRACK_DISC_ID
EMOTION_META_INFO_TRACK_COUNT
pass
cdef enum Emotion_Channel_Settings:
EMOTION_CHANNEL_AUTO = -1
EMOTION_CHANNEL_DEFAULT = 0
ctypedef enum Emotion_Aspect:
pass
ctypedef enum Emotion_Suspend:
pass
Eina_Bool emotion_init()
Eina_Bool emotion_shutdown()

View File

@ -77,12 +77,12 @@ edje_ext = Extension("efl.edje", ["efl/edje/efl.edje.pyx"],
modules.append(edje_ext)
# Emotion
# emotion_cflags, emotion_libs = pkg_config('Emotion', 'emotion', "1.7.99")
# emotion_ext = Extension("efl.emotion", ["efl/emotion/efl.emotion.pyx"],
# include_dirs = ['include/'],
# extra_compile_args = emotion_cflags,
# extra_link_args = emotion_libs)
# modules.append(emotion_ext)
emotion_cflags, emotion_libs = pkg_config('Emotion', 'emotion', "1.7.99")
emotion_ext = Extension("efl.emotion", ["efl/emotion/efl.emotion.pyx"],
include_dirs = ['include/'],
extra_compile_args = emotion_cflags,
extra_link_args = emotion_libs)
modules.append(emotion_ext)
# Elementary
elm_cflags, elm_libs = pkg_config('Elementary', 'elementary', "1.7.99")

View File

@ -25,28 +25,28 @@ theme_file = data_dir + "/theme.edj"
class MovieWindow(edje.Edje):
def __init__(self, canvas, media_module, media_file):
# emotion video
# self.vid = emotion.Emotion(canvas, module_filename=media_module)
# self.vid.file = media_file
# self.vid.smooth_scale = True
# self.vid.play = True
self.vid = emotion.Emotion(canvas, module_name=media_module)
self.vid.file = media_file
self.vid.smooth_scale = True
self.vid.play = True
# edje scene object
edje.Edje.__init__(self, canvas, size=(320, 240),
file=theme_file, group="video_controller")
self.part_drag_value_set("video_speed", 0.0, 1.0)
self.part_text_set("video_speed_txt", "1.0")
# self.part_swallow("video_swallow", self.vid)
self.part_swallow("video_swallow", self.vid)
self.data["moving"] = False
self.data["resizing"] = False
# connect edje + emotion signals
# self._setup_signals_video()
# self._setup_signals_frame()
self._setup_signals_video()
self._setup_signals_frame()
def _setup_signals_video(self):
# connect emotion events
# self.vid.on_frame_decode_add(self.vid_frame_decode_cb)
# self.vid.on_length_change_add(self.vid_length_change_cb)
self.vid.on_frame_decode_add(self.vid_frame_decode_cb)
self.vid.on_length_change_add(self.vid_length_change_cb)
self.vid.on_frame_resize_add(self.vid_frame_resize_cb)
self.vid.on_decode_stop_add(self.vid_decode_stop_cb)
self.vid.on_channels_change_add(self.vid_channels_change_cb)
@ -194,7 +194,7 @@ class MovieWindow(edje.Edje):
def vid_button_change_cb(self, vid):
print "spu button:", vid.spu_button
"""
class AppKeyboardEvents(object):
def broadcast_event(win, event):
for mw in win.data["movie_windows"]:
@ -237,11 +237,11 @@ class AppKeyboardEvents(object):
# print "avoid_damage is now", win.avoid_damage
def shaped_change(win):
win.shaped = not win.shaped
win.shaped = False if win.shaped else True
print "shaped is now", win.shaped
def bordless_change(win):
win.borderless = not win.borderless
win.borderless = False if win.borderless else True
print "borderless is now", win.borderless
def main_delete_request(win):
@ -290,37 +290,7 @@ class AppKeyboardEvents(object):
pass
except Exception, e:
print "%s ignored exception: %s" % (self.__class__.__name__, e)
"""
"""
def create_scene(ee, canvas):
bg = edje.Edje(canvas, file=theme_file, group="background")
bg.size = canvas.size
bg.layer = -999
bg.focus = True
bg.show()
bg.on_key_down_add(AppKeyboardEvents(), ee)
ee.data["bg"] = bg
def create_videos(ee, canvas, media_module, args):
objects = []
for fname in args:
mw = MovieWindow(canvas, media_module=media_module, media_file=fname)
mw.show()
mw.play = True
objects.append(mw)
ee.data["movie_windows"] = objects
def destroy_videos(ee):
for obj in ee.data["movie_windows"]:
obj.delete()
del ee.data["movie_windows"]
"""
def parse_geometry(option, opt, value, parser):
@ -341,9 +311,9 @@ def cmdline_parse():
default=(800, 600),
help="use given window geometry")
parser.add_option("-e", "--engine", type="choice",
choices=("xine", "gstreamer", "generic"), default="gstreamer",
help=("which multimedia engine to use (xine, gst, generic), "
"default=%default"))
choices=("xine", "gstreamer", "vlc"), default="gstreamer",
help=("multimedia engine to use (xine, gstreamer or vlc) "
"default=%default") )
options, args = parser.parse_args()
if not args:
parser.error("missing filename")
@ -359,13 +329,12 @@ if __name__ == "__main__"or True:
win = elementary.Window("test-emotion", elementary.ELM_WIN_BASIC)
win.title_set("python-emotion test application")
win.callback_delete_request_add(lambda o: elementary.exit())
# win.on_key_down_add(AppKeyboardEvents())
win.on_key_down_add(AppKeyboardEvents())
# edje main scene object
scene = edje.Edje(win.evas, file=theme_file, group="background")
win.resize_object_add(scene)
# win.data["scene"] = scene
scene.show()
# one edje frame for each file passed
@ -379,36 +348,22 @@ if __name__ == "__main__"or True:
i += 40
win.data["movie_windows"] = objects
r = evas.Rectangle(win.evas, size=(100,100))
r.show()
r.delete()
# vid = emotion.Emotion(win.evas, module_filename=options.engine)
# vid.file = args[0]
# vid.size=(200,200)
# vid.smooth_scale = True
# vid.play = True
# vid.show()
# show the win and enter elm main loop
win.resize(*options.geometry)
win.show()
elementary.run()
# Cleanup objects or you'll get "NAUGHTY PROGRAMMER!!!" on shutdown ;-)
# vid.delete()
# r.delete()
# for obj in win.data["movie_windows"]:
# obj.delete()
for obj in win.data["movie_windows"]:
obj.delete()
# scene.delete()
# del win.data["movie_windows"]
# win.delete()
# del scene
scene.delete()
del win.data["movie_windows"]
win.delete()
del scene
elementary.shutdown()
# emotion.shutdown()
# evas.shutdown()
emotion.shutdown()
edje.shutdown()
evas.shutdown()