From 6d8c81050e28234440b3fd1e5793af2e0f8c738f Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sat, 15 Jun 2013 23:37:10 +0200 Subject: [PATCH] change dbus link_detect to mousein/out --- src/bin/dbus.c | 61 +++++++++++++++++++++++++++++++++++++++++--- src/bin/dbus.h | 3 ++- src/bin/termio.c | 17 +++++++++--- src/bin/termiolink.c | 8 ++---- 4 files changed, 75 insertions(+), 14 deletions(-) diff --git a/src/bin/dbus.c b/src/bin/dbus.c index bbed85d..7f06b1e 100644 --- a/src/bin/dbus.c +++ b/src/bin/dbus.c @@ -6,26 +6,78 @@ static Eldbus_Connection *ty_dbus_conn = NULL; static Eldbus_Object *ty_e_object = NULL; +static Eina_Stringshare *_current_url = NULL; void -ty_dbus_link_detect(const char *url) +_cleanup_current_url(void) { Eldbus_Message *msg; + if ((!ty_e_object) || (!_current_url)) return; + msg = eldbus_message_method_call_new("org.enlightenment.wm.service", "/org/enlightenment/wm/RemoteObject", "org.enlightenment.wm.Teamwork", - "LinkDetect"); + "LinkMouseOut"); + + eldbus_message_arguments_append(msg, "s", _current_url); + eldbus_object_send(ty_e_object, msg, NULL, NULL, -1); + + eina_stringshare_del(_current_url); + _current_url = NULL; +} + +void +ty_dbus_link_mouseout(const char *url) +{ + Eldbus_Message *msg; + + if (!ty_e_object) return; + + if ((!url) || + ((_current_url) && (!strcmp(url, _current_url)))) + { + _cleanup_current_url(); + return; + } + + _cleanup_current_url(); + + msg = eldbus_message_method_call_new("org.enlightenment.wm.service", + "/org/enlightenment/wm/RemoteObject", + "org.enlightenment.wm.Teamwork", + "LinkMouseOut"); eldbus_message_arguments_append(msg, "s", url); eldbus_object_send(ty_e_object, msg, NULL, NULL, -1); } + void -ty_dbus_init(void) +ty_dbus_link_mousein(const char *url) { - Eldbus_Service_Interface *iface; + Eldbus_Message *msg; + + if (!ty_e_object) return; + + if ((_current_url) && (!strcmp(url, _current_url))) return; + + msg = eldbus_message_method_call_new("org.enlightenment.wm.service", + "/org/enlightenment/wm/RemoteObject", + "org.enlightenment.wm.Teamwork", + "LinkMouseIn"); + _cleanup_current_url(); + + _current_url = eina_stringshare_add(url); + + eldbus_message_arguments_append(msg, "s", _current_url); + eldbus_object_send(ty_e_object, msg, NULL, NULL, -1); +} + +void +ty_dbus_init(void) +{ if (ty_dbus_conn) return; eldbus_init(); @@ -39,6 +91,7 @@ ty_dbus_init(void) void ty_dbus_shutdown(void) { + _cleanup_current_url(); if (ty_dbus_conn) eldbus_connection_unref(ty_dbus_conn); ty_dbus_conn = NULL; ty_e_object = NULL; diff --git a/src/bin/dbus.h b/src/bin/dbus.h index 089e113..0583708 100644 --- a/src/bin/dbus.h +++ b/src/bin/dbus.h @@ -1,7 +1,8 @@ #ifndef _DBUS_H__ #define _DBUS_H__ 1 -void ty_dbus_link_detect(const char *url); +void ty_dbus_link_mousein(const char *url); +void ty_dbus_link_mouseout(const char *url); void ty_dbus_init(void); void ty_dbus_shutdown(void); diff --git a/src/bin/termio.c b/src/bin/termio.c index 1f26921..7657d9a 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -527,8 +527,13 @@ _smart_mouseover_apply(Evas_Object *obj) &x1, &y1, &x2, &y2); if (!s) { - if (sd->link.string) free(sd->link.string); - sd->link.string = NULL; + if (sd->link.string) + { + if (link_is_url(sd->link.string)) + ty_dbus_link_mouseout(sd->link.string); + free(sd->link.string); + sd->link.string = NULL; + } sd->link.x1 = -1; sd->link.y1 = -1; sd->link.x2 = -1; @@ -536,11 +541,17 @@ _smart_mouseover_apply(Evas_Object *obj) _update_link(obj, same_link, same_geom); return; } - + if ((sd->link.string) && (!strcmp(sd->link.string, s))) same_link = EINA_TRUE; if (sd->link.string) free(sd->link.string); sd->link.string = s; + + if ((!same_link) && (link_is_url(s))) + { + ty_dbus_link_mousein(s); + } + if ((x1 == sd->link.x1) && (y1 == sd->link.y1) && (x2 == sd->link.x2) && (y2 == sd->link.y2)) same_geom = EINA_TRUE; diff --git a/src/bin/termiolink.c b/src/bin/termiolink.c index f7255e5..d624e06 100644 --- a/src/bin/termiolink.c +++ b/src/bin/termiolink.c @@ -205,10 +205,10 @@ _termio_link_find(Evas_Object *obj, int cx, int cy, if ((len > 1) && (!endmatch)) { Eina_Bool is_file = _is_file(s); - Eina_Bool is_url = link_is_url(s); + if (is_file || link_is_email(s) || - is_url) + link_is_url(s)) { if (x1r) *x1r = x1; if (y1r) *y1r = y1; @@ -221,10 +221,6 @@ _termio_link_find(Evas_Object *obj, int cx, int cy, free(s); return ret; } - else if (is_url) - { - ty_dbus_link_detect(s); - } return s; }