Revert to single instance per window.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 22 Mar 2013 16:43:08 +0000 (17:43 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 22 Mar 2013 22:55:22 +0000 (23:55 +0100)
19 files changed:
src/command.c
src/command.h
src/completion.c
src/completion.h
src/dom.c
src/dom.h
src/hints.c
src/hints.h
src/history.c
src/history.h
src/keybind.c
src/keybind.h
src/main.c
src/main.h
src/searchengine.c
src/setting.c
src/setting.h
src/url_history.c
src/url_history.h

index d6783dd..2ac7915 100644 (file)
@@ -27,6 +27,7 @@
 #include "searchengine.h"
 #include "history.h"
 
+extern VbCore vb;
 static CommandInfo cmd_list[] = {
     /* command              function             arg                                                                                 mode */
     {"open",                command_open,        {VB_TARGET_CURRENT, ""}},
@@ -94,61 +95,59 @@ static CommandInfo cmd_list[] = {
     {"command-hist-prev",   command_history,     {VB_SEARCH_BACKWARD}},
 };
 
-static void command_write_input(Client* c, const char* str);
+static void command_write_input(const char* str);
 
 
 void command_init(void)
 {
     guint i;
-    core.behave.commands = g_hash_table_new(g_str_hash, g_str_equal);
+    vb.behave.commands = g_hash_table_new(g_str_hash, g_str_equal);
 
     for (i = 0; i < LENGTH(cmd_list); i++) {
-        g_hash_table_insert(core.behave.commands, (gpointer)cmd_list[i].name, &cmd_list[i]);
+        g_hash_table_insert(vb.behave.commands, (gpointer)cmd_list[i].name, &cmd_list[i]);
     }
 }
 
 void command_cleanup(void)
 {
-    if (core.behave.commands) {
-        g_hash_table_destroy(core.behave.commands);
+    if (vb.behave.commands) {
+        g_hash_table_destroy(vb.behave.commands);
     }
 }
 
 gboolean command_exists(const char* name)
 {
-    return g_hash_table_contains(core.behave.commands, name);
+    return g_hash_table_contains(vb.behave.commands, name);
 }
 
-gboolean command_run(Client* c, const char* name, const char* param)
+gboolean command_run(const char* name, const char* param)
 {
     CommandInfo* command = NULL;
     gboolean result;
     Arg a;
-    command = g_hash_table_lookup(core.behave.commands, name);
+    command = g_hash_table_lookup(vb.behave.commands, name);
     if (!command) {
-        if (c) {
-            vb_echo(c, VB_MSG_ERROR, TRUE, "Command '%s' not found", name);
-            vb_set_mode(c, VB_MODE_NORMAL, FALSE);
-        }
+        vb_echo(VB_MSG_ERROR, TRUE, "Command '%s' not found", name);
+        vb_set_mode(VB_MODE_NORMAL, FALSE);
 
         return FALSE;
     }
     a.i = command->arg.i;
     a.s = g_strdup(param ? param : command->arg.s);
-    result = command->function(c, &a);
+    result = command->function(&a);
     g_free(a.s);
 
     return result;
 }
 
-gboolean command_open(Client* c, const Arg* arg)
+gboolean command_open(const Arg* arg)
 {
     char* uri = NULL;
     gboolean result;
 
     if (!arg->s || arg->s[0] == '\0') {
-        Arg a = {arg->i, core.config.home_page};
-        return vb_load_uri(c, &a);
+        Arg a = {arg->i, vb.config.home_page};
+        return vb_load_uri(&a);
     }
     /* check for searchengine handles */
     /* split into handle and searchterms */
@@ -158,11 +157,11 @@ gboolean command_open(Client* c, const Arg* arg)
     ) {
         char* term = soup_uri_encode(string[1], "&");
         Arg a  = {arg->i, g_strdup_printf(uri, term)};
-        result = vb_load_uri(c, &a);
+        result = vb_load_uri(&a);
         g_free(term);
         g_free(a.s);
     } else {
-        result = vb_load_uri(c, arg);
+        result = vb_load_uri(arg);
     }
     g_strfreev(string);
 
@@ -172,99 +171,100 @@ gboolean command_open(Client* c, const Arg* arg)
 /**
  * Reopens the last closed page.
  */
-gboolean command_open_closed(Client* c, const Arg* arg)
+gboolean command_open_closed(const Arg* arg)
 {
     gboolean result;
 
     Arg a = {arg->i};
-    a.s = util_get_file_contents(core.files[FILES_CLOSED], NULL);
-    result = vb_load_uri(c, &a);
+    a.s = util_get_file_contents(vb.files[FILES_CLOSED], NULL);
+    result = vb_load_uri(&a);
     g_free(a.s);
 
     return result;
 }
 
-gboolean command_input(Client* c, const Arg* arg)
+gboolean command_input(const Arg* arg)
 {
     const char* url;
 
     /* add current url if requested */
     if (VB_INPUT_CURRENT_URI == arg->i
-        && (url = webkit_web_view_get_uri(c->gui.webview))
+        && (url = webkit_web_view_get_uri(vb.gui.webview))
     ) {
         /* append the current url to the input message */
         char* input = g_strconcat(arg->s, url, NULL);
-        command_write_input(c, input);
+        command_write_input(input);
         g_free(input);
     } else {
-        command_write_input(c, arg->s);
+        command_write_input(arg->s);
     }
 
-    vb_set_mode(c, VB_MODE_COMMAND, FALSE);
+    vb_set_mode(VB_MODE_COMMAND, FALSE);
 
     return TRUE;
 }
 
-gboolean command_close(Client* c, const Arg* arg)
+gboolean command_close(const Arg* arg)
 {
-    gtk_widget_destroy(GTK_WIDGET(c->gui.window));
+    gtk_widget_destroy(GTK_WIDGET(vb.gui.window));
 
     return TRUE;
 }
 
-gboolean command_view_source(Client* c, const Arg* arg)
+gboolean command_view_source(const Arg* arg)
 {
-    gboolean mode = webkit_web_view_get_view_source_mode(c->gui.webview);
-    webkit_web_view_set_view_source_mode(c->gui.webview, !mode);
-    webkit_web_view_reload(c->gui.webview);
+    gboolean mode = webkit_web_view_get_view_source_mode(vb.gui.webview);
+    webkit_web_view_set_view_source_mode(vb.gui.webview, !mode);
+    webkit_web_view_reload(vb.gui.webview);
 
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     return TRUE;
 }
 
-gboolean command_navigate(Client* c, const Arg* arg)
+gboolean command_navigate(const Arg* arg)
 {
+    WebKitWebView* view = vb.gui.webview;
     if (arg->i <= VB_NAVIG_FORWARD) {
-        int count = c->state.count ? c->state.count : 1;
+        int count = vb.state.count ? vb.state.count : 1;
         webkit_web_view_go_back_or_forward(
-            c->gui.webview, (arg->i == VB_NAVIG_BACK ? -count : count)
+            view, (arg->i == VB_NAVIG_BACK ? -count : count)
         );
     } else if (arg->i == VB_NAVIG_RELOAD) {
-        webkit_web_view_reload(c->gui.webview);
+        webkit_web_view_reload(view);
     } else if (arg->i == VB_NAVIG_RELOAD_FORCE) {
-        webkit_web_view_reload_bypass_cache(c->gui.webview);
+        webkit_web_view_reload_bypass_cache(view);
     } else {
-        webkit_web_view_stop_loading(c->gui.webview);
+        webkit_web_view_stop_loading(view);
     }
 
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     return TRUE;
 }
 
-gboolean command_scroll(Client* c, const Arg* arg)
+gboolean command_scroll(const Arg* arg)
 {
-    GtkAdjustment *adjust = (arg->i & VB_SCROLL_AXIS_H) ? c->gui.adjust_h : c->gui.adjust_v;
+    GtkAdjustment *adjust = (arg->i & VB_SCROLL_AXIS_H) ? vb.gui.adjust_h : vb.gui.adjust_v;
 
     int direction  = (arg->i & (1 << 2)) ? 1 : -1;
 
     /* type scroll */
     if (arg->i & VB_SCROLL_TYPE_SCROLL) {
         gdouble value;
-        int count = c->state.count ? c->state.count : 1;
+        int count = vb.state.count ? vb.state.count : 1;
         if (arg->i & VB_SCROLL_UNIT_LINE) {
-            value = core.config.scrollstep;
+            value = vb.config.scrollstep;
         } else if (arg->i & VB_SCROLL_UNIT_HALFPAGE) {
             value = gtk_adjustment_get_page_size(adjust) / 2;
         } else {
             value = gtk_adjustment_get_page_size(adjust);
         }
         gtk_adjustment_set_value(adjust, gtk_adjustment_get_value(adjust) + direction * value * count);
-    } else if (c->state.count) {
+    } else if (vb.state.count) {
         /* jump - if count is set to count% of page */
         gdouble max = gtk_adjustment_get_upper(adjust) - gtk_adjustment_get_page_size(adjust);
-        gtk_adjustment_set_value(adjust, max * c->state.count / 100);
+        gtk_adjustment_set_value(adjust, max * vb.state.count / 100);
     } else if (direction == 1) {
         /* jump to top */
         gtk_adjustment_set_value(adjust, gtk_adjustment_get_upper(adjust));
@@ -273,15 +273,15 @@ gboolean command_scroll(Client* c, const Arg* arg)
         gtk_adjustment_set_value(adjust, gtk_adjustment_get_lower(adjust));
     }
 
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     return TRUE;
 }
 
-gboolean command_map(Client* c, const Arg* arg)
+gboolean command_map(const Arg* arg)
 {
     gboolean result;
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     char **string = g_strsplit(arg->s, "=", 2);
     if (g_strv_length(string) != 2) {
@@ -293,14 +293,14 @@ gboolean command_map(Client* c, const Arg* arg)
     return result;
 }
 
-gboolean command_unmap(Client* c, const Arg* arg)
+gboolean command_unmap(const Arg* arg)
 {
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     return keybind_remove_from_string(arg->s, arg->i);
 }
 
-gboolean command_set(Client* c, const Arg* arg)
+gboolean command_set(const Arg* arg)
 {
     gboolean success;
     char* line = NULL;
@@ -317,81 +317,81 @@ gboolean command_set(Client* c, const Arg* arg)
     token = g_strsplit(line, "=", 2);
     g_free(line);
 
-    success = setting_run(c, token[0], token[1] ? token[1] : NULL);
+    success = setting_run(token[0], token[1] ? token[1] : NULL);
     g_strfreev(token);
 
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     return success;
 }
 
-gboolean command_complete(Client* c, const Arg* arg)
+gboolean command_complete(const Arg* arg)
 {
-    completion_complete(c, arg->i ? TRUE : FALSE);
+    completion_complete(arg->i ? TRUE : FALSE);
 
-    vb_set_mode(c, VB_MODE_COMMAND | VB_MODE_COMPLETE, FALSE);
+    vb_set_mode(VB_MODE_COMMAND | VB_MODE_COMPLETE, FALSE);
 
     return TRUE;
 }
 
-gboolean command_inspect(Client* c, const Arg* arg)
+gboolean command_inspect(const Arg* arg)
 {
     gboolean enabled;
     WebKitWebSettings* settings = NULL;
 
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
-    settings = webkit_web_view_get_settings(c->gui.webview);
+    settings = webkit_web_view_get_settings(vb.gui.webview);
     g_object_get(G_OBJECT(settings), "enable-developer-extras", &enabled, NULL);
     if (enabled) {
-        if (c->state.is_inspecting) {
-            webkit_web_inspector_close(c->gui.inspector);
+        if (vb.state.is_inspecting) {
+            webkit_web_inspector_close(vb.gui.inspector);
         } else {
-            webkit_web_inspector_show(c->gui.inspector);
+            webkit_web_inspector_show(vb.gui.inspector);
         }
         return TRUE;
     }
 
-    vb_echo(c, VB_MSG_ERROR, TRUE, "webinspector is not enabled");
+    vb_echo(VB_MSG_ERROR, TRUE, "webinspector is not enabled");
 
     return FALSE;
 }
 
-gboolean command_hints(Client* c, const Arg* arg)
+gboolean command_hints(const Arg* arg)
 {
-    command_write_input(c, arg->s);
-    hints_create(c, NULL, arg->i, (arg->s ? strlen(arg->s) : 0));
+    command_write_input(arg->s);
+    hints_create(NULL, arg->i, (arg->s ? strlen(arg->s) : 0));
 
-    vb_set_mode(c, VB_MODE_HINTING, FALSE);
+    vb_set_mode(VB_MODE_HINTING, FALSE);
 
     return TRUE;
 }
 
-gboolean command_hints_focus(Client* c, const Arg* arg)
+gboolean command_hints_focus(const Arg* arg)
 {
-    hints_focus_next(c, arg->i ? TRUE : FALSE);
+    hints_focus_next(arg->i ? TRUE : FALSE);
 
-    vb_set_mode(c, VB_MODE_HINTING, FALSE);
+    vb_set_mode(VB_MODE_HINTING, FALSE);
 
     return TRUE;
 }
 
-gboolean command_yank(Client* c, const Arg* arg)
+gboolean command_yank(const Arg* arg)
 {
-    vb_set_mode(c, VB_MODE_NORMAL, TRUE);
+    vb_set_mode(VB_MODE_NORMAL, TRUE);
 
     if (arg->i & COMMAND_YANK_SELECTION) {
         char* text = NULL;
         /* copy current selection to clipboard */
-        webkit_web_view_copy_clipboard(c->gui.webview);
+        webkit_web_view_copy_clipboard(vb.gui.webview);
         text = gtk_clipboard_wait_for_text(PRIMARY_CLIPBOARD());
         if (!text) {
             text = gtk_clipboard_wait_for_text(SECONDARY_CLIPBOARD());
         }
         if (text) {
             /* TODO is this the rigth place to switch the focus */
-            gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "Yanked: %s", text);
+            gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
+            vb_echo(VB_MSG_NORMAL, FALSE, "Yanked: %s", text);
             g_free(text);
 
             return TRUE;
@@ -403,15 +403,15 @@ gboolean command_yank(Client* c, const Arg* arg)
     Arg a = {arg->i};
     if (arg->i & COMMAND_YANK_URI) {
         /* yank current url */
-        a.s = g_strdup(webkit_web_view_get_uri(c->gui.webview));
+        a.s = g_strdup(webkit_web_view_get_uri(vb.gui.webview));
     } else {
         a.s = arg->s ? g_strdup(arg->s) : NULL;
     }
     if (a.s) {
         vb_set_clipboard(&a);
         /* TODO is this the rigth place to switch the focus */
-        gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
-        vb_echo(c, VB_MSG_NORMAL, FALSE, "Yanked: %s", a.s);
+        gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
+        vb_echo(VB_MSG_NORMAL, FALSE, "Yanked: %s", a.s);
         g_free(a.s);
 
         return TRUE;
@@ -420,7 +420,7 @@ gboolean command_yank(Client* c, const Arg* arg)
     return FALSE;
 }
 
-gboolean command_paste(Client* c, const Arg* arg)
+gboolean command_paste(const Arg* arg)
 {
     Arg a = {.i = arg->i & VB_TARGET_NEW};
     if (arg->i & VB_CLIPBOARD_PRIMARY) {
@@ -431,7 +431,7 @@ gboolean command_paste(Client* c, const Arg* arg)
     }
 
     if (a.s) {
-        vb_load_uri(c, &a);
+        vb_load_uri(&a);
         g_free(a.s);
 
         return TRUE;
@@ -439,14 +439,14 @@ gboolean command_paste(Client* c, const Arg* arg)
     return FALSE;
 }
 
-gboolean command_search(Client* c, const Arg* arg)
+gboolean command_search(const Arg* arg)
 {
-    gboolean forward = !(arg->i ^ c->state.search_dir);
+    gboolean forward = !(arg->i ^ vb.state.search_dir);
 
-    if (arg->i == VB_SEARCH_OFF && c->state.search_query) {
-        OVERWRITE_STRING(c->state.search_query, NULL);
+    if (arg->i == VB_SEARCH_OFF && vb.state.search_query) {
+        OVERWRITE_STRING(vb.state.search_query, NULL);
 #ifdef FEATURE_SEARCH_HIGHLIGHT
-        webkit_web_view_unmark_text_matches(c->gui.webview);
+        webkit_web_view_unmark_text_matches(vb.gui.webview);
 #endif
 
         return TRUE;
@@ -454,29 +454,29 @@ gboolean command_search(Client* c, const Arg* arg)
 
     /* copy search query for later use */
     if (arg->s) {
-        OVERWRITE_STRING(c->state.search_query, arg->s);
+        OVERWRITE_STRING(vb.state.search_query, arg->s);
         /* set dearch dir only when the searching is started */
-        c->state.search_dir = arg->i;
+        vb.state.search_dir = arg->i;
     }
 
-    if (c->state.search_query) {
+    if (vb.state.search_query) {
 #ifdef FEATURE_SEARCH_HIGHLIGHT
-        webkit_web_view_mark_text_matches(c->gui.webview, c->state.search_query, FALSE, 0);
-        webkit_web_view_set_highlight_text_matches(c->gui.webview, TRUE);
+        webkit_web_view_mark_text_matches(vb.gui.webview, vb.state.search_query, FALSE, 0);
+        webkit_web_view_set_highlight_text_matches(vb.gui.webview, TRUE);
 #endif
         /* make sure we have a count greater than 0 */
-        c->state.count = c->state.count ? c->state.count : 1;
+        vb.state.count = vb.state.count ? vb.state.count : 1;
         do {
-            webkit_web_view_search_text(c->gui.webview, c->state.search_query, FALSE, forward, TRUE);
-        } while (--c->state.count);
+            webkit_web_view_search_text(vb.gui.webview, vb.state.search_query, FALSE, forward, TRUE);
+        } while (--vb.state.count);
     }
 
-    vb_set_mode(c, VB_MODE_SEARCH, FALSE);
+    vb_set_mode(VB_MODE_SEARCH, FALSE);
 
     return TRUE;
 }
 
-gboolean command_searchengine(Client* c, const Arg* arg)
+gboolean command_searchengine(const Arg* arg)
 {
     gboolean result;
     if (arg->i) {
@@ -492,68 +492,68 @@ gboolean command_searchengine(Client* c, const Arg* arg)
         result = searchengine_remove(arg->s);
     }
 
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     return result;
 }
 
-gboolean command_zoom(Client* c, const Arg* arg)
+gboolean command_zoom(const Arg* arg)
 {
     float step, level;
     int count;
 
     if (arg->i & COMMAND_ZOOM_RESET) {
-        webkit_web_view_set_zoom_level(c->gui.webview, 1.0);
-        vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+        webkit_web_view_set_zoom_level(vb.gui.webview, 1.0);
+        vb_set_mode(VB_MODE_NORMAL, FALSE);
 
         return TRUE;
     }
 
-    count = c->state.count ? c->state.count : 1;
-    level = webkit_web_view_get_zoom_level(c->gui.webview);
+    count = vb.state.count ? vb.state.count : 1;
+    level = webkit_web_view_get_zoom_level(vb.gui.webview);
 
-    WebKitWebSettings* setting = webkit_web_view_get_settings(c->gui.webview);
+    WebKitWebSettings* setting = webkit_web_view_get_settings(vb.gui.webview);
     g_object_get(G_OBJECT(setting), "zoom-step", &step, NULL);
 
     webkit_web_view_set_full_content_zoom(
-        c->gui.webview, (arg->i & COMMAND_ZOOM_FULL) > 0
+        vb.gui.webview, (arg->i & COMMAND_ZOOM_FULL) > 0
     );
 
     webkit_web_view_set_zoom_level(
-        c->gui.webview,
+        vb.gui.webview,
         level + (float)(count *step) * (arg->i & COMMAND_ZOOM_IN ? 1.0 : -1.0)
     );
 
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     return TRUE;
 
 }
 
-gboolean command_history(Client* c, const Arg* arg)
+gboolean command_history(const Arg* arg)
 {
-    const int count = c->state.count ? c->state.count : 1;
+    const int count = vb.state.count ? vb.state.count : 1;
     const gint step = count * (arg->i == VB_SEARCH_BACKWARD ? -1 : 1);
-    const char* entry = history_get(c, step);
+    const char* entry = history_get(step);
 
     if (!entry) {
         return FALSE;
     }
-    command_write_input(c, entry);
+    command_write_input(entry);
 
     return TRUE;
 }
 
-static void command_write_input(Client* c, const char* str)
+static void command_write_input(const char* str)
 {
     int pos = 0;
-    GtkEditable* box = GTK_EDITABLE(c->gui.inputbox);
+    GtkEditable* box = GTK_EDITABLE(vb.gui.inputbox);
     /* reset the colors and fonts to defalts */
     vb_set_widget_font(
-        c->gui.inputbox,
-        &core.style.input_fg[VB_MSG_NORMAL],
-        &core.style.input_bg[VB_MSG_NORMAL],
-        core.style.input_font[VB_MSG_NORMAL]
+        vb.gui.inputbox,
+        &vb.style.input_fg[VB_MSG_NORMAL],
+        &vb.style.input_bg[VB_MSG_NORMAL],
+        vb.style.input_font[VB_MSG_NORMAL]
     );
 
     /* remove content from input box */
index 7231915..a2aeee2 100644 (file)
@@ -34,7 +34,7 @@ enum {
     COMMAND_ZOOM_RESET = (1<<2)
 };
 
-typedef gboolean (*Command)(Client* c, const Arg* arg);
+typedef gboolean (*Command)(const Arg* arg);
 
 typedef struct {
     const char* name;
@@ -46,28 +46,28 @@ typedef struct {
 void command_init(void);
 void command_cleanup(void);
 gboolean command_exists(const char* name);
-gboolean command_run(Client* c, const char* name, const char* param);
+gboolean command_run(const char* name, const char* param);
 
-gboolean command_open(Client* c, const Arg* arg);
-gboolean command_open_home(Client* c, const Arg* arg);
-gboolean command_open_closed(Client* c, const Arg* arg);
-gboolean command_input(Client* c, const Arg* arg);
-gboolean command_close(Client* c, const Arg* arg);
-gboolean command_view_source(Client* c, const Arg* arg);
-gboolean command_navigate(Client* c, const Arg* arg);
-gboolean command_scroll(Client* c, const Arg* arg);
-gboolean command_map(Client* c, const Arg* arg);
-gboolean command_unmap(Client* c, const Arg* arg);
-gboolean command_set(Client* c, const Arg* arg);
-gboolean command_complete(Client* c, const Arg* arg);
-gboolean command_inspect(Client* c, const Arg* arg);
-gboolean command_hints(Client* c, const Arg* arg);
-gboolean command_hints_focus(Client* c, const Arg* arg);
-gboolean command_yank(Client* c, const Arg* arg);
-gboolean command_paste(Client* c, const Arg* arg);
-gboolean command_search(Client* c, const Arg* arg);
-gboolean command_searchengine(Client* c, const Arg* arg);
-gboolean command_zoom(Client* c, const Arg* arg);
-gboolean command_history(Client* c, const Arg* arg);
+gboolean command_open(const Arg* arg);
+gboolean command_open_home(const Arg* arg);
+gboolean command_open_closed(const Arg* arg);
+gboolean command_input(const Arg* arg);
+gboolean command_close(const Arg* arg);
+gboolean command_view_source(const Arg* arg);
+gboolean command_navigate(const Arg* arg);
+gboolean command_scroll(const Arg* arg);
+gboolean command_map(const Arg* arg);
+gboolean command_unmap(const Arg* arg);
+gboolean command_set(const Arg* arg);
+gboolean command_complete(const Arg* arg);
+gboolean command_inspect(const Arg* arg);
+gboolean command_hints(const Arg* arg);
+gboolean command_hints_focus(const Arg* arg);
+gboolean command_yank(const Arg* arg);
+gboolean command_paste(const Arg* arg);
+gboolean command_search(const Arg* arg);
+gboolean command_searchengine(const Arg* arg);
+gboolean command_zoom(const Arg* arg);
+gboolean command_history(const Arg* arg);
 
 #endif /* end of include guard: _COMMAND_H */
index 8ee6207..ae16674 100644 (file)
@@ -21,6 +21,8 @@
 #include "util.h"
 #include "url_history.h"
 
+extern VbCore vb;
+
 typedef gboolean (*Comp_Func)(char*, const char*);
 typedef struct {
     GtkWidget* label;
@@ -28,103 +30,99 @@ typedef struct {
     char*     prefix;
 } Completion;
 
-static GList* completion_init_completion(Client* c, GList* target, GList* source,
+static GList* completion_init_completion(GList* target, GList* source,
     Comp_Func func, const char* input, const char* prefix);
-static GList* completion_update(Client* c, GList* completion, GList* active, gboolean back);
-static void completion_show(Client* c, gboolean back);
-static void completion_set_entry_text(Client* c, Completion* completion);
-static char* completion_get_text(Client* c, Completion* completion);
+static GList* completion_update(GList* completion, GList* active, gboolean back);
+static void completion_show(gboolean back);
+static void completion_set_entry_text(Completion* completion);
+static char* completion_get_text(Completion* completion);
 static Completion* completion_get_new(const char* label, const char* prefix);
 static void completion_free(Completion* completion);
 
-gboolean completion_complete(Client* c, gboolean back)
+gboolean completion_complete(gboolean back)
 {
-    const char* input = gtk_entry_get_text(GTK_ENTRY(c->gui.inputbox));
+    const char* input = gtk_entry_get_text(GTK_ENTRY(vb.gui.inputbox));
     GList* source = NULL;
 
-    if (c->comps.completions
-        && c->comps.active
-        && (c->state.mode & VB_MODE_COMPLETE)
+    if (vb.comps.completions
+        && vb.comps.active
+        && (vb.state.mode & VB_MODE_COMPLETE)
     ) {
-        char* text = completion_get_text(c, (Completion*)c->comps.active->data);
+        char* text = completion_get_text((Completion*)vb.comps.active->data);
         if (!strcmp(input, text)) {
             /* updatecompletions */
-            c->comps.active = completion_update(c, c->comps.completions, c->comps.active, back);
+            vb.comps.active = completion_update(vb.comps.completions, vb.comps.active, back);
             g_free(text);
             return TRUE;
         } else {
             g_free(text);
             /* if current input isn't the content of the completion item */
-            completion_clean(c);
+            completion_clean();
         }
     }
 
     /* create new completion */
 #ifdef HAS_GTK3
-    c->gui.compbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-    gtk_box_set_homogeneous(GTK_BOX(c->gui.compbox), TRUE);
+    vb.gui.compbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+    gtk_box_set_homogeneous(GTK_BOX(vb.gui.compbox), TRUE);
 #else
-    c->gui.compbox = gtk_vbox_new(TRUE, 0);
+    vb.gui.compbox = gtk_vbox_new(TRUE, 0);
 #endif
-    gtk_box_pack_start(GTK_BOX(c->gui.box), c->gui.compbox, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vb.gui.box), vb.gui.compbox, FALSE, FALSE, 0);
 
     /* TODO move these decision to a more generic place */
     if (!strncmp(input, ":set ", 5)) {
-        source = g_hash_table_get_keys(core.settings);
+        source = g_hash_table_get_keys(vb.settings);
         source = g_list_sort(source, (GCompareFunc)g_strcmp0);
-        c->comps.completions = completion_init_completion(
-            c,
-            c->comps.completions, source, (Comp_Func)g_str_has_prefix, &input[5], ":set "
+        vb.comps.completions = completion_init_completion(
+            vb.comps.completions, source, (Comp_Func)g_str_has_prefix, &input[5], ":set "
         );
     } else if (!strncmp(input, ":open ", 6)) {
         url_history_get_all(&source);
-        c->comps.completions = completion_init_completion(
-            c,
-            c->comps.completions, source, (Comp_Func)util_strcasestr, &input[6], ":open "
+        vb.comps.completions = completion_init_completion(
+            vb.comps.completions, source, (Comp_Func)util_strcasestr, &input[6], ":open "
         );
         g_list_free(source);
     } else if (!strncmp(input, ":tabopen ", 9)) {
         url_history_get_all(&source);
-        c->comps.completions = completion_init_completion(
-            c,
-            c->comps.completions, source, (Comp_Func)util_strcasestr, &input[9], ":tabopen "
+        vb.comps.completions = completion_init_completion(
+            vb.comps.completions, source, (Comp_Func)util_strcasestr, &input[9], ":tabopen "
         );
         g_list_free(source);
     } else {
-        source = g_hash_table_get_keys(core.behave.commands);
+        source = g_hash_table_get_keys(vb.behave.commands);
         source = g_list_sort(source, (GCompareFunc)g_strcmp0);
-        c->comps.completions = completion_init_completion(
-            c,
-            c->comps.completions, source, (Comp_Func)g_str_has_prefix, &input[1], ":"
+        vb.comps.completions = completion_init_completion(
+            vb.comps.completions, source, (Comp_Func)g_str_has_prefix, &input[1], ":"
         );
     }
 
-    if (!c->comps.completions) {
+    if (!vb.comps.completions) {
         return FALSE;
     }
-    completion_show(c, back);
+    completion_show(back);
 
     return TRUE;
 }
 
-void completion_clean(Client* c)
+void completion_clean()
 {
-    g_list_free_full(c->comps.completions, (GDestroyNotify)completion_free);
-    c->comps.completions = NULL;
+    g_list_free_full(vb.comps.completions, (GDestroyNotify)completion_free);
+    vb.comps.completions = NULL;
 
-    if (c->gui.compbox) {
-        gtk_widget_destroy(c->gui.compbox);
-        c->gui.compbox = NULL;
+    if (vb.gui.compbox) {
+        gtk_widget_destroy(vb.gui.compbox);
+        vb.gui.compbox = NULL;
     }
-    OVERWRITE_STRING(c->comps.prefix, NULL);
-    c->comps.active = NULL;
-    c->comps.count  = 0;
+    OVERWRITE_STRING(vb.comps.prefix, NULL);
+    vb.comps.active = NULL;
+    vb.comps.count  = 0;
 
     /* remove completion flag from mode */
-    c->state.mode &= ~VB_MODE_COMPLETE;
+    vb.state.mode &= ~VB_MODE_COMPLETE;
 }
 
-static GList* completion_init_completion(Client* c, GList* target, GList* source,
+static GList* completion_init_completion(GList* target, GList* source,
     Comp_Func func, const char* input, const char* prefix)
 {
     char* command = NULL;
@@ -133,8 +131,8 @@ static GList* completion_init_completion(Client* c, GList* target, GList* source
     char **token = NULL;
 
     /* remove counts before command and save it to print it later in inputbox */
-    c->comps.count  = g_ascii_strtoll(input, &command, 10);
-    OVERWRITE_STRING(c->comps.prefix, prefix);
+    vb.comps.count  = g_ascii_strtoll(input, &command, 10);
+    OVERWRITE_STRING(vb.comps.prefix, prefix);
 
     token = g_strsplit(command, " ", -1);
 
@@ -155,7 +153,7 @@ static GList* completion_init_completion(Client* c, GList* target, GList* source
         }
         if (match) {
             Completion* completion = completion_get_new(data, prefix);
-            gtk_box_pack_start(GTK_BOX(c->gui.compbox), completion->event, TRUE, TRUE, 0);
+            gtk_box_pack_start(GTK_BOX(vb.gui.compbox), completion->event, TRUE, TRUE, 0);
             /* use prepend because that faster */
             target = g_list_prepend(target, completion);
         }
@@ -167,13 +165,13 @@ static GList* completion_init_completion(Client* c, GList* target, GList* source
     return target;
 }
 
-static GList* completion_update(Client* c, GList* completion, GList* active, gboolean back)
+static GList* completion_update(GList* completion, GList* active, gboolean back)
 {
     GList *old, *new;
     Completion *comp;
 
     int length = g_list_length(completion);
-    int max    = core.config.max_completion_items;
+    int max    = vb.config.max_completion_items;
     int items  = MAX(length, max);
     int r      = (max) % 2;
     int offset = max / 2 - 1 + r;
@@ -227,55 +225,55 @@ static GList* completion_update(Client* c, GList* completion, GList* active, gbo
     VB_WIDGET_SET_STATE(((Completion*)new->data)->event, VB_GTK_STATE_ACTIVE);
 
     active = new;
-    completion_set_entry_text(c, active->data);
+    completion_set_entry_text(active->data);
     return active;
 }
 
 /* allow to chenge the direction of display */
-static void completion_show(Client* c, gboolean back)
+static void completion_show(gboolean back)
 {
-    guint max = core.config.max_completion_items;
+    guint max = vb.config.max_completion_items;
     int i = 0;
     if (back) {
-        c->comps.active = g_list_last(c->comps.completions);
-        for (GList *l = c->comps.active; l && i < max; l = l->prev, i++) {
+        vb.comps.active = g_list_last(vb.comps.completions);
+        for (GList *l = vb.comps.active; l && i < max; l = l->prev, i++) {
             gtk_widget_show_all(((Completion*)l->data)->event);
         }
     } else {
-        c->comps.active = g_list_first(c->comps.completions);
-        for (GList *l = c->comps.active; l && i < max; l = l->next, i++) {
+        vb.comps.active = g_list_first(vb.comps.completions);
+        for (GList *l = vb.comps.active; l && i < max; l = l->next, i++) {
             gtk_widget_show_all(((Completion*)l->data)->event);
         }
     }
-    if (c->comps.active != NULL) {
-        Completion* active = (Completion*)c->comps.active->data;
+    if (vb.comps.active != NULL) {
+        Completion* active = (Completion*)vb.comps.active->data;
         VB_WIDGET_SET_STATE(active->label, VB_GTK_STATE_ACTIVE);
         VB_WIDGET_SET_STATE(active->event, VB_GTK_STATE_ACTIVE);
 
-        completion_set_entry_text(c, active);
-        gtk_widget_show(c->gui.compbox);
+        completion_set_entry_text(active);
+        gtk_widget_show(vb.gui.compbox);
     }
 }
 
-static void completion_set_entry_text(Client* c, Completion* completion)
+static void completion_set_entry_text(Completion* completion)
 {
-    char* text = completion_get_text(c, completion);
-    gtk_entry_set_text(GTK_ENTRY(c->gui.inputbox), text);
-    gtk_editable_set_position(GTK_EDITABLE(c->gui.inputbox), -1);
+    char* text = completion_get_text(completion);
+    gtk_entry_set_text(GTK_ENTRY(vb.gui.inputbox), text);
+    gtk_editable_set_position(GTK_EDITABLE(vb.gui.inputbox), -1);
     g_free(text);
 }
 
 /**
  * Retrieves the full new allocated entry text for given completion item.
  */
-static char* completion_get_text(Client* c, Completion* completion)
+static char* completion_get_text(Completion* completion)
 {
     char* text = NULL;
 
     /* print the previous typed command count into inputbox too */
-    if (c->comps.count) {
+    if (vb.comps.count) {
         text = g_strdup_printf(
-            "%s%d%s", completion->prefix, c->comps.count, gtk_label_get_text(GTK_LABEL(completion->label))
+            "%s%d%s", completion->prefix, vb.comps.count, gtk_label_get_text(GTK_LABEL(completion->label))
         );
     } else {
         text = g_strdup_printf(
@@ -309,11 +307,11 @@ static Completion* completion_get_new(const char* label, const char* prefix)
     VB_WIDGET_SET_STATE(c->label, VB_GTK_STATE_NORMAL);
     VB_WIDGET_SET_STATE(c->event, VB_GTK_STATE_NORMAL);
 
-    VB_WIDGET_OVERRIDE_COLOR(c->label, GTK_STATE_NORMAL, &core.style.comp_fg[VB_COMP_NORMAL]);
-    VB_WIDGET_OVERRIDE_COLOR(c->label, GTK_STATE_ACTIVE, &core.style.comp_fg[VB_COMP_ACTIVE]);
-    VB_WIDGET_OVERRIDE_BACKGROUND(c->event, GTK_STATE_NORMAL, &core.style.comp_bg[VB_COMP_NORMAL]);
-    VB_WIDGET_OVERRIDE_BACKGROUND(c->event, GTK_STATE_ACTIVE, &core.style.comp_bg[VB_COMP_ACTIVE]);
-    VB_WIDGET_OVERRIDE_FONT(c->label, core.style.comp_font);
+    VB_WIDGET_OVERRIDE_COLOR(c->label, GTK_STATE_NORMAL, &vb.style.comp_fg[VB_COMP_NORMAL]);
+    VB_WIDGET_OVERRIDE_COLOR(c->label, GTK_STATE_ACTIVE, &vb.style.comp_fg[VB_COMP_ACTIVE]);
+    VB_WIDGET_OVERRIDE_BACKGROUND(c->event, GTK_STATE_NORMAL, &vb.style.comp_bg[VB_COMP_NORMAL]);
+    VB_WIDGET_OVERRIDE_BACKGROUND(c->event, GTK_STATE_ACTIVE, &vb.style.comp_bg[VB_COMP_ACTIVE]);
+    VB_WIDGET_OVERRIDE_FONT(c->label, vb.style.comp_font);
 
     GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1, 1);
     gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), padding, padding, padding, padding);
index b312679..0b66b08 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "main.h"
 
-void completion_clean(Client* c);
-gboolean completion_complete(Client* c, gboolean back);
+void completion_clean();
+gboolean completion_complete(gboolean back);
 
 #endif /* end of include guard: _COMPLETION_H */
index 56c17cb..d745ace 100644 (file)
--- a/src/dom.c
+++ b/src/dom.c
 #include "main.h"
 #include "dom.h"
 
-static gboolean dom_auto_insert(Client* c, Element* element);
-static gboolean dom_editable_focus_cb(Element* element, Event* event, Client* c);
+extern VbCore vb;
+
+static gboolean dom_auto_insert(Element* element);
+static gboolean dom_editable_focus_cb(Element* element, Event* event);
 static Element* dom_get_active_element(Document* doc);
 
 
-void dom_check_auto_insert(Client* c)
+void dom_check_auto_insert()
 {
-    Document* doc   = webkit_web_view_get_dom_document(c->gui.webview);
+    Document* doc   = webkit_web_view_get_dom_document(vb.gui.webview);
     Element* active = dom_get_active_element(doc);
-    if (!dom_auto_insert(c, active)) {
+    if (!dom_auto_insert(active)) {
         HtmlElement* element = webkit_dom_document_get_body(doc);
         if (!element) {
             element = WEBKIT_DOM_HTML_ELEMENT(webkit_dom_document_get_document_element(doc));
         }
         webkit_dom_event_target_add_event_listener(
-            WEBKIT_DOM_EVENT_TARGET(element), "focus", G_CALLBACK(dom_editable_focus_cb), true, c
+            WEBKIT_DOM_EVENT_TARGET(element), "focus", G_CALLBACK(dom_editable_focus_cb), true, NULL
         );
     }
 }
@@ -70,23 +72,23 @@ gboolean dom_is_editable(Element* element)
     return result;
 }
 
-static gboolean dom_auto_insert(Client* c, Element* element)
+static gboolean dom_auto_insert(Element* element)
 {
     if (dom_is_editable(element)) {
-        vb_set_mode(c, VB_MODE_INSERT, FALSE);
+        vb_set_mode(VB_MODE_INSERT, FALSE);
         return TRUE;
     }
     return FALSE;
 }
 
-static gboolean dom_editable_focus_cb(Element* element, Event* event, Client* c)
+static gboolean dom_editable_focus_cb(Element* element, Event* event)
 {
     webkit_dom_event_target_remove_event_listener(
         WEBKIT_DOM_EVENT_TARGET(element), "focus", G_CALLBACK(dom_editable_focus_cb), true
     );
-    if (CLEAN_MODE(c->state.mode) != VB_MODE_INSERT) {
+    if (CLEAN_MODE(vb.state.mode) != VB_MODE_INSERT) {
         EventTarget* target = webkit_dom_event_get_target(event);
-        dom_auto_insert(c, (void*)target);
+        dom_auto_insert((void*)target);
     }
     return FALSE;
 }
index 27a7210..dd00eda 100644 (file)
--- a/src/dom.h
+++ b/src/dom.h
@@ -39,7 +39,7 @@ typedef struct {
     gulong bottom;
 } DomBoundingRect;
 
-void dom_check_auto_insert(Client* c);
+void dom_check_auto_insert();
 gboolean dom_is_editable(Element* element);
 
 #endif /* end of include guard: _DOM_H */
index 4e53391..5515c47 100644 (file)
 #define HINT_VAR "VpHint"
 #define HINT_FILE "hints.js"
 
+extern VbCore vb;
 extern const unsigned int MAXIMUM_HINTS;
 
-static void hints_run_script(Client* c, char* js);
-static void hints_fire(Client* c);
-static void hints_observe_input(Client* c, gboolean observe);
-static gboolean hints_changed_callback(GtkEditable *entry, Client* c);
-static gboolean hints_keypress_callback(WebKitWebView* webview, GdkEventKey* event, Client* c);
+static void hints_run_script(char* js);
+static void hints_fire();
+static void hints_observe_input(gboolean observe);
+static gboolean hints_changed_callback(GtkEditable *entry);
+static gboolean hints_keypress_callback(WebKitWebView* webview, GdkEventKey* event);
 
 void hints_init(WebKitWebFrame* frame)
 {
@@ -42,28 +43,28 @@ void hints_init(WebKitWebFrame* frame)
     g_free(value);
 }
 
-void hints_clear(Client* c)
+void hints_clear()
 {
-    hints_observe_input(c, FALSE);
-    if (CLEAN_MODE(c->state.mode) == VB_MODE_HINTING) {
+    hints_observe_input(FALSE);
+    if (CLEAN_MODE(vb.state.mode) == VB_MODE_HINTING) {
         char* js = g_strdup_printf("%s.clear();", HINT_VAR);
         char* value = NULL;
-        vb_eval_script(webkit_web_view_get_main_frame(c->gui.webview), js, HINT_FILE, &value);
+        vb_eval_script(webkit_web_view_get_main_frame(vb.gui.webview), js, HINT_FILE, &value);
         g_free(value);
         g_free(js);
 
-        g_signal_emit_by_name(c->gui.webview, "hovering-over-link", NULL, NULL);
+        g_signal_emit_by_name(vb.gui.webview, "hovering-over-link", NULL, NULL);
     }
 }
 
-void hints_create(Client* c, const char* input, guint mode, const guint prefixLength)
+void hints_create(const char* input, guint mode, const guint prefixLength)
 {
     char* js = NULL;
-    if (CLEAN_MODE(c->state.mode) != VB_MODE_HINTING) {
-        Style* style = &core.style;
-        c->hints.prefixLength = prefixLength;
-        c->hints.mode         = mode;
-        c->hints.num          = 0;
+    if (CLEAN_MODE(vb.state.mode) != VB_MODE_HINTING) {
+        Style* style = &vb.style;
+        vb.hints.prefixLength = prefixLength;
+        vb.hints.mode         = mode;
+        vb.hints.num          = 0;
 
         char type, usage;
         /* convert the mode into the type chare used in the hint script */
@@ -84,136 +85,136 @@ void hints_create(Client* c, const char* input, guint mode, const guint prefixLe
             style->hint_style,
             MAXIMUM_HINTS
         );
-        hints_run_script(c, js);
+        hints_run_script(js);
         g_free(js);
 
-        hints_observe_input(c, TRUE);
+        hints_observe_input(TRUE);
     }
 
 
     js = g_strdup_printf("%s.create('%s');", HINT_VAR, input ? input : "");
-    hints_run_script(c, js);
+    hints_run_script(js);
     g_free(js);
 }
 
-void hints_update(Client* c, const gulong num)
+void hints_update(const gulong num)
 {
     char* js = g_strdup_printf("%s.update(%lu);", HINT_VAR, num);
-    hints_run_script(c, js);
+    hints_run_script(js);
     g_free(js);
 }
 
-void hints_focus_next(Client* c, const gboolean back)
+void hints_focus_next(const gboolean back)
 {
     char* js = g_strdup_printf(back ? "%s.focusPrev()" : "%s.focusNext();", HINT_VAR);
-    hints_run_script(c, js);
+    hints_run_script(js);
     g_free(js);
 }
 
-static void hints_run_script(Client* c, char* js)
+static void hints_run_script(char* js)
 {
     char* value = NULL;
-    int mode = c->hints.mode;
+    int mode = vb.hints.mode;
 
     gboolean success = vb_eval_script(
-        webkit_web_view_get_main_frame(c->gui.webview), js, HINT_FILE, &value
+        webkit_web_view_get_main_frame(vb.gui.webview), js, HINT_FILE, &value
     );
     if (!success) {
         fprintf(stderr, "%s\n", value);
         g_free(value);
 
-        vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+        vb_set_mode(VB_MODE_NORMAL, FALSE);
 
         return;
     }
 
     if (!strncmp(value, "OVER:", 5)) {
         g_signal_emit_by_name(
-            c->gui.webview, "hovering-over-link", NULL, *(value + 5) == '\0' ? NULL : (value + 5)
+            vb.gui.webview, "hovering-over-link", NULL, *(value + 5) == '\0' ? NULL : (value + 5)
         );
     } else if (!strncmp(value, "DONE:", 5)) {
-        hints_observe_input(c, FALSE);
-        vb_set_mode(c, VB_MODE_NORMAL, TRUE);
+        hints_observe_input(FALSE);
+        vb_set_mode(VB_MODE_NORMAL, TRUE);
     } else if (!strncmp(value, "INSERT:", 7)) {
-        hints_observe_input(c, FALSE);
-        vb_set_mode(c, VB_MODE_INSERT, FALSE);
+        hints_observe_input(FALSE);
+        vb_set_mode(VB_MODE_INSERT, FALSE);
     } else if (!strncmp(value, "DATA:", 5)) {
-        hints_observe_input(c, FALSE);
+        hints_observe_input(FALSE);
         Arg a = {0};
         char* v = (value + 5);
         if (mode & HINTS_PROCESS_INPUT) {
             a.s = g_strconcat((mode & HINTS_OPEN_NEW) ? ":tabopen " : ":open ", v, NULL);
-            command_input(c, &a);
+            command_input(&a);
             g_free(a.s);
         } else {
             a.i = COMMAND_YANK_PRIMARY | COMMAND_YANK_SECONDARY;
             a.s = v;
-            command_yank(c, &a);
+            command_yank(&a);
         }
     }
     g_free(value);
 }
 
-static void hints_fire(Client* c)
+static void hints_fire()
 {
-    hints_observe_input(c, FALSE);
+    hints_observe_input(FALSE);
     char* js = g_strdup_printf("%s.fire();", HINT_VAR);
-    hints_run_script(c, js);
+    hints_run_script(js);
     g_free(js);
 }
 
-static void hints_observe_input(Client* c, gboolean observe)
+static void hints_observe_input(gboolean observe)
 {
     if (observe) {
-        c->hints.change_handler = g_signal_connect(
-            G_OBJECT(c->gui.inputbox), "changed", G_CALLBACK(hints_changed_callback), c
+        vb.hints.change_handler = g_signal_connect(
+            G_OBJECT(vb.gui.inputbox), "changed", G_CALLBACK(hints_changed_callback), NULL
         );
-        c->hints.keypress_handler = g_signal_connect(
-            G_OBJECT(c->gui.inputbox), "key-press-event", G_CALLBACK(hints_keypress_callback), c
+        vb.hints.keypress_handler = g_signal_connect(
+            G_OBJECT(vb.gui.inputbox), "key-press-event", G_CALLBACK(hints_keypress_callback), NULL
         );
-    } else if (c->hints.change_handler && c->hints.keypress_handler) {
-        g_signal_handler_disconnect(G_OBJECT(c->gui.inputbox), c->hints.change_handler);
-        g_signal_handler_disconnect(G_OBJECT(c->gui.inputbox), c->hints.keypress_handler);
+    } else if (vb.hints.change_handler && vb.hints.keypress_handler) {
+        g_signal_handler_disconnect(G_OBJECT(vb.gui.inputbox), vb.hints.change_handler);
+        g_signal_handler_disconnect(G_OBJECT(vb.gui.inputbox), vb.hints.keypress_handler);
 
-        c->hints.change_handler = c->hints.keypress_handler = 0;
+        vb.hints.change_handler = vb.hints.keypress_handler = 0;
 
         /* clear the input box - TODO move this to a better place */
-        gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
-        gtk_entry_set_text(GTK_ENTRY(c->gui.inputbox), "");
+        gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
+        gtk_entry_set_text(GTK_ENTRY(vb.gui.inputbox), "");
     }
 }
 
-static gboolean hints_changed_callback(GtkEditable *entry, Client* c)
+static gboolean hints_changed_callback(GtkEditable *entry)
 {
-    const char* text = gtk_entry_get_text(GTK_ENTRY(c->gui.inputbox));
+    const char* text = gtk_entry_get_text(GTK_ENTRY(vb.gui.inputbox));
 
     /* skip hinting prefixes like '.', ',', ';y' ... */
-    hints_create(c, text + c->hints.prefixLength, c->hints.mode, c->hints.prefixLength);
+    hints_create(text + vb.hints.prefixLength, vb.hints.mode, vb.hints.prefixLength);
 
     return TRUE;
 }
 
-static gboolean hints_keypress_callback(WebKitWebView* webview, GdkEventKey* event, Client* c)
+static gboolean hints_keypress_callback(WebKitWebView* webview, GdkEventKey* event)
 {
     int numval;
     guint keyval = event->keyval;
     guint state  = CLEAN_STATE_WITH_SHIFT(event);
 
     if (keyval == GDK_Return) {
-        hints_fire(c);
+        hints_fire();
         return TRUE;
     }
     if (keyval == GDK_BackSpace && (state & GDK_SHIFT_MASK) && (state & GDK_CONTROL_MASK)) {
-        c->hints.num /= 10;
-        hints_update(c, c->hints.num);
+        vb.hints.num /= 10;
+        hints_update(vb.hints.num);
 
         return TRUE;
     }
     numval = g_unichar_digit_value((gunichar)gdk_keyval_to_unicode(keyval));
-    if ((numval >= 1 && numval <= 9) || (numval == 0 && c->hints.num)) {
+    if ((numval >= 1 && numval <= 9) || (numval == 0 && vb.hints.num)) {
         /* allow a zero as non-first number */
-        c->hints.num = (c->hints.num ? c->hints.num * 10 : 0) + numval;
-        hints_update(c, c->hints.num);
+        vb.hints.num = (vb.hints.num ? vb.hints.num * 10 : 0) + numval;
+        hints_update(vb.hints.num);
 
         return TRUE;
     }
index 6f3c720..c96dd8e 100644 (file)
@@ -34,9 +34,9 @@ enum {
 };
 
 void hints_init(WebKitWebFrame* frame);
-void hints_create(Client* c, const char* input, guint mode, const guint prefixLength);
-void hints_update(Client* c, const gulong num);
-void hints_clear(Client* c);
-void hints_focus_next(Client* c, const gboolean back);
+void hints_create(const char* input, guint mode, const guint prefixLength);
+void hints_update(const gulong num);
+void hints_clear();
+void hints_focus_next(const gboolean back);
 
 #endif /* end of include guard: _HINTS_H */
index 52175f7..43eeb6c 100644 (file)
 #include "main.h"
 #include "history.h"
 
+extern VbCore vb;
 extern const unsigned int COMMAND_HISTORY_SIZE;
 
 void history_cleanup(void)
 {
-    g_list_free_full(core.behave.history, (GDestroyNotify)g_free);
+    g_list_free_full(vb.behave.history, (GDestroyNotify)g_free);
 }
 
 void history_append(const char* line)
 {
-    if (COMMAND_HISTORY_SIZE <= g_list_length(core.behave.history)) {
+    if (COMMAND_HISTORY_SIZE <= g_list_length(vb.behave.history)) {
         /* if list is too long - remove items from beginning */
-        GList* first = g_list_first(core.behave.history);
+        GList* first = g_list_first(vb.behave.history);
         g_free((char*)first->data);
-        core.behave.history = g_list_delete_link(core.behave.history, first);
+        vb.behave.history = g_list_delete_link(vb.behave.history, first);
     }
-    core.behave.history = g_list_append(core.behave.history, g_strdup(line));
+    vb.behave.history = g_list_append(vb.behave.history, g_strdup(line));
 }
 
-const char* history_get(Client* c, const int step)
+const char* history_get(const int step)
 {
     const char* command;
 
     /* get the search prefix only on start of history search */
-    if (!c->state.history_active) {
-        OVERWRITE_STRING(c->state.history_prefix, gtk_entry_get_text(GTK_ENTRY(c->gui.inputbox)));
+    if (!vb.state.history_active) {
+        OVERWRITE_STRING(vb.state.history_prefix, gtk_entry_get_text(GTK_ENTRY(vb.gui.inputbox)));
 
         /* generate new history list with the matching items */
-        for (GList* l = core.behave.history; l; l = l->next) {
+        for (GList* l = vb.behave.history; l; l = l->next) {
             char* entry = g_strdup((char*)l->data);
-            if (g_str_has_prefix(entry, c->state.history_prefix)) {
-                c->state.history_active = g_list_prepend(c->state.history_active, entry);
+            if (g_str_has_prefix(entry, vb.state.history_prefix)) {
+                vb.state.history_active = g_list_prepend(vb.state.history_active, entry);
             }
         }
 
-        c->state.history_active = g_list_reverse(c->state.history_active);
+        vb.state.history_active = g_list_reverse(vb.state.history_active);
     }
 
-    const int len = g_list_length(c->state.history_active);
+    const int len = g_list_length(vb.state.history_active);
     if (!len) {
         return NULL;
     }
 
     /* if reached end/beginnen start at the opposit site of list again */
-    c->state.history_pointer = (len + c->state.history_pointer + step) % len;
+    vb.state.history_pointer = (len + vb.state.history_pointer + step) % len;
 
-    command = (char*)g_list_nth_data(c->state.history_active, c->state.history_pointer);
+    command = (char*)g_list_nth_data(vb.state.history_active, vb.state.history_pointer);
 
     return command;
 }
 
-void history_rewind(Client* c)
+void history_rewind()
 {
-    if (c->state.history_active) {
-        OVERWRITE_STRING(c->state.history_prefix, NULL);
-        c->state.history_pointer = 0;
+    if (vb.state.history_active) {
+        OVERWRITE_STRING(vb.state.history_prefix, NULL);
+        vb.state.history_pointer = 0;
         /* free temporary used history list */
-        g_list_free_full(c->state.history_active, (GDestroyNotify)g_free);
-        c->state.history_active = NULL;
+        g_list_free_full(vb.state.history_active, (GDestroyNotify)g_free);
+        vb.state.history_active = NULL;
     }
 }
index a80dd19..b968ed2 100644 (file)
@@ -22,7 +22,7 @@
 
 void history_cleanup(void);
 void history_append(const char* line);
-const char* history_get(Client* c, const int step);
-void history_rewind(Client* c);
+const char* history_get(const int step);
+void history_rewind();
 
 #endif /* end of include guard: _HISTORY_H */
index 8542f5f..2067b28 100644 (file)
 #include "command.h"
 #include "completion.h"
 
+extern VbCore vb;
+
 static void keybind_rebuild_modkeys(void);
 static GSList* keybind_find(int mode, guint modkey, guint modmask, guint keyval);
 static void keybind_str_to_keybind(char* str, Keybind* key);
 static guint keybind_str_to_modmask(const char* str);
 static guint keybind_str_to_value(const char* str);
-static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* event, Client* c);
+static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* event);
 static void keybind_free(Keybind* keybind);
 
 
 void keybind_init(void)
 {
-    core.behave.modkeys = g_string_new("");
-}
-
-void keybind_init_client(Client* c)
-{
-    g_signal_connect(G_OBJECT(c->gui.window), "key-press-event", G_CALLBACK(keybind_keypress_callback), c);
+    vb.behave.modkeys = g_string_new("");
+    g_signal_connect(G_OBJECT(vb.gui.window), "key-press-event", G_CALLBACK(keybind_keypress_callback), NULL);
 }
 
 void keybind_cleanup(void)
 {
-    if (core.behave.keys) {
-        g_slist_free_full(core.behave.keys, (GDestroyNotify)keybind_free);
+    if (vb.behave.keys) {
+        g_slist_free_full(vb.behave.keys, (GDestroyNotify)keybind_free);
     }
-    if (core.behave.modkeys) {
-        g_string_free(core.behave.modkeys, TRUE);
+    if (vb.behave.modkeys) {
+        g_string_free(vb.behave.modkeys, TRUE);
     }
 }
 
@@ -73,11 +71,11 @@ gboolean keybind_add_from_string(char* keys, const char* command, const Mode mod
     keybind_str_to_keybind(keys, keybind);
 
     /* add the keybinding to the list */
-    core.behave.keys = g_slist_prepend(core.behave.keys, keybind);
+    vb.behave.keys = g_slist_prepend(vb.behave.keys, keybind);
 
     /* save the modkey also in the modkey string if not exists already */
-    if (keybind->modkey && strchr(core.behave.modkeys->str, keybind->modkey) == NULL) {
-        g_string_append_c(core.behave.modkeys, keybind->modkey);
+    if (keybind->modkey && strchr(vb.behave.modkeys->str, keybind->modkey) == NULL) {
+        g_string_append_c(vb.behave.modkeys, keybind->modkey);
     }
 
     return TRUE;
@@ -98,10 +96,10 @@ gboolean keybind_remove_from_string(char* str, const Mode mode)
     GSList* link = keybind_find(keybind.mode, keybind.modkey, keybind.modmask, keybind.keyval);
     if (link) {
         keybind_free((Keybind*)link->data);
-        core.behave.keys = g_slist_delete_link(core.behave.keys, link);
+        vb.behave.keys = g_slist_delete_link(vb.behave.keys, link);
     }
 
-    if (keybind.modkey && strchr(core.behave.modkeys->str, keybind.modkey) != NULL) {
+    if (keybind.modkey && strchr(vb.behave.modkeys->str, keybind.modkey) != NULL) {
         /* remove eventually no more used modkeys */
         keybind_rebuild_modkeys();
     }
@@ -116,17 +114,17 @@ static void keybind_rebuild_modkeys(void)
 {
     GSList* link;
     /* remove previous modkeys */
-    if (core.behave.modkeys) {
-        g_string_free(core.behave.modkeys, TRUE);
-        core.behave.modkeys = g_string_new("");
+    if (vb.behave.modkeys) {
+        g_string_free(vb.behave.modkeys, TRUE);
+        vb.behave.modkeys = g_string_new("");
     }
 
     /* regenerate the modekeys */
-    for (link = core.behave.keys; link != NULL; link = link->next) {
+    for (link = vb.behave.keys; link != NULL; link = link->next) {
         Keybind* keybind = (Keybind*)link->data;
         /* if not not exists - add it */
-        if (keybind->modkey && strchr(core.behave.modkeys->str, keybind->modkey) == NULL) {
-            g_string_append_c(core.behave.modkeys, keybind->modkey);
+        if (keybind->modkey && strchr(vb.behave.modkeys->str, keybind->modkey) == NULL) {
+            g_string_append_c(vb.behave.modkeys, keybind->modkey);
         }
     }
 }
@@ -134,7 +132,7 @@ static void keybind_rebuild_modkeys(void)
 static GSList* keybind_find(int mode, guint modkey, guint modmask, guint keyval)
 {
     GSList* link;
-    for (link = core.behave.keys; link != NULL; link = link->next) {
+    for (link = vb.behave.keys; link != NULL; link = link->next) {
         Keybind* keybind = (Keybind*)link->data;
         if (keybind->keyval == keyval
             && keybind->modmask == modmask
@@ -227,7 +225,7 @@ static guint keybind_str_to_value(const char* str)
     return str[0];
 }
 
-static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* event, Client* c)
+static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* event)
 {
     guint keyval = event->keyval;
     guint state  = CLEAN_STATE_WITH_SHIFT(event);
@@ -235,34 +233,34 @@ static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* e
     /* check for escape or modkeys or counts */
     if (IS_ESCAPE_KEY(keyval, state)) {
         /* switch to normal mode and clear the input box */
-        vb_set_mode(c, VB_MODE_NORMAL, TRUE);
+        vb_set_mode(VB_MODE_NORMAL, TRUE);
 
         return TRUE;
     }
     /* allow mode keys and counts only in normal mode */
-    if ((VB_MODE_SEARCH | VB_MODE_NORMAL) & c->state.mode) {
-        if (c->state.modkey == 0 && ((keyval >= GDK_1 && keyval <= GDK_9)
-                || (keyval == GDK_0 && c->state.count))) {
+    if ((VB_MODE_SEARCH | VB_MODE_NORMAL) & vb.state.mode) {
+        if (vb.state.modkey == 0 && ((keyval >= GDK_1 && keyval <= GDK_9)
+                || (keyval == GDK_0 && vb.state.count))) {
             /* append the new entered count to previous one */
-            c->state.count = (c->state.count ? c->state.count * 10 : 0) + (keyval - GDK_0);
-            vb_update_statusbar(c);
+            vb.state.count = (vb.state.count ? vb.state.count * 10 : 0) + (keyval - GDK_0);
+            vb_update_statusbar();
 
             return TRUE;
         }
-        if (strchr(core.behave.modkeys->str, keyval) && c->state.modkey != keyval) {
-            c->state.modkey = (char)keyval;
-            vb_update_statusbar(c);
+        if (strchr(vb.behave.modkeys->str, keyval) && vb.state.modkey != keyval) {
+            vb.state.modkey = (char)keyval;
+            vb_update_statusbar();
 
             return TRUE;
         }
     }
 
     /* check for keybinding */
-    GSList* link = keybind_find(CLEAN_MODE(c->state.mode), c->state.modkey, state, keyval);
+    GSList* link = keybind_find(CLEAN_MODE(vb.state.mode), vb.state.modkey, state, keyval);
 
     if (link) {
         Keybind* keybind = (Keybind*)link->data;
-        command_run(c, keybind->command, keybind->param);
+        command_run(keybind->command, keybind->param);
 
         return TRUE;
     }
index 7d97d11..c9164c1 100644 (file)
@@ -33,7 +33,6 @@ typedef struct {
 } Keybind;
 
 void keybind_init(void);
-void keybind_init_client(Client* c);
 void keybind_cleanup(void);
 gboolean keybind_add_from_string(char* keys, const char* command, const Mode mode);
 gboolean keybind_remove_from_string(char* str, const Mode mode);
index a86e16d..156b133 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
+#include <sys/stat.h>
 #include "main.h"
 #include "util.h"
 #include "command.h"
 
 /* variables */
 static char **args;
-VbCore      core;
-Client* clients = NULL;
+VbCore      vb;
 
 /* callbacks */
-static void vb_webview_progress_cb(WebKitWebView* view, GParamSpec* pspec, Client* c);
-static void vb_webview_download_progress_cb(WebKitWebView* view, GParamSpec* pspec, Client* c);
-static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, Client* c);
-static void vb_destroy_window_cb(GtkWidget* widget, Client* c);
-static void vb_inputbox_activate_cb(GtkEntry* entry, Client* c);
-static gboolean vb_inputbox_keyrelease_cb(GtkEntry* entry, GdkEventKey* event, Client* c);
-static void vb_scroll_cb(GtkAdjustment* adjustment, Client* c);
-static void vb_new_request_cb(SoupSession* session, SoupMessage *message, Client* c);
-static void vb_gotheaders_cb(SoupMessage* message, Client* c);
-static WebKitWebView* vb_inspector_new(WebKitWebInspector* inspector, WebKitWebView* webview, Client* c);
-static gboolean vb_inspector_show(WebKitWebInspector* inspector, Client* c);
-static gboolean vb_inspector_close(WebKitWebInspector* inspector, Client* c);
-static void vb_inspector_finished(WebKitWebInspector* inspector, Client* c);
-static gboolean vb_button_relase_cb(WebKitWebView *webview, GdkEventButton* event, Client* c);
+static void vb_webview_progress_cb(WebKitWebView* view, GParamSpec* pspec);
+static void vb_webview_download_progress_cb(WebKitWebView* view, GParamSpec* pspec);
+static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec);
+static void vb_destroy_window_cb(GtkWidget* widget);
+static void vb_inputbox_activate_cb(GtkEntry* entry);
+static gboolean vb_inputbox_keyrelease_cb(GtkEntry* entry, GdkEventKey* event);
+static void vb_scroll_cb(GtkAdjustment* adjustment);
+static void vb_new_request_cb(SoupSession* session, SoupMessage *message);
+static void vb_gotheaders_cb(SoupMessage* message);
+static WebKitWebView* vb_inspector_new(WebKitWebInspector* inspector, WebKitWebView* webview);
+static gboolean vb_inspector_show(WebKitWebInspector* inspector);
+static gboolean vb_inspector_close(WebKitWebInspector* inspector);
+static void vb_inspector_finished(WebKitWebInspector* inspector);
+static gboolean vb_button_relase_cb(WebKitWebView *webview, GdkEventButton* event);
 static gboolean vb_new_window_policy_cb(
     WebKitWebView* view, WebKitWebFrame* frame, WebKitNetworkRequest* request,
-    WebKitWebNavigationAction* navig, WebKitWebPolicyDecision* policy, Client* c);
-static WebKitWebView* vb_create_new_webview_cb(WebKitWebView* webview, WebKitWebFrame* frame, Client* c);
-static void vb_hover_link_cb(WebKitWebView* webview, const char* title, const char* link, Client* c);
-static void vb_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const char* title, Client* c);
+    WebKitWebNavigationAction* navig, WebKitWebPolicyDecision* policy);
+static void vb_hover_link_cb(WebKitWebView* webview, const char* title, const char* link);
+static void vb_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const char* title);
 static gboolean vb_mimetype_decision_cb(WebKitWebView* webview,
     WebKitWebFrame* frame, WebKitNetworkRequest* request, char*
-    mime_type, WebKitWebPolicyDecision* decision, Client* c);
-static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* download, Client* c);
-static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec, Client* c);
+    mime_type, WebKitWebPolicyDecision* decision);
+static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* download);
+static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec);
 static void vb_request_start_cb(WebKitWebView* webview, WebKitWebFrame* frame,
     WebKitWebResource* resource, WebKitNetworkRequest* request,
-    WebKitNetworkResponse* response, Client* c);
+    WebKitNetworkResponse* response);
 
 /* functions */
-static gboolean vb_process_input(Client* c, const char* input);
+static gboolean vb_process_input(const char* input);
 static void vb_run_user_script(WebKitWebFrame* frame);
 static char* vb_jsref_to_string(JSContextRef context, JSValueRef ref);
 static void vb_init_core(void);
-static void vb_read_global_config(void);
-static void vb_process_config_file(Client* c, VpFile file);
-static Client* vb_client_new(void);
-static void vb_setup_signals(Client* c);
+static void vb_read_config(void);
+static void vb_setup_signals();
 static void vb_init_files(void);
 static void vb_set_cookie(SoupCookie* cookie);
 static const char* vb_get_cookies(SoupURI *uri);
-static gboolean vb_hide_message(Client* c);
-static void vb_set_status(Client* c, const StatusType status);
-static void vb_destroy_client(Client* c);
-static void vb_clean_up(void);
+static gboolean vb_hide_message();
+static void vb_set_status(const StatusType status);
+static void vb_destroy_client();
 
-void vb_clean_input(Client* c)
+void vb_clean_input()
 {
     /* move focus from input box to clean it */
-    gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
-    vb_echo(c, VB_MSG_NORMAL, FALSE, "");
+    gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
+    vb_echo(VB_MSG_NORMAL, FALSE, "");
 }
 
-void vb_echo(Client* c, const MessageType type, gboolean hide, const char *error, ...)
+void vb_echo(const MessageType type, gboolean hide, const char *error, ...)
 {
     va_list arg_list;
 
@@ -99,14 +95,14 @@ void vb_echo(Client* c, const MessageType type, gboolean hide, const char *error
     va_end(arg_list);
 
     /* don't print message if the input is focussed */
-    if (gtk_widget_is_focus(GTK_WIDGET(c->gui.inputbox))) {
+    if (gtk_widget_is_focus(GTK_WIDGET(vb.gui.inputbox))) {
         return;
     }
 
-    vb_update_input_style(c, type);
-    gtk_entry_set_text(GTK_ENTRY(c->gui.inputbox), message);
+    vb_update_input_style(type);
+    gtk_entry_set_text(GTK_ENTRY(vb.gui.inputbox), message);
     if (hide) {
-        g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)vb_hide_message, c);
+        g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)vb_hide_message, NULL);
     }
 }
 
@@ -133,7 +129,7 @@ gboolean vb_eval_script(WebKitWebFrame* frame, char* script, char* file, char**
     return FALSE;
 }
 
-gboolean vb_load_uri(Client* c, const Arg* arg)
+gboolean vb_load_uri(const Arg* arg)
 {
     char* uri;
     char* path = arg->s;
@@ -157,14 +153,27 @@ gboolean vb_load_uri(Client* c, const Arg* arg)
     }
 
     /* change state to normal mode */
-    vb_set_mode(c, VB_MODE_NORMAL, FALSE);
+    vb_set_mode(VB_MODE_NORMAL, FALSE);
 
     if (arg->i == VB_TARGET_NEW) {
-        Client* new = vb_client_new();
-        webkit_web_view_load_uri(new->gui.webview, uri);
+        guint i = 0;
+        char* cmd[5];
+        char xid[64];
+
+        cmd[i++] = *args;
+        if (vb.embed) {
+            cmd[i++] = "-e";
+            snprintf(xid, LENGTH(xid), "%u", (int)vb.embed);
+            cmd[i++] = xid;
+        }
+        cmd[i++] = uri;
+        cmd[i++] = NULL;
+
+        /* spawn a new browser instance */
+        g_spawn_async(NULL, cmd, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
     } else {
         /* Load a web page into the browser instance */
-        webkit_web_view_load_uri(c->gui.webview, uri);
+        webkit_web_view_load_uri(vb.gui.webview, uri);
     }
     g_free(uri);
 
@@ -192,62 +201,59 @@ gboolean vb_set_clipboard(const Arg* arg)
 
 /**
  * Set the base modes. All other mode flags like completion can be set directly
- * to c->state.mode.
+ * to vb.state.mode.
  */
-gboolean vb_set_mode(Client* c, Mode mode, gboolean clean)
+gboolean vb_set_mode(Mode mode, gboolean clean)
 {
-    if (!c) {
-        return FALSE;
-    }
-    if ((c->state.mode & VB_MODE_COMPLETE)
+    if ((vb.state.mode & VB_MODE_COMPLETE)
         && !(mode & VB_MODE_COMPLETE)
     ) {
-        completion_clean(c);
+        completion_clean();
     }
-    int clean_mode = CLEAN_MODE(c->state.mode);
+    int clean_mode = CLEAN_MODE(vb.state.mode);
     switch (CLEAN_MODE(mode)) {
         case VB_MODE_NORMAL:
             /* do this only if the mode is really switched */
             if (clean_mode != VB_MODE_NORMAL) {
-                history_rewind(c);
+                history_rewind();
             }
             if (clean_mode == VB_MODE_HINTING) {
                 /* if previous mode was hinting clear the hints */
-                hints_clear(c);
+                hints_clear();
             } else if (clean_mode == VB_MODE_INSERT) {
                 /* clean the input if current mode is insert to remove -- INPUT -- */
                 clean = TRUE;
             } else if (clean_mode == VB_MODE_SEARCH) {
                 /* cleaup previous search */
-                command_search(c, &((Arg){VB_SEARCH_OFF}));
+                command_search(&((Arg){VB_SEARCH_OFF}));
             }
-            gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
+            gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
             break;
 
         case VB_MODE_COMMAND:
         case VB_MODE_HINTING:
-            gtk_widget_grab_focus(GTK_WIDGET(c->gui.inputbox));
+            gtk_widget_grab_focus(GTK_WIDGET(vb.gui.inputbox));
             break;
 
         case VB_MODE_INSERT:
-            gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "-- INPUT --");
+            gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
+            vb_echo(VB_MSG_NORMAL, FALSE, "-- INPUT --");
             break;
 
         case VB_MODE_PATH_THROUGH:
-            gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
+            gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
             break;
     }
 
-    c->state.mode = mode;
-    c->state.modkey = c->state.count  = 0;
+    vb.state.mode = mode;
+    vb.state.modkey = vb.state.count  = 0;
 
     /* echo message if given */
     if (clean) {
-        vb_echo(c, VB_MSG_NORMAL, FALSE, "");
+        vb_echo(VB_MSG_NORMAL, FALSE, "");
     }
 
-    vb_update_statusbar(c);
+    vb_update_statusbar();
 
     return TRUE;
 }
@@ -261,31 +267,31 @@ void vb_set_widget_font(GtkWidget* widget, const VpColor* fg, const VpColor* bg,
     VB_WIDGET_OVERRIDE_BACKGROUND(widget, GTK_STATE_NORMAL, bg);
 }
 
-void vb_update_statusbar(Client* c)
+void vb_update_statusbar()
 {
     GString* status = g_string_new("");
 
     /* show current count */
-    g_string_append_printf(status, "%.0d", c->state.count);
+    g_string_append_printf(status, "%.0d", vb.state.count);
     /* show current modkey */
-    if (c->state.modkey) {
-        g_string_append_c(status, c->state.modkey);
+    if (vb.state.modkey) {
+        g_string_append_c(status, vb.state.modkey);
     }
 
     /* show the active downloads */
-    if (c->state.downloads) {
-        int num = g_list_length(c->state.downloads);
+    if (vb.state.downloads) {
+        int num = g_list_length(vb.state.downloads);
         g_string_append_printf(status, " %d %s", num, num == 1 ? "download" : "downloads");
     }
 
     /* show load status of page or the downloads */
-    if (c->state.progress != 100) {
-        g_string_append_printf(status, " [%i%%]", c->state.progress);
+    if (vb.state.progress != 100) {
+        g_string_append_printf(status, " [%i%%]", vb.state.progress);
     }
 
     /* show the scroll status */
-    int max = gtk_adjustment_get_upper(c->gui.adjust_v) - gtk_adjustment_get_page_size(c->gui.adjust_v);
-    int val = (int)(gtk_adjustment_get_value(c->gui.adjust_v) / max * 100);
+    int max = gtk_adjustment_get_upper(vb.gui.adjust_v) - gtk_adjustment_get_page_size(vb.gui.adjust_v);
+    int val = (int)(gtk_adjustment_get_value(vb.gui.adjust_v) / max * 100);
 
     if (max == 0) {
         g_string_append(status, " All");
@@ -297,76 +303,76 @@ void vb_update_statusbar(Client* c)
         g_string_append_printf(status, " %d%%", val);
     }
 
-    gtk_label_set_text(GTK_LABEL(c->gui.statusbar.right), status->str);
+    gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.right), status->str);
     g_string_free(status, TRUE);
 }
 
-void vb_update_status_style(Client* c)
+void vb_update_status_style()
 {
-    StatusType type = c->state.status;
+    StatusType type = vb.state.status;
     vb_set_widget_font(
-        c->gui.eventbox, &core.style.status_fg[type], &core.style.status_bg[type], core.style.status_font[type]
+        vb.gui.eventbox, &vb.style.status_fg[type], &vb.style.status_bg[type], vb.style.status_font[type]
     );
     vb_set_widget_font(
-        c->gui.statusbar.left, &core.style.status_fg[type], &core.style.status_bg[type], core.style.status_font[type]
+        vb.gui.statusbar.left, &vb.style.status_fg[type], &vb.style.status_bg[type], vb.style.status_font[type]
     );
     vb_set_widget_font(
-        c->gui.statusbar.right, &core.style.status_fg[type], &core.style.status_bg[type], core.style.status_font[type]
+        vb.gui.statusbar.right, &vb.style.status_fg[type], &vb.style.status_bg[type], vb.style.status_font[type]
     );
 }
 
-void vb_update_input_style(Client* c, MessageType type)
+void vb_update_input_style(MessageType type)
 {
     vb_set_widget_font(
-        c->gui.inputbox, &core.style.input_fg[type], &core.style.input_bg[type], core.style.input_font[type]
+        vb.gui.inputbox, &vb.style.input_fg[type], &vb.style.input_bg[type], vb.style.input_font[type]
     );
 }
 
-void vb_update_urlbar(Client* c, const char* uri)
+void vb_update_urlbar(const char* uri)
 {
-    gtk_label_set_text(GTK_LABEL(c->gui.statusbar.left), uri);
+    gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), uri);
 }
 
-static gboolean vb_hide_message(Client* c)
+static gboolean vb_hide_message()
 {
-    vb_echo(c, VB_MSG_NORMAL, FALSE, "");
+    vb_echo(VB_MSG_NORMAL, FALSE, "");
 
     return FALSE;
 }
 
-static void vb_webview_progress_cb(WebKitWebView* view, GParamSpec* pspec, Client* c)
+static void vb_webview_progress_cb(WebKitWebView* view, GParamSpec* pspec)
 {
-    c->state.progress = webkit_web_view_get_progress(view) * 100;
-    vb_update_statusbar(c);
+    vb.state.progress = webkit_web_view_get_progress(view) * 100;
+    vb_update_statusbar();
 }
 
-static void vb_webview_download_progress_cb(WebKitWebView* view, GParamSpec* pspec, Client* c)
+static void vb_webview_download_progress_cb(WebKitWebView* view, GParamSpec* pspec)
 {
-    if (c->state.downloads) {
-        c->state.progress = 0;
+    if (vb.state.downloads) {
+        vb.state.progress = 0;
         GList* ptr;
-        for (ptr = c->state.downloads; ptr; ptr = g_list_next(ptr)) {
-            c->state.progress += 100 * webkit_download_get_progress(ptr->data);
+        for (ptr = vb.state.downloads; ptr; ptr = g_list_next(ptr)) {
+            vb.state.progress += 100 * webkit_download_get_progress(ptr->data);
         }
-        c->state.progress /= g_list_length(c->state.downloads);
+        vb.state.progress /= g_list_length(vb.state.downloads);
     }
-    vb_update_statusbar(c);
+    vb_update_statusbar();
 }
 
-static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, Client* c)
+static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec)
 {
-    const char* uri = webkit_web_view_get_uri(c->gui.webview);
+    const char* uri = webkit_web_view_get_uri(vb.gui.webview);
 
-    switch (webkit_web_view_get_load_status(c->gui.webview)) {
+    switch (webkit_web_view_get_load_status(vb.gui.webview)) {
         case WEBKIT_LOAD_PROVISIONAL:
             /* update load progress in statusbar */
-            c->state.progress = 0;
-            vb_update_statusbar(c);
+            vb.state.progress = 0;
+            vb_update_statusbar();
             break;
 
         case WEBKIT_LOAD_COMMITTED:
             {
-                WebKitWebFrame* frame = webkit_web_view_get_main_frame(c->gui.webview);
+                WebKitWebFrame* frame = webkit_web_view_get_main_frame(vb.gui.webview);
                 /* set the status */
                 if (g_str_has_prefix(uri, "https://")) {
                     WebKitWebDataSource* src      = webkit_web_frame_get_data_source(frame);
@@ -374,11 +380,10 @@ static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, Cl
                     SoupMessage* msg              = webkit_network_request_get_message(request);
                     SoupMessageFlags flags        = soup_message_get_flags(msg);
                     vb_set_status(
-                        c,
                         (flags & SOUP_MESSAGE_CERTIFICATE_TRUSTED) ? VB_STATUS_SSL_VALID : VB_STATUS_SSL_INVALID
                     );
                 } else {
-                    vb_set_status(c, VB_STATUS_NORMAL);
+                    vb_set_status(VB_STATUS_NORMAL);
                 }
 
                 /* inject the hinting javascript */
@@ -389,8 +394,8 @@ static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, Cl
             }
 
             /* status bar is updated by vb_set_mode */
-            vb_set_mode(c, VB_MODE_NORMAL , FALSE);
-            vb_update_urlbar(c, uri);
+            vb_set_mode(VB_MODE_NORMAL , FALSE);
+            vb_update_urlbar(uri);
 
             break;
 
@@ -399,12 +404,12 @@ static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, Cl
 
         case WEBKIT_LOAD_FINISHED:
             /* update load progress in statusbar */
-            c->state.progress = 100;
-            vb_update_statusbar(c);
+            vb.state.progress = 100;
+            vb_update_statusbar();
 
-            dom_check_auto_insert(c);
+            dom_check_auto_insert();
 
-            url_history_add(uri, webkit_web_view_get_title(c->gui.webview));
+            url_history_add(uri, webkit_web_view_get_title(vb.gui.webview));
             break;
 
         case WEBKIT_LOAD_FAILED:
@@ -412,12 +417,12 @@ static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, Cl
     }
 }
 
-static void vb_destroy_window_cb(GtkWidget* widget, Client* c)
+static void vb_destroy_window_cb(GtkWidget* widget)
 {
-    vb_destroy_client(c);
+    vb_destroy_client();
 }
 
-static void vb_inputbox_activate_cb(GtkEntry *entry, Client* c)
+static void vb_inputbox_activate_cb(GtkEntry *entry)
 {
     const char* text;
     gboolean hist_save = FALSE;
@@ -428,7 +433,7 @@ static void vb_inputbox_activate_cb(GtkEntry *entry, Client* c)
         return;
     }
 
-    gtk_widget_grab_focus(GTK_WIDGET(c->gui.webview));
+    gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
 
     if (length <= 1) {
         return;
@@ -448,13 +453,13 @@ static void vb_inputbox_activate_cb(GtkEntry *entry, Client* c)
         case '?':
             a.i = *text == '/' ? VB_SEARCH_FORWARD : VB_SEARCH_BACKWARD;
             a.s = (command + 1);
-            command_search(c, &a);
+            command_search(&a);
             hist_save = TRUE;
             break;
 
         case ':':
-            completion_clean(c);
-            vb_process_input(c, (command + 1));
+            completion_clean();
+            vb_process_input((command + 1));
             hist_save = TRUE;
             break;
     }
@@ -466,17 +471,17 @@ static void vb_inputbox_activate_cb(GtkEntry *entry, Client* c)
     g_free(command);
 }
 
-static gboolean vb_inputbox_keyrelease_cb(GtkEntry* entry, GdkEventKey* event, Client* c)
+static gboolean vb_inputbox_keyrelease_cb(GtkEntry* entry, GdkEventKey* event)
 {
     return FALSE;
 }
 
-static void vb_scroll_cb(GtkAdjustment* adjustment, Client* c)
+static void vb_scroll_cb(GtkAdjustment* adjustment)
 {
-    vb_update_statusbar(c);
+    vb_update_statusbar();
 }
 
-static void vb_new_request_cb(SoupSession* session, SoupMessage *message, Client* c)
+static void vb_new_request_cb(SoupSession* session, SoupMessage *message)
 {
     SoupMessageHeaders* header = message->request_headers;
     SoupURI* uri;
@@ -487,10 +492,10 @@ static void vb_new_request_cb(SoupSession* session, SoupMessage *message, Client
     if ((cookie = vb_get_cookies(uri))) {
         soup_message_headers_append(header, "Cookie", cookie);
     }
-    g_signal_connect_after(G_OBJECT(message), "got-headers", G_CALLBACK(vb_gotheaders_cb), c);
+    g_signal_connect_after(G_OBJECT(message), "got-headers", G_CALLBACK(vb_gotheaders_cb), NULL);
 }
 
-static void vb_gotheaders_cb(SoupMessage* message, Client* c)
+static void vb_gotheaders_cb(SoupMessage* message)
 {
     GSList* list = NULL;
     GSList* p = NULL;
@@ -501,60 +506,60 @@ static void vb_gotheaders_cb(SoupMessage* message, Client* c)
     soup_cookies_free(list);
 }
 
-static WebKitWebView* vb_inspector_new(WebKitWebInspector* inspector, WebKitWebView* webview, Client* c)
+static WebKitWebView* vb_inspector_new(WebKitWebInspector* inspector, WebKitWebView* webview)
 {
     return WEBKIT_WEB_VIEW(webkit_web_view_new());
 }
 
-static gboolean vb_inspector_show(WebKitWebInspector* inspector, Client* c)
+static gboolean vb_inspector_show(WebKitWebInspector* inspector)
 {
     WebKitWebView* webview;
     int height;
 
-    if (c->state.is_inspecting) {
+    if (vb.state.is_inspecting) {
         return FALSE;
     }
 
     webview = webkit_web_inspector_get_web_view(inspector);
 
     /* use about 1/3 of window height for the inspector */
-    gtk_window_get_size(GTK_WINDOW(c->gui.window), NULL, &height);
-    gtk_paned_set_position(GTK_PANED(c->gui.pane), 2 * height / 3);
+    gtk_window_get_size(GTK_WINDOW(vb.gui.window), NULL, &height);
+    gtk_paned_set_position(GTK_PANED(vb.gui.pane), 2 * height / 3);
 
-    gtk_paned_pack2(GTK_PANED(c->gui.pane), GTK_WIDGET(webview), TRUE, TRUE);
+    gtk_paned_pack2(GTK_PANED(vb.gui.pane), GTK_WIDGET(webview), TRUE, TRUE);
     gtk_widget_show(GTK_WIDGET(webview));
 
-    c->state.is_inspecting = TRUE;
+    vb.state.is_inspecting = TRUE;
 
     return TRUE;
 }
 
-static gboolean vb_inspector_close(WebKitWebInspector* inspector, Client* c)
+static gboolean vb_inspector_close(WebKitWebInspector* inspector)
 {
     WebKitWebView* webview;
 
-    if (!c->state.is_inspecting) {
+    if (!vb.state.is_inspecting) {
         return FALSE;
     }
     webview = webkit_web_inspector_get_web_view(inspector);
     gtk_widget_hide(GTK_WIDGET(webview));
     gtk_widget_destroy(GTK_WIDGET(webview));
 
-    c->state.is_inspecting = FALSE;
+    vb.state.is_inspecting = FALSE;
 
     return TRUE;
 }
 
-static void vb_inspector_finished(WebKitWebInspector* inspector, Client* c)
+static void vb_inspector_finished(WebKitWebInspector* inspector)
 {
-    g_free(c->gui.inspector);
+    g_free(vb.gui.inspector);
 }
 
 /**
  * Processed input from input box without trailing : or ? /, input from config
  * file and default config.
  */
-static gboolean vb_process_input(Client* c, const char* input)
+static gboolean vb_process_input(const char* input)
 {
     gboolean success;
     char* command = NULL;
@@ -565,11 +570,7 @@ static gboolean vb_process_input(Client* c, const char* input)
     }
 
     /* get a possible command count */
-    if (c) {
-        c->state.count = g_ascii_strtoll(input, &command, 10);
-    } else {
-        command = (char*)input;
-    }
+    vb.state.count = g_ascii_strtoll(input, &command, 10);
 
     /* split the input string into command and parameter part */
     token = g_strsplit(command, " ", 2);
@@ -578,7 +579,7 @@ static gboolean vb_process_input(Client* c, const char* input)
         g_strfreev(token);
         return FALSE;
     }
-    success = command_run(c, token[0], token[1] ? token[1] : NULL);
+    success = command_run(token[0], token[1] ? token[1] : NULL);
     g_strfreev(token);
 
     return success;
@@ -589,10 +590,10 @@ static void vb_set_cookie(SoupCookie* cookie)
 {
     SoupDate* date;
 
-    SoupCookieJar* jar = soup_cookie_jar_text_new(core.files[FILES_COOKIE], FALSE);
+    SoupCookieJar* jar = soup_cookie_jar_text_new(vb.files[FILES_COOKIE], FALSE);
     cookie = soup_cookie_copy(cookie);
-    if (cookie->expires == NULL && core.config.cookie_timeout) {
-        date = soup_date_new_from_time_t(time(NULL) + core.config.cookie_timeout);
+    if (cookie->expires == NULL && vb.config.cookie_timeout) {
+        date = soup_date_new_from_time_t(time(NULL) + vb.config.cookie_timeout);
         soup_cookie_set_expires(cookie, date);
     }
     soup_cookie_jar_add_cookie(jar, cookie);
@@ -603,7 +604,7 @@ static const char* vb_get_cookies(SoupURI *uri)
 {
     const char* cookie;
 
-    SoupCookieJar* jar = soup_cookie_jar_text_new(core.files[FILES_COOKIE], TRUE);
+    SoupCookieJar* jar = soup_cookie_jar_text_new(vb.files[FILES_COOKIE], TRUE);
     cookie = soup_cookie_jar_get_cookies(jar, uri, TRUE);
     g_object_unref(jar);
 
@@ -611,12 +612,12 @@ static const char* vb_get_cookies(SoupURI *uri)
 }
 #endif
 
-static void vb_set_status(Client* c, const StatusType status)
+static void vb_set_status(const StatusType status)
 {
-    if (c->state.status != status) {
-        c->state.status = status;
+    if (vb.state.status != status) {
+        vb.state.status = status;
         /* update the statusbar style only if the status changed */
-        vb_update_status_style(c);
+        vb_update_status_style();
     }
 }
 
@@ -625,11 +626,11 @@ static void vb_run_user_script(WebKitWebFrame* frame)
     char* js      = NULL;
     GError* error = NULL;
 
-    if (g_file_test(core.files[FILES_SCRIPT], G_FILE_TEST_IS_REGULAR)
-        && g_file_get_contents(core.files[FILES_SCRIPT], &js, NULL, &error)
+    if (g_file_test(vb.files[FILES_SCRIPT], G_FILE_TEST_IS_REGULAR)
+        && g_file_get_contents(vb.files[FILES_SCRIPT], &js, NULL, &error)
     ) {
         char* value = NULL;
-        gboolean success = vb_eval_script(frame, js, core.files[FILES_SCRIPT], &value);
+        gboolean success = vb_eval_script(frame, js, vb.files[FILES_SCRIPT], &value);
         if (!success) {
             fprintf(stderr, "%s", value);
         }
@@ -653,73 +654,10 @@ static char* vb_jsref_to_string(JSContextRef context, JSValueRef ref)
 
 static void vb_init_core(void)
 {
-    /* TODO */
-    /* initialize the commands hash map */
-    command_init();
-
-    /* initialize the config files */
-    vb_init_files();
-
-    /* initialize the keybindings */
-    keybind_init();
-
-    /* init soup session */
-    core.soup_session = webkit_get_default_session();
-    soup_session_remove_feature_by_type(core.soup_session, soup_cookie_jar_get_type());
-    g_object_set(core.soup_session, "max-conns", SETTING_MAX_CONNS , NULL);
-    g_object_set(core.soup_session, "max-conns-per-host", SETTING_MAX_CONNS_PER_HOST, NULL);
-
-    /* initialize settings */
-    setting_init();
-
-    /* read additional configuration from config files */
-    vb_read_global_config();
-
-    url_history_init();
-}
-
-static void vb_read_global_config(void)
-{
-    /* load default config */
-    for (guint i = 0; default_config[i].command != NULL; i++) {
-        if (!vb_process_input(NULL, default_config[i].command)) {
-            fprintf(stderr, "Invalid default config: %s\n", default_config[i].command);
-        }
-    }
-
-    vb_process_config_file(NULL, FILES_GLOBAL_CONFIG);
-}
-
-static void vb_process_config_file(Client* c, VpFile file)
-{
-    /* read config from config files */
-    char **lines = util_get_lines(core.files[file]);
-    char *line;
-
-    if (lines) {
-        int length = g_strv_length(lines) - 1;
-        for (int i = 0; i < length; i++) {
-            line = lines[i];
-            g_strstrip(line);
-
-            if (!g_ascii_isalpha(line[0])) {
-                continue;
-            }
-            if (!vb_process_input(c, line)) {
-                fprintf(stderr, "Invalid config: %s\n", line);
-            }
-        }
-    }
-    g_strfreev(lines);
-}
-
-static Client* vb_client_new(void)
-{
-    Client* c = g_new0(Client, 1);
-    Gui* gui  = &c->gui;
+    Gui* gui = &vb.gui;
 
-    if (core.embed) {
-        gui->window = gtk_plug_new(core.embed);
+    if (vb.embed) {
+        gui->window = gtk_plug_new(vb.embed);
     } else {
         gui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
         gtk_window_set_wmclass(GTK_WINDOW(gui->window), "vimb", "Vimb");
@@ -764,7 +702,13 @@ static Client* vb_client_new(void)
 
     gtk_paned_pack1(GTK_PANED(gui->pane), GTK_WIDGET(gui->box), TRUE, TRUE);
 
-    vb_setup_signals(c);
+    /* init soup session */
+    vb.soup_session = webkit_get_default_session();
+    soup_session_remove_feature_by_type(vb.soup_session, soup_cookie_jar_get_type());
+    g_object_set(vb.soup_session, "max-conns", SETTING_MAX_CONNS , NULL);
+    g_object_set(vb.soup_session, "max-conns-per-host", SETTING_MAX_CONNS_PER_HOST, NULL);
+
+    vb_setup_signals();
 
     /* Put all part together */
     gtk_container_add(GTK_CONTAINER(gui->scroll), GTK_WIDGET(gui->webview));
@@ -784,103 +728,125 @@ static Client* vb_client_new(void)
      * and keyboard events */
     gtk_widget_grab_focus(GTK_WIDGET(gui->webview));
 
-    /* Make sure the main window and all its contents are visible */
-    gtk_widget_show_all(gui->window);
+    vb_init_files();
+    setting_init();
+    command_init();
+    keybind_init();
+    url_history_init();
+    vb_read_config();
 
-    keybind_init_client(c);
-    setting_init_client(c);
+    vb_update_status_style();
+    vb_update_input_style(VB_MSG_NORMAL);
 
-    vb_process_config_file(c, FILES_LOCAL_CONFIG);
+    /* make sure the main window and all its contents are visible */
+    gtk_widget_show_all(gui->window);
+}
 
-    /* apply global settings to the status bar and input box */
-    vb_update_status_style(c);
-    vb_update_input_style(c, VB_MSG_NORMAL);
+static void vb_read_config(void)
+{
+    /* load default config */
+    for (guint i = 0; default_config[i].command != NULL; i++) {
+        if (!vb_process_input(default_config[i].command)) {
+            fprintf(stderr, "Invalid default config: %s\n", default_config[i].command);
+        }
+    }
+
+    /* read config from config files */
+    char **lines = util_get_lines(vb.files[FILES_CONFIG]);
+    char *line;
 
-    c->next = clients;
-    clients = c;
+    if (lines) {
+        int length = g_strv_length(lines) - 1;
+        for (int i = 0; i < length; i++) {
+            line = lines[i];
+            g_strstrip(line);
 
-    return c;
+            if (!g_ascii_isalpha(line[0])) {
+                continue;
+            }
+            if (!vb_process_input(line)) {
+                fprintf(stderr, "Invalid config: %s\n", line);
+            }
+        }
+    }
+    g_strfreev(lines);
 }
 
-static void vb_setup_signals(Client* c)
+static void vb_setup_signals()
 {
     /* Set up callbacks so that if either the main window or the browser
      * instance is closed, the program will exit */
-    g_signal_connect(c->gui.window, "destroy", G_CALLBACK(vb_destroy_window_cb), c);
+    g_signal_connect(vb.gui.window, "destroy", G_CALLBACK(vb_destroy_window_cb), NULL);
     g_object_connect(
-        G_OBJECT(c->gui.webview),
-        "signal::notify::progress", G_CALLBACK(vb_webview_progress_cb), c,
-        "signal::notify::load-status", G_CALLBACK(vb_webview_load_status_cb), c,
-        "signal::button-release-event", G_CALLBACK(vb_button_relase_cb), c,
-        "signal::new-window-policy-decision-requested", G_CALLBACK(vb_new_window_policy_cb), c,
-        "signal::create-web-view", G_CALLBACK(vb_create_new_webview_cb), c,
-        "signal::hovering-over-link", G_CALLBACK(vb_hover_link_cb), c,
-        "signal::title-changed", G_CALLBACK(vb_title_changed_cb), c,
-        "signal::mime-type-policy-decision-requested", G_CALLBACK(vb_mimetype_decision_cb), c,
-        "signal::download-requested", G_CALLBACK(vb_download_requested_cb), c,
-        "signal::resource-request-starting", G_CALLBACK(vb_request_start_cb), c,
+        G_OBJECT(vb.gui.webview),
+        "signal::notify::progress", G_CALLBACK(vb_webview_progress_cb), NULL,
+        "signal::notify::load-status", G_CALLBACK(vb_webview_load_status_cb), NULL,
+        "signal::button-release-event", G_CALLBACK(vb_button_relase_cb), NULL,
+        "signal::new-window-policy-decision-requested", G_CALLBACK(vb_new_window_policy_cb), NULL,
+        "signal::hovering-over-link", G_CALLBACK(vb_hover_link_cb), NULL,
+        "signal::title-changed", G_CALLBACK(vb_title_changed_cb), NULL,
+        "signal::mime-type-policy-decision-requested", G_CALLBACK(vb_mimetype_decision_cb), NULL,
+        "signal::download-requested", G_CALLBACK(vb_download_requested_cb), NULL,
+        "signal::resource-request-starting", G_CALLBACK(vb_request_start_cb), NULL,
         NULL
     );
 
     g_object_connect(
-        G_OBJECT(c->gui.inputbox),
-        "signal::activate",          G_CALLBACK(vb_inputbox_activate_cb),   c,
-        "signal::key-release-event", G_CALLBACK(vb_inputbox_keyrelease_cb), c,
+        G_OBJECT(vb.gui.inputbox),
+        "signal::activate",          G_CALLBACK(vb_inputbox_activate_cb),   NULL,
+        "signal::key-release-event", G_CALLBACK(vb_inputbox_keyrelease_cb), NULL,
         NULL
     );
     /* webview adjustment */
-    g_object_connect(G_OBJECT(c->gui.adjust_v),
-        "signal::value-changed",     G_CALLBACK(vb_scroll_cb),              c,
+    g_object_connect(G_OBJECT(vb.gui.adjust_v),
+        "signal::value-changed", G_CALLBACK(vb_scroll_cb), NULL,
         NULL
     );
 
-    g_signal_connect_after(G_OBJECT(core.soup_session), "request-started", G_CALLBACK(vb_new_request_cb), c);
+    g_signal_connect_after(G_OBJECT(vb.soup_session), "request-started", G_CALLBACK(vb_new_request_cb), NULL);
 
     /* inspector */
     /* TODO use g_object_connect instead */
-    g_signal_connect(G_OBJECT(c->gui.inspector), "inspect-web-view", G_CALLBACK(vb_inspector_new), c);
-    g_signal_connect(G_OBJECT(c->gui.inspector), "show-window", G_CALLBACK(vb_inspector_show), c);
-    g_signal_connect(G_OBJECT(c->gui.inspector), "close-window", G_CALLBACK(vb_inspector_close), c);
-    g_signal_connect(G_OBJECT(c->gui.inspector), "finished", G_CALLBACK(vb_inspector_finished), c);
+    g_signal_connect(G_OBJECT(vb.gui.inspector), "inspect-web-view", G_CALLBACK(vb_inspector_new), NULL);
+    g_signal_connect(G_OBJECT(vb.gui.inspector), "show-window", G_CALLBACK(vb_inspector_show), NULL);
+    g_signal_connect(G_OBJECT(vb.gui.inspector), "close-window", G_CALLBACK(vb_inspector_close), NULL);
+    g_signal_connect(G_OBJECT(vb.gui.inspector), "finished", G_CALLBACK(vb_inspector_finished), NULL);
 }
 
 static void vb_init_files(void)
 {
     char* path = util_get_config_dir();
 
-    core.files[FILES_GLOBAL_CONFIG] = g_build_filename(path, "global.conf", NULL);
-    util_create_file_if_not_exists(core.files[FILES_GLOBAL_CONFIG]);
-
-    core.files[FILES_LOCAL_CONFIG] = g_build_filename(path, "local.conf", NULL);
-    util_create_file_if_not_exists(core.files[FILES_LOCAL_CONFIG]);
+    vb.files[FILES_CONFIG] = g_build_filename(path, "config", NULL);
+    util_create_file_if_not_exists(vb.files[FILES_CONFIG]);
 
-    core.files[FILES_COOKIE] = g_build_filename(path, "cookies", NULL);
-    util_create_file_if_not_exists(core.files[FILES_COOKIE]);
+    vb.files[FILES_COOKIE] = g_build_filename(path, "cookies", NULL);
+    util_create_file_if_not_exists(vb.files[FILES_COOKIE]);
 
-    core.files[FILES_CLOSED] = g_build_filename(path, "closed", NULL);
-    util_create_file_if_not_exists(core.files[FILES_CLOSED]);
+    vb.files[FILES_CLOSED] = g_build_filename(path, "closed", NULL);
+    util_create_file_if_not_exists(vb.files[FILES_CLOSED]);
 
-    core.files[FILES_HISTORY] = g_build_filename(path, "history", NULL);
-    util_create_file_if_not_exists(core.files[FILES_HISTORY]);
+    vb.files[FILES_HISTORY] = g_build_filename(path, "history", NULL);
+    util_create_file_if_not_exists(vb.files[FILES_HISTORY]);
 
-    core.files[FILES_SCRIPT] = g_build_filename(path, "scripts.js", NULL);
+    vb.files[FILES_SCRIPT] = g_build_filename(path, "scripts.js", NULL);
 
-    core.files[FILES_USER_STYLE] = g_build_filename(path, "style.css", NULL);
+    vb.files[FILES_USER_STYLE] = g_build_filename(path, "style.css", NULL);
 
     g_free(path);
 }
 
-static gboolean vb_button_relase_cb(WebKitWebView* webview, GdkEventButton* event, Client* c)
+static gboolean vb_button_relase_cb(WebKitWebView* webview, GdkEventButton* event)
 {
     gboolean propagate = FALSE;
     WebKitHitTestResultContext context;
-    Mode mode = CLEAN_MODE(c->state.mode);
+    Mode mode = CLEAN_MODE(vb.state.mode);
 
     WebKitHitTestResult *result = webkit_web_view_get_hit_test_result(webview, event);
 
     g_object_get(result, "context", &context, NULL);
     if (mode == VB_MODE_NORMAL && context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
-        vb_set_mode(c, VB_MODE_INSERT, FALSE);
+        vb_set_mode(VB_MODE_INSERT, FALSE);
 
         propagate = TRUE;
     }
@@ -888,7 +854,7 @@ static gboolean vb_button_relase_cb(WebKitWebView* webview, GdkEventButton* even
     if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK && event->button == 2) {
         Arg a = {VB_TARGET_NEW};
         g_object_get(result, "link-uri", &a.s, NULL);
-        vb_load_uri(c, &a);
+        vb_load_uri(&a);
 
         propagate = TRUE;
     }
@@ -899,43 +865,37 @@ static gboolean vb_button_relase_cb(WebKitWebView* webview, GdkEventButton* even
 
 static gboolean vb_new_window_policy_cb(
     WebKitWebView* view, WebKitWebFrame* frame, WebKitNetworkRequest* request,
-    WebKitWebNavigationAction* navig, WebKitWebPolicyDecision* policy, Client* c)
+    WebKitWebNavigationAction* navig, WebKitWebPolicyDecision* policy)
 {
     if (webkit_web_navigation_action_get_reason(navig) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
+        webkit_web_policy_decision_ignore(policy);
         /* open in a new window */
         Arg a = {VB_TARGET_NEW, (char*)webkit_network_request_get_uri(request)};
-        vb_load_uri(c, &a);
-        webkit_web_policy_decision_ignore(policy);
+        vb_load_uri(&a);
         return TRUE;
     }
     return FALSE;
 }
 
-static WebKitWebView* vb_create_new_webview_cb(WebKitWebView* webview, WebKitWebFrame* frame, Client* c)
-{
-    Client* new = vb_client_new();
-    return new->gui.webview;
-}
-
-static void vb_hover_link_cb(WebKitWebView* webview, const char* title, const char* link, Client* c)
+static void vb_hover_link_cb(WebKitWebView* webview, const char* title, const char* link)
 {
     if (link) {
         char* message = g_strdup_printf("Link: %s", link);
-        gtk_label_set_text(GTK_LABEL(c->gui.statusbar.left), message);
+        gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), message);
         g_free(message);
     } else {
-        vb_update_urlbar(c, webkit_web_view_get_uri(webview));
+        vb_update_urlbar(webkit_web_view_get_uri(webview));
     }
 }
 
-static void vb_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const char* title, Client* c)
+static void vb_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const char* title)
 {
-    gtk_window_set_title(GTK_WINDOW(c->gui.window), title);
+    gtk_window_set_title(GTK_WINDOW(vb.gui.window), title);
 }
 
 static gboolean vb_mimetype_decision_cb(WebKitWebView* webview,
     WebKitWebFrame* frame, WebKitNetworkRequest* request, char*
-    mime_type, WebKitWebPolicyDecision* decision, Client* c)
+    mime_type, WebKitWebPolicyDecision* decision)
 {
     if (webkit_web_view_can_show_mime_type(webview, mime_type) == FALSE) {
         webkit_web_policy_decision_download(decision);
@@ -945,7 +905,7 @@ static gboolean vb_mimetype_decision_cb(WebKitWebView* webview,
     return FALSE;
 }
 
-static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* download, Client* c)
+static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* download)
 {
     WebKitDownloadStatus status;
     char* uri = NULL;
@@ -956,15 +916,15 @@ static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* do
     }
 
     /* prepare the download target path */
-    uri = g_strdup_printf("file://%s%c%s", core.config.download_dir, G_DIR_SEPARATOR, filename);
+    uri = g_strdup_printf("file://%s%c%s", vb.config.download_dir, G_DIR_SEPARATOR, filename);
     webkit_download_set_destination_uri(download, uri);
     g_free(uri);
 
     guint64 size = webkit_download_get_total_size(download);
     if (size > 0) {
-        vb_echo(c, VB_MSG_NORMAL, FALSE, "Download %s [~%uB] started ...", filename, size);
+        vb_echo(VB_MSG_NORMAL, FALSE, "Download %s [~%uB] started ...", filename, size);
     } else {
-        vb_echo(c, VB_MSG_NORMAL, FALSE, "Download %s started ...", filename);
+        vb_echo(VB_MSG_NORMAL, FALSE, "Download %s started ...", filename);
     }
 
     status = webkit_download_get_status(download);
@@ -973,13 +933,13 @@ static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* do
     }
 
     /* prepend the download to the download list */
-    c->state.downloads = g_list_prepend(c->state.downloads, download);
+    vb.state.downloads = g_list_prepend(vb.state.downloads, download);
 
     /* connect signal handler to check if the download is done */
-    g_signal_connect(download, "notify::status", G_CALLBACK(vb_download_progress_cp), c);
-    g_signal_connect(download, "notify::progress", G_CALLBACK(vb_webview_download_progress_cb), c);
+    g_signal_connect(download, "notify::status", G_CALLBACK(vb_download_progress_cp), NULL);
+    g_signal_connect(download, "notify::progress", G_CALLBACK(vb_webview_download_progress_cb), NULL);
 
-    vb_update_statusbar(c);
+    vb_update_statusbar();
 
     return TRUE;
 }
@@ -989,7 +949,7 @@ static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* do
  */
 static void vb_request_start_cb(WebKitWebView* webview, WebKitWebFrame* frame,
     WebKitWebResource* resource, WebKitNetworkRequest* request,
-    WebKitNetworkResponse* response, Client* c)
+    WebKitNetworkResponse* response)
 {
     const char* uri = webkit_network_request_get_uri(request);
     if (g_str_has_suffix(uri, "/favicon.ico")) {
@@ -997,7 +957,7 @@ static void vb_request_start_cb(WebKitWebView* webview, WebKitWebFrame* frame,
     }
 }
 
-static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec, Client* c)
+static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec)
 {
     WebKitDownloadStatus status = webkit_download_get_status(download);
 
@@ -1007,53 +967,33 @@ static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec,
 
     char* file = g_path_get_basename(webkit_download_get_destination_uri(download));
     if (status != WEBKIT_DOWNLOAD_STATUS_FINISHED) {
-        vb_echo(c, VB_MSG_ERROR, FALSE, "Error downloading %s", file);
+        vb_echo(VB_MSG_ERROR, FALSE, "Error downloading %s", file);
     } else {
-        vb_echo(c, VB_MSG_NORMAL, FALSE, "Download %s finished", file);
+        vb_echo(VB_MSG_NORMAL, FALSE, "Download %s finished", file);
     }
     g_free(file);
 
     /* remove the donwload from the list */
-    c->state.downloads = g_list_remove(c->state.downloads, download);
+    vb.state.downloads = g_list_remove(vb.state.downloads, download);
 
-    vb_update_statusbar(c);
+    vb_update_statusbar();
 }
 
-static void vb_destroy_client(Client* c)
+static void vb_destroy_client()
 {
-    const char* uri = webkit_web_view_get_uri(c->gui.webview);
+    const char* uri = webkit_web_view_get_uri(vb.gui.webview);
     /* write last URL into file for recreation */
     if (uri) {
-        g_file_set_contents(core.files[FILES_CLOSED], uri, -1, NULL);
+        g_file_set_contents(vb.files[FILES_CLOSED], uri, -1, NULL);
     }
 
-    Client* p;
-
-    completion_clean(c);
-
-    webkit_web_view_stop_loading(c->gui.webview);
-    gtk_widget_destroy(GTK_WIDGET(c->gui.webview));
-    gtk_widget_destroy(GTK_WIDGET(c->gui.scroll));
-    gtk_widget_destroy(GTK_WIDGET(c->gui.box));
-    gtk_widget_destroy(GTK_WIDGET(c->gui.window));
-
-    for(p = clients; p && p->next != c; p = p->next);
-    if (p) {
-        p->next = c->next;
-    } else {
-        clients = c->next;
-    }
-    g_free(c);
-    if (clients == NULL) {
-        gtk_main_quit();
-    }
-}
+    completion_clean();
 
-static void vb_clean_up(void)
-{
-    while (clients) {
-        vb_destroy_client(clients);
-    }
+    webkit_web_view_stop_loading(vb.gui.webview);
+    gtk_widget_destroy(GTK_WIDGET(vb.gui.webview));
+    gtk_widget_destroy(GTK_WIDGET(vb.gui.scroll));
+    gtk_widget_destroy(GTK_WIDGET(vb.gui.box));
+    gtk_widget_destroy(GTK_WIDGET(vb.gui.window));
 
     command_cleanup();
     setting_cleanup();
@@ -1062,8 +1002,10 @@ static void vb_clean_up(void)
     url_history_cleanup();
 
     for (int i = 0; i < FILES_LAST; i++) {
-        g_free(core.files[i]);
+        g_free(vb.files[i]);
     }
+
+    gtk_main_quit();
 }
 
 int main(int argc, char* argv[])
@@ -1093,26 +1035,23 @@ int main(int argc, char* argv[])
     args = argv;
 
     if (winid) {
-        core.embed = strtol(winid, NULL, 0);
+        vb.embed = strtol(winid, NULL, 0);
     }
 
     vb_init_core();
 
-    vb_client_new();
-
     /* command line argument: URL */
     Arg arg = {VB_TARGET_CURRENT};
     if (argc > 1) {
         arg.s = g_strdup(argv[argc - 1]);
     } else {
-        arg.s = g_strdup(core.config.home_page);
+        arg.s = g_strdup(vb.config.home_page);
     }
-    vb_load_uri(clients, &arg);
+    vb_load_uri(&arg);
     g_free(arg.s);
 
     /* Run the main GTK+ event loop */
     gtk_main();
-    vb_clean_up();
 
     return EXIT_SUCCESS;
 }
index 0bb790d..6ad8a78 100644 (file)
@@ -177,8 +177,7 @@ typedef enum {
 } CompletionStyle;
 
 typedef enum {
-    FILES_GLOBAL_CONFIG,
-    FILES_LOCAL_CONFIG,
+    FILES_CONFIG,
     FILES_COOKIE,
     FILES_CLOSED,
     FILES_SCRIPT,
@@ -304,16 +303,12 @@ typedef struct {
     gulong keypress_handler;
 } Hints;
 
-/* core struct */
-typedef struct Client {
-    Gui            gui;
-    State          state;
-    Completions    comps;
-    Hints          hints;
-    struct Client* next;
-} Client;
-
 typedef struct {
+    Gui             gui;
+    State           state;
+    Completions     comps;
+    Hints           hints;
+
     char*           files[FILES_LAST];
     Config          config;
     Style           style;
@@ -331,16 +326,16 @@ typedef struct {
 extern VbCore core;
 
 /* functions */
-void vb_clean_input(Client* c);
-void vb_echo(Client* c, const MessageType type, gboolean hide, const char *error, ...);
+void vb_clean_input(void);
+void vb_echo(const MessageType type, gboolean hide, const char *error, ...);
 gboolean vb_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value);
-gboolean vb_load_uri(Client* c, const Arg* arg);
+gboolean vb_load_uri(const Arg* arg);
 gboolean vb_set_clipboard(const Arg* arg);
-gboolean vb_set_mode(Client* c, Mode mode, gboolean clean);
+gboolean vb_set_mode(Mode mode, gboolean clean);
 void vb_set_widget_font(GtkWidget* widget, const VpColor* fg, const VpColor* bg, PangoFontDescription* font);
-void vb_update_statusbar(Client* c);
-void vb_update_status_style(Client* c);
-void vb_update_input_style(Client* c, MessageType type);
-void vb_update_urlbar(Client* c, const char* uri);
+void vb_update_statusbar(void);
+void vb_update_status_style(void);
+void vb_update_input_style(MessageType type);
+void vb_update_urlbar(const char* uri);
 
 #endif /* end of include guard: _MAIN_H */
index 0a267f9..a19e076 100644 (file)
@@ -20,6 +20,8 @@
 #include "main.h"
 #include "searchengine.h"
 
+extern VbCore vb;
+
 static GSList* searchengine_find(const char* handle);
 static gboolean searchengine_is_valid_uri(const char* uri);
 static void searchengine_free(Searchengine* se);
@@ -27,8 +29,8 @@ static void searchengine_free(Searchengine* se);
 
 void searchengine_cleanup(void)
 {
-    if (core.behave.searchengines) {
-        g_slist_free_full(core.behave.searchengines, (GDestroyNotify)searchengine_free);
+    if (vb.behave.searchengines) {
+        g_slist_free_full(vb.behave.searchengines, (GDestroyNotify)searchengine_free);
     }
 }
 
@@ -43,7 +45,7 @@ gboolean searchengine_add(const char* handle, const char* uri)
     s->handle = g_strdup(handle);
     s->uri    = g_strdup(uri);
 
-    core.behave.searchengines = g_slist_prepend(core.behave.searchengines, s);
+    vb.behave.searchengines = g_slist_prepend(vb.behave.searchengines, s);
 
     return TRUE;
 }
@@ -54,7 +56,7 @@ gboolean searchengine_remove(const char* handle)
 
     if (list) {
         searchengine_free((Searchengine*)list->data);
-        core.behave.searchengines = g_slist_delete_link(core.behave.searchengines, list);
+        vb.behave.searchengines = g_slist_delete_link(vb.behave.searchengines, list);
 
         return TRUE;
     }
@@ -76,7 +78,7 @@ char* searchengine_get_uri(const char* handle)
 static GSList* searchengine_find(const char* handle)
 {
     GSList* s;
-    for (s = core.behave.searchengines; s != NULL; s = s->next) {
+    for (s = vb.behave.searchengines; s != NULL; s = s->next) {
         if (!strcmp(((Searchengine*)s->data)->handle, handle)) {
             return s;
         }
index 03c7645..a663baf 100644 (file)
 #include "setting.h"
 #include "util.h"
 
+extern VbCore vb;
+
 static Arg* setting_char_to_arg(const char* str, const Type type);
-static void setting_print_value(Client* c, const Setting* s, void* value);
-static gboolean setting_webkit(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_cookie_timeout(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_scrollstep(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_status_color_bg(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_status_color_fg(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_status_font(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_input_style(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_completion_style(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_hint_style(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_strict_ssl(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_ca_bundle(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_home_page(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_download_path(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_proxy(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_user_style(Client* c, const Setting* s, const SettingType type);
-static gboolean setting_history_max_items(Client* c, const Setting* s, const SettingType type);
+static void setting_print_value(const Setting* s, void* value);
+static gboolean setting_webkit(const Setting* s, const SettingType type);
+static gboolean setting_cookie_timeout(const Setting* s, const SettingType type);
+static gboolean setting_scrollstep(const Setting* s, const SettingType type);
+static gboolean setting_status_color_bg(const Setting* s, const SettingType type);
+static gboolean setting_status_color_fg(const Setting* s, const SettingType type);
+static gboolean setting_status_font(const Setting* s, const SettingType type);
+static gboolean setting_input_style(const Setting* s, const SettingType type);
+static gboolean setting_completion_style(const Setting* s, const SettingType type);
+static gboolean setting_hint_style(const Setting* s, const SettingType type);
+static gboolean setting_strict_ssl(const Setting* s, const SettingType type);
+static gboolean setting_ca_bundle(const Setting* s, const SettingType type);
+static gboolean setting_home_page(const Setting* s, const SettingType type);
+static gboolean setting_download_path(const Setting* s, const SettingType type);
+static gboolean setting_proxy(const Setting* s, const SettingType type);
+static gboolean setting_user_style(const Setting* s, const SettingType type);
+static gboolean setting_history_max_items(const Setting* s, const SettingType type);
 
 static Setting default_settings[] = {
     /* webkit settings */
@@ -124,46 +126,28 @@ static Setting default_settings[] = {
     {NULL, "history-max-items", TYPE_INTEGER, setting_history_max_items, {.i = 500}, TRUE},
 };
 
-extern Client* clients;
-
 void setting_init(void)
 {
     Setting* s;
     guint i;
-    core.settings = g_hash_table_new(g_str_hash, g_str_equal);
+    vb.settings = g_hash_table_new(g_str_hash, g_str_equal);
 
     for (i = 0; i < LENGTH(default_settings); i++) {
         s = &default_settings[i];
         /* use alias as key if available */
-        g_hash_table_insert(core.settings, (gpointer)s->alias != NULL ? s->alias : s->name, s);
-
-        /* set the global settings */
-        if (s->global) {
-            s->func(NULL, s, FALSE);
-        }
-    }
-}
-
-void setting_init_client(Client* c)
-{
-    Setting* s = NULL;
-    /* set the default settings */
-    for (int i = 0; i < LENGTH(default_settings); i++) {
-        s = &default_settings[i];
-        if (!s->global) {
-            s->func(c, s, FALSE);
-        }
+        g_hash_table_insert(vb.settings, (gpointer)s->alias != NULL ? s->alias : s->name, s);
+        s->func(s, FALSE);
     }
 }
 
 void setting_cleanup(void)
 {
-    if (core.settings) {
-        g_hash_table_destroy(core.settings);
+    if (vb.settings) {
+        g_hash_table_destroy(vb.settings);
     }
 }
 
-gboolean setting_run(Client* c, char* name, const char* param)
+gboolean setting_run(char* name, const char* param)
 {
     Arg* a          = NULL;
     gboolean result = FALSE;
@@ -182,15 +166,9 @@ gboolean setting_run(Client* c, char* name, const char* param)
         type = SETTING_GET;
     }
 
-    Setting* s = g_hash_table_lookup(core.settings, name);
+    Setting* s = g_hash_table_lookup(vb.settings, name);
     if (!s) {
-        vb_echo(c, VB_MSG_ERROR, TRUE, "Config '%s' not found", name);
-        return FALSE;
-    }
-
-    /* don't process locl settings if no client is given */
-    if (!c && !s->global) {
-        fprintf(stderr, "Can't set local config %s without client\n", s->alias ? s->alias : s->name);
+        vb_echo(VB_MSG_ERROR, TRUE, "Config '%s' not found", name);
         return FALSE;
     }
 
@@ -199,28 +177,28 @@ gboolean setting_run(Client* c, char* name, const char* param)
          * it to the arg of the setting */
         a = setting_char_to_arg(param, s->type);
         if (a == NULL) {
-            vb_echo(c, VB_MSG_ERROR, TRUE, "No valid value");
+            vb_echo(VB_MSG_ERROR, TRUE, "No valid value");
             return FALSE;
         }
 
         s->arg = *a;
-        result = s->func(c, s, get);
+        result = s->func(s, get);
         if (a->s) {
             g_free(a->s);
         }
         g_free(a);
 
         if (!result) {
-            vb_echo(c, VB_MSG_ERROR, TRUE, "Could not set %s", s->alias ? s->alias : s->name);
+            vb_echo(VB_MSG_ERROR, TRUE, "Could not set %s", s->alias ? s->alias : s->name);
         }
 
         return result;
     }
 
     if (type == SETTING_GET) {
-        result = s->func(c, s, type);
+        result = s->func(s, type);
         if (!result) {
-            vb_echo(c, VB_MSG_ERROR, TRUE, "Could not get %s", s->alias ? s->alias : s->name);
+            vb_echo(VB_MSG_ERROR, TRUE, "Could not get %s", s->alias ? s->alias : s->name);
         }
 
         return result;
@@ -228,14 +206,14 @@ gboolean setting_run(Client* c, char* name, const char* param)
 
     /* toggle bolean vars */
     if (s->type != TYPE_BOOLEAN) {
-        vb_echo(c, VB_MSG_ERROR, TRUE, "Could not toggle none boolean %s", s->alias ? s->alias : s->name);
+        vb_echo(VB_MSG_ERROR, TRUE, "Could not toggle none boolean %s", s->alias ? s->alias : s->name);
 
         return FALSE;
     }
 
-    result = s->func(c, s, type);
+    result = s->func(s, type);
     if (!result) {
-        vb_echo(c, VB_MSG_ERROR, TRUE, "Could not toggle %s", s->alias ? s->alias : s->name);
+        vb_echo(VB_MSG_ERROR, TRUE, "Could not toggle %s", s->alias ? s->alias : s->name);
     }
 
     return result;
@@ -278,48 +256,45 @@ static Arg* setting_char_to_arg(const char* str, const Type type)
 /**
  * Print the setting value to the input box.
  */
-static void setting_print_value(Client* c, const Setting* s, void* value)
+static void setting_print_value(const Setting* s, void* value)
 {
-    if (!c) {
-        return;
-    }
     const char* name = s->alias ? s->alias : s->name;
     char* string = NULL;
 
     switch (s->type) {
         case TYPE_BOOLEAN:
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "  %s=%s", name, *(gboolean*)value ? "true" : "false");
+            vb_echo(VB_MSG_NORMAL, FALSE, "  %s=%s", name, *(gboolean*)value ? "true" : "false");
             break;
 
         case TYPE_INTEGER:
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "  %s=%d", name, *(int*)value);
+            vb_echo(VB_MSG_NORMAL, FALSE, "  %s=%d", name, *(int*)value);
             break;
 
         case TYPE_FLOAT:
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "  %s=%g", name, *(gfloat*)value);
+            vb_echo(VB_MSG_NORMAL, FALSE, "  %s=%g", name, *(gfloat*)value);
             break;
 
         case TYPE_CHAR:
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "  %s=%s", name, (char*)value);
+            vb_echo(VB_MSG_NORMAL, FALSE, "  %s=%s", name, (char*)value);
             break;
 
         case TYPE_COLOR:
             string = VB_COLOR_TO_STRING((VpColor*)value);
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "  %s=%s", name, string);
+            vb_echo(VB_MSG_NORMAL, FALSE, "  %s=%s", name, string);
             g_free(string);
             break;
 
         case TYPE_FONT:
             string = pango_font_description_to_string((PangoFontDescription*)value);
-            vb_echo(c, VB_MSG_NORMAL, FALSE, "  %s=%s", name, string);
+            vb_echo(VB_MSG_NORMAL, FALSE, "  %s=%s", name, string);
             g_free(string);
             break;
     }
 }
 
-static gboolean setting_webkit(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_webkit(const Setting* s, const SettingType type)
 {
-    WebKitWebSettings* web_setting = webkit_web_view_get_settings(c->gui.webview);
+    WebKitWebSettings* web_setting = webkit_web_view_get_settings(vb.gui.webview);
 
     switch (s->type) {
         case TYPE_BOOLEAN:
@@ -335,7 +310,7 @@ static gboolean setting_webkit(Client* c, const Setting* s, const SettingType ty
                 }
 
                 /* print the new value */
-                setting_print_value(c, s, &value);
+                setting_print_value(s, &value);
             } else {
                 g_object_set(G_OBJECT(web_setting), s->name, s->arg.i ? TRUE : FALSE, NULL);
             }
@@ -345,7 +320,7 @@ static gboolean setting_webkit(Client* c, const Setting* s, const SettingType ty
             if (type == SETTING_GET) {
                 int value;
                 g_object_get(G_OBJECT(web_setting), s->name, &value, NULL);
-                setting_print_value(c, s, &value);
+                setting_print_value(s, &value);
             } else {
                 g_object_set(G_OBJECT(web_setting), s->name, s->arg.i, NULL);
             }
@@ -355,7 +330,7 @@ static gboolean setting_webkit(Client* c, const Setting* s, const SettingType ty
             if (type == SETTING_GET) {
                 gfloat value;
                 g_object_get(G_OBJECT(web_setting), s->name, &value, NULL);
-                setting_print_value(c, s, &value);
+                setting_print_value(s, &value);
             } else {
                 g_object_set(G_OBJECT(web_setting), s->name, (gfloat)(s->arg.i / 1000000.0), NULL);
             }
@@ -367,7 +342,7 @@ static gboolean setting_webkit(Client* c, const Setting* s, const SettingType ty
             if (type == SETTING_GET) {
                 char* value = NULL;
                 g_object_get(G_OBJECT(web_setting), s->name, &value, NULL);
-                setting_print_value(c, s, value);
+                setting_print_value(s, value);
             } else {
                 g_object_set(G_OBJECT(web_setting), s->name, s->arg.s, NULL);
             }
@@ -376,29 +351,29 @@ static gboolean setting_webkit(Client* c, const Setting* s, const SettingType ty
 
     return TRUE;
 }
-static gboolean setting_cookie_timeout(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_cookie_timeout(const Setting* s, const SettingType type)
 {
     if (type == SETTING_GET) {
-        setting_print_value(c, s, &core.config.cookie_timeout);
+        setting_print_value(s, &vb.config.cookie_timeout);
     } else {
-        core.config.cookie_timeout = s->arg.i;
+        vb.config.cookie_timeout = s->arg.i;
     }
 
     return TRUE;
 }
 
-static gboolean setting_scrollstep(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_scrollstep(const Setting* s, const SettingType type)
 {
     if (type == SETTING_GET) {
-        setting_print_value(c, s, &core.config.scrollstep);
+        setting_print_value(s, &vb.config.scrollstep);
     } else {
-        core.config.scrollstep = s->arg.i;
+        vb.config.scrollstep = s->arg.i;
     }
 
     return TRUE;
 }
 
-static gboolean setting_status_color_bg(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_status_color_bg(const Setting* s, const SettingType type)
 {
     StatusType stype;
     if (g_str_has_prefix(s->name, "status-sslinvalid")) {
@@ -410,19 +385,16 @@ static gboolean setting_status_color_bg(Client* c, const Setting* s, const Setti
     }
 
     if (type == SETTING_GET) {
-        setting_print_value(c, s, &core.style.status_bg[stype]);
+        setting_print_value(s, &vb.style.status_bg[stype]);
     } else {
-        VB_COLOR_PARSE(&core.style.status_bg[stype], s->arg.s);
-        /* update the status style for all clients */
-        for(Client* p = clients; p; p = p->next) {
-            vb_update_status_style(p);
-        }
+        VB_COLOR_PARSE(&vb.style.status_bg[stype], s->arg.s);
+        vb_update_status_style();
     }
 
     return TRUE;
 }
 
-static gboolean setting_status_color_fg(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_status_color_fg(const Setting* s, const SettingType type)
 {
     StatusType stype;
     if (g_str_has_prefix(s->name, "status-sslinvalid")) {
@@ -434,19 +406,16 @@ static gboolean setting_status_color_fg(Client* c, const Setting* s, const Setti
     }
 
     if (type == SETTING_GET) {
-        setting_print_value(c, s, &core.style.status_fg[stype]);
+        setting_print_value(s, &vb.style.status_fg[stype]);
     } else {
-        VB_COLOR_PARSE(&core.style.status_fg[stype], s->arg.s);
-        /* update the status style for all clients */
-        for(Client* p = clients; p; p = p->next) {
-            vb_update_status_style(p);
-        }
+        VB_COLOR_PARSE(&vb.style.status_fg[stype], s->arg.s);
+        vb_update_status_style();
     }
 
     return TRUE;
 }
 
-static gboolean setting_status_font(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_status_font(const Setting* s, const SettingType type)
 {
     StatusType stype;
     if (g_str_has_prefix(s->name, "status-sslinvalid")) {
@@ -458,31 +427,28 @@ static gboolean setting_status_font(Client* c, const Setting* s, const SettingTy
     }
 
     if (type == SETTING_GET) {
-        setting_print_value(c, s, core.style.status_font[stype]);
+        setting_print_value(s, vb.style.status_font[stype]);
     } else {
-        if (core.style.status_font[stype]) {
+        if (vb.style.status_font[stype]) {
             /* free previous font description */
-            pango_font_description_free(core.style.status_font[stype]);
-        }
-        core.style.status_font[stype] = pango_font_description_from_string(s->arg.s);
-        /* update the status style for all clients */
-        for(Client* p = clients; p; p = p->next) {
-            vb_update_status_style(p);
+            pango_font_description_free(vb.style.status_font[stype]);
         }
+        vb.style.status_font[stype] = pango_font_description_from_string(s->arg.s);
+        vb_update_status_style();
     }
 
     return TRUE;
 }
 
-static gboolean setting_input_style(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_input_style(const Setting* s, const SettingType type)
 {
-    Style* style = &core.style;
+    Style* style = &vb.style;
     MessageType itype = g_str_has_suffix(s->name, "normal") ? VB_MSG_NORMAL : VB_MSG_ERROR;
 
     if (s->type == TYPE_FONT) {
         /* input font */
         if (type == SETTING_GET) {
-            setting_print_value(c, s, style->input_font[itype]);
+            setting_print_value(s, style->input_font[itype]);
         } else {
             if (style->input_font[itype]) {
                 pango_font_description_free(style->input_font[itype]);
@@ -500,37 +466,34 @@ static gboolean setting_input_style(Client* c, const Setting* s, const SettingTy
         }
 
         if (type == SETTING_GET) {
-            setting_print_value(c, s, color);
+            setting_print_value(s, color);
         } else {
             VB_COLOR_PARSE(color, s->arg.s);
         }
     }
     if (type != SETTING_GET) {
-        /* update the inputbox style for all clients */
-        for(Client* p = clients; p; p = p->next) {
-            /* vb_update_input_style seems to take no immediatly effect */
-            vb_echo(p, VB_MSG_NORMAL, FALSE, gtk_entry_get_text(GTK_ENTRY(p->gui.inputbox)));
-        }
+        /* vb_update_input_style seems to take no immediatly effect */
+        vb_echo(VB_MSG_NORMAL, FALSE, gtk_entry_get_text(GTK_ENTRY(vb.gui.inputbox)));
     }
 
     return TRUE;
 }
 
-static gboolean setting_completion_style(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_completion_style(const Setting* s, const SettingType type)
 {
-    Style* style = &core.style;
+    Style* style = &vb.style;
     CompletionStyle ctype = g_str_has_suffix(s->name, "normal") ? VB_COMP_NORMAL : VB_COMP_ACTIVE;
 
     if (s->type == TYPE_INTEGER) {
         /* max completion items */
         if (type == SETTING_GET) {
-            setting_print_value(c, s, &core.config.max_completion_items);
+            setting_print_value(s, &vb.config.max_completion_items);
         } else {
-            core.config.max_completion_items = s->arg.i;
+            vb.config.max_completion_items = s->arg.i;
         }
     } else if (s->type == TYPE_FONT) {
         if (type == SETTING_GET) {
-            setting_print_value(c, s, style->comp_font);
+            setting_print_value(s, style->comp_font);
         } else {
             if (style->comp_font) {
                 pango_font_description_free(style->comp_font);
@@ -548,7 +511,7 @@ static gboolean setting_completion_style(Client* c, const Setting* s, const Sett
         }
 
         if (type == SETTING_GET) {
-            setting_print_value(c, s, color);
+            setting_print_value(s, color);
         } else {
             VB_COLOR_PARSE(color, s->arg.s);
         }
@@ -557,30 +520,30 @@ static gboolean setting_completion_style(Client* c, const Setting* s, const Sett
     return TRUE;
 }
 
-static gboolean setting_hint_style(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_hint_style(const Setting* s, const SettingType type)
 {
-    Style* style = &core.style;
+    Style* style = &vb.style;
     if (!g_strcmp0(s->name, "hint-bg")) {
         if (type == SETTING_GET) {
-            setting_print_value(c, s, style->hint_bg);
+            setting_print_value(s, style->hint_bg);
         } else {
             OVERWRITE_STRING(style->hint_bg, s->arg.s)
         }
     } else if (!g_strcmp0(s->name, "hint-bg-focus")) {
         if (type == SETTING_GET) {
-            setting_print_value(c, s, style->hint_bg_focus);
+            setting_print_value(s, style->hint_bg_focus);
         } else {
             OVERWRITE_STRING(style->hint_bg_focus, s->arg.s)
         }
     } else if (!g_strcmp0(s->name, "hint-fg")) {
         if (type == SETTING_GET) {
-            setting_print_value(c, s, style->hint_fg);
+            setting_print_value(s, style->hint_fg);
         } else {
             OVERWRITE_STRING(style->hint_fg, s->arg.s)
         }
     } else {
         if (type == SETTING_GET) {
-            setting_print_value(c, s, style->hint_style);
+            setting_print_value(s, style->hint_style);
         } else {
             OVERWRITE_STRING(style->hint_style, s->arg.s);
         }
@@ -589,13 +552,13 @@ static gboolean setting_hint_style(Client* c, const Setting* s, const SettingTyp
     return TRUE;
 }
 
-static gboolean setting_strict_ssl(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_strict_ssl(const Setting* s, const SettingType type)
 {
     gboolean value;
     if (type != SETTING_SET) {
-        g_object_get(core.soup_session, "ssl-strict", &value, NULL);
+        g_object_get(vb.soup_session, "ssl-strict", &value, NULL);
         if (type == SETTING_GET) {
-            setting_print_value(c, s, &value);
+            setting_print_value(s, &value);
 
             return TRUE;
         }
@@ -603,70 +566,70 @@ static gboolean setting_strict_ssl(Client* c, const Setting* s, const SettingTyp
 
     value = type == SETTING_TOGGLE ? !value : (s->arg.i ? TRUE : FALSE);
 
-    g_object_set(core.soup_session, "ssl-strict", value, NULL);
+    g_object_set(vb.soup_session, "ssl-strict", value, NULL);
 
     return TRUE;
 }
 
-static gboolean setting_ca_bundle(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_ca_bundle(const Setting* s, const SettingType type)
 {
     if (type == SETTING_GET) {
         char* value = NULL;
-        g_object_get(core.soup_session, "ssl-ca-file", &value, NULL);
-        setting_print_value(c, s, value);
+        g_object_get(vb.soup_session, "ssl-ca-file", &value, NULL);
+        setting_print_value(s, value);
         g_free(value);
     } else {
-        g_object_set(core.soup_session, "ssl-ca-file", s->arg.s, NULL);
+        g_object_set(vb.soup_session, "ssl-ca-file", s->arg.s, NULL);
     }
 
     return TRUE;
 }
 
-static gboolean setting_home_page(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_home_page(const Setting* s, const SettingType type)
 {
     if (type == SETTING_GET) {
-        setting_print_value(c, s, core.config.home_page);
+        setting_print_value(s, vb.config.home_page);
     } else {
-        OVERWRITE_STRING(core.config.home_page, s->arg.s);
+        OVERWRITE_STRING(vb.config.home_page, s->arg.s);
     }
 
     return TRUE;
 }
 
-static gboolean setting_download_path(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_download_path(const Setting* s, const SettingType type)
 {
     if (type == SETTING_GET) {
-        setting_print_value(c, s, core.config.download_dir);
+        setting_print_value(s, vb.config.download_dir);
     } else {
-        if (core.config.download_dir) {
-            g_free(core.config.download_dir);
-            core.config.download_dir = NULL;
+        if (vb.config.download_dir) {
+            g_free(vb.config.download_dir);
+            vb.config.download_dir = NULL;
         }
         /* if path is not absolute create it in the home directory */
         if (s->arg.s[0] != '/') {
-            core.config.download_dir = g_build_filename(util_get_home_dir(), s->arg.s, NULL);
+            vb.config.download_dir = g_build_filename(util_get_home_dir(), s->arg.s, NULL);
         } else {
-            core.config.download_dir = g_strdup(s->arg.s);
+            vb.config.download_dir = g_strdup(s->arg.s);
         }
         /* create the path if it does not exist */
-        util_create_dir_if_not_exists(core.config.download_dir);
+        util_create_dir_if_not_exists(vb.config.download_dir);
     }
 
     return TRUE;
 }
 
-static gboolean setting_proxy(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_proxy(const Setting* s, const SettingType type)
 {
     gboolean enabled;
     SoupURI* proxy_uri = NULL;
 
     /* get the current status */
     if (type != SETTING_SET) {
-        g_object_get(core.soup_session, "proxy-uri", &proxy_uri, NULL);
+        g_object_get(vb.soup_session, "proxy-uri", &proxy_uri, NULL);
         enabled = (proxy_uri != NULL);
 
         if (type == SETTING_GET) {
-            setting_print_value(c, s, &enabled);
+            setting_print_value(s, &enabled);
 
             return TRUE;
         }
@@ -675,7 +638,7 @@ static gboolean setting_proxy(Client* c, const Setting* s, const SettingType typ
     if (type == SETTING_TOGGLE) {
         enabled = !enabled;
         /* print the new value */
-        setting_print_value(c, s, &enabled);
+        setting_print_value(s, &enabled);
     } else {
         enabled = s->arg.i;
     }
@@ -688,29 +651,29 @@ static gboolean setting_proxy(Client* c, const Setting* s, const SettingType typ
                 : g_strdup_printf("http://%s", proxy);
             proxy_uri = soup_uri_new(proxy_new);
 
-            g_object_set(core.soup_session, "proxy-uri", proxy_uri, NULL);
+            g_object_set(vb.soup_session, "proxy-uri", proxy_uri, NULL);
 
             soup_uri_free(proxy_uri);
             g_free(proxy_new);
         }
     } else {
-        g_object_set(core.soup_session, "proxy-uri", NULL, NULL);
+        g_object_set(vb.soup_session, "proxy-uri", NULL, NULL);
     }
 
     return TRUE;
 }
 
-static gboolean setting_user_style(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_user_style(const Setting* s, const SettingType type)
 {
     gboolean enabled = FALSE;
     char* uri = NULL;
-    WebKitWebSettings* web_setting = webkit_web_view_get_settings(c->gui.webview);
+    WebKitWebSettings* web_setting = webkit_web_view_get_settings(vb.gui.webview);
     if (type != SETTING_SET) {
         g_object_get(web_setting, "user-stylesheet-uri", &uri, NULL);
         enabled = (uri != NULL);
 
         if (type == SETTING_GET) {
-            setting_print_value(c, s, &enabled);
+            setting_print_value(s, &enabled);
 
             return TRUE;
         }
@@ -719,13 +682,13 @@ static gboolean setting_user_style(Client* c, const Setting* s, const SettingTyp
     if (type == SETTING_TOGGLE) {
         enabled = !enabled;
         /* print the new value */
-        setting_print_value(c, s, &enabled);
+        setting_print_value(s, &enabled);
     } else {
         enabled = s->arg.i;
     }
 
     if (enabled) {
-        uri = g_strconcat("file://", core.files[FILES_USER_STYLE], NULL);
+        uri = g_strconcat("file://", vb.files[FILES_USER_STYLE], NULL);
         g_object_set(web_setting, "user-stylesheet-uri", uri, NULL);
         g_free(uri);
     } else {
@@ -735,15 +698,15 @@ static gboolean setting_user_style(Client* c, const Setting* s, const SettingTyp
     return TRUE;
 }
 
-static gboolean setting_history_max_items(Client* c, const Setting* s, const SettingType type)
+static gboolean setting_history_max_items(const Setting* s, const SettingType type)
 {
     if (type == SETTING_GET) {
-        setting_print_value(c, s, &core.config.url_history_max);
+        setting_print_value(s, &vb.config.url_history_max);
 
         return TRUE;
     }
 
-    core.config.url_history_max = s->arg.i;
+    vb.config.url_history_max = s->arg.i;
 
     return TRUE;
 }
index 618f818..4201690 100644 (file)
@@ -29,7 +29,7 @@ typedef enum {
 } SettingType;
 
 typedef struct _Setting Setting;
-typedef gboolean (*SettingFunc)(Client* c, const Setting*, const SettingType);
+typedef gboolean (*SettingFunc)(const Setting*, const SettingType);
 
 struct _Setting {
     char*       alias;
@@ -41,8 +41,7 @@ struct _Setting {
 };
 
 void setting_init(void);
-void setting_init_client(Client* c);
 void setting_cleanup(void);
-gboolean setting_run(Client* c, char* name, const char* param);
+gboolean setting_run(char* name, const char* param);
 
 #endif /* end of include guard: _SETTING_H */
index a2bc8b3..5ebcbfe 100644 (file)
@@ -1,6 +1,26 @@
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2013 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
 #include "main.h"
 #include "url_history.h"
 
+extern VbCore vb;
 static void url_history_free(UrlHist* item);
 
 
@@ -8,8 +28,8 @@ void url_history_init(void)
 {
     /* read the history items from file */
     char buf[512] = {0};
-    guint max = core.config.url_history_max;
-    FILE* file = fopen(core.files[FILES_HISTORY], "r");
+    guint max = vb.config.url_history_max;
+    FILE* file = fopen(vb.files[FILES_HISTORY], "r");
     if (!file) {
         return;
     }
@@ -29,18 +49,18 @@ void url_history_init(void)
     fclose(file);
 
     /* reverse the history because we read it from lates to old from file */
-    core.behave.url_history = g_list_reverse(core.behave.url_history);
+    vb.behave.url_history = g_list_reverse(vb.behave.url_history);
 }
 
 void url_history_cleanup(void)
 {
-    FILE* file = fopen(core.files[FILES_HISTORY], "w");
+    FILE* file = fopen(vb.files[FILES_HISTORY], "w");
     if (file) {
         file_lock_set(fileno(file), F_WRLCK);
 
         /* write the history to the file */
         GList* link;
-        for (link = core.behave.url_history; link != NULL; link = link->next) {
+        for (link = vb.behave.url_history; link != NULL; link = link->next) {
             UrlHist* item = (UrlHist*)link->data;
             char* title = g_shell_quote(item->title ? item->title : "");
             char* new   = g_strdup_printf("%s %s\n", item->uri, title);
@@ -54,8 +74,8 @@ void url_history_cleanup(void)
         fclose(file);
     }
 
-    if (core.behave.url_history) {
-        g_list_free_full(core.behave.url_history, (GDestroyNotify)url_history_free);
+    if (vb.behave.url_history) {
+        g_list_free_full(vb.behave.url_history, (GDestroyNotify)url_history_free);
     }
 }
 
@@ -63,27 +83,27 @@ void url_history_add(const char* url, const char* title)
 {
     /* uf the url is already in history, remove this entry */
     /* TODO use g_list_find_custom for this task */
-    for (GList* link = core.behave.url_history; link; link = link->next) {
+    for (GList* link = vb.behave.url_history; link; link = link->next) {
         UrlHist* hi = (UrlHist*)link->data;
         if (!g_strcmp0(url, hi->uri)) {
             url_history_free(hi);
-            core.behave.url_history = g_list_delete_link(core.behave.url_history, link);
+            vb.behave.url_history = g_list_delete_link(vb.behave.url_history, link);
             break;
         }
     }
 
-    while (core.config.url_history_max < g_list_length(core.behave.url_history)) {
+    while (vb.config.url_history_max < g_list_length(vb.behave.url_history)) {
         /* if list is too long - remove items from end */
-        GList* last = g_list_last(core.behave.url_history);
+        GList* last = g_list_last(vb.behave.url_history);
         url_history_free((UrlHist*)last->data);
-        core.behave.url_history = g_list_delete_link(core.behave.url_history, last);
+        vb.behave.url_history = g_list_delete_link(vb.behave.url_history, last);
     }
 
     UrlHist* item = g_new0(UrlHist, 1);
     item->uri   = g_strdup(url);
     item->title = title ? g_strdup(title) : NULL;
 
-    core.behave.url_history = g_list_prepend(core.behave.url_history, item);
+    vb.behave.url_history = g_list_prepend(vb.behave.url_history, item);
 }
 
 /**
@@ -91,7 +111,7 @@ void url_history_add(const char* url, const char* title)
  */
 void url_history_get_all(GList** list)
 {
-    for (GList* link = core.behave.url_history; link; link = link->next) {
+    for (GList* link = vb.behave.url_history; link; link = link->next) {
         UrlHist* hi = (UrlHist*)link->data;
         /* put only the url in the list - do not allocate new memory */
         *list = g_list_prepend(*list, hi->uri);
index 7e2cabd..68012db 100644 (file)
@@ -1,3 +1,22 @@
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2013 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
 #ifndef _URL_HISTORY_H
 #define _URL_HISTORY_H