hints: re-enable hints function return value processing
authorVirgil Dupras <hsoft@hardcoded.net>
Sat, 29 Apr 2017 02:24:37 +0000 (22:24 -0400)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 6 May 2017 23:31:56 +0000 (01:31 +0200)
src/hints.c
src/setting.c

index c5e8346..3cd9e5f 100644 (file)
@@ -45,7 +45,7 @@ static struct {
 
 extern struct Vimb vb;
 
-static gboolean call_hints_function(Client *c, const char *func, char* args);
+static void call_hints_function(Client *c, const char *func, char* args);
 static void fire_timeout(Client *c, gboolean on);
 static gboolean fire_cb(gpointer data);
 
@@ -89,7 +89,7 @@ void hints_clear(Client *c)
 
         call_hints_function(c, "clear", "");
 
-        g_signal_emit_by_name(c->webview, "hovering-over-link", NULL, NULL);
+        /* g_signal_emit_by_name(c->webview, "hovering-over-link", NULL, NULL); */
 
         /* if open window was not allowed for JavaScript, restore this */
         /* if (!hints.allow_open_win) {                                                                                  */
@@ -244,30 +244,32 @@ gboolean hints_parse_prompt(const char *prompt, char *mode, gboolean *is_gmode)
     return res;
 }
 
-static gboolean call_hints_function(Client *c, const char *func, char* args)
+static void hints_function_callback(GDBusProxy *proxy, GAsyncResult *result, Client *c)
 {
-    char *jscode;
+    gboolean success = FALSE;
+    char *value = NULL;
 
-    jscode = g_strdup_printf("hints.%s(%s);", func, args);
-    ext_proxy_eval_script(c, jscode, NULL);
-    g_free(jscode);
-    char *value = "";
-    return true;
+    g_print("callback!\n");
+    GVariant *return_value = g_dbus_proxy_call_finish(proxy, result, NULL);   
+    if (!return_value) {
+        return;
+    }
 
-    g_return_val_if_fail(value != NULL, false);
+    g_variant_get(return_value, "(bs)", &success, &value);
+    if (!success) {
+        return;
+    }
+    g_print("foo! %s\n", value);
 
     if (!strncmp(value, "ERROR:", 6)) {
-        g_free(value);
-        return false;
+        return;
     }
 
     if (!strncmp(value, "OVER:", 5)) {
-        g_signal_emit_by_name(
-            c->webview, "hovering-over-link", NULL, *(value + 5) == '\0' ? NULL : (value + 5)
-        );
-        g_free(value);
-
-        return true;
+        /* g_signal_emit_by_name(                                                                */
+        /*     c->webview, "hovering-over-link", NULL, *(value + 5) == '\0' ? NULL : (value + 5) */
+        /* );                                                                                    */
+        return;
     }
 
     /* following return values mark fired hints */
@@ -342,8 +344,16 @@ static gboolean call_hints_function(Client *c, const char *func, char* args)
 #endif
         }
     }
-    g_free(value);
-    return true;
+}
+
+static void call_hints_function(Client *c, const char *func, char* args)
+{
+    char *jscode;
+
+    jscode = g_strdup_printf("hints.%s(%s);", func, args);
+    ext_proxy_eval_script(c, jscode, (GAsyncReadyCallback)hints_function_callback);
+    g_free(jscode);
+
 }
 
 static void fire_timeout(Client *c, gboolean on)
@@ -357,6 +367,7 @@ static void fire_timeout(Client *c, gboolean on)
 
     if (on) {
         millis = GET_INT(c, "hint-timeout");
+        g_print("millis %d", millis);
         if (millis) {
             hints.timeout_id = g_timeout_add(millis, (GSourceFunc)fire_cb, c);
         }
index a64f0de..92b0f42 100644 (file)
@@ -87,6 +87,7 @@ void setting_init(Client *c)
     setting_add(c, "fontsize", TYPE_INTEGER, &i, webkit, 0, "default-font-size");
     setting_add(c, "frame-flattening", TYPE_BOOLEAN, &off, webkit, 0, "enable-frame-flattening");
     setting_add(c, "header", TYPE_CHAR, &"", headers, FLAG_LIST|FLAG_NODUP, "header");
+    i = 1000;
     setting_add(c, "hint-timeout", TYPE_INTEGER, &i, NULL, 0, NULL);
     setting_add(c, "hintkeys", TYPE_CHAR, &"0123456789", NULL, 0, NULL);
     setting_add(c, "hint-follow-last", TYPE_BOOLEAN, &on, NULL, 0, NULL);