void hints_init(WebKitWebFrame* frame)
{
char* value = NULL;
- char* error = NULL;
- vp_eval_script(frame, HINTS_JS, HINT_FILE, &value, &error);
+ vp_eval_script(frame, HINTS_JS, HINT_FILE, &value);
g_free(value);
- g_free(error);
}
void hints_clear(Client* c)
if (CLEAN_MODE(c->state.mode) == VP_MODE_HINTING) {
char* js = g_strdup_printf("%s.clear();", HINT_VAR);
char* value = NULL;
- char* error = NULL;
-
- vp_eval_script(
- webkit_web_view_get_main_frame(c->gui.webview), js, HINT_FILE, &value, &error
- );
+ vp_eval_script(webkit_web_view_get_main_frame(c->gui.webview), js, HINT_FILE, &value);
g_free(value);
- g_free(error);
g_free(js);
g_signal_emit_by_name(c->gui.webview, "hovering-over-link", NULL, NULL);
static void hints_run_script(Client* c, char* js)
{
char* value = NULL;
- char* error = NULL;
int mode = c->hints.mode;
- vp_eval_script(
- webkit_web_view_get_main_frame(c->gui.webview), js, HINT_FILE, &value, &error
+ gboolean success = vp_eval_script(
+ webkit_web_view_get_main_frame(c->gui.webview), js, HINT_FILE, &value
);
- if (error) {
- fprintf(stderr, "%s\n", error);
- g_free(error);
+ if (!success) {
+ fprintf(stderr, "%s\n", value);
+ g_free(value);
vp_set_mode(c, VP_MODE_NORMAL, FALSE);
}
}
-void vp_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value, char** error)
+gboolean vp_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value)
{
JSStringRef str, file_name;
JSValueRef exception = NULL, result = NULL;
if (result) {
*value = vp_jsref_to_string(js, result);
- } else {
- *error = vp_jsref_to_string(js, exception);
+ return TRUE;
}
+
+ *value = vp_jsref_to_string(js, exception);
+ return FALSE;
}
gboolean vp_load_uri(Client* c, const Arg* arg)
&& g_file_get_contents(core.files[FILES_SCRIPT], &js, NULL, &error)
) {
char* value = NULL;
- char* error = NULL;
-
- vp_eval_script(frame, js, core.files[FILES_SCRIPT], &value, &error);
- if (error) {
- fprintf(stderr, "%s", error);
- g_free(error);
- } else {
- g_free(value);
+ gboolean success = vp_eval_script(frame, js, core.files[FILES_SCRIPT], &value);
+ if (!success) {
+ fprintf(stderr, "%s", value);
}
+ g_free(value);
g_free(js);
}
}
/* functions */
void vp_clean_input(Client* c);
void vp_echo(Client* c, const MessageType type, gboolean hide, const char *error, ...);
-void vp_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value, char** error);
+gboolean vp_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value);
gboolean vp_load_uri(Client* c, const Arg* arg);
gboolean vp_set_clipboard(const Arg* arg);
gboolean vp_set_mode(Client* c, Mode mode, gboolean clean);