Show link url in urlbar for hinted links.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 31 Dec 2012 15:55:39 +0000 (16:55 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 31 Dec 2012 16:18:16 +0000 (17:18 +0100)
Every time the focus is set, we show the hinted elements url in the urlbar.

src/hints.c
src/main.c

index 90e93c5..626c733 100644 (file)
@@ -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;
index fe3d6f3..4553cdb 100644 (file)
@@ -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);