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, 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 diff --git a/api_coverage.py b/api_coverage.py index 859830a..e2de438 100755 --- a/api_coverage.py +++ b/api_coverage.py @@ -75,7 +75,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() 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 ----------------------------------------------------- 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/__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/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) diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index fb0204e..f0388d2 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c @@ -30,245 +30,194 @@ 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; 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_fd_handler_del(E_DBus_Handler_Data *hd) -{ - 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; -} - -static Eina_Bool -e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) -{ - E_DBus_Handler_Data *hd; - unsigned int condition = 0; - - DBG("fd handler (%p)!", fd_handler); - - 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", - (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; - - 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; - - 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; - } - - DBG("fd handler add (%d)", hd->fd); - hd->fd_handler = ecore_main_fd_handler_add(hd->fd, - eflags, - e_dbus_fd_handler, - hd, - NULL, - NULL); - - 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; - - DBG("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_connection_data_watch_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; - - 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; + 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--; + 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; + } } +/* ecore fd handler */ +static Eina_Bool +e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) +{ + E_DBus_Handler_Data *hd = data; + unsigned int condition = 0; + + 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; + + 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_update(E_DBus_Handler_Data *hd) +{ + 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; + int dflags; + int fd; + + fd = dbus_watch_get_unix_fd(watch); + dflags = dbus_watch_get_flags(watch); + + EINA_LIST_FOREACH(cd->fd_handlers, l, hd2) + { + if (hd2->fd == fd) + { + hd = hd2; + break; + } + } + + 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); + } + + 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_fd_handler_del(E_DBus_Handler_Data *hd) +{ + 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); +} + /* watch */ static dbus_bool_t cb_watch_add(DBusWatch *watch, void *data) { - E_DBus_Connection *cd; - cd = data; + E_DBus_Connection *cd = data; - DBG("cb_watch_add"); - e_dbus_connection_data_watch_add(cd, 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)); - return true; + e_dbus_fd_handler_add(cd, watch); + + return true; } static void cb_watch_del(DBusWatch *watch, void *data) { - E_DBus_Handler_Data *hd; + E_DBus_Handler_Data *hd; - DBG("cb_watch_del"); - hd = (E_DBus_Handler_Data *)dbus_watch_get_data(watch); - e_dbus_fd_handler_del(hd); + DDBG("Watch del on fd: %d (flags: %d)", dbus_watch_get_unix_fd(watch), + dbus_watch_get_flags(watch)); + + 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 cb_watch_toggle(DBusWatch *watch, void *data) { - E_DBus_Handler_Data *hd; + 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)); - 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); + hd = dbus_watch_get_data(watch); + e_dbus_fd_handler_update(hd); } @@ -276,89 +225,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; + } } @@ -366,53 +315,32 @@ 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; - 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; - 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; + 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; + 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); + 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->idler) ecore_idler_del(cd->idler); - // e_dbus_signal_handlers_free_all(cd); - - if (cd->conn_name) free(cd->conn_name); - - if (cd->idler) ecore_idler_del(cd->idler); - - free(cd); + free(cd); } @@ -420,131 +348,126 @@ 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_object_init(); - - 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; - // e_dbus_object_shutdown(); - 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); + 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_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 } +#undef DDBG diff --git a/efl/dbus_mainloop/e_dbus.h b/efl/dbus_mainloop/e_dbus.h index 1d6e5ae..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; }; @@ -50,8 +43,8 @@ struct E_DBus_Handler_Data int fd; Ecore_Fd_Handler *fd_handler; E_DBus_Connection *cd; - DBusWatch *watch; - int enabled; + DBusWatch *watch_read; + DBusWatch *watch_write; }; struct E_DBus_Timeout_Data 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" 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/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/efl/elementary/enums.pxd b/efl/elementary/enums.pxd index 624f01d..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 @@ -188,6 +192,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/gengrid.pxd b/efl/elementary/gengrid.pxd index cc705c6..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_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) @@ -101,3 +102,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.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_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/gengrid_widget.pxi b/efl/elementary/gengrid_widget.pxi index b0a8900..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 @@ -558,6 +575,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/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_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/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/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..83b6e31 100644 --- a/efl/elementary/map.pyx +++ b/efl/elementary/map.pyx @@ -1092,6 +1092,26 @@ 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 + + .. versionadded:: 1.11 + + """ + 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. 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/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/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/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 diff --git a/efl/emotion/efl.emotion.pyx b/efl/emotion/efl.emotion.pyx index b7e3fbe..619cd30 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)) @@ -1252,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): 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/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) 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_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") diff --git a/examples/elementary/test_gengrid.py b/examples/elementary/test_gengrid.py index a18d1d6..302c451 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()) @@ -113,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() @@ -332,6 +344,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() 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) 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() 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) 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) diff --git a/setup.py b/setup.py index df8aef2..561e809 100755 --- a/setup.py +++ b/setup.py @@ -7,30 +7,37 @@ 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" - -# Add git commit count for dev builds -if RELEASE.split(".")[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) +# 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 = "1.10.99" -ELM_MIN_VERSION = "1.10.99" +EFL_MIN_VERSION = RELEASE +ELM_MIN_VERSION = RELEASE +# Add git commit count for dev builds +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"]: os.environ["CFLAGS"] += " -fvisibility=default" @@ -106,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 @@ -421,7 +434,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)