From 2a303f29e18513aad046d607873babcf397429d3 Mon Sep 17 00:00:00 2001 From: davemds Date: Mon, 30 Jun 2014 20:52:36 +0200 Subject: [PATCH 01/30] Follow recent Eo class names changes --- efl/edje/efl.edje_object.pxi | 2 +- efl/evas/efl.evas_canvas.pxi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/efl/edje/efl.edje_object.pxi b/efl/edje/efl.edje_object.pxi index 2a49060..ed9ce29 100644 --- a/efl/edje/efl.edje_object.pxi +++ b/efl/edje/efl.edje_object.pxi @@ -1332,4 +1332,4 @@ def on_text_change(func): return func -_object_mapping_register("Edje", Edje) +_object_mapping_register("Edje_Object", Edje) diff --git a/efl/evas/efl.evas_canvas.pxi b/efl/evas/efl.evas_canvas.pxi index 708f615..c70fa30 100644 --- a/efl/evas/efl.evas_canvas.pxi +++ b/efl/evas/efl.evas_canvas.pxi @@ -880,4 +880,4 @@ cdef class Canvas(Eo): return Box(self, **kargs) -_object_mapping_register("Evas", Canvas) +_object_mapping_register("Evas_Canvas", Canvas) From bb77d08ed9e7e44ec06933ab2283dea944573939 Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Tue, 1 Jul 2014 20:39:09 +0300 Subject: [PATCH 02/30] Elementary: Fix object item tooltips It would be an ABI breakage if the tooltips had ever worked in the first place but apparently they never did. --- efl/elementary/gengrid_item.pxi | 14 +++++++------- efl/elementary/genlist_item.pxi | 13 +++++++------ efl/elementary/object_item.pyx | 13 ++++++------- efl/elementary/tooltips.pxi | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/efl/elementary/gengrid_item.pxi b/efl/elementary/gengrid_item.pxi index bc9013f..a535bf5 100644 --- a/efl/elementary/gengrid_item.pxi +++ b/efl/elementary/gengrid_item.pxi @@ -319,11 +319,11 @@ cdef class GengridItem(ObjectItem): def tooltip_content_cb_set(self, func, *args, **kargs): """Set the content to be shown in the tooltip object - Setup the tooltip to object. The object can have only one tooltip, - so any previews tooltip data is removed. ``func(args, kargs)`` will - be called every time that need show the tooltip and it should return a - valid Evas_Object. This object is then managed fully by tooltip system - and is deleted when the tooltip is gone. + Setup the tooltip to object. The object can have only one tooltip, so + any previews tooltip data is removed. ``func(owner, item, tooltip, + args, kargs)`` will be called every time that need show the tooltip and + it should return a valid Evas_Object. This object is then managed fully + by tooltip system and is deleted when the tooltip is gone. :param func: Function to be create tooltip content, called when need show tooltip. @@ -334,9 +334,9 @@ cdef class GengridItem(ObjectItem): cdef void *cbdata - data = (func, self, args, kargs) + data = (func, args, kargs) Py_INCREF(data) - # FIXME: refleak? + # DECREF is in data_del_cb cbdata = data elm_gengrid_item_tooltip_content_cb_set(self.item, _tooltip_item_content_create, diff --git a/efl/elementary/genlist_item.pxi b/efl/elementary/genlist_item.pxi index 96daebe..a5f84cc 100644 --- a/efl/elementary/genlist_item.pxi +++ b/efl/elementary/genlist_item.pxi @@ -399,11 +399,11 @@ cdef class GenlistItem(ObjectItem): def tooltip_content_cb_set(self, func, *args, **kargs): """Set the content to be shown in the tooltip object - Setup the tooltip to object. The object can have only one tooltip, - so any previews tooltip data is removed. ``func(args,kargs)`` will - be called every time that need show the tooltip and it should return - a valid Evas_Object. This object is then managed fully by tooltip - system and is deleted when the tooltip is gone. + Setup the tooltip to object. The object can have only one tooltip, so + any previews tooltip data is removed. ``func(owner, item, tooltip, + args, kargs)`` will be called every time that need show the tooltip and + it should return a valid Evas_Object. This object is then managed fully + by tooltip system and is deleted when the tooltip is gone. :param func: Function to be create tooltip content, called when need show tooltip. @@ -414,8 +414,9 @@ cdef class GenlistItem(ObjectItem): cdef void *cbdata - data = (func, self, args, kargs) + data = (func, args, kargs) Py_INCREF(data) + # DECREF is in data_del_cb cbdata = data elm_genlist_item_tooltip_content_cb_set(self.item, _tooltip_item_content_create, diff --git a/efl/elementary/object_item.pyx b/efl/elementary/object_item.pyx index 02e8a31..1e81dd6 100644 --- a/efl/elementary/object_item.pyx +++ b/efl/elementary/object_item.pyx @@ -477,12 +477,11 @@ cdef class ObjectItem(object): def tooltip_content_cb_set(self, func, *args, **kargs): """Set the content to be shown in the tooltip object - Setup the tooltip to object. The object can have only one tooltip, - so any previews tooltip data is removed. ``func(owner, tooltip, - args, kargs)`` will be called every time that need show the tooltip - and it should return a valid Evas_Object. This object is then - managed fully by tooltip system and is deleted when the tooltip is - gone. + Setup the tooltip to object. The object can have only one tooltip, so + any previews tooltip data is removed. ``func(owner, item, tooltip, + args, kargs)`` will be called every time that need show the tooltip and + it should return a valid Evas_Object. This object is then managed fully + by tooltip system and is deleted when the tooltip is gone. :param func: Function to be create tooltip content, called when need show tooltip. @@ -495,8 +494,8 @@ cdef class ObjectItem(object): cdef void *cbdata data = (func, args, kargs) - # FIXME: refleak Py_INCREF(data) + # DECREF is in data_del_cb cbdata = data elm_object_item_tooltip_content_cb_set(self.item, _tooltip_item_content_create, cbdata, _tooltip_item_data_del_cb) diff --git a/efl/elementary/tooltips.pxi b/efl/elementary/tooltips.pxi index 50f9947..ea57ed0 100644 --- a/efl/elementary/tooltips.pxi +++ b/efl/elementary/tooltips.pxi @@ -42,7 +42,7 @@ cdef Evas_Object *_tooltip_item_content_create(void *data, Evas_Object *o, Evas_ tooltip = object_from_instance(t) item = _object_item_to_python(it) (func, args, kargs) = data - ret = func(obj, item, *args, **kargs) + ret = func(obj, item, tooltip, *args, **kargs) if not ret: return NULL return ret.obj From 32e55a777f3eeb049cc4c55bf9a74e77a0694eda Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Wed, 2 Jul 2014 03:58:19 +0300 Subject: [PATCH 03/30] Fix build from tarball with Cython installed --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index efbc169..7e34505 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include README.rst INSTALL COPYING COPYING.LESSER AUTHORS changes.html -recursive-include efl *.c *.h *.pyx *.pxi +recursive-include efl *.c *.h *.pyx *.pxi *.pxd graft include graft tests recursive-exclude tests *.pyc From 622bf1d41f8ae6aef8c738284142b34f2d76f76f Mon Sep 17 00:00:00 2001 From: godfath3r Date: Wed, 23 Jul 2014 23:05:59 +0300 Subject: [PATCH 04/30] doc: add cleanup command in INSTALL file. Reviewers: kuuko Reviewed By: kuuko Projects: #python_bindings_for_efl Differential Revision: https://phab.enlightenment.org/D1224 --- INSTALL | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index 82ddfeb..90a6411 100644 --- a/INSTALL +++ b/INSTALL @@ -48,7 +48,15 @@ -3. INSTALLATION: +3. CLEANUP: +----------- + * For cleaning up + + python setup.py clean_generated_files + + + +4. INSTALLATION: ---------------- * For system-wide installation (needs administrator privileges): @@ -69,7 +77,7 @@ -4. DOCUMENTATION: +5. DOCUMENTATION: ----------------- To build the docs for the bindings you need to have Sphinx installed, for @@ -87,7 +95,7 @@ up with empty documentation. -5. TESTS and EXAMPLES: +6. TESTS and EXAMPLES: ---------------------- The tests/ folder contains all the unit tests available, you can run individual @@ -101,7 +109,7 @@ -6. UNINSTALL: +7. UNINSTALL: ------------- Unfortunately setup.py does not provide a way to remove the installed packages, From f9247fa99f33e53b304f73c41f8b8639ef3f2462 Mon Sep 17 00:00:00 2001 From: davemds Date: Thu, 31 Jul 2014 16:11:26 +0200 Subject: [PATCH 05/30] New Map function: region_zoom_bring_in --- efl/elementary/map.pxd | 1 + efl/elementary/map.pyx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/efl/elementary/map.pxd b/efl/elementary/map.pxd index f9c43c9..b577866 100644 --- a/efl/elementary/map.pxd +++ b/efl/elementary/map.pxd @@ -22,6 +22,7 @@ cdef extern from "Elementary.h": int elm_map_zoom_max_get(const Evas_Object *obj) void elm_map_region_get(const Evas_Object *obj, double *lon, double *lat) void elm_map_region_bring_in(Evas_Object *obj, double lon, double lat) + void elm_map_region_zoom_bring_in(Evas_Object *obj, int zoom, double lon, double lat) void elm_map_region_show(Evas_Object *obj, double lon, double lat) void elm_map_canvas_to_region_convert(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, double *lon, double *lat) void elm_map_region_to_canvas_convert(const Evas_Object *obj, double lon, double lat, Evas_Coord *x, Evas_Coord *y) diff --git a/efl/elementary/map.pyx b/efl/elementary/map.pyx index f5c82a9..8c2a3a8 100644 --- a/efl/elementary/map.pyx +++ b/efl/elementary/map.pyx @@ -1092,6 +1092,24 @@ cdef class Map(Object): """ elm_map_region_show(self.obj, lon, lat) + def region_zoom_bring_in(self, zoom, lon, lat): + """ Animatedly set the zoom level of the map and bring in given + coordinates to the center of the map. + + This causes map to zoom into specific zoom level and also move to the + given lat and lon coordinates and show it (by scrolling) in the + center of the viewport concurrently. + + :param zoom: The zoom level to set + :type zoom: int + :param lon: The longitude to center at + :type lon: float + :param lat: The latitude to center at + :type lat: float + + """ + elm_map_region_zoom_bring_in(self.obj, zoom, lon, lat) + def canvas_to_region_convert(self, x, y): """ Convert canvas coordinates into geographic coordinates. From 1af5adb8cd2bddc404a2f480f7f9d066ad286bd1 Mon Sep 17 00:00:00 2001 From: davemds Date: Thu, 31 Jul 2014 17:01:53 +0200 Subject: [PATCH 06/30] Panes: new content_[left/right]_min_[relative]_size properties --- efl/elementary/map.pyx | 2 + efl/elementary/panes.pxd | 10 ++++- efl/elementary/panes.pyx | 62 +++++++++++++++++++++++++++++++ examples/elementary/test_panes.py | 9 +++-- 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/efl/elementary/map.pyx b/efl/elementary/map.pyx index 8c2a3a8..83b6e31 100644 --- a/efl/elementary/map.pyx +++ b/efl/elementary/map.pyx @@ -1107,6 +1107,8 @@ cdef class Map(Object): :param lat: The latitude to center at :type lat: float + .. versionadded:: 1.11 + """ elm_map_region_zoom_bring_in(self.obj, zoom, lon, lat) diff --git a/efl/elementary/panes.pxd b/efl/elementary/panes.pxd index 1672b59..71a89e1 100644 --- a/efl/elementary/panes.pxd +++ b/efl/elementary/panes.pxd @@ -1,4 +1,4 @@ -from efl.evas cimport Eina_Bool, Evas_Object +from efl.evas cimport Eina_Bool, Evas_Object, Evas_Coord cdef extern from "Elementary.h": Evas_Object *elm_panes_add(Evas_Object *parent) @@ -8,5 +8,13 @@ cdef extern from "Elementary.h": void elm_panes_content_left_size_set(Evas_Object *obj, double size) double elm_panes_content_right_size_get(const Evas_Object *obj) void elm_panes_content_right_size_set(Evas_Object *obj, double size) + void elm_panes_content_left_min_relative_size_set(Evas_Object *obj, double size) + double elm_panes_content_left_min_relative_size_get(const Evas_Object *obj) + void elm_panes_content_right_min_relative_size_set(Evas_Object *obj, double size) + double elm_panes_content_right_min_relative_size_get(const Evas_Object *obj) + void elm_panes_content_left_min_size_set(Evas_Object *obj, Evas_Coord size) + Evas_Coord elm_panes_content_left_min_size_get(const Evas_Object *obj) + void elm_panes_content_right_min_size_set(Evas_Object *obj, Evas_Coord size) + Evas_Coord elm_panes_content_right_min_size_get(const Evas_Object *obj) void elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) Eina_Bool elm_panes_horizontal_get(const Evas_Object *obj) diff --git a/efl/elementary/panes.pyx b/efl/elementary/panes.pyx index fac2d53..42c064d 100644 --- a/efl/elementary/panes.pyx +++ b/efl/elementary/panes.pyx @@ -125,6 +125,68 @@ cdef class Panes(LayoutClass): def __set__(self, size): elm_panes_content_right_size_set(self.obj, size) + property content_left_min_relative_size: + """The relative minimum size of panes widget's left side. + + The value must be between 0.0 and 1.0 representing size + proportion of minimum size of left side. + + :type: float + + .. versionadded:: 1.11 + + """ + def __get__(self): + return elm_panes_content_left_min_relative_size_get(self.obj) + def __set__(self, size): + elm_panes_content_left_min_relative_size_set(self.obj, size) + + property content_right_min_relative_size: + """The relative minimum size of panes widget's right side. + + The value must be between 0.0 and 1.0 representing size + proportion of minimum size of right side. + + :type: float + + .. versionadded:: 1.11 + + """ + def __get__(self): + return elm_panes_content_right_min_relative_size_get(self.obj) + def __set__(self, size): + elm_panes_content_right_min_relative_size_set(self.obj, size) + + property content_left_min_size: + """The absolute minimum size of panes widget's left side. + + The value represent the minimum size of left side in pixels. + + :type: int + + .. versionadded:: 1.11 + + """ + def __get__(self): + return elm_panes_content_left_min_size_get(self.obj) + def __set__(self, size): + elm_panes_content_left_min_size_set(self.obj, size) + + property content_right_min_size: + """The absolute minimum size of panes widget's right side. + + The value represent the minimum size of right side in pixels. + + :type: int + + .. versionadded:: 1.11 + + """ + def __get__(self): + return elm_panes_content_right_min_size_get(self.obj) + def __set__(self, size): + elm_panes_content_right_min_size_set(self.obj, size) + property horizontal: """The orientation of a given panes widget. diff --git a/examples/elementary/test_panes.py b/examples/elementary/test_panes.py index accc3be..7b55fe2 100644 --- a/examples/elementary/test_panes.py +++ b/examples/elementary/test_panes.py @@ -18,7 +18,8 @@ def panes_clicked(obj): if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) - panes = Panes(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) + panes = Panes(win, content_left_min_relative_size=0.3, + size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(panes) panes.callback_clicked_add(cb_panes, "clicked") panes.callback_clicked_double_add(cb_panes, "clicked,double") @@ -30,9 +31,9 @@ def panes_clicked(obj): panes.part_content_set("left", bt) bt.show() - panes_h = Panes(win, horizontal=True, size_hint_weight=EXPAND_BOTH, - size_hint_align=FILL_BOTH) - panes_h.horizontal = True + panes_h = Panes(win, horizontal=True, + size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, + content_left_min_size=30, content_right_min_size=100) panes.part_content_set("right", panes_h) panes_h.show() From 5aa12930a1ac3971d36c3b713fa010d96cd1c607 Mon Sep 17 00:00:00 2001 From: davemds Date: Thu, 31 Jul 2014 21:23:35 +0200 Subject: [PATCH 07/30] Implemented missed ecore.x screensaver functions --- efl/ecore/x.pxd | 17 +++++++++++++ efl/ecore/x.pyx | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/efl/ecore/x.pxd b/efl/ecore/x.pxd index 12dd83b..6b24b84 100644 --- a/efl/ecore/x.pxd +++ b/efl/ecore/x.pxd @@ -1303,6 +1303,23 @@ cdef extern from "Ecore_X.h": void ecore_x_e_virtual_keyboard_state_set(Ecore_X_Window win, Ecore_X_Virtual_Keyboard_State state) + Eina_Bool ecore_x_screensaver_event_available_get() + int ecore_x_screensaver_idle_time_get() + void ecore_x_screensaver_set(int timeout, int interval, int prefer_blanking, int allow_exposures) + void ecore_x_screensaver_timeout_set(int timeout) + int ecore_x_screensaver_timeout_get() + void ecore_x_screensaver_blank_set(int timeout) + int ecore_x_screensaver_blank_get() + void ecore_x_screensaver_expose_set(int timeout) + int ecore_x_screensaver_expose_get() + void ecore_x_screensaver_interval_set(int timeout) + int ecore_x_screensaver_interval_get() + void ecore_x_screensaver_event_listen_set(Eina_Bool on) + Eina_Bool ecore_x_screensaver_custom_blanking_enable() + Eina_Bool ecore_x_screensaver_custom_blanking_disable() + void ecore_x_screensaver_supend() + void ecore_x_screensaver_resume() + from efl.ecore cimport Event diff --git a/efl/ecore/x.pyx b/efl/ecore/x.pyx index c0e6f74..2f854b7 100644 --- a/efl/ecore/x.pyx +++ b/efl/ecore/x.pyx @@ -233,5 +233,70 @@ 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 "x_window.pxi" include "x_events.pxi" From a97e61dd4ffceb30e62cc0973e879e60a8d43169 Mon Sep 17 00:00:00 2001 From: davemds Date: Thu, 31 Jul 2014 22:18:41 +0200 Subject: [PATCH 08/30] Ctxpopup: new getters for items and the item_prepend method, with tests --- efl/elementary/ctxpopup.pxd | 8 +- efl/elementary/ctxpopup.pyx | 142 ++++++++++++++++++++++++++- examples/elementary/test_ctxpopup.py | 23 +++++ 3 files changed, 169 insertions(+), 4 deletions(-) diff --git a/efl/elementary/ctxpopup.pxd b/efl/elementary/ctxpopup.pxd index a976554..31ab98f 100644 --- a/efl/elementary/ctxpopup.pxd +++ b/efl/elementary/ctxpopup.pxd @@ -1,4 +1,4 @@ -from efl.evas cimport Eina_Bool, Evas_Object, Evas_Smart_Cb +from efl.evas cimport Eina_Bool, Eina_List, Evas_Object, Evas_Smart_Cb from object_item cimport Elm_Object_Item from enums cimport Elm_Ctxpopup_Direction @@ -10,10 +10,16 @@ cdef extern from "Elementary.h": void elm_ctxpopup_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) Eina_Bool elm_ctxpopup_horizontal_get(const Evas_Object *obj) Elm_Object_Item *elm_ctxpopup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, void *data) + Elm_Object_Item *elm_ctxpopup_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, void *data) void elm_ctxpopup_direction_priority_set(Evas_Object *obj, Elm_Ctxpopup_Direction first, Elm_Ctxpopup_Direction second, Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth) void elm_ctxpopup_direction_priority_get(const Evas_Object *obj, Elm_Ctxpopup_Direction *first, Elm_Ctxpopup_Direction *second, Elm_Ctxpopup_Direction *third, Elm_Ctxpopup_Direction *fourth) Elm_Ctxpopup_Direction elm_ctxpopup_direction_get(const Evas_Object *obj) void elm_ctxpopup_dismiss(Evas_Object *obj) void elm_ctxpopup_auto_hide_disabled_set(Evas_Object *obj, Eina_Bool disabled) Eina_Bool elm_ctxpopup_auto_hide_disabled_get(const Evas_Object *obj) + Eina_List *elm_ctxpopup_items_get(const Evas_Object *obj) + Elm_Object_Item *elm_ctxpopup_first_item_get(const Evas_Object *obj) + Elm_Object_Item *elm_ctxpopup_last_item_get(const Evas_Object *obj) + Elm_Object_Item *elm_ctxpopup_item_prev_get(const Elm_Object_Item *it) + Elm_Object_Item *elm_ctxpopup_item_next_get(const Elm_Object_Item *it) diff --git a/efl/elementary/ctxpopup.pyx b/efl/elementary/ctxpopup.pyx index 28e08d5..feba3a7 100644 --- a/efl/elementary/ctxpopup.pyx +++ b/efl/elementary/ctxpopup.pyx @@ -95,7 +95,7 @@ from efl.eo cimport _object_mapping_register, object_from_instance from efl.evas cimport Object as evasObject from layout_class cimport LayoutClass from object_item cimport ObjectItem, _object_item_callback, \ - _object_item_callback2 + _object_item_callback2, _object_item_to_python, _object_item_list_to_python cimport enums @@ -175,6 +175,63 @@ cdef class CtxpopupItem(ObjectItem): self._set_properties_from_keyword_args(self.kwargs) return self + def prepend_to(self, evasObject ctxpopup): + """Prepend a new item to a ctxpopup object. + + .. warning:: Ctxpopup can't hold both an item list and a content at the + same time. When an item is added, any previous content will be + removed. + + .. seealso:: :py:attr:`~efl.elementary.object.Object.content` + + :param ctxpopup: The Ctxpopup widget this item is to be prepended on + :type ctxpopup: :py:class:`Ctxpopup` + :return: The item added or ``None``, on errors + :rtype: :py:class:`CtxpopupItem` + + ..versionadded:: 1.11 + + """ + cdef Elm_Object_Item *item + cdef Evas_Smart_Cb cb = NULL + + if self.cb_func is not None: + cb = _object_item_callback2 + + item = elm_ctxpopup_item_prepend(ctxpopup.obj, + self.label if self.label is not None else NULL, + self.icon.obj if self.icon is not None else NULL, + cb, self) + + if item == NULL: + raise RuntimeError("The item could not be added to the widget.") + + self._set_obj(item) + self._set_properties_from_keyword_args(self.kwargs) + return self + + property prev: + """ The previous item. + + :type: :py:class:`CtxpopupItem` + + ..versionadded:: 1.11 + + """ + def __get__(self): + return _object_item_to_python(elm_ctxpopup_item_prev_get(self.item)) + + property next: + """ The next item. + + :type: :py:class:`CtxpopupItem` + + ..versionadded:: 1.11 + + """ + def __get__(self): + return _object_item_to_python(elm_ctxpopup_item_next_get(self.item)) + cdef class Ctxpopup(LayoutClass): """This is the class that actually implements the widget. @@ -226,8 +283,8 @@ cdef class Ctxpopup(LayoutClass): def horizontal_get(self): return bool(elm_ctxpopup_horizontal_get(self.obj)) - def item_append(self, label, evasObject icon = None, func = None, - *args, **kwargs): + def item_append(self, label, evasObject icon=None, + func=None, *args, **kwargs): """A constructor for a :py:class:`CtxpopupItem`. :see: :py:func:`CtxpopupItem.append_to` @@ -257,6 +314,85 @@ cdef class Ctxpopup(LayoutClass): else: return None + def item_prepend(self, label, evasObject icon=None, + func=None, *args, **kwargs): + """A constructor for a :py:class:`CtxpopupItem`. + + :see: :py:func:`CtxpopupItem.prepend_to` + + ..versionadded:: 1.11 + + """ + cdef: + Elm_Object_Item *item + Evas_Smart_Cb cb = NULL + CtxpopupItem ret = CtxpopupItem.__new__(CtxpopupItem) + + if func is not None and callable(func): + cb = _object_item_callback + + if isinstance(label, unicode): label = PyUnicode_AsUTF8String(label) + + item = elm_ctxpopup_item_prepend(self.obj, + label if label is not None else NULL, + icon.obj if icon is not None else NULL, + cb, ret) + + if item != NULL: + ret._set_obj(item) + ret.cb_func = func + ret.args = args + ret.kwargs = kwargs + return ret + else: + return None + + property items: + """ Get the list of items in the ctxpopup widget. + + This list is not to be modified in any way and is only valid until + the object internal items list is changed. It should be fetched again + with another call to this function when changes happen. + + :type: list of :py:class:`CtxpopupItem` + + ..versionadded:: 1.11 + + """ + def __get__(self): + return _object_item_list_to_python(elm_ctxpopup_items_get(self.obj)) + + def items_get(self): + return _object_item_list_to_python(elm_ctxpopup_items_get(self.obj)) + + property first_item: + """ The first item of the Ctxpopup. + + :type: :py:class:`CtxpopupItem` + + ..versionadded:: 1.11 + + """ + def __get__(self): + return _object_item_to_python(elm_ctxpopup_first_item_get(self.obj)) + + def first_item_get(self): + return _object_item_to_python(elm_ctxpopup_first_item_get(self.obj)) + + property last_item: + """ The last item of the Ctxpopup. + + :type: :py:class:`CtxpopupItem` + + ..versionadded:: 1.11 + + """ + def __get__(self): + return _object_item_to_python(elm_ctxpopup_last_item_get(self.obj)) + + def last_item_get(self): + return _object_item_to_python(elm_ctxpopup_last_item_get(self.obj)) + property direction_priority: """The direction priority order of a ctxpopup. diff --git a/examples/elementary/test_ctxpopup.py b/examples/elementary/test_ctxpopup.py index ce1120f..af874a0 100644 --- a/examples/elementary/test_ctxpopup.py +++ b/examples/elementary/test_ctxpopup.py @@ -59,10 +59,33 @@ def cb_item1(li, item): it = item_new(cp, "Sate date and time", "clock") it.disabled = True + ic = Icon(cp, standard="home", resizable=(False,False)) + cp.item_prepend("Prepended item", ic, cb_items) + (x, y) = li.evas.pointer_canvas_xy_get() cp.move(x, y) cp.show() + print("\n### Testing items getters 1") + for it in cp.items: + print("ITEM: " + it.text) + + print("\n### Testing items getters 2") + print("FIRST ITEM: " + cp.first_item.text) + print("LAST ITEM: " + cp.last_item.text) + + print("\n### Testing items getters 3") + it = cp.first_item + while it: + print("ITEM: " + it.text) + it = it.next + + print("\n### Testing items getters 4") + it = cp.last_item + while it: + print("ITEM: " + it.text) + it = it.prev + def cb_item2(li, item): cp = Ctxpopup(li) it = item_new(cp, "", "home") From 401145f4fa5eb54ba962b59de79390dc9cec19dc Mon Sep 17 00:00:00 2001 From: davemds Date: Fri, 1 Aug 2014 13:35:50 +0200 Subject: [PATCH 09/30] Toolbar: new un/selected signals, with tests --- efl/elementary/toolbar.pyx | 22 ++++++++++++++++++++++ examples/elementary/test_toolbar.py | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/efl/elementary/toolbar.pyx b/efl/elementary/toolbar.pyx index 03a6829..6b04029 100644 --- a/efl/elementary/toolbar.pyx +++ b/efl/elementary/toolbar.pyx @@ -1182,6 +1182,28 @@ cdef class Toolbar(LayoutClass): def callback_item_unfocused_del(self, func): self._callback_del_full("item,unfocused", _cb_object_item_conv, func) + def callback_selected_add(self, func, *args, **kwargs): + """When the toolbar item is selected. + + .. versionadded:: 1.11 + + """ + self._callback_add_full("selected", _cb_object_item_conv, func, *args, **kwargs) + + def callback_selected_del(self, func): + self._callback_del_full("selected", _cb_object_item_conv, func) + + def callback_unselected_add(self, func, *args, **kwargs): + """When the toolbar item is unselected. + + .. versionadded:: 1.11 + + """ + self._callback_add_full("unselected", _cb_object_item_conv, func, *args, **kwargs) + + def callback_unselected_del(self, func): + self._callback_del_full("unselected", _cb_object_item_conv, func) + property scroller_policy: """ diff --git a/examples/elementary/test_toolbar.py b/examples/elementary/test_toolbar.py index bd82038..67f4372 100644 --- a/examples/elementary/test_toolbar.py +++ b/examples/elementary/test_toolbar.py @@ -48,6 +48,20 @@ def tb_4a(obj, it, ph): def tb_5(obj, it, ph): ph.file = None +def cb_clicked(tb): + print("CLICKED") + print(tb) + +def cb_item_focused(tb, item): + print("ITEM FOCUSED") + print(tb) + print(item) + +def cb_selected(tb, item): + print("SELECTED") + print(tb) + print(item) + def toolbar_clicked(obj, item=None): win = StandardWindow("toolbar", "Toolbar", autodel=True, size=(320, 300)) if obj is None: @@ -62,6 +76,9 @@ def toolbar_clicked(obj, item=None): tb = Toolbar(win, homogeneous=False, size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) + tb.callback_clicked_add(cb_clicked) + tb.callback_selected_add(cb_selected) + tb.callback_item_focused_add(cb_item_focused) ph1 = Photo(win, size=40, file=os.path.join(img_path, "plant_01.jpg"), size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER) From d8174aea3d6f185eca3a84934ef4bba67d713b91 Mon Sep 17 00:00:00 2001 From: davemds Date: Fri, 1 Aug 2014 16:31:24 +0200 Subject: [PATCH 10/30] Genlist: implemented search_by_text_item_get(), with a proper test --- efl/elementary/enums.pxd | 6 ++ efl/elementary/general.pyx | 42 ++++++++++++++ efl/elementary/genlist.pxd | 3 +- efl/elementary/genlist_widget.pxi | 41 ++++++++++++++ examples/elementary/test.py | 1 + examples/elementary/test_genlist.py | 86 ++++++++++++++++++++++++++++- 6 files changed, 177 insertions(+), 2 deletions(-) diff --git a/efl/elementary/enums.pxd b/efl/elementary/enums.pxd index 624f01d..87ea2e9 100644 --- a/efl/elementary/enums.pxd +++ b/efl/elementary/enums.pxd @@ -188,6 +188,12 @@ cdef extern from "Elementary.h": ELM_GENLIST_ITEM_SCROLLTO_TOP ELM_GENLIST_ITEM_SCROLLTO_MIDDLE + ctypedef enum Elm_Glob_Match_Flags: + ELM_GLOB_MATCH_NO_ESCAPE + ELM_GLOB_MATCH_PATH + ELM_GLOB_MATCH_PERIOD + ELM_GLOB_MATCH_NOCASE + ctypedef enum Elm_Gesture_State: ELM_GESTURE_STATE_UNDEFINED ELM_GESTURE_STATE_START diff --git a/efl/elementary/general.pyx b/efl/elementary/general.pyx index 13d50e4..be3a096 100644 --- a/efl/elementary/general.pyx +++ b/efl/elementary/general.pyx @@ -177,6 +177,43 @@ Urgency levels of a notification .. versionadded:: 1.10 +.. _Elm_Glob_Match_Flags: + +Glob matching +------------- + +Glob matching bitfiled flags + +.. data:: ELM_GLOB_MATCH_NO_ESCAPE + + Treat backslash as an ordinary character instead of escape. + + .. versionadded:: 1.11 + +.. data:: ELM_GLOB_MATCH_PATH + + Match a slash in string only with a slash in pattern and not by an + asterisk (*) or a question mark (?) metacharacter, nor by a bracket + expression ([]) containing a slash. + + .. versionadded:: 1.11 + +.. data:: ELM_GLOB_MATCH_PERIOD + + Leading period in string has to be matched exactly by a period in + pattern. A period is considered to be leading if it is the first + character in string, or if both ELM_GLOB_MATCH_PATH is set and the + period immediately follows a slash. + + .. versionadded:: 1.11 + +.. data:: ELM_GLOB_MATCH_NOCASE + + The pattern is matched case-insensitively. + + .. versionadded:: 1.11 + + """ from cpython cimport PyUnicode_AsUTF8String, PyMem_Malloc, Py_DECREF, Py_INCREF @@ -228,6 +265,11 @@ ELM_SYS_NOTIFY_URGENCY_CRITICAL = enums.ELM_SYS_NOTIFY_URGENCY_CRITICAL ELM_EVENT_SYS_NOTIFY_NOTIFICATION_CLOSED = enums.ELM_EVENT_SYS_NOTIFY_NOTIFICATION_CLOSED ELM_EVENT_SYS_NOTIFY_ACTION_INVOKED = enums.ELM_EVENT_SYS_NOTIFY_ACTION_INVOKED +ELM_GLOB_MATCH_NO_ESCAPE = enums.ELM_GLOB_MATCH_NO_ESCAPE +ELM_GLOB_MATCH_PATH = enums.ELM_GLOB_MATCH_PATH +ELM_GLOB_MATCH_PERIOD = enums.ELM_GLOB_MATCH_PERIOD +ELM_GLOB_MATCH_NOCASE = enums.ELM_GLOB_MATCH_NOCASE + import traceback cdef void py_elm_sys_notify_send_cb(void *data, unsigned int id): diff --git a/efl/elementary/genlist.pxd b/efl/elementary/genlist.pxd index 7941c48..0d8d367 100644 --- a/efl/elementary/genlist.pxd +++ b/efl/elementary/genlist.pxd @@ -4,7 +4,7 @@ from object_item cimport Elm_Object_Item from general cimport Elm_Tooltip_Item_Content_Cb from enums cimport Elm_List_Mode, Elm_Object_Select_Mode, \ Elm_Genlist_Item_Type, Elm_Genlist_Item_Scrollto_Type, \ - Elm_Genlist_Item_Field_Type + Elm_Genlist_Item_Field_Type, Elm_Glob_Match_Flags cdef extern from "Elementary.h": ctypedef char *(*GenlistItemLabelGetFunc) (void *data, Evas_Object *obj, const char *part) @@ -81,6 +81,7 @@ cdef extern from "Elementary.h": void elm_genlist_longpress_timeout_set(Evas_Object *obj, double timeout) double elm_genlist_longpress_timeout_get(const Evas_Object *obj) Elm_Object_Item * elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *posret) + Elm_Object_Item * elm_genlist_search_by_text_item_get(const Evas_Object *obj, Elm_Object_Item *item_to_search_from, const char *part_name, const char *pattern, Elm_Glob_Match_Flags flags) Elm_Object_Item * elm_genlist_item_parent_get(const Elm_Object_Item *it) void elm_genlist_item_subitems_clear(Elm_Object_Item *item) diff --git a/efl/elementary/genlist_widget.pxi b/efl/elementary/genlist_widget.pxi index 68cf2a8..dcc0c2d 100644 --- a/efl/elementary/genlist_widget.pxi +++ b/efl/elementary/genlist_widget.pxi @@ -634,6 +634,47 @@ cdef class Genlist(Object): """ return _object_item_to_python(elm_genlist_nth_item_get(self.obj, nth)) + def search_by_text_item_get(self, GenlistItem item_to_search_from, + part_name, pattern, Elm_Glob_Match_Flags flags): + """Search genlist item by given string. + + This function uses globs (like "\*.jpg") for searching and takes + search flags as last parameter. That is a bitfield with values + to be ored together or 0 for no flags. + + :param item_to_search_from: item to start search from, or None to + search from the first item. + :type item_to_search_from: :py:class:`GenlistItem` + :param part_name: Name of the TEXT part of genlist item to search + string in (usually "elm.text"). + :type part_name: string + :param pattern: The search pattern. + :type pattern: string + :param flags: Search flags + :type flags: :ref:`Elm_Glob_Match_Flags` + + :return: The first item found + :rtype: :py:class:`GenlistItem` + + .. versionadded:: 1.11 + + """ + cdef Elm_Object_Item *from_item = NULL + + if isinstance(part_name, unicode): + part_name = PyUnicode_AsUTF8String(part_name) + if isinstance(pattern, unicode): + pattern = PyUnicode_AsUTF8String(pattern) + if item_to_search_from is not None: + from_item = _object_item_from_python(item_to_search_from) + + return _object_item_to_python(elm_genlist_search_by_text_item_get( + self.obj, from_item, + part_name if part_name is not None else NULL, + pattern if pattern is not None else NULL, + flags)) + + property focus_on_selection: """ diff --git a/examples/elementary/test.py b/examples/elementary/test.py index b0014f6..0f7f0dd 100755 --- a/examples/elementary/test.py +++ b/examples/elementary/test.py @@ -181,6 +181,7 @@ items = [ ("Genlist Iteration", "test_genlist", "genlist5_clicked"), ("Genlist Decorate Item Mode", "test_genlist", "genlist10_clicked"), ("Genlist Decorate All Mode", "test_genlist", "genlist15_clicked"), + ("Genlist Search By Text", "test_genlist", "genlist20_clicked"), ("List", "test_list", "list_clicked"), ("List 2", "test_list", "list2_clicked"), ("List 3", "test_list", "list3_clicked"), diff --git a/examples/elementary/test_genlist.py b/examples/elementary/test_genlist.py index 611cb86..6bdea80 100644 --- a/examples/elementary/test_genlist.py +++ b/examples/elementary/test_genlist.py @@ -23,9 +23,10 @@ from efl.elementary.genlist import Genlist, GenlistItem, GenlistItemClass, \ ELM_GENLIST_ITEM_NONE, ELM_OBJECT_SELECT_MODE_ALWAYS, \ ELM_OBJECT_SELECT_MODE_DEFAULT, ELM_GENLIST_ITEM_GROUP, \ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY -from efl.elementary.general import cache_all_flush +from efl.elementary.general import cache_all_flush, ELM_GLOB_MATCH_NOCASE from efl.elementary.radio import Radio from efl.elementary.check import Check +from efl.elementary.entry import Entry EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 @@ -647,6 +648,88 @@ def genlist15_clicked(obj, item=None): win.show() +### Genlist search by text +cities = ("Albany","Annapolis","Atlanta","Augusta","Austin","Baton Rouge", +"Bismarck","Boise","Boston","Carson City","Charleston","Cheyenne","Columbia", +"Columbus","Concord","Denver","Des Moines","Dover","Frankfort","Harrisburg", +"Hartford","Helena","Honolulu","Indianapolis","Jackson","Jefferson City", +"Juneau","Lansing","Lincoln","Little Rock","Madison","Montgomery","Montpelier", +"Nashville","Oklahoma City","Olympia","Phoenix","Pierre","Providence", +"Raleigh","Richmond","Sacramento","Saint Paul","Salem","Salt Lake City", +"Santa Fe","Springfield","Tallahassee","Topeka","Trenton" +) + +class ItemClass20(GenlistItemClass): + def text_get(self, obj, part, data): + if part == "elm.text": + return data + + def content_get(self, obj, part, data): + if part == "elm.swallow.icon": + return Icon(obj, file=os.path.join(img_path, "logo_small.png")) + +def genlist20_search_cb(en, gl, tg): + flags = ELM_GLOB_MATCH_NOCASE if tg.state == False else 0 + from_item = gl.selected_item.next if gl.selected_item else None + + item = gl.search_by_text_item_get(from_item, "elm.text", en.text, flags) + if item: + item.selected = True + en.focus = True + elif gl.selected_item: + gl.selected_item.selected = False + + +def genlist20_clicked(obj, item=None): + win = StandardWindow("genlist-search-by-text", + "Genlist Search By Text", autodel=True, size=(300, 520)) + + gl = Genlist(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) + + bx = Box(win, size_hint_weight=EXPAND_BOTH) + win.resize_object_add(bx) + bx.show() + + lb = Label(win) + lb.text = \ + "This example show the usage of search_by_text_item_get().
" \ + "Enter a search string and press Enter to show the next result.
" \ + "Search will start from the selected item (not included).
" \ + "You can search using glob patterns." + fr = Frame(win, text="Information", content=lb, + size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) + bx.pack_end(fr) + fr.show() + + tg = Check(win, style="toggle", text="Case Sensitive Search"); + bx.pack_end(tg) + tg.show() + + bx_entry = Box(win, horizontal=True, + size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) + bx.pack_end(bx_entry) + bx_entry.show() + + lb = Label(win, text="Search:") + bx_entry.pack_end(lb) + lb.show() + + en = Entry(win, single_line=True, scrollable=True, + size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) + en.part_text_set("guide", "Type the search query") + en.callback_activated_add(genlist20_search_cb, gl, tg) + bx_entry.pack_end(en) + en.show() + en.focus = True + + bx.pack_end(gl) + gl.show() + + itc20 = ItemClass20() + for name in cities: + gl.item_append(itc20, name) + + win.show() if __name__ == "__main__": elementary.init() @@ -676,6 +759,7 @@ if __name__ == "__main__": ("Genlist Iteration", genlist5_clicked), ("Genlist Decorate Item Mode", genlist10_clicked), ("Genlist Decorate All Mode", genlist15_clicked), + ("Genlist Search By Text", genlist20_clicked), ] li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) From f5dd70b70fd9e1ae529b6f55c1c81bff3677da16 Mon Sep 17 00:00:00 2001 From: davemds Date: Fri, 1 Aug 2014 17:31:09 +0200 Subject: [PATCH 11/30] Gengrid: implemented search_by_text_item_get(), with a proper test --- efl/elementary/gengrid.pxd | 4 ++- efl/elementary/gengrid_widget.pxi | 40 +++++++++++++++++++++++++++++ examples/elementary/test_gengrid.py | 30 +++++++++++++++++++++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/efl/elementary/gengrid.pxd b/efl/elementary/gengrid.pxd index cc705c6..a8f5bb9 100644 --- a/efl/elementary/gengrid.pxd +++ b/efl/elementary/gengrid.pxd @@ -4,7 +4,7 @@ from efl.c_eo cimport Eo from object_item cimport Elm_Object_Item from general cimport Elm_Tooltip_Item_Content_Cb from enums cimport Elm_Genlist_Item_Scrollto_Type, Elm_Object_Select_Mode, \ - Elm_Object_Multi_Select_Mode + Elm_Object_Multi_Select_Mode, Elm_Glob_Match_Flags from efl.ecore.enums cimport Ecore_Pos_Map cdef extern from "Elementary.h": @@ -101,3 +101,5 @@ cdef extern from "Elementary.h": Eina_Bool elm_gengrid_item_cursor_engine_only_get(const Elm_Object_Item *item) Elm_Object_Item * elm_gengrid_nth_item_get(const Evas_Object *obj, unsigned int nth) Elm_Object_Item * elm_gengrid_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *xposret, int *yposret) + Elm_Object_Item * elm_gengrid_search_by_text_item_get(const Evas_Object *obj, Elm_Object_Item *item_to_search_from, const char *part_name, const char *pattern, Elm_Glob_Match_Flags flags) + diff --git a/efl/elementary/gengrid_widget.pxi b/efl/elementary/gengrid_widget.pxi index b0a8900..4e6af66 100644 --- a/efl/elementary/gengrid_widget.pxi +++ b/efl/elementary/gengrid_widget.pxi @@ -558,6 +558,46 @@ cdef class Gengrid(Object): return _object_item_to_python(ret), xposret, yposret + def search_by_text_item_get(self, GengridItem item_to_search_from, + part_name, pattern, Elm_Glob_Match_Flags flags): + """Search gengrid item by given string. + + This function uses globs (like "\*.jpg") for searching and takes + search flags as last parameter. That is a bitfield with values + to be ored together or 0 for no flags. + + :param item_to_search_from: item to start search from, or None to + search from the first item. + :type item_to_search_from: :py:class:`GengridItem` + :param part_name: Name of the TEXT part of gengrid item to search + string in (usually "elm.text"). + :type part_name: string + :param pattern: The search pattern. + :type pattern: string + :param flags: Search flags + :type flags: :ref:`Elm_Glob_Match_Flags` + + :return: The first item found + :rtype: :py:class:`GengridItem` + + .. versionadded:: 1.11 + + """ + cdef Elm_Object_Item *from_item = NULL + + if isinstance(part_name, unicode): + part_name = PyUnicode_AsUTF8String(part_name) + if isinstance(pattern, unicode): + pattern = PyUnicode_AsUTF8String(pattern) + if item_to_search_from is not None: + from_item = _object_item_from_python(item_to_search_from) + + return _object_item_to_python(elm_gengrid_search_by_text_item_get( + self.obj, from_item, + part_name if part_name is not None else NULL, + pattern if pattern is not None else NULL, + flags)) + # # TODO: Drag and Drop # ============= diff --git a/examples/elementary/test_gengrid.py b/examples/elementary/test_gengrid.py index a18d1d6..5d0cb2c 100644 --- a/examples/elementary/test_gengrid.py +++ b/examples/elementary/test_gengrid.py @@ -10,7 +10,10 @@ from efl.elementary.window import StandardWindow from efl.elementary.background import Background from efl.elementary.button import Button from efl.elementary.check import Check +from efl.elementary.entry import Entry from efl.elementary.image import Image +from efl.elementary.label import Label +from efl.elementary.general import ELM_GLOB_MATCH_NOCASE from efl.elementary.gengrid import Gengrid, GengridItemClass from efl.elementary.slider import Slider from efl.elementary.table import Table @@ -67,7 +70,7 @@ def gengrid_clicked(obj): global item_count item_count = 25 - win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 800)) + win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) @@ -332,6 +335,31 @@ def gengrid_clicked(obj): tb.pack(bt, 4, 5, 1, 1) bt.show() + # search_by_text_item_get + def search_cb(en, gg): + flags = ELM_GLOB_MATCH_NOCASE + from_item = gg.selected_item.next if gg.selected_item else None + + item = gg.search_by_text_item_get(from_item, "elm.text", en.text, flags) + if item: + item.selected = True + en.focus = True + elif gg.selected_item: + gg.selected_item.selected = False + + lb = Label(win, text="Search:") + tb.pack(lb, 2, 6, 1, 1) + lb.show() + + en = Entry(win, single_line=True, scrollable=True, + size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) + en.part_text_set("guide", "Type the search query") + en.callback_activated_add(search_cb, gg) + tb.pack(en, 3, 6, 3, 1) + en.show() + en.focus = True + + print(gg) win.show() From a4d321dacc846a62821a5cbe7f45baaeaa1409e7 Mon Sep 17 00:00:00 2001 From: davemds Date: Fri, 1 Aug 2014 18:14:55 +0200 Subject: [PATCH 12/30] Gengrid: new property reorder_type, with test for reorder mode --- efl/elementary/enums.pxd | 4 ++++ efl/elementary/gengrid.pxd | 3 ++- efl/elementary/gengrid.pyx | 21 +++++++++++++++++++++ efl/elementary/gengrid_widget.pxi | 17 +++++++++++++++++ examples/elementary/test_gengrid.py | 9 +++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/efl/elementary/enums.pxd b/efl/elementary/enums.pxd index 87ea2e9..5ac71f4 100644 --- a/efl/elementary/enums.pxd +++ b/efl/elementary/enums.pxd @@ -170,6 +170,10 @@ cdef extern from "Elementary.h": ELM_FOCUS_AUTOSCROLL_MODE_NONE ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN + ctypedef enum Elm_Gengrid_Reorder_Type: + ELM_GENGRID_REORDER_TYPE_NORMAL + ELM_GENGRID_REORDER_TYPE_SWAP + ctypedef enum Elm_Genlist_Item_Type: ELM_GENLIST_ITEM_NONE ELM_GENLIST_ITEM_TREE diff --git a/efl/elementary/gengrid.pxd b/efl/elementary/gengrid.pxd index a8f5bb9..3d166d7 100644 --- a/efl/elementary/gengrid.pxd +++ b/efl/elementary/gengrid.pxd @@ -4,7 +4,7 @@ from efl.c_eo cimport Eo from object_item cimport Elm_Object_Item from general cimport Elm_Tooltip_Item_Content_Cb from enums cimport Elm_Genlist_Item_Scrollto_Type, Elm_Object_Select_Mode, \ - Elm_Object_Multi_Select_Mode, Elm_Glob_Match_Flags + Elm_Object_Multi_Select_Mode, Elm_Glob_Match_Flags, Elm_Gengrid_Reorder_Type from efl.ecore.enums cimport Ecore_Pos_Map cdef extern from "Elementary.h": @@ -56,6 +56,7 @@ cdef extern from "Elementary.h": Eina_Bool elm_gengrid_reorder_mode_get(const Evas_Object *obj) void elm_gengrid_reorder_mode_start(Evas_Object *obj, Ecore_Pos_Map tween_mode) void elm_gengrid_reorder_mode_stop(Evas_Object *obj) + void elm_gengrid_reorder_type_set(Evas_Object *obj, Elm_Gengrid_Reorder_Type reorder_type) void elm_gengrid_page_show(Evas_Object *obj, int h_pagenum, int v_pagenum) void elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill) Eina_Bool elm_gengrid_filled_get(const Evas_Object *obj) diff --git a/efl/elementary/gengrid.pyx b/efl/elementary/gengrid.pyx index 42c36e6..46b25fe 100644 --- a/efl/elementary/gengrid.pyx +++ b/efl/elementary/gengrid.pyx @@ -304,6 +304,24 @@ Multi-select mode .. versionadded:: 1.10 + +.. _Elm_Gengrid_Reorder_Type: + +Reorder type +============ + +.. data:: ELM_GENGRID_REORDER_TYPE_NORMAL + + Normal reorder mode + + .. versionadded:: 1.11 + +.. data:: ELM_GENGRID_REORDER_TYPE_SWAP + + Swap reorder mode + + .. versionadded:: 1.11 + """ include "tooltips.pxi" @@ -337,6 +355,9 @@ ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT = enums.ELM_OBJECT_MULTI_SELECT_MODE_DEFAUL ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL = enums.ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL ELM_OBJECT_MULTI_SELECT_MODE_MAX = enums.ELM_OBJECT_MULTI_SELECT_MODE_MAX +ELM_GENGRID_REORDER_TYPE_NORMAL = enums.ELM_GENGRID_REORDER_TYPE_NORMAL +ELM_GENGRID_REORDER_TYPE_SWAP = enums.ELM_GENGRID_REORDER_TYPE_SWAP + def _cb_object_item_conv(uintptr_t addr): cdef Elm_Object_Item *it = addr return _object_item_to_python(it) diff --git a/efl/elementary/gengrid_widget.pxi b/efl/elementary/gengrid_widget.pxi index 4e6af66..d9cab8a 100644 --- a/efl/elementary/gengrid_widget.pxi +++ b/efl/elementary/gengrid_widget.pxi @@ -431,6 +431,23 @@ cdef class Gengrid(Object): elm_gengrid_reorder_mode_stop(self.obj) + property reorder_type: + """ Set the order type. + + This affect the way items are moved (when in reorder mode) with the + keyboard arrows. + + :type: :ref:`Elm_Gengrid_Reorder_Type` + + .. versionadded:: 1.11 + + """ + def __set__(self, value): + elm_gengrid_reorder_type_set(self.obj, value) + + def reorder_type_set(self, value): + elm_gengrid_reorder_type_set(self.obj, value) + property filled: """The fill state of the whole grid of items of a gengrid within its given viewport. By default, this value is False, meaning diff --git a/examples/elementary/test_gengrid.py b/examples/elementary/test_gengrid.py index 5d0cb2c..302c451 100644 --- a/examples/elementary/test_gengrid.py +++ b/examples/elementary/test_gengrid.py @@ -116,6 +116,15 @@ def gengrid_clicked(obj): tb.pack(bt, 1, 1, 1, 1) bt.show() + # reorder mode + def reorder_mode_changed(bt, gg): + gg.reorder_mode = bt.state + + bt = Check(win, text="Reorder mode enable") + bt.callback_changed_add(reorder_mode_changed, gg) + tb.pack(bt, 2, 1, 2, 1) + bt.show() + # bounce h def bounce_h_changed(bt, gg): (h_bounce, v_bounce) = gg.bounce_get() From 0567c52013053596a9fc87f2c2bde2e94f5e378d Mon Sep 17 00:00:00 2001 From: davemds Date: Mon, 4 Aug 2014 17:24:05 +0200 Subject: [PATCH 13/30] Fix emotion.__repr__ function self.type_get() is not a function, dunno what was the intention here --- efl/emotion/efl.emotion.pyx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/efl/emotion/efl.emotion.pyx b/efl/emotion/efl.emotion.pyx index b7e3fbe..0c85a46 100644 --- a/efl/emotion/efl.emotion.pyx +++ b/efl/emotion/efl.emotion.pyx @@ -223,11 +223,10 @@ cdef class Emotion(evasObject): def __repr__(self): x, y, w, h = self.geometry_get() r, g, b, a = self.color_get() - return ("<%s(%#x, type=%r, name=%r, " - "file=%r, geometry=(%d, %d, %d, %d), " + return ("<%s(%#x, name=%r, file=%r, geometry=(%d, %d, %d, %d), " "color=(%d, %d, %d, %d), layer=%s, clip=%r, visible=%s) %s>") % \ (self.__class__.__name__, self, - self.type_get(), self.name_get(), self.file_get(), + self.name_get(), self.file_get(), x, y, w, h, r, g, b, a, self.layer_get(), self.clip_get(), self.visible_get(), evasObject.__repr__(self)) From 042dc0f835b37811babb75b32d2874cf340e78ec Mon Sep 17 00:00:00 2001 From: davemds Date: Mon, 11 Aug 2014 23:30:46 +0200 Subject: [PATCH 14/30] emotion: implemented missed smart signals --- doc/emotion/emotion.rst | 4 ++ efl/emotion/efl.emotion.pyx | 84 +++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/doc/emotion/emotion.rst b/doc/emotion/emotion.rst index 963fa95..3fce189 100644 --- a/doc/emotion/emotion.rst +++ b/doc/emotion/emotion.rst @@ -74,6 +74,10 @@ a list of interesting signals: - ``ref_change`` - ``button_num_change`` - ``button_change`` + - ``position_save,succeed`` + - ``position_save,failed`` + - ``position_load,succeed`` + - ``position_load,failed`` Reference diff --git a/efl/emotion/efl.emotion.pyx b/efl/emotion/efl.emotion.pyx index 0c85a46..619cd30 100644 --- a/efl/emotion/efl.emotion.pyx +++ b/efl/emotion/efl.emotion.pyx @@ -1251,6 +1251,90 @@ cdef class Emotion(evasObject): """Same as calling: callback_del('audio_level_change', func)""" self.callback_del("audio_level_change", func) + def on_position_update_add(self, func, *args, **kargs): + """Same as calling: callback_add('position_update', func, ...) + + .. versionadded:: 1.11 """ + self.callback_add("position_update", func, *args, **kargs) + + def on_position_update_del(self, func): + """Same as calling: callback_del('position_update', func) + + .. versionadded:: 1.11 """ + self.callback_del("position_update", func) + + def on_playback_started_add(self, func, *args, **kargs): + """Same as calling: callback_add('playback_started', func, ...) + + .. versionadded:: 1.11 """ + self.callback_add("playback_started", func, *args, **kargs) + + def on_playback_started_del(self, func): + """Same as calling: callback_del('playback_started', func) + + .. versionadded:: 1.11 """ + self.callback_del("playback_started", func) + + def on_open_done_add(self, func, *args, **kargs): + """Same as calling: callback_add('open_done', func, ...) + + .. versionadded:: 1.11 """ + self.callback_add("open_done", func, *args, **kargs) + + def on_open_done_del(self, func): + """Same as calling: callback_del('open_done', func) + + .. versionadded:: 1.11 """ + self.callback_del("open_done", func) + + def on_position_save_succeed_add(self, func, *args, **kargs): + """Same as calling: callback_add('position_save,succeed', func, ...) + + .. versionadded:: 1.11 """ + self.callback_add("position_save,succeed", func, *args, **kargs) + + def on_position_save_succeed_del(self, func): + """Same as calling: callback_del('position_save,succeed', func) + + .. versionadded:: 1.11 """ + self.callback_del("position_save,succeed", func) + + def on_position_save_failed_add(self, func, *args, **kargs): + """Same as calling: callback_add('position_save,failed', func, ...) + + .. versionadded:: 1.11 """ + self.callback_add("position_save,failed", func, *args, **kargs) + + def on_position_save_failed_del(self, func): + """Same as calling: callback_del('position_save,failed', func) + + .. versionadded:: 1.11 """ + self.callback_del("position_save,failed", func) + + def on_position_load_succeed_add(self, func, *args, **kargs): + """Same as calling: callback_add('position_load,succeed', func, ...) + + .. versionadded:: 1.11 """ + self.callback_add("position_load,succeed", func, *args, **kargs) + + def on_position_load_succeed_del(self, func): + """Same as calling: callback_del('position_load,succeed', func) + + .. versionadded:: 1.11 """ + self.callback_del("position_load,succeed", func) + + def on_position_load_failed_add(self, func, *args, **kargs): + """Same as calling: callback_add('position_load,failed', func, ...) + + .. versionadded:: 1.11 """ + self.callback_add("position_load,failed", func, *args, **kargs) + + def on_position_load_failed_del(self, func): + """Same as calling: callback_del('position_load,failed', func) + + .. versionadded:: 1.11 """ + self.callback_del("position_load,failed", func) + # decorator def on_event(event_name): From 9a78c4e22d8e0483749aa2093c29a28a181a3838 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 16 Aug 2014 12:33:29 +0200 Subject: [PATCH 15/30] Expose object_from_instance and the inverse to other C code This create the efl.eo_api.h file that you can copy to your source if you want to use the exported api --- efl/eo/efl.eo.pyx | 6 +++++- include/efl.eo.pxd | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx index d9547bb..6a2cd03 100644 --- a/efl/eo/efl.eo.pyx +++ b/efl/eo/efl.eo.pyx @@ -95,7 +95,7 @@ cdef void _object_mapping_unregister(char *name): eina_hash_del(object_mapping, name, NULL) -cdef object object_from_instance(cEo *obj): +cdef api object object_from_instance(cEo *obj): """ Create a python object from a C Eo object pointer. """ cdef: void *data @@ -140,6 +140,10 @@ cdef object object_from_instance(cEo *obj): o._set_obj(obj) return o +cdef api cEo *instance_from_object(object obj): + cdef Eo o = obj + return o.obj + cdef void _register_decorated_callbacks(Eo obj): """ diff --git a/include/efl.eo.pxd b/include/efl.eo.pxd index 96e6727..3e8e2b1 100644 --- a/include/efl.eo.pxd +++ b/include/efl.eo.pxd @@ -30,8 +30,11 @@ cdef: int PY_REFCOUNT(object o) - object object_from_instance(cEo *obj) void _object_mapping_register(char *name, object cls) except * void _object_mapping_unregister(char *name) void _register_decorated_callbacks(Eo obj) + +cdef api: + object object_from_instance(cEo *obj) + cEo *instance_from_object(object o) From c7ae54df152446433592cd8ce868cc00d78aad61 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 16 Aug 2014 14:11:06 +0200 Subject: [PATCH 16/30] Add version info in the efl package. Also removed the logger import in efl, not usefull and only create problems --- efl/__init__.py | 4 +++- setup.py | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/efl/__init__.py b/efl/__init__.py index 5fc98c8..6db8b76 100644 --- a/efl/__init__.py +++ b/efl/__init__.py @@ -1 +1,3 @@ -import efl.utils.logger + +__version__ = "1.10.99" +__version_info__ = ( 1, 10, 99 ) diff --git a/setup.py b/setup.py index dee9e17..2e48c24 100755 --- a/setup.py +++ b/setup.py @@ -7,16 +7,23 @@ import subprocess from distutils.core import setup, Command from distutils.extension import Extension from distutils.version import StrictVersion, LooseVersion +from efl import __version_info__ as vers script_path = os.path.dirname(os.path.abspath(__file__)) -# python-efl version -VERSION = "1.11" -RELEASE = "1.10.99" +# python-efl version (change in efl/__init__.py) +RELEASE = "%d.%d.%d" % (vers[0], vers[1], vers[2]) +VERSION = "%d.%d" % (vers[0], vers[1] if vers[2] < 99 else vers[1] + 1) + +# dependencies +CYTHON_MIN_VERSION = "0.19" +EFL_MIN_VERSION = RELEASE +ELM_MIN_VERSION = RELEASE + # Add git commit count for dev builds -if RELEASE.split(".")[2] == "99": +if vers[2] >= 99: call = subprocess.Popen( ["git", "log", "--oneline"], stdout=subprocess.PIPE) out, err = call.communicate() @@ -25,11 +32,6 @@ if RELEASE.split(".")[2] == "99": ver = log.count("\n") RELEASE += "a" + str(ver) -# dependencies -CYTHON_MIN_VERSION = "0.19" -EFL_MIN_VERSION = "1.10.99" -ELM_MIN_VERSION = "1.10.99" - # XXX: Force default visibility. See phab T504 if os.getenv("CFLAGS") is not None and "-fvisibility=" in os.environ["CFLAGS"]: From 17733d7e234eae347090cd48084c0513abc8be93 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 16 Aug 2014 15:42:03 +0200 Subject: [PATCH 17/30] Unbreak doc generation --- doc/conf.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index 8ba635d..7b2da65 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -26,6 +26,10 @@ d = "lib.%s-%s-%d.%d" % ( sys.path.insert(0, os.path.abspath("../build/"+d)) #sys.path.insert(0, os.path.abspath('../build/lib.linux-i686-3.2')) +# Delete any previously imported efl package +if "efl" in sys.modules: + del sys.modules["efl"] + # -- General configuration ----------------------------------------------------- From a1140f96416ffedb6b59b388fbed7ee18754e536 Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Sat, 16 Aug 2014 16:50:06 +0300 Subject: [PATCH 18/30] setup.py: add missing ecore-x include dir for elm --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2e48c24..c3e5ce0 100755 --- a/setup.py +++ b/setup.py @@ -410,7 +410,7 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv): "elementary." + m, ["efl/elementary/" + m + module_suffix], include_dirs=["include/"], - extra_compile_args=elm_cflags, + extra_compile_args=elm_cflags + ecore_x_cflags, extra_link_args=elm_libs + eina_libs + evas_libs, ) modules.append(e) From 4a337ccc10559ebc694ad65b30579b2cb2a5fccd Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Mon, 18 Aug 2014 07:58:36 +0300 Subject: [PATCH 19/30] setup.py: Add dummy commit count for dev build if git is not found --- setup.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index c3e5ce0..864ce8a 100755 --- a/setup.py +++ b/setup.py @@ -23,15 +23,20 @@ ELM_MIN_VERSION = RELEASE # Add git commit count for dev builds -if vers[2] >= 99: - call = subprocess.Popen( - ["git", "log", "--oneline"], stdout=subprocess.PIPE) - out, err = call.communicate() - log = out.decode("utf-8").strip() - if log: - ver = log.count("\n") - RELEASE += "a" + str(ver) - +if vers[2] == 99: + try: + call = subprocess.Popen( + ["git", "log", "--oneline"], stdout=subprocess.PIPE) + out, err = call.communicate() + except Exception: + RELEASE += "a0" + else: + log = out.decode("utf-8").strip() + if log: + ver = log.count("\n") + RELEASE += "a" + str(ver) + else: + RELEASE += "a0" # XXX: Force default visibility. See phab T504 if os.getenv("CFLAGS") is not None and "-fvisibility=" in os.environ["CFLAGS"]: From e5d3ea2e96556ebb4e7f0ef227a67323951f1dd6 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 15:56:09 +0200 Subject: [PATCH 20/30] just move some functions around for readability --- efl/dbus_mainloop/e_dbus.c | 187 ++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 95 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index fb0204e..d133a54 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -37,6 +37,97 @@ static int close_connection = 0; static int _edbus_init_count = 0; +static void +e_dbus_message_free(void *data, void *message) +{ + dbus_message_unref(message); +} + +static DBusHandlerResult +e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data) +{ + E_DBus_Connection *cd = user_data; + DBG("-----------------"); + DBG("Message!"); + + DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message))); + DBG("path: %s", dbus_message_get_path(message)); + DBG("interface: %s", dbus_message_get_interface(message)); + DBG("member: %s", dbus_message_get_member(message)); + DBG("sender: %s", dbus_message_get_sender(message)); + + switch (dbus_message_get_type(message)) + { + case DBUS_MESSAGE_TYPE_METHOD_CALL: + DBG("signature: %s", dbus_message_get_signature(message)); + break; + case DBUS_MESSAGE_TYPE_METHOD_RETURN: + DBG("reply serial %d", dbus_message_get_reply_serial(message)); + break; + case DBUS_MESSAGE_TYPE_ERROR: + DBG("error: %s", dbus_message_get_error_name(message)); + break; + case DBUS_MESSAGE_TYPE_SIGNAL: + dbus_message_ref(message); + if (cd->signal_dispatcher) cd->signal_dispatcher(cd, message); + ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL); + break; + default: + break; + } + DBG("-----------------"); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static Eina_Bool +e_dbus_idler(void *data) +{ + E_DBus_Connection *cd; + cd = data; + + if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn)) + { + DBG("done dispatching!"); + cd->idler = NULL; + return ECORE_CALLBACK_CANCEL; + } + e_dbus_idler_active++; + dbus_connection_ref(cd->conn); + DBG("dispatch()"); + dbus_connection_dispatch(cd->conn); + dbus_connection_unref(cd->conn); + e_dbus_idler_active--; + // e_dbus_signal_handlers_clean(cd); // TODO XXX + if (!e_dbus_idler_active && close_connection) + { + do + { + e_dbus_connection_close(cd); + } while (--close_connection); + } + return ECORE_CALLBACK_RENEW; +} + +static void +cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *data) +{ + E_DBus_Connection *cd; + + DBG("dispatch status: %d!", new_status); + cd = data; + + if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler) + cd->idler = ecore_idler_add(e_dbus_idler, cd); + else if (new_status != DBUS_DISPATCH_DATA_REMAINS && cd->idler) + { + ecore_idler_del(cd->idler); + cd->idler = NULL; + } +} + + +/* ecore fd handler */ static void e_dbus_fd_handler_del(E_DBus_Handler_Data *hd) { @@ -132,104 +223,12 @@ e_dbus_connection_data_watch_add(E_DBus_Connection *cd, DBusWatch *watch) hd->watch = watch; hd->enabled = dbus_watch_get_enabled(watch); -// #if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO>= 1) || (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR > 1) || (DBUS_VERSION_MAJOR > 1) hd->fd = dbus_watch_get_unix_fd(hd->watch); -// #else - // hd->fd = dbus_watch_get_fd(hd->watch); -// #endif + DBG("watch add (enabled: %d)", hd->enabled); if (hd->enabled) e_dbus_fd_handler_add(hd); } -static void -e_dbus_message_free(void *data, void *message) -{ - dbus_message_unref(message); -} - -static DBusHandlerResult -e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data) -{ - E_DBus_Connection *cd = user_data; - DBG("-----------------"); - DBG("Message!"); - - DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message))); - DBG("path: %s", dbus_message_get_path(message)); - DBG("interface: %s", dbus_message_get_interface(message)); - DBG("member: %s", dbus_message_get_member(message)); - DBG("sender: %s", dbus_message_get_sender(message)); - - switch (dbus_message_get_type(message)) - { - case DBUS_MESSAGE_TYPE_METHOD_CALL: - DBG("signature: %s", dbus_message_get_signature(message)); - break; - case DBUS_MESSAGE_TYPE_METHOD_RETURN: - DBG("reply serial %d", dbus_message_get_reply_serial(message)); - break; - case DBUS_MESSAGE_TYPE_ERROR: - DBG("error: %s", dbus_message_get_error_name(message)); - break; - case DBUS_MESSAGE_TYPE_SIGNAL: - dbus_message_ref(message); - if (cd->signal_dispatcher) cd->signal_dispatcher(cd, message); - ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL); - break; - default: - break; - } - DBG("-----------------"); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static Eina_Bool -e_dbus_idler(void *data) -{ - E_DBus_Connection *cd; - cd = data; - - if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn)) - { - DBG("done dispatching!"); - cd->idler = NULL; - return ECORE_CALLBACK_CANCEL; - } - e_dbus_idler_active++; - dbus_connection_ref(cd->conn); - DBG("dispatch()"); - dbus_connection_dispatch(cd->conn); - dbus_connection_unref(cd->conn); - e_dbus_idler_active--; - // e_dbus_signal_handlers_clean(cd); // TODO XXX - if (!e_dbus_idler_active && close_connection) - { - do - { - e_dbus_connection_close(cd); - } while (--close_connection); - } - return ECORE_CALLBACK_RENEW; -} - -static void -cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *data) -{ - E_DBus_Connection *cd; - - DBG("dispatch status: %d!", new_status); - cd = data; - - if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler) - cd->idler = ecore_idler_add(e_dbus_idler, cd); - else if (new_status != DBUS_DISPATCH_DATA_REMAINS && cd->idler) - { - ecore_idler_del(cd->idler); - cd->idler = NULL; - } -} - /* watch */ static dbus_bool_t @@ -445,7 +444,6 @@ e_dbus_init(void) } E_DBUS_EVENT_SIGNAL = ecore_event_type_new(); - // e_dbus_object_init(); return _edbus_init_count; } @@ -461,7 +459,6 @@ e_dbus_shutdown(void) if (--_edbus_init_count) return _edbus_init_count; - // e_dbus_object_shutdown(); ecore_shutdown(); eina_log_domain_unregister(_e_dbus_log_dom); _e_dbus_log_dom = -1; From e592aa9647e76184c78acb3841eab2d7032b4617 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 16:17:18 +0200 Subject: [PATCH 21/30] renamed a function to a better name --- efl/dbus_mainloop/e_dbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index d133a54..db43717 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -213,7 +213,7 @@ e_dbus_handler_data_free(void *data) } static void -e_dbus_connection_data_watch_add(E_DBus_Connection *cd, DBusWatch *watch) +e_dbus_handler_data_add(E_DBus_Connection *cd, DBusWatch *watch) { E_DBus_Handler_Data *hd; @@ -238,7 +238,7 @@ cb_watch_add(DBusWatch *watch, void *data) cd = data; DBG("cb_watch_add"); - e_dbus_connection_data_watch_add(cd, watch); + e_dbus_handler_data_add(cd, watch); return true; } From a41106348ac94f9aa559ae35d8ef7262ae9ea0d7 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 16:50:16 +0200 Subject: [PATCH 22/30] added extra debug info (to be manually enabled) --- efl/dbus_mainloop/e_dbus.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index db43717..8798f46 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -36,6 +36,10 @@ static int e_dbus_idler_active = 0; static int close_connection = 0; static int _edbus_init_count = 0; +// change this define for extra debug +// #define DDBG(...) printf(__VA_ARGS__); printf("\n"); +#define DDBG(...) + static void e_dbus_message_free(void *data, void *message) @@ -176,6 +180,7 @@ e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) Eina_List *l; Ecore_Fd_Handler *fdh; + DDBG("FD handler add"); if (hd->fd_handler) return; dflags = dbus_watch_get_flags(hd->watch); eflags = ECORE_FD_ERROR; @@ -187,13 +192,14 @@ e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) if (ecore_main_fd_handler_fd_get(fdh) == hd->fd) return; } - DBG("fd handler add (%d)", hd->fd); + DDBG("FD handler add on fd:%d (flags: %d)", hd->fd, dflags); hd->fd_handler = ecore_main_fd_handler_add(hd->fd, eflags, e_dbus_fd_handler, hd, NULL, NULL); + if (!hd->fd_handler) { DDBG("ERROR! cannot create FD handler") } hd->cd->fd_handlers = eina_list_append(hd->cd->fd_handlers, hd->fd_handler); } @@ -203,7 +209,7 @@ e_dbus_handler_data_free(void *data) { E_DBus_Handler_Data *hd = data; - DBG("e_dbus_handler_data_free"); + DDBG("e_dbus_handler_data_free"); if (hd->fd_handler) { hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->fd_handler); @@ -225,7 +231,6 @@ e_dbus_handler_data_add(E_DBus_Connection *cd, DBusWatch *watch) hd->enabled = dbus_watch_get_enabled(watch); hd->fd = dbus_watch_get_unix_fd(hd->watch); - DBG("watch add (enabled: %d)", hd->enabled); if (hd->enabled) e_dbus_fd_handler_add(hd); } @@ -237,7 +242,9 @@ cb_watch_add(DBusWatch *watch, void *data) E_DBus_Connection *cd; cd = data; - DBG("cb_watch_add"); + DDBG("Watch add on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), + dbus_watch_get_flags(watch), dbus_watch_get_enabled(watch)); + e_dbus_handler_data_add(cd, watch); return true; @@ -248,7 +255,9 @@ cb_watch_del(DBusWatch *watch, void *data) { E_DBus_Handler_Data *hd; - DBG("cb_watch_del"); + DDBG("Watch del on fd: %d (flags: %d)", dbus_watch_get_unix_fd(watch), + dbus_watch_get_flags(watch)); + hd = (E_DBus_Handler_Data *)dbus_watch_get_data(watch); e_dbus_fd_handler_del(hd); } @@ -258,14 +267,14 @@ cb_watch_toggle(DBusWatch *watch, void *data) { E_DBus_Handler_Data *hd; - DBG("cb_watch_toggle"); - hd = dbus_watch_get_data(watch); + DDBG("Watch toggle on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), + dbus_watch_get_flags(watch), dbus_watch_get_enabled(watch)); + hd = dbus_watch_get_data(watch); if (!hd) return; hd->enabled = dbus_watch_get_enabled(watch); - INFO("watch %p is %sabled", hd, hd->enabled ? "en" : "dis"); if (hd->enabled) e_dbus_fd_handler_add(hd); else e_dbus_fd_handler_del(hd); } @@ -545,3 +554,4 @@ e_dbus_connection_close(E_DBus_Connection *conn) } +#undef DDBG From 6d5a1d1169aa01a549cd8c28d97fc92ba904461c Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 17:06:28 +0200 Subject: [PATCH 23/30] use 3 spaces indentation, not 2 --- efl/dbus_mainloop/e_dbus.c | 590 +++++++++++++++++++------------------ 1 file changed, 297 insertions(+), 293 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index 8798f46..ff9d9d4 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -44,90 +44,91 @@ static int _edbus_init_count = 0; static void e_dbus_message_free(void *data, void *message) { - dbus_message_unref(message); + dbus_message_unref(message); } static DBusHandlerResult e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data) { - E_DBus_Connection *cd = user_data; - DBG("-----------------"); - DBG("Message!"); + E_DBus_Connection *cd = user_data; + DBG("-----------------"); + DBG("Message!"); - DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message))); - DBG("path: %s", dbus_message_get_path(message)); - DBG("interface: %s", dbus_message_get_interface(message)); - DBG("member: %s", dbus_message_get_member(message)); - DBG("sender: %s", dbus_message_get_sender(message)); + DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message))); + DBG("path: %s", dbus_message_get_path(message)); + DBG("interface: %s", dbus_message_get_interface(message)); + DBG("member: %s", dbus_message_get_member(message)); + DBG("sender: %s", dbus_message_get_sender(message)); - switch (dbus_message_get_type(message)) - { - case DBUS_MESSAGE_TYPE_METHOD_CALL: - DBG("signature: %s", dbus_message_get_signature(message)); - break; - case DBUS_MESSAGE_TYPE_METHOD_RETURN: - DBG("reply serial %d", dbus_message_get_reply_serial(message)); - break; - case DBUS_MESSAGE_TYPE_ERROR: - DBG("error: %s", dbus_message_get_error_name(message)); - break; - case DBUS_MESSAGE_TYPE_SIGNAL: - dbus_message_ref(message); - if (cd->signal_dispatcher) cd->signal_dispatcher(cd, message); - ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL); - break; - default: - break; - } - DBG("-----------------"); + switch (dbus_message_get_type(message)) + { + case DBUS_MESSAGE_TYPE_METHOD_CALL: + DBG("signature: %s", dbus_message_get_signature(message)); + break; + case DBUS_MESSAGE_TYPE_METHOD_RETURN: + DBG("reply serial %d", dbus_message_get_reply_serial(message)); + break; + case DBUS_MESSAGE_TYPE_ERROR: + DBG("error: %s", dbus_message_get_error_name(message)); + break; + case DBUS_MESSAGE_TYPE_SIGNAL: + dbus_message_ref(message); + if (cd->signal_dispatcher) + cd->signal_dispatcher(cd, message); + ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL); + break; + default: + break; + } + DBG("-----------------"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static Eina_Bool e_dbus_idler(void *data) { - E_DBus_Connection *cd; - cd = data; + E_DBus_Connection *cd; + cd = data; - if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn)) - { - DBG("done dispatching!"); - cd->idler = NULL; - return ECORE_CALLBACK_CANCEL; - } - e_dbus_idler_active++; - dbus_connection_ref(cd->conn); - DBG("dispatch()"); - dbus_connection_dispatch(cd->conn); - dbus_connection_unref(cd->conn); - e_dbus_idler_active--; - // e_dbus_signal_handlers_clean(cd); // TODO XXX - if (!e_dbus_idler_active && close_connection) - { - do - { - e_dbus_connection_close(cd); - } while (--close_connection); - } - return ECORE_CALLBACK_RENEW; + if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn)) + { + DBG("done dispatching!"); + cd->idler = NULL; + return ECORE_CALLBACK_CANCEL; + } + e_dbus_idler_active++; + dbus_connection_ref(cd->conn); + DBG("dispatch()"); + dbus_connection_dispatch(cd->conn); + dbus_connection_unref(cd->conn); + e_dbus_idler_active--; + // e_dbus_signal_handlers_clean(cd); // TODO XXX + if (!e_dbus_idler_active && close_connection) + { + do + { + e_dbus_connection_close(cd); + } while (--close_connection); + } + return ECORE_CALLBACK_RENEW; } static void cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *data) { - E_DBus_Connection *cd; + E_DBus_Connection *cd; - DBG("dispatch status: %d!", new_status); - cd = data; + DBG("dispatch status: %d!", new_status); + cd = data; - if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler) - cd->idler = ecore_idler_add(e_dbus_idler, cd); - else if (new_status != DBUS_DISPATCH_DATA_REMAINS && cd->idler) - { - ecore_idler_del(cd->idler); - cd->idler = NULL; - } + if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler) + cd->idler = ecore_idler_add(e_dbus_idler, cd); + else if (new_status != DBUS_DISPATCH_DATA_REMAINS && cd->idler) + { + ecore_idler_del(cd->idler); + cd->idler = NULL; + } } @@ -135,103 +136,106 @@ cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *da static void e_dbus_fd_handler_del(E_DBus_Handler_Data *hd) { - if (!hd->fd_handler) return; + if (!hd->fd_handler) return; - DBG("handler disabled"); - hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->fd_handler); - ecore_main_fd_handler_del(hd->fd_handler); - hd->fd_handler = NULL; + DDBG(" FD handler del"); + hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->fd_handler); + ecore_main_fd_handler_del(hd->fd_handler); + hd->fd_handler = NULL; } static Eina_Bool e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) { - E_DBus_Handler_Data *hd; - unsigned int condition = 0; + E_DBus_Handler_Data *hd; + unsigned int condition = 0; - DBG("fd handler (%p)!", fd_handler); + DBG("fd handler (%p)!", fd_handler); - hd = data; + hd = data; - if (!hd->enabled) - { - e_dbus_fd_handler_del(hd); - return ECORE_CALLBACK_CANCEL; - } - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) condition |= DBUS_WATCH_READABLE; - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) condition |= DBUS_WATCH_WRITABLE; - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) condition |= DBUS_WATCH_ERROR; - DBG("fdh || READ: %d, WRITE: %d", + if (!hd->enabled) + { + e_dbus_fd_handler_del(hd); + return ECORE_CALLBACK_CANCEL; + } + if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) + condition |= DBUS_WATCH_READABLE; + if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) + condition |= DBUS_WATCH_WRITABLE; + if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) + condition |= DBUS_WATCH_ERROR; + DBG("fdh || READ: %d, WRITE: %d", (condition & DBUS_WATCH_READABLE) == DBUS_WATCH_READABLE, (condition & DBUS_WATCH_WRITABLE) == DBUS_WATCH_WRITABLE); - if (condition & DBUS_WATCH_ERROR) DBG("DBUS watch error"); - dbus_watch_handle(hd->watch, condition); - hd = NULL; + if (condition & DBUS_WATCH_ERROR) DBG("DBUS watch error"); + dbus_watch_handle(hd->watch, condition); + hd = NULL; - return ECORE_CALLBACK_RENEW; + return ECORE_CALLBACK_RENEW; } static void e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) { - unsigned int dflags; - Ecore_Fd_Handler_Flags eflags; - Eina_List *l; - Ecore_Fd_Handler *fdh; + unsigned int dflags; + Ecore_Fd_Handler_Flags eflags; + Eina_List *l; + Ecore_Fd_Handler *fdh; - DDBG("FD handler add"); - if (hd->fd_handler) return; - dflags = dbus_watch_get_flags(hd->watch); - eflags = ECORE_FD_ERROR; - if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ; - if (dflags & DBUS_WATCH_WRITABLE) eflags |= ECORE_FD_WRITE; + DDBG(" FD handler add"); + if (hd->fd_handler) return; + dflags = dbus_watch_get_flags(hd->watch); + eflags = ECORE_FD_ERROR; + if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ; + if (dflags & DBUS_WATCH_WRITABLE) eflags |= ECORE_FD_WRITE; - EINA_LIST_FOREACH(hd->cd->fd_handlers, l, fdh) - { - if (ecore_main_fd_handler_fd_get(fdh) == hd->fd) return; - } + EINA_LIST_FOREACH(hd->cd->fd_handlers, l, fdh) + { + if (ecore_main_fd_handler_fd_get(fdh) == hd->fd) return; + } - DDBG("FD handler add on fd:%d (flags: %d)", hd->fd, dflags); - hd->fd_handler = ecore_main_fd_handler_add(hd->fd, - eflags, - e_dbus_fd_handler, - hd, - NULL, - NULL); - if (!hd->fd_handler) { DDBG("ERROR! cannot create FD handler") } + DDBG(" FD handler add on fd:%d (flags: %d)", hd->fd, dflags); + hd->fd_handler = ecore_main_fd_handler_add(hd->fd, + eflags, + e_dbus_fd_handler, + hd, + NULL, + NULL); + if (!hd->fd_handler) { DDBG("ERROR! cannot create FD handler") } - hd->cd->fd_handlers = eina_list_append(hd->cd->fd_handlers, hd->fd_handler); + hd->cd->fd_handlers = eina_list_append(hd->cd->fd_handlers, hd->fd_handler); } static void e_dbus_handler_data_free(void *data) { - E_DBus_Handler_Data *hd = data; + E_DBus_Handler_Data *hd = data; - DDBG("e_dbus_handler_data_free"); - if (hd->fd_handler) - { - hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->fd_handler); - ecore_main_fd_handler_del(hd->fd_handler); - } - free(hd); + DDBG("e_dbus_handler_data_free"); + if (hd->fd_handler) + { + hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->fd_handler); + ecore_main_fd_handler_del(hd->fd_handler); + } + free(hd); } static void e_dbus_handler_data_add(E_DBus_Connection *cd, DBusWatch *watch) { - E_DBus_Handler_Data *hd; + E_DBus_Handler_Data *hd; - hd = calloc(1, sizeof(E_DBus_Handler_Data)); - dbus_watch_set_data(watch, hd, e_dbus_handler_data_free); - hd->cd = cd; - hd->watch = watch; + hd = calloc(1, sizeof(E_DBus_Handler_Data)); + dbus_watch_set_data(watch, hd, e_dbus_handler_data_free); + hd->cd = cd; + hd->watch = watch; - hd->enabled = dbus_watch_get_enabled(watch); - hd->fd = dbus_watch_get_unix_fd(hd->watch); + hd->enabled = dbus_watch_get_enabled(watch); + hd->fd = dbus_watch_get_unix_fd(hd->watch); - if (hd->enabled) e_dbus_fd_handler_add(hd); + if (hd->enabled) e_dbus_fd_handler_add(hd); } @@ -239,44 +243,44 @@ e_dbus_handler_data_add(E_DBus_Connection *cd, DBusWatch *watch) static dbus_bool_t cb_watch_add(DBusWatch *watch, void *data) { - E_DBus_Connection *cd; - cd = data; + E_DBus_Connection *cd; + cd = data; - DDBG("Watch add on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), + DDBG("Watch add on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), dbus_watch_get_flags(watch), dbus_watch_get_enabled(watch)); - e_dbus_handler_data_add(cd, watch); + e_dbus_handler_data_add(cd, watch); - return true; + return true; } static void cb_watch_del(DBusWatch *watch, void *data) { - E_DBus_Handler_Data *hd; + E_DBus_Handler_Data *hd; - DDBG("Watch del on fd: %d (flags: %d)", dbus_watch_get_unix_fd(watch), + DDBG("Watch del on fd: %d (flags: %d)", dbus_watch_get_unix_fd(watch), dbus_watch_get_flags(watch)); - hd = (E_DBus_Handler_Data *)dbus_watch_get_data(watch); - e_dbus_fd_handler_del(hd); + hd = (E_DBus_Handler_Data *)dbus_watch_get_data(watch); + e_dbus_fd_handler_del(hd); } static void cb_watch_toggle(DBusWatch *watch, void *data) { - E_DBus_Handler_Data *hd; + E_DBus_Handler_Data *hd; - DDBG("Watch toggle on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), + DDBG("Watch toggle on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), dbus_watch_get_flags(watch), dbus_watch_get_enabled(watch)); - hd = dbus_watch_get_data(watch); - if (!hd) return; + hd = dbus_watch_get_data(watch); + if (!hd) return; - hd->enabled = dbus_watch_get_enabled(watch); + hd->enabled = dbus_watch_get_enabled(watch); - if (hd->enabled) e_dbus_fd_handler_add(hd); - else e_dbus_fd_handler_del(hd); + if (hd->enabled) e_dbus_fd_handler_add(hd); + else e_dbus_fd_handler_del(hd); } @@ -284,89 +288,89 @@ cb_watch_toggle(DBusWatch *watch, void *data) static Eina_Bool e_dbus_timeout_handler(void *data) { - E_DBus_Timeout_Data *td; + E_DBus_Timeout_Data *td; - td = data; + td = data; - if (!dbus_timeout_get_enabled(td->timeout)) - { - DBG("timeout_handler (not enabled, ending)"); - td->handler = NULL; - return ECORE_CALLBACK_CANCEL; - } + if (!dbus_timeout_get_enabled(td->timeout)) + { + DBG("timeout_handler (not enabled, ending)"); + td->handler = NULL; + return ECORE_CALLBACK_CANCEL; + } - DBG("timeout handler!"); - dbus_timeout_handle(td->timeout); - return ECORE_CALLBACK_CANCEL; + DBG("timeout handler!"); + dbus_timeout_handle(td->timeout); + return ECORE_CALLBACK_CANCEL; } static void e_dbus_timeout_data_free(void *timeout_data) { - E_DBus_Timeout_Data *td = timeout_data; - DBG("e_dbus_timeout_data_free"); - if (td->handler) ecore_timer_del(td->handler); - free(td); + E_DBus_Timeout_Data *td = timeout_data; + DBG("e_dbus_timeout_data_free"); + if (td->handler) ecore_timer_del(td->handler); + free(td); } static dbus_bool_t cb_timeout_add(DBusTimeout *timeout, void *data) { - E_DBus_Connection *cd; - E_DBus_Timeout_Data *td; - - cd = data; - DBG("timeout add!"); - td = calloc(1, sizeof(E_DBus_Timeout_Data)); - td->cd = cd; - dbus_timeout_set_data(timeout, (void *)td, e_dbus_timeout_data_free); + E_DBus_Connection *cd; + E_DBus_Timeout_Data *td; - td->interval = dbus_timeout_get_interval(timeout); - td->timeout = timeout; + cd = data; + DBG("timeout add!"); + td = calloc(1, sizeof(E_DBus_Timeout_Data)); + td->cd = cd; + dbus_timeout_set_data(timeout, (void *)td, e_dbus_timeout_data_free); - if (dbus_timeout_get_enabled(timeout)) - td->handler = ecore_timer_add(td->interval, e_dbus_timeout_handler, td); - td->cd->timeouts = eina_list_append(td->cd->timeouts, td->handler); + td->interval = dbus_timeout_get_interval(timeout); + td->timeout = timeout; - return true; + if (dbus_timeout_get_enabled(timeout)) + td->handler = ecore_timer_add(td->interval, e_dbus_timeout_handler, td); + td->cd->timeouts = eina_list_append(td->cd->timeouts, td->handler); + + return true; } static void cb_timeout_del(DBusTimeout *timeout, void *data) { - E_DBus_Timeout_Data *td; - DBG("timeout del!"); + E_DBus_Timeout_Data *td; + DBG("timeout del!"); - td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout); + td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout); - if (td->handler) - { - td->cd->timeouts = eina_list_remove(td->cd->timeouts, td->handler); - ecore_timer_del(td->handler); - td->handler = NULL; - } + if (td->handler) + { + td->cd->timeouts = eina_list_remove(td->cd->timeouts, td->handler); + ecore_timer_del(td->handler); + td->handler = NULL; + } - /* Note: timeout data gets freed when the timeout itself is freed by dbus */ + /* Note: timeout data gets freed when the timeout itself is freed by dbus */ } static void cb_timeout_toggle(DBusTimeout *timeout, void *data) { - E_DBus_Timeout_Data *td; - DBG("timeout toggle!"); + E_DBus_Timeout_Data *td; + DBG("timeout toggle!"); - td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout); + td = (E_DBus_Timeout_Data *)dbus_timeout_get_data(timeout); - if (dbus_timeout_get_enabled(td->timeout)) - { - td->interval = dbus_timeout_get_interval(timeout); - td->handler = ecore_timer_add(td->interval, e_dbus_timeout_handler, td); - } - else - { - ecore_timer_del(td->handler); - td->handler = NULL; - } + if (dbus_timeout_get_enabled(td->timeout)) + { + td->interval = dbus_timeout_get_interval(timeout); + td->handler = ecore_timer_add(td->interval, e_dbus_timeout_handler, td); + } + else + { + ecore_timer_del(td->handler); + td->handler = NULL; + } } @@ -374,53 +378,53 @@ cb_timeout_toggle(DBusTimeout *timeout, void *data) static E_DBus_Connection * e_dbus_connection_new(DBusConnection *conn) { - E_DBus_Connection *cd; - const char *conn_name; + E_DBus_Connection *cd; + const char *conn_name; - cd = calloc(1, sizeof(E_DBus_Connection)); - if (!cd) return NULL; + cd = calloc(1, sizeof(E_DBus_Connection)); + if (!cd) return NULL; - cd->conn = conn; - conn_name = dbus_bus_get_unique_name(conn); - if (conn_name) - { - DBG("Connected! Name: %s", conn_name); - cd->conn_name = strdup(conn_name); - } - else - DBG("Not connected"); + cd->conn = conn; + conn_name = dbus_bus_get_unique_name(conn); + if (conn_name) + { + DBG("Connected! Name: %s", conn_name); + cd->conn_name = strdup(conn_name); + } + else + DBG("Not connected"); - cd->shared_type = (unsigned int)-1; - cd->fd_handlers = NULL; - cd->timeouts = NULL; + cd->shared_type = (unsigned int)-1; + cd->fd_handlers = NULL; + cd->timeouts = NULL; - return cd; + return cd; } static void e_dbus_connection_free(void *data) { - E_DBus_Connection *cd = data; - Ecore_Fd_Handler *fd_handler; - Ecore_Timer *timer; - DBG("e_dbus_connection free!"); + E_DBus_Connection *cd = data; + Ecore_Fd_Handler *fd_handler; + Ecore_Timer *timer; + DBG("e_dbus_connection free!"); - EINA_LIST_FREE(cd->fd_handlers, fd_handler) - ecore_main_fd_handler_del(fd_handler); + EINA_LIST_FREE(cd->fd_handlers, fd_handler) + ecore_main_fd_handler_del(fd_handler); - EINA_LIST_FREE(cd->timeouts, timer) - ecore_timer_del(timer); + EINA_LIST_FREE(cd->timeouts, timer) + ecore_timer_del(timer); - // if (cd->shared_type != (unsigned int)-1) - // shared_connections[cd->shared_type] = NULL; + // if (cd->shared_type != (unsigned int)-1) + // shared_connections[cd->shared_type] = NULL; - // e_dbus_signal_handlers_free_all(cd); + // e_dbus_signal_handlers_free_all(cd); - if (cd->conn_name) free(cd->conn_name); + if (cd->conn_name) free(cd->conn_name); - if (cd->idler) ecore_idler_del(cd->idler); + if (cd->idler) ecore_idler_del(cd->idler); - free(cd); + free(cd); } @@ -428,129 +432,129 @@ e_dbus_connection_free(void *data) int e_dbus_init(void) { - if (++_edbus_init_count != 1) - return _edbus_init_count; + if (++_edbus_init_count != 1) + return _edbus_init_count; - if (!eina_init()) - { + if (!eina_init()) + { fprintf(stderr,"E-dbus: Enable to initialize eina\n"); return --_edbus_init_count; - } + } - _e_dbus_log_dom = eina_log_domain_register("e_dbus", E_DBUS_COLOR_DEFAULT); - if (_e_dbus_log_dom < 0) - { + _e_dbus_log_dom = eina_log_domain_register("e_dbus", E_DBUS_COLOR_DEFAULT); + if (_e_dbus_log_dom < 0) + { EINA_LOG_ERR("Unable to create an 'e_dbus' log domain"); eina_shutdown(); return --_edbus_init_count; - } + } - if (!ecore_init()) - { + if (!ecore_init()) + { ERR("E-dbus: Unable to initialize ecore"); eina_shutdown(); return --_edbus_init_count; - } + } - E_DBUS_EVENT_SIGNAL = ecore_event_type_new(); + E_DBUS_EVENT_SIGNAL = ecore_event_type_new(); - return _edbus_init_count; + return _edbus_init_count; } int e_dbus_shutdown(void) { - if (_edbus_init_count <= 0) - { - EINA_LOG_ERR("Init count not greater than 0 in shutdown."); - return 0; - } - if (--_edbus_init_count) - return _edbus_init_count; + if (_edbus_init_count <= 0) + { + EINA_LOG_ERR("Init count not greater than 0 in shutdown."); + return 0; + } + if (--_edbus_init_count) + return _edbus_init_count; - ecore_shutdown(); - eina_log_domain_unregister(_e_dbus_log_dom); - _e_dbus_log_dom = -1; - eina_shutdown(); + ecore_shutdown(); + eina_log_domain_unregister(_e_dbus_log_dom); + _e_dbus_log_dom = -1; + eina_shutdown(); - return _edbus_init_count; + return _edbus_init_count; } E_DBus_Connection * e_dbus_connection_setup(DBusConnection *conn) { - E_DBus_Connection *cd; + E_DBus_Connection *cd; - cd = e_dbus_connection_new(conn); - if (!cd) return NULL; + cd = e_dbus_connection_new(conn); + if (!cd) return NULL; - /* connection_setup */ - dbus_connection_set_exit_on_disconnect(cd->conn, EINA_FALSE); - dbus_connection_allocate_data_slot(&connection_slot); + /* connection_setup */ + dbus_connection_set_exit_on_disconnect(cd->conn, EINA_FALSE); + dbus_connection_allocate_data_slot(&connection_slot); - dbus_connection_set_data(cd->conn, connection_slot, (void *)cd, e_dbus_connection_free); - dbus_connection_set_watch_functions(cd->conn, - cb_watch_add, - cb_watch_del, - cb_watch_toggle, - cd, - NULL); + dbus_connection_set_data(cd->conn, connection_slot, (void *)cd, + e_dbus_connection_free); + dbus_connection_set_watch_functions(cd->conn, + cb_watch_add, + cb_watch_del, + cb_watch_toggle, + cd, + NULL); - dbus_connection_set_timeout_functions(cd->conn, - cb_timeout_add, - cb_timeout_del, - cb_timeout_toggle, - cd, - NULL); + dbus_connection_set_timeout_functions(cd->conn, + cb_timeout_add, + cb_timeout_del, + cb_timeout_toggle, + cd, + NULL); - dbus_connection_set_dispatch_status_function(cd->conn, cb_dispatch_status, cd, NULL); - dbus_connection_add_filter(cd->conn, e_dbus_filter, cd, NULL); + dbus_connection_set_dispatch_status_function(cd->conn, cb_dispatch_status, cd, NULL); + dbus_connection_add_filter(cd->conn, e_dbus_filter, cd, NULL); + cb_dispatch_status(cd->conn, dbus_connection_get_dispatch_status(cd->conn), cd); - cb_dispatch_status(cd->conn, dbus_connection_get_dispatch_status(cd->conn), cd); - - return cd; + return cd; } void e_dbus_connection_close(E_DBus_Connection *conn) { - if (!conn) return; - DBG("e_dbus_connection_close"); + if (!conn) return; + DBG("e_dbus_connection_close"); - if (e_dbus_idler_active) - { - close_connection++; - return; - } - if (--(conn->refcount) != 0) return; + if (e_dbus_idler_active) + { + close_connection++; + return; + } + if (--(conn->refcount) != 0) return; - dbus_connection_free_data_slot(&connection_slot); - dbus_connection_remove_filter(conn->conn, e_dbus_filter, conn); - dbus_connection_set_watch_functions (conn->conn, + dbus_connection_free_data_slot(&connection_slot); + dbus_connection_remove_filter(conn->conn, e_dbus_filter, conn); + dbus_connection_set_watch_functions(conn->conn, NULL, NULL, NULL, NULL, NULL); - dbus_connection_set_timeout_functions (conn->conn, + dbus_connection_set_timeout_functions(conn->conn, NULL, NULL, NULL, NULL, NULL); - dbus_connection_set_dispatch_status_function (conn->conn, NULL, NULL, NULL); + dbus_connection_set_dispatch_status_function(conn->conn, NULL, NULL, NULL); - /* Idler functin must be cancelled when dbus connection is unreferenced */ - if (conn->idler) - { + /* Idler functin must be cancelled when dbus connection is unreferenced */ + if (conn->idler) + { ecore_idler_del(conn->idler); conn->idler = NULL; - } + } - dbus_connection_close(conn->conn); - dbus_connection_unref(conn->conn); + dbus_connection_close(conn->conn); + dbus_connection_unref(conn->conn); - // Note: the E_DBus_Connection gets freed when the dbus_connection is cleaned up by the previous unref + // Note: the E_DBus_Connection gets freed when the dbus_connection is cleaned up by the previous unref } From 1de3ffccd6bd3ff33e6c45fcdc1c181ae904341d Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 17:34:37 +0200 Subject: [PATCH 24/30] Simplify: no need to keep a local copy of the watch state --- efl/dbus_mainloop/e_dbus.c | 25 +++++++++++++------------ efl/dbus_mainloop/e_dbus.h | 2 -- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index ff9d9d4..730f309 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -154,7 +154,7 @@ e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) hd = data; - if (!hd->enabled) + if (!dbus_watch_get_enabled(hd->watch)) { e_dbus_fd_handler_del(hd); return ECORE_CALLBACK_CANCEL; @@ -183,9 +183,12 @@ e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) Ecore_Fd_Handler_Flags eflags; Eina_List *l; Ecore_Fd_Handler *fdh; + int fd; DDBG(" FD handler add"); if (hd->fd_handler) return; + + fd = dbus_watch_get_unix_fd(hd->watch); dflags = dbus_watch_get_flags(hd->watch); eflags = ECORE_FD_ERROR; if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ; @@ -193,11 +196,11 @@ e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) EINA_LIST_FOREACH(hd->cd->fd_handlers, l, fdh) { - if (ecore_main_fd_handler_fd_get(fdh) == hd->fd) return; + if (ecore_main_fd_handler_fd_get(fdh) == fd) return; } - DDBG(" FD handler add on fd:%d (flags: %d)", hd->fd, dflags); - hd->fd_handler = ecore_main_fd_handler_add(hd->fd, + DDBG(" FD handler add on fd:%d (flags: %d)", fd, dflags); + hd->fd_handler = ecore_main_fd_handler_add(fd, eflags, e_dbus_fd_handler, hd, @@ -232,10 +235,8 @@ e_dbus_handler_data_add(E_DBus_Connection *cd, DBusWatch *watch) hd->cd = cd; hd->watch = watch; - hd->enabled = dbus_watch_get_enabled(watch); - hd->fd = dbus_watch_get_unix_fd(hd->watch); - - if (hd->enabled) e_dbus_fd_handler_add(hd); + if (dbus_watch_get_enabled(watch)) + e_dbus_fd_handler_add(hd); } @@ -277,10 +278,10 @@ cb_watch_toggle(DBusWatch *watch, void *data) hd = dbus_watch_get_data(watch); if (!hd) return; - hd->enabled = dbus_watch_get_enabled(watch); - - if (hd->enabled) e_dbus_fd_handler_add(hd); - else e_dbus_fd_handler_del(hd); + if (dbus_watch_get_enabled(watch)) + e_dbus_fd_handler_add(hd); + else + e_dbus_fd_handler_del(hd); } diff --git a/efl/dbus_mainloop/e_dbus.h b/efl/dbus_mainloop/e_dbus.h index 1d6e5ae..dff55fb 100644 --- a/efl/dbus_mainloop/e_dbus.h +++ b/efl/dbus_mainloop/e_dbus.h @@ -47,11 +47,9 @@ struct E_DBus_Connection struct E_DBus_Handler_Data { - int fd; Ecore_Fd_Handler *fd_handler; E_DBus_Connection *cd; DBusWatch *watch; - int enabled; }; struct E_DBus_Timeout_Data From bc02e43181b3c669f89cbed5e942aa5c1be2ebbe Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 17:59:22 +0200 Subject: [PATCH 25/30] Cleanups: the filter are not used here and the ecore_event is not used enywhere --- efl/dbus_mainloop/e_dbus.c | 49 -------------------------------------- 1 file changed, 49 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index 730f309..ad45f8b 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -30,7 +30,6 @@ static int _e_dbus_log_dom = -1; #define WARN(...) EINA_LOG_DOM_WARN(_e_dbus_log_dom, __VA_ARGS__) #define ERR(...) EINA_LOG_DOM_ERR(_e_dbus_log_dom, __VA_ARGS__) -int E_DBUS_EVENT_SIGNAL = 0; static int connection_slot = -1; static int e_dbus_idler_active = 0; static int close_connection = 0; @@ -41,50 +40,6 @@ static int _edbus_init_count = 0; #define DDBG(...) -static void -e_dbus_message_free(void *data, void *message) -{ - dbus_message_unref(message); -} - -static DBusHandlerResult -e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data) -{ - E_DBus_Connection *cd = user_data; - DBG("-----------------"); - DBG("Message!"); - - DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message))); - DBG("path: %s", dbus_message_get_path(message)); - DBG("interface: %s", dbus_message_get_interface(message)); - DBG("member: %s", dbus_message_get_member(message)); - DBG("sender: %s", dbus_message_get_sender(message)); - - switch (dbus_message_get_type(message)) - { - case DBUS_MESSAGE_TYPE_METHOD_CALL: - DBG("signature: %s", dbus_message_get_signature(message)); - break; - case DBUS_MESSAGE_TYPE_METHOD_RETURN: - DBG("reply serial %d", dbus_message_get_reply_serial(message)); - break; - case DBUS_MESSAGE_TYPE_ERROR: - DBG("error: %s", dbus_message_get_error_name(message)); - break; - case DBUS_MESSAGE_TYPE_SIGNAL: - dbus_message_ref(message); - if (cd->signal_dispatcher) - cd->signal_dispatcher(cd, message); - ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL); - break; - default: - break; - } - DBG("-----------------"); - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - static Eina_Bool e_dbus_idler(void *data) { @@ -457,8 +412,6 @@ e_dbus_init(void) return --_edbus_init_count; } - E_DBUS_EVENT_SIGNAL = ecore_event_type_new(); - return _edbus_init_count; } @@ -510,7 +463,6 @@ e_dbus_connection_setup(DBusConnection *conn) NULL); dbus_connection_set_dispatch_status_function(cd->conn, cb_dispatch_status, cd, NULL); - dbus_connection_add_filter(cd->conn, e_dbus_filter, cd, NULL); cb_dispatch_status(cd->conn, dbus_connection_get_dispatch_status(cd->conn), cd); return cd; @@ -530,7 +482,6 @@ e_dbus_connection_close(E_DBus_Connection *conn) if (--(conn->refcount) != 0) return; dbus_connection_free_data_slot(&connection_slot); - dbus_connection_remove_filter(conn->conn, e_dbus_filter, conn); dbus_connection_set_watch_functions(conn->conn, NULL, NULL, From d0bea312ef54cc515a3f7b0b9135b550bff90ed3 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 20:37:15 +0200 Subject: [PATCH 26/30] dbus_mainloop: reworked how we manage the dbus watch requests. Dbus can request (via watch_add) more than one watch on the same fd (one for write and one for read), but ecore cannot setup more than one fd_handler on the same fd. So we need to manage this (weired) case internally, reusing an existing fd_handler for more than one dbus watch. This, at the end of the story, fix the ability to connect to the (fucking) PulseAudio dbus server, that do not use the Session or System buses, but provide its own bus. --- efl/dbus_mainloop/e_dbus.c | 171 ++++++++++++++++--------------------- efl/dbus_mainloop/e_dbus.h | 4 +- 2 files changed, 78 insertions(+), 97 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index ad45f8b..20875ba 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -58,7 +58,6 @@ e_dbus_idler(void *data) dbus_connection_dispatch(cd->conn); dbus_connection_unref(cd->conn); e_dbus_idler_active--; - // e_dbus_signal_handlers_clean(cd); // TODO XXX if (!e_dbus_idler_active && close_connection) { do @@ -88,124 +87,102 @@ cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *da /* ecore fd handler */ -static void -e_dbus_fd_handler_del(E_DBus_Handler_Data *hd) -{ - if (!hd->fd_handler) return; - - DDBG(" FD handler del"); - hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->fd_handler); - ecore_main_fd_handler_del(hd->fd_handler); - hd->fd_handler = NULL; -} - static Eina_Bool e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) { - E_DBus_Handler_Data *hd; + E_DBus_Handler_Data *hd = data; unsigned int condition = 0; - DBG("fd handler (%p)!", fd_handler); - - hd = data; - - if (!dbus_watch_get_enabled(hd->watch)) - { - e_dbus_fd_handler_del(hd); - return ECORE_CALLBACK_CANCEL; - } + DDBG("DATA READY ON FD"); if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) condition |= DBUS_WATCH_READABLE; if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) condition |= DBUS_WATCH_WRITABLE; if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR)) condition |= DBUS_WATCH_ERROR; - DBG("fdh || READ: %d, WRITE: %d", - (condition & DBUS_WATCH_READABLE) == DBUS_WATCH_READABLE, - (condition & DBUS_WATCH_WRITABLE) == DBUS_WATCH_WRITABLE); - - if (condition & DBUS_WATCH_ERROR) DBG("DBUS watch error"); - dbus_watch_handle(hd->watch, condition); - hd = NULL; + if (hd->watch_read && dbus_watch_get_enabled(hd->watch_read)) + dbus_watch_handle(hd->watch_read, condition); + if (hd->watch_read != hd->watch_write && + hd->watch_write && dbus_watch_get_enabled(hd->watch_write)) + dbus_watch_handle(hd->watch_write, condition); + return ECORE_CALLBACK_RENEW; } static void -e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) +e_dbus_fd_handler_update(E_DBus_Handler_Data *hd) { - unsigned int dflags; - Ecore_Fd_Handler_Flags eflags; + Ecore_Fd_Handler_Flags eflags = ECORE_FD_ERROR; + + if (hd->watch_read && dbus_watch_get_enabled(hd->watch_read)) + eflags |= ECORE_FD_READ; + if (hd->watch_write && dbus_watch_get_enabled(hd->watch_write)) + eflags |= ECORE_FD_WRITE; + + DDBG("FD update %d (flags: %d)", hd->fd, eflags) + ecore_main_fd_handler_active_set(hd->fd_handler, eflags); +} + +static void +e_dbus_fd_handler_add(E_DBus_Connection *cd, DBusWatch *watch) +{ + E_DBus_Handler_Data *hd = NULL, *hd2; Eina_List *l; - Ecore_Fd_Handler *fdh; + int dflags; int fd; - DDBG(" FD handler add"); - if (hd->fd_handler) return; + fd = dbus_watch_get_unix_fd(watch); + dflags = dbus_watch_get_flags(watch); - fd = dbus_watch_get_unix_fd(hd->watch); - dflags = dbus_watch_get_flags(hd->watch); - eflags = ECORE_FD_ERROR; - if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ; - if (dflags & DBUS_WATCH_WRITABLE) eflags |= ECORE_FD_WRITE; - - EINA_LIST_FOREACH(hd->cd->fd_handlers, l, fdh) + EINA_LIST_FOREACH(cd->fd_handlers, l, hd2) { - if (ecore_main_fd_handler_fd_get(fdh) == fd) return; + if (hd2->fd == fd) + { + hd = hd2; + break; + } } - DDBG(" FD handler add on fd:%d (flags: %d)", fd, dflags); - hd->fd_handler = ecore_main_fd_handler_add(fd, - eflags, - e_dbus_fd_handler, - hd, - NULL, - NULL); - if (!hd->fd_handler) { DDBG("ERROR! cannot create FD handler") } + if (!hd) + { + hd = calloc(1, sizeof(E_DBus_Handler_Data)); + if (!hd) return; + hd->cd = cd; + hd->fd = fd; + hd->fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_ERROR, + e_dbus_fd_handler, + hd, NULL, NULL); + if (!hd->fd_handler) { DDBG("ERROR! cannot create FD handler") } + cd->fd_handlers = eina_list_append(cd->fd_handlers, hd); + } - hd->cd->fd_handlers = eina_list_append(hd->cd->fd_handlers, hd->fd_handler); + if (dflags & DBUS_WATCH_READABLE) hd->watch_read = watch; + if (dflags & DBUS_WATCH_WRITABLE) hd->watch_write = watch; + dbus_watch_set_data(watch, hd, NULL); + e_dbus_fd_handler_update(hd); } static void -e_dbus_handler_data_free(void *data) +e_dbus_fd_handler_del(E_DBus_Handler_Data *hd) { - E_DBus_Handler_Data *hd = data; - - DDBG("e_dbus_handler_data_free"); - if (hd->fd_handler) - { - hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd->fd_handler); - ecore_main_fd_handler_del(hd->fd_handler); - } + DDBG(" FD handler del"); + hd->cd->fd_handlers = eina_list_remove(hd->cd->fd_handlers, hd); + ecore_main_fd_handler_del(hd->fd_handler); free(hd); } -static void -e_dbus_handler_data_add(E_DBus_Connection *cd, DBusWatch *watch) -{ - E_DBus_Handler_Data *hd; - - hd = calloc(1, sizeof(E_DBus_Handler_Data)); - dbus_watch_set_data(watch, hd, e_dbus_handler_data_free); - hd->cd = cd; - hd->watch = watch; - - if (dbus_watch_get_enabled(watch)) - e_dbus_fd_handler_add(hd); -} - - /* watch */ static dbus_bool_t cb_watch_add(DBusWatch *watch, void *data) { - E_DBus_Connection *cd; - cd = data; + E_DBus_Connection *cd = data; - DDBG("Watch add on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), - dbus_watch_get_flags(watch), dbus_watch_get_enabled(watch)); + DDBG("Watch add on fd: %d (flags: %d) enable: %d", + dbus_watch_get_unix_fd(watch), dbus_watch_get_flags(watch), + dbus_watch_get_enabled(watch)); - e_dbus_handler_data_add(cd, watch); + e_dbus_fd_handler_add(cd, watch); return true; } @@ -218,8 +195,16 @@ cb_watch_del(DBusWatch *watch, void *data) DDBG("Watch del on fd: %d (flags: %d)", dbus_watch_get_unix_fd(watch), dbus_watch_get_flags(watch)); - hd = (E_DBus_Handler_Data *)dbus_watch_get_data(watch); - e_dbus_fd_handler_del(hd); + hd = dbus_watch_get_data(watch); + + int dflags = dbus_watch_get_flags(watch); + if (dflags & DBUS_WATCH_READABLE) hd->watch_read = NULL; + if (dflags & DBUS_WATCH_WRITABLE) hd->watch_write = NULL; + + if (!hd->watch_read && !hd->watch_write) + e_dbus_fd_handler_del(hd); + else + e_dbus_fd_handler_update(hd); } static void @@ -227,16 +212,12 @@ cb_watch_toggle(DBusWatch *watch, void *data) { E_DBus_Handler_Data *hd; - DDBG("Watch toggle on fd: %d (flags: %d) enable: %d", dbus_watch_get_unix_fd(watch), - dbus_watch_get_flags(watch), dbus_watch_get_enabled(watch)); + DDBG("Watch toggle on fd: %d (flags: %d) enable: %d", + dbus_watch_get_unix_fd(watch), dbus_watch_get_flags(watch), + dbus_watch_get_enabled(watch)); hd = dbus_watch_get_data(watch); - if (!hd) return; - - if (dbus_watch_get_enabled(watch)) - e_dbus_fd_handler_add(hd); - else - e_dbus_fd_handler_del(hd); + e_dbus_fd_handler_update(hd); } @@ -361,12 +342,12 @@ static void e_dbus_connection_free(void *data) { E_DBus_Connection *cd = data; - Ecore_Fd_Handler *fd_handler; + E_DBus_Handler_Data *hd; Ecore_Timer *timer; DBG("e_dbus_connection free!"); - EINA_LIST_FREE(cd->fd_handlers, fd_handler) - ecore_main_fd_handler_del(fd_handler); + EINA_LIST_FREE(cd->fd_handlers, hd) + e_dbus_fd_handler_del(hd); EINA_LIST_FREE(cd->timeouts, timer) ecore_timer_del(timer); @@ -374,8 +355,6 @@ e_dbus_connection_free(void *data) // if (cd->shared_type != (unsigned int)-1) // shared_connections[cd->shared_type] = NULL; - // e_dbus_signal_handlers_free_all(cd); - if (cd->conn_name) free(cd->conn_name); if (cd->idler) ecore_idler_del(cd->idler); diff --git a/efl/dbus_mainloop/e_dbus.h b/efl/dbus_mainloop/e_dbus.h index dff55fb..7b4939a 100644 --- a/efl/dbus_mainloop/e_dbus.h +++ b/efl/dbus_mainloop/e_dbus.h @@ -47,9 +47,11 @@ struct E_DBus_Connection struct E_DBus_Handler_Data { + int fd; Ecore_Fd_Handler *fd_handler; E_DBus_Connection *cd; - DBusWatch *watch; + DBusWatch *watch_read; + DBusWatch *watch_write; }; struct E_DBus_Timeout_Data From 3544e7408f7675b5c0618f4e43b725fc592f1978 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 20:42:19 +0200 Subject: [PATCH 27/30] Cleanup, remove unused stuff --- efl/dbus_mainloop/e_dbus.c | 19 ------------------- efl/dbus_mainloop/e_dbus.h | 7 ------- 2 files changed, 26 deletions(-) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index 20875ba..f0388d2 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -316,24 +316,10 @@ static E_DBus_Connection * e_dbus_connection_new(DBusConnection *conn) { E_DBus_Connection *cd; - const char *conn_name; cd = calloc(1, sizeof(E_DBus_Connection)); if (!cd) return NULL; - cd->conn = conn; - conn_name = dbus_bus_get_unique_name(conn); - if (conn_name) - { - DBG("Connected! Name: %s", conn_name); - cd->conn_name = strdup(conn_name); - } - else - DBG("Not connected"); - - cd->shared_type = (unsigned int)-1; - cd->fd_handlers = NULL; - cd->timeouts = NULL; return cd; } @@ -352,11 +338,6 @@ e_dbus_connection_free(void *data) EINA_LIST_FREE(cd->timeouts, timer) ecore_timer_del(timer); - // if (cd->shared_type != (unsigned int)-1) - // shared_connections[cd->shared_type] = NULL; - - if (cd->conn_name) free(cd->conn_name); - if (cd->idler) ecore_idler_del(cd->idler); free(cd); diff --git a/efl/dbus_mainloop/e_dbus.h b/efl/dbus_mainloop/e_dbus.h index 7b4939a..f5bb786 100644 --- a/efl/dbus_mainloop/e_dbus.h +++ b/efl/dbus_mainloop/e_dbus.h @@ -31,17 +31,10 @@ typedef struct E_DBus_Timeout_Data E_DBus_Timeout_Data; struct E_DBus_Connection { - DBusBusType shared_type; DBusConnection *conn; - char *conn_name; - Eina_List *fd_handlers; Eina_List *timeouts; - Eina_List *signal_handlers; - void (*signal_dispatcher)(E_DBus_Connection *conn, DBusMessage *msg); - Ecore_Idler *idler; - int refcount; }; From d3794d9566330ef8d00006f476b90fc90bcef0a2 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 23 Aug 2014 21:15:46 +0200 Subject: [PATCH 28/30] No need to call ecore init/shutodown here they are called in e_dbus_init/shutdown --- efl/dbus_mainloop/dbus_mainloop.pxd | 4 ---- efl/dbus_mainloop/dbus_mainloop.pyx | 2 -- 2 files changed, 6 deletions(-) diff --git a/efl/dbus_mainloop/dbus_mainloop.pxd b/efl/dbus_mainloop/dbus_mainloop.pxd index 78f73ce..d16562c 100644 --- a/efl/dbus_mainloop/dbus_mainloop.pxd +++ b/efl/dbus_mainloop/dbus_mainloop.pxd @@ -12,10 +12,6 @@ cdef extern from "dbus/dbus-python.h": PyObject *DBusPyNativeMainLoop_New4(_dbus_py_conn_setup_func conn_func, _dbus_py_srv_setup_func srv_func, _dbus_py_free_func free_func, void *) int import_dbus_bindings(const char *this_module_name) -cdef extern from "Ecore.h": - int ecore_init() - void ecore_shutdown() - cdef extern from "e_dbus.h": ctypedef struct E_DBus_Connection diff --git a/efl/dbus_mainloop/dbus_mainloop.pyx b/efl/dbus_mainloop/dbus_mainloop.pyx index 68ddfdb..d2fb42b 100644 --- a/efl/dbus_mainloop/dbus_mainloop.pyx +++ b/efl/dbus_mainloop/dbus_mainloop.pyx @@ -46,12 +46,10 @@ def DBusEcoreMainLoop(set_as_default = None): def module_cleanup(): e_dbus_shutdown() - ecore_shutdown() if import_dbus_bindings("efl.dbus_mainloop") < 0: raise ImportError("failed to import D-Bus bindings") -ecore_init() e_dbus_init() atexit.register(module_cleanup) From 2d3784e8cb0487de35ee8988f092cac80a877a33 Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Sun, 31 Aug 2014 17:26:19 +0300 Subject: [PATCH 29/30] api_coverage.py: py3k compatibility fix --- api_coverage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_coverage.py b/api_coverage.py index 9c713a9..e51624f 100755 --- a/api_coverage.py +++ b/api_coverage.py @@ -74,7 +74,7 @@ api_group.add_argument( parser.add_argument( "libs", nargs="*", - choices=(params.keys() + ["all"]), + choices=(list(params.keys()) + ["all"]), default="all" ) args = parser.parse_args() From cf358655c079fb13ecf0f28e212f1ba20d443f61 Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Wed, 10 Sep 2014 20:04:18 +0300 Subject: [PATCH 30/30] setup.py: Fix check for Cython when building from git source --- setup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.py b/setup.py index 864ce8a..8624512 100755 --- a/setup.py +++ b/setup.py @@ -113,6 +113,12 @@ else: from Cython.Build import cythonize import Cython.Compiler.Options except ImportError: + if not os.path.exists(os.path.join(script_path, "efl/eo/efl.eo.c")): + raise SystemExit( + "Requires Cython >= %s (http://cython.org/)" % ( + CYTHON_MIN_VERSION + ) + ) module_suffix = ".c" from distutils.command.build_ext import build_ext