Allow to open fired hint elements.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 16 Dec 2012 13:05:13 +0000 (14:05 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 16 Dec 2012 13:05:13 +0000 (14:05 +0100)
src/hints.c
src/hints.h
src/main.c
src/main.h

index a365d64..35ed56d 100644 (file)
@@ -21,6 +21,7 @@
 #include <gdk/gdkkeysyms-compat.h>
 #include "hints.h"
 #include "dom.h"
+#include "main.h"
 
 #define MAX_HINTS 200
 #define HINT_CONTAINER_ID "__hint_container"
@@ -56,6 +57,7 @@ static void hints_create_for_window(
     const gchar* input, Window* win, gulong top_width,
     gulong top_height, gulong offsetX, gulong offsetY);
 static void hints_focus(const gulong num);
+static void hints_fire(const gulong num);
 static Hint* hints_get_hint_by_number(const gulong num);
 static GList* hints_get_hint_list_by_number(const gulong num);
 static gchar* hints_get_xpath(const gchar* input);
@@ -176,11 +178,6 @@ void hints_update(const gulong num)
     }
 }
 
-void hints_fire(const gulong num)
-{
-    PRINT_DEBUG("fire hint %lu", num);
-}
-
 void hints_clear_focus(void)
 {
 
@@ -309,6 +306,26 @@ static void hints_focus(const gulong num)
     currentFocusNum = num;
 }
 
+static void hints_fire(const gulong num)
+{
+    Hint* hint = hints_get_hint_by_number(num);
+    if (hint) {
+        Element* element = hint->elem;
+        /* TODO
+         * if the elemt has a target attribute - remove it temporary
+         * fire mousedown and click events on the element
+         * if it is an form element focus it and return
+         * get the src or href attribute and call vp_fired_hint */
+
+        Arg a;
+        a.i = currentMode;
+        a.s = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(element));
+        vp_fired_hint(&a);
+
+        hints_clear();
+    }
+}
+
 static Hint* hints_get_hint_by_number(const gulong num)
 {
     GList* list = hints_get_hint_list_by_number(num);
index 74b2274..9f9360d 100644 (file)
@@ -29,7 +29,6 @@ typedef enum {
 
 void hints_create(const gchar* input, HintMode mode);
 void hints_update(const gulong num);
-void hints_fire(const gulong num);
 void hints_clear(void);
 void hints_clear_focus(void);
 void hints_focus_next(const gboolean back);
index 83ccbae..cfc74df 100644 (file)
@@ -229,7 +229,7 @@ gboolean vp_load_uri(const Arg* arg)
     g_free(uri);
 
     /* change state to normal mode */
-    vp_set_mode(VP_MODE_NORMAL, FALSE);
+    vp_set_mode(VP_MODE_NORMAL, TRUE);
 
     return TRUE;
 }
@@ -390,6 +390,11 @@ void vp_echo(const MessageType type, gboolean hide, const char *error, ...)
     }
 }
 
+void vp_fired_hint(const Arg* arg)
+{
+    vp_load_uri(arg);
+}
+
 static void vp_print_version(void)
 {
     fprintf(stderr, "%s/%s (build %s %s)\n", VERSION, PROJECT, __DATE__, __TIME__);
index 7329ace..6017965 100644 (file)
@@ -240,6 +240,7 @@ extern VpCore vp;
 void vp_update_statusbar(void);
 void vp_update_urlbar(const gchar* uri);
 void vp_echo(const MessageType type, gboolean hide, const char *error, ...);
+void vp_fired_hint(const Arg* arg);
 gboolean vp_set_mode(Mode mode, gboolean clean);
 void vp_set_widget_font(GtkWidget* widget, const VpColor* fg, const VpColor* bg, PangoFontDescription* font);
 gboolean vp_load_uri(const Arg* arg);