From: Daniel Carl Date: Mon, 31 Dec 2012 15:55:39 +0000 (+0100) Subject: Show link url in urlbar for hinted links. X-Git-Url: https://git.owens.tech/git.owens.tech/git.owens.tech/git?a=commitdiff_plain;h=dbf0b22b17223eea68ac743abf0504c1212dccf4;p=vimb.git Show link url in urlbar for hinted links. Every time the focus is set, we show the hinted elements url in the urlbar. --- diff --git a/src/hints.c b/src/hints.c index 90e93c5..626c733 100644 --- a/src/hints.c +++ b/src/hints.c @@ -91,6 +91,9 @@ void hints_clear(void) } hints_observe_input(FALSE); + + /* simulate the mouse out of the last focused hint */ + g_signal_emit_by_name(vp.gui.webview, "hovering-over-link", NULL, NULL); } void hints_create(const gchar* input, guint mode, const guint prefixLength) @@ -321,6 +324,21 @@ static void hints_focus(const gulong num) doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(hint->elem)); dom_dispatch_mouse_event(doc, hint->elem, "mouseover", 0); webkit_dom_element_blur(hint->elem); + + const gchar* tag = webkit_dom_element_get_tag_name(hint->elem); + if (!g_ascii_strcasecmp(tag, "a")) { + /* simulate the hovering over the hinted element this is done to show + * the hinted elements url in the url bar */ + g_signal_emit_by_name( + vp.gui.webview, + "hovering-over-link", + "", + dom_element_get_source(hint->elem) + ); + } else { + /* if hinted element has no url unhover the previous element */ + g_signal_emit_by_name(vp.gui.webview, "hovering-over-link", NULL, NULL); + } } vp.hints.focusNum = num; diff --git a/src/main.c b/src/main.c index fe3d6f3..4553cdb 100644 --- a/src/main.c +++ b/src/main.c @@ -48,7 +48,7 @@ static gboolean vp_new_window_policy_cb( WebKitWebNavigationAction* navig, WebKitWebPolicyDecision* policy, gpointer data); static WebKitWebView* vp_create_new_webview_cb(WebKitWebView* webview, WebKitWebFrame* frame, gpointer data); static void vp_create_new_webview_uri_cb(WebKitWebView* view, GParamSpec param_spec); -static void vp_hover_link_cb(WebKitWebView* webview, const gchar* titl, const char* link, gpointer data); +static void vp_hover_link_cb(WebKitWebView* webview, const gchar* title, const char* link, gpointer data); /* functions */ static gboolean vp_process_input(const char* input); @@ -715,7 +715,7 @@ static void vp_create_new_webview_uri_cb(WebKitWebView* view, GParamSpec param_s vp_load_uri(&a); } -static void vp_hover_link_cb(WebKitWebView* webview, const gchar* titl, const char* link, gpointer data) +static void vp_hover_link_cb(WebKitWebView* webview, const gchar* title, const char* link, gpointer data) { if (link) { gchar* message = g_strdup_printf("Link: %s", link);