void command_init(void)
{
guint i;
- vp.behave.commands = g_hash_table_new(g_str_hash, g_str_equal);
+ core.behave.commands = g_hash_table_new(g_str_hash, g_str_equal);
for (i = 0; i < LENGTH(cmd_list); i++) {
- g_hash_table_insert(vp.behave.commands, (gpointer)cmd_list[i].name, &cmd_list[i]);
+ g_hash_table_insert(core.behave.commands, (gpointer)cmd_list[i].name, &cmd_list[i]);
}
}
void command_cleanup(void)
{
- if (vp.behave.commands) {
- g_hash_table_destroy(vp.behave.commands);
+ if (core.behave.commands) {
+ g_hash_table_destroy(core.behave.commands);
}
}
gboolean command_exists(const char* name)
{
- return g_hash_table_contains(vp.behave.commands, name);
+ return g_hash_table_contains(core.behave.commands, name);
}
gboolean command_run(const char* name, const char* param)
CommandInfo* c = NULL;
gboolean result;
Arg a;
- c = g_hash_table_lookup(vp.behave.commands, name);
+ c = g_hash_table_lookup(core.behave.commands, name);
if (!c) {
vp_echo(VP_MSG_ERROR, TRUE, "Command '%s' not found", name);
vp_set_mode(VP_MODE_NORMAL, FALSE);
gboolean result;
if (!arg->s || arg->s[0] == '\0') {
- Arg a = {arg->i, vp.config.home_page};
+ Arg a = {arg->i, core.config.home_page};
return vp_load_uri(&a);
}
/* check for searchengine handles */
gboolean result;
Arg a = {arg->i};
- a.s = util_get_file_contents(vp.files[FILES_CLOSED], NULL);
+ a.s = util_get_file_contents(core.files[FILES_CLOSED], NULL);
result = vp_load_uri(&a);
g_free(a.s);
gdouble value;
int count = vp.state.count ? vp.state.count : 1;
if (arg->i & VP_SCROLL_UNIT_LINE) {
- value = vp.config.scrollstep;
+ value = core.config.scrollstep;
} else if (arg->i & VP_SCROLL_UNIT_HALFPAGE) {
value = gtk_adjustment_get_page_size(adjust) / 2;
} else {
gboolean command_history(const Arg* arg)
{
- State* state = &vp.state;
- const int len = g_list_length(state->history);
+ const int len = g_list_length(core.behave.history);
char* message = NULL;
- const int count = state->count ? state->count : 1;
+ const int count = vp.state.count ? vp.state.count : 1;
if (!len) {
return FALSE;
}
if (arg->i == VP_SEARCH_BACKWARD) {
- state->history_pointer = (len + state->history_pointer - count) % len;
+ core.behave.history_pointer = (len + core.behave.history_pointer - count) % len;
} else {
- state->history_pointer = (len + state->history_pointer + count) % len;
+ core.behave.history_pointer = (len + core.behave.history_pointer + count) % len;
}
- const char* command = (char*)g_list_nth_data(state->history, state->history_pointer);
+ const char* command = (char*)g_list_nth_data(core.behave.history, core.behave.history_pointer);
message = g_strconcat(arg->s, command, NULL);
command_write_input(message);
g_free(message);
/* reset the colors and fonts to defalts */
vp_set_widget_font(
vp.gui.inputbox,
- &vp.style.input_fg[VP_MSG_NORMAL],
- &vp.style.input_bg[VP_MSG_NORMAL],
- vp.style.input_font[VP_MSG_NORMAL]
+ &core.style.input_fg[VP_MSG_NORMAL],
+ &core.style.input_bg[VP_MSG_NORMAL],
+ core.style.input_font[VP_MSG_NORMAL]
);
/* remove content from input box */
input = GET_TEXT();
/* TODO move these decision to a more generic place */
if (g_str_has_prefix(input, ":set ")) {
- source = g_hash_table_get_keys(vp.settings);
+ source = g_hash_table_get_keys(core.settings);
source = g_list_sort(source, (GCompareFunc)g_strcmp0);
vp.comps.completions = completion_init_completion(vp.comps.completions, source, ":set ");
} else {
- source = g_hash_table_get_keys(vp.behave.commands);
+ source = g_hash_table_get_keys(core.behave.commands);
source = g_list_sort(source, (GCompareFunc)g_strcmp0);
vp.comps.completions = completion_init_completion(vp.comps.completions, source, ":");
}
Completion *c;
int length = g_list_length(completion);
- int max = vp.config.max_completion_items;
+ int max = core.config.max_completion_items;
int items = MAX(length, max);
int r = (max) % 2;
int offset = max / 2 - 1 + r;
completion_set_color(
old->data,
- &vp.style.comp_fg[VP_COMP_NORMAL],
- &vp.style.comp_bg[VP_COMP_NORMAL],
- vp.style.comp_font[VP_COMP_NORMAL]
+ &core.style.comp_fg[VP_COMP_NORMAL],
+ &core.style.comp_bg[VP_COMP_NORMAL],
+ core.style.comp_font[VP_COMP_NORMAL]
);
completion_set_color(
new->data,
- &vp.style.comp_fg[VP_COMP_ACTIVE],
- &vp.style.comp_bg[VP_COMP_ACTIVE],
- vp.style.comp_font[VP_COMP_ACTIVE]
+ &core.style.comp_fg[VP_COMP_ACTIVE],
+ &core.style.comp_bg[VP_COMP_ACTIVE],
+ core.style.comp_font[VP_COMP_ACTIVE]
);
active = new;
/* allow to chenge the direction of display */
static void completion_show(gboolean back)
{
- guint max = vp.config.max_completion_items;
+ guint max = core.config.max_completion_items;
int i = 0;
if (back) {
vp.comps.active = g_list_last(vp.comps.completions);
if (vp.comps.active != NULL) {
completion_set_color(
vp.comps.active->data,
- &vp.style.comp_fg[VP_COMP_ACTIVE],
- &vp.style.comp_bg[VP_COMP_ACTIVE],
- vp.style.comp_font[VP_COMP_ACTIVE]
+ &core.style.comp_fg[VP_COMP_ACTIVE],
+ &core.style.comp_bg[VP_COMP_ACTIVE],
+ core.style.comp_font[VP_COMP_ACTIVE]
);
completion_set_entry_text(vp.comps.active->data);
gtk_widget_show(vp.gui.compbox);
completion_set_color(
c,
- &vp.style.comp_fg[VP_COMP_NORMAL],
- &vp.style.comp_bg[VP_COMP_NORMAL],
- vp.style.comp_font[VP_COMP_NORMAL]
+ &core.style.comp_fg[VP_COMP_NORMAL],
+ &core.style.comp_bg[VP_COMP_NORMAL],
+ core.style.comp_font[VP_COMP_NORMAL]
);
GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1, 1);
gulong left = rect.left - 3;
gulong top = rect.top - 3;
- dom_element_set_style(hint, HINT_STYLE, left, top, vp.style.hint_style);
+ dom_element_set_style(hint, HINT_STYLE, left, top, core.style.hint_style);
char* num = g_strdup_printf("%li", newHint->num);
webkit_dom_html_element_set_inner_text(WEBKIT_DOM_HTML_ELEMENT(hint), num, NULL);
g_free(num);
/* change the style of the hinted element */
- dom_element_style_set_property(newHint->elem, "background-color", vp.style.hint_bg);
- dom_element_style_set_property(newHint->elem, "color", vp.style.hint_fg);
+ dom_element_style_set_property(newHint->elem, "background-color", core.style.hint_bg);
+ dom_element_style_set_property(newHint->elem, "color", core.style.hint_fg);
webkit_dom_node_append_child(WEBKIT_DOM_NODE(container), WEBKIT_DOM_NODE(hint), NULL);
}
Hint* hint = hints_get_hint_by_number(vp.hints.focusNum);
if (hint) {
/* reset previous focused element */
- dom_element_style_set_property(hint->elem, "background-color", vp.style.hint_bg);
+ dom_element_style_set_property(hint->elem, "background-color", core.style.hint_bg);
doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(hint->elem));
dom_dispatch_mouse_event(doc, hint->elem, "mouseout", 0);
hint = hints_get_hint_by_number(num);
if (hint) {
/* mark new hint as focused */
- dom_element_style_set_property(hint->elem, "background-color", vp.style.hint_bg_focus);
+ dom_element_style_set_property(hint->elem, "background-color", core.style.hint_bg_focus);
doc = webkit_dom_node_get_owner_document(WEBKIT_DOM_NODE(hint->elem));
dom_dispatch_mouse_event(doc, hint->elem, "mouseover", 0);
void history_cleanup(void)
{
- g_list_free_full(vp.state.history, (GDestroyNotify)g_free);
+ g_list_free_full(core.behave.history, (GDestroyNotify)g_free);
}
void history_append(const char* line)
{
- State *s = &vp.state;
-
- if (COMMAND_HISTORY_SIZE <= g_list_length(s->history)) {
+ if (COMMAND_HISTORY_SIZE <= g_list_length(core.behave.history)) {
/* if list is too long - remove items from beginning */
- s->history = g_list_delete_link(s->history, g_list_first(s->history));
+ core.behave.history = g_list_delete_link(core.behave.history, g_list_first(core.behave.history));
}
- s->history = g_list_append(s->history, g_strdup(line));
+ core.behave.history = g_list_append(core.behave.history, g_strdup(line));
}
void history_rewind(void)
{
- vp.state.history_pointer = 0;
+ core.behave.history_pointer = 0;
}
void keybind_init(void)
{
- vp.behave.modkeys = g_string_new("");
+ core.behave.modkeys = g_string_new("");
g_signal_connect(G_OBJECT(vp.gui.window), "key-press-event", G_CALLBACK(keybind_keypress_callback), NULL);
}
void keybind_cleanup(void)
{
- if (vp.behave.keys) {
- g_slist_free_full(vp.behave.keys, (GDestroyNotify)keybind_free);
+ if (core.behave.keys) {
+ g_slist_free_full(core.behave.keys, (GDestroyNotify)keybind_free);
}
- if (vp.behave.modkeys) {
- g_string_free(vp.behave.modkeys, TRUE);
+ if (core.behave.modkeys) {
+ g_string_free(core.behave.modkeys, TRUE);
}
}
keybind_str_to_keybind(keys, keybind);
/* add the keybinding to the list */
- vp.behave.keys = g_slist_prepend(vp.behave.keys, keybind);
+ core.behave.keys = g_slist_prepend(core.behave.keys, keybind);
/* save the modkey also in the modkey string if not exists already */
- if (keybind->modkey && strchr(vp.behave.modkeys->str, keybind->modkey) == NULL) {
- g_string_append_c(vp.behave.modkeys, keybind->modkey);
+ if (keybind->modkey && strchr(core.behave.modkeys->str, keybind->modkey) == NULL) {
+ g_string_append_c(core.behave.modkeys, keybind->modkey);
}
return TRUE;
GSList* link = keybind_find(keybind.mode, keybind.modkey, keybind.modmask, keybind.keyval);
if (link) {
- vp.behave.keys = g_slist_delete_link(vp.behave.keys, link);
+ core.behave.keys = g_slist_delete_link(core.behave.keys, link);
}
- if (keybind.modkey && strchr(vp.behave.modkeys->str, keybind.modkey) != NULL) {
+ if (keybind.modkey && strchr(core.behave.modkeys->str, keybind.modkey) != NULL) {
/* remove eventually no more used modkeys */
keybind_rebuild_modkeys();
}
{
GSList* link;
/* remove previous modkeys */
- if (vp.behave.modkeys) {
- g_string_free(vp.behave.modkeys, TRUE);
- vp.behave.modkeys = g_string_new("");
+ if (core.behave.modkeys) {
+ g_string_free(core.behave.modkeys, TRUE);
+ core.behave.modkeys = g_string_new("");
}
/* regenerate the modekeys */
- for (link = vp.behave.keys; link != NULL; link = link->next) {
+ for (link = core.behave.keys; link != NULL; link = link->next) {
Keybind* keybind = (Keybind*)link->data;
/* if not not exists - add it */
- if (keybind->modkey && strchr(vp.behave.modkeys->str, keybind->modkey) == NULL) {
- g_string_append_c(vp.behave.modkeys, keybind->modkey);
+ if (keybind->modkey && strchr(core.behave.modkeys->str, keybind->modkey) == NULL) {
+ g_string_append_c(core.behave.modkeys, keybind->modkey);
}
}
}
static GSList* keybind_find(int mode, guint modkey, guint modmask, guint keyval)
{
GSList* link;
- for (link = vp.behave.keys; link != NULL; link = link->next) {
+ for (link = core.behave.keys; link != NULL; link = link->next) {
Keybind* keybind = (Keybind*)link->data;
if (keybind->keyval == keyval
&& keybind->modmask == modmask
return TRUE;
}
- if (strchr(vp.behave.modkeys->str, keyval) && vp.state.modkey != keyval) {
+ if (strchr(core.behave.modkeys->str, keyval) && vp.state.modkey != keyval) {
vp.state.modkey = (char)keyval;
vp_update_statusbar();
/* variables */
static char **args;
-VpCore vp;
+VpClient vp;
+VpCore core;
/* callbacks */
static void vp_webview_progress_cb(WebKitWebView* view, GParamSpec* pspec, gboolean download);
static void vp_webview_progress_cb(WebKitWebView* view, GParamSpec* pspec, gboolean download)
{
if (download) {
- if (vp.net.downloads) {
+ if (vp.state.downloads) {
vp.state.progress = 0;
GList* ptr;
- for (ptr = vp.net.downloads; ptr; ptr = g_list_next(ptr)) {
+ for (ptr = vp.state.downloads; ptr; ptr = g_list_next(ptr)) {
vp.state.progress += 100 * webkit_download_get_progress(ptr->data);
}
- vp.state.progress /= g_list_length(vp.net.downloads);
+ vp.state.progress /= g_list_length(vp.state.downloads);
}
} else {
vp.state.progress = webkit_web_view_get_progress(view) * 100;
{
SoupDate* date;
- SoupCookieJar* jar = soup_cookie_jar_text_new(vp.files[FILES_COOKIE], FALSE);
+ SoupCookieJar* jar = soup_cookie_jar_text_new(core.files[FILES_COOKIE], FALSE);
cookie = soup_cookie_copy(cookie);
- if (cookie->expires == NULL && vp.config.cookie_timeout) {
- date = soup_date_new_from_time_t(time(NULL) + vp.config.cookie_timeout);
+ if (cookie->expires == NULL && core.config.cookie_timeout) {
+ date = soup_date_new_from_time_t(time(NULL) + core.config.cookie_timeout);
soup_cookie_set_expires(cookie, date);
}
soup_cookie_jar_add_cookie(jar, cookie);
{
const char* cookie;
- SoupCookieJar* jar = soup_cookie_jar_text_new(vp.files[FILES_COOKIE], TRUE);
+ SoupCookieJar* jar = soup_cookie_jar_text_new(core.files[FILES_COOKIE], TRUE);
cookie = soup_cookie_jar_get_cookies(jar, uri, TRUE);
g_object_unref(jar);
const char* uri = CURRENT_URL();
/* write last URL into file for recreation */
if (uri) {
- g_file_set_contents(vp.files[FILES_CLOSED], uri, -1, NULL);
+ g_file_set_contents(core.files[FILES_CLOSED], uri, -1, NULL);
}
for (int i = FILES_FIRST; i < FILES_LAST; i++) {
- g_free(vp.files[i]);
+ g_free(core.files[i]);
}
command_cleanup();
setting_cleanup();
}
/* show the active downloads */
- if (vp.net.downloads) {
- int num = g_list_length(vp.net.downloads);
+ if (vp.state.downloads) {
+ int num = g_list_length(vp.state.downloads);
g_string_append_printf(status, " %d %s", num, num == 1 ? "download" : "downloads");
}
void vp_update_status_style(void)
{
StatusType type = vp.state.status;
- vp_set_widget_font(vp.gui.eventbox, &vp.style.status_fg[type], &vp.style.status_bg[type], vp.style.status_font[type]);
- vp_set_widget_font(vp.gui.statusbar.left, &vp.style.status_fg[type], &vp.style.status_bg[type], vp.style.status_font[type]);
- vp_set_widget_font(vp.gui.statusbar.right, &vp.style.status_fg[type], &vp.style.status_bg[type], vp.style.status_font[type]);
+ vp_set_widget_font(vp.gui.eventbox, &core.style.status_fg[type], &core.style.status_bg[type], core.style.status_font[type]);
+ vp_set_widget_font(vp.gui.statusbar.left, &core.style.status_fg[type], &core.style.status_bg[type], core.style.status_font[type]);
+ vp_set_widget_font(vp.gui.statusbar.right, &core.style.status_fg[type], &core.style.status_bg[type], core.style.status_font[type]);
}
void vp_echo(const MessageType type, gboolean hide, const char *error, ...)
/* set the collors according to message type */
vp_set_widget_font(
vp.gui.inputbox,
- &vp.style.input_fg[type],
- &vp.style.input_bg[type],
- vp.style.input_font[type]
+ &core.style.input_fg[type],
+ &core.style.input_bg[type],
+ core.style.input_font[type]
);
gtk_entry_set_text(GTK_ENTRY(vp.gui.inputbox), message);
if (hide) {
}
/* read config from config files */
- char **lines = util_get_lines(vp.files[FILES_CONFIG]);
+ char **lines = util_get_lines(core.files[FILES_CONFIG]);
char *line;
if (lines) {
gui->inspector = webkit_web_view_get_inspector(gui->webview);
/* init soup session */
- vp.net.soup_session = webkit_get_default_session();
- soup_session_remove_feature_by_type(vp.net.soup_session, soup_cookie_jar_get_type());
+ core.soup_session = webkit_get_default_session();
+ soup_session_remove_feature_by_type(core.soup_session, soup_cookie_jar_get_type());
/* Create a scrollable area */
gui->scroll = gtk_scrolled_window_new(NULL, NULL);
{
char* path = util_get_config_dir();
- vp.files[FILES_CONFIG] = g_build_filename(path, "config", NULL);
- util_create_file_if_not_exists(vp.files[FILES_CONFIG]);
+ core.files[FILES_CONFIG] = g_build_filename(path, "config", NULL);
+ util_create_file_if_not_exists(core.files[FILES_CONFIG]);
- vp.files[FILES_COOKIE] = g_build_filename(path, "cookies", NULL);
- util_create_file_if_not_exists(vp.files[FILES_COOKIE]);
+ core.files[FILES_COOKIE] = g_build_filename(path, "cookies", NULL);
+ util_create_file_if_not_exists(core.files[FILES_COOKIE]);
- vp.files[FILES_CLOSED] = g_build_filename(path, "closed", NULL);
- util_create_file_if_not_exists(vp.files[FILES_CLOSED]);
+ core.files[FILES_CLOSED] = g_build_filename(path, "closed", NULL);
+ util_create_file_if_not_exists(core.files[FILES_CLOSED]);
g_free(path);
}
NULL
);
- g_signal_connect_after(G_OBJECT(vp.net.soup_session), "request-started", G_CALLBACK(vp_new_request_cb), NULL);
+ g_signal_connect_after(G_OBJECT(core.soup_session), "request-started", G_CALLBACK(vp_new_request_cb), NULL);
/* inspector */
g_signal_connect(G_OBJECT(vp.gui.inspector), "inspect-web-view", G_CALLBACK(vp_inspector_new), NULL);
static void vp_setup_settings(void)
{
- g_object_set(vp.net.soup_session, "max-conns", SETTING_MAX_CONNS , NULL);
- g_object_set(vp.net.soup_session, "max-conns-per-host", SETTING_MAX_CONNS_PER_HOST, NULL);
+ 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);
}
static gboolean vp_button_relase_cb(WebKitWebView* webview, GdkEventButton* event, gpointer data)
}
/* prepare the download target path */
- uri = g_strdup_printf("file://%s%c%s", vp.config.download_dir, G_DIR_SEPARATOR, filename);
+ uri = g_strdup_printf("file://%s%c%s", core.config.download_dir, G_DIR_SEPARATOR, filename);
webkit_download_set_destination_uri(download, uri);
g_free(uri);
}
/* prepend the download to the download list */
- vp.net.downloads = g_list_prepend(vp.net.downloads, download);
+ vp.state.downloads = g_list_prepend(vp.state.downloads, download);
/* connect signal handler to check if the download is done */
g_signal_connect(download, "notify::status", G_CALLBACK(vp_download_progress_cp), NULL);
g_free(file);
/* remove the donwload from the list */
- vp.net.downloads = g_list_remove(vp.net.downloads, download);
+ vp.state.downloads = g_list_remove(vp.state.downloads, download);
vp_update_statusbar();
}
if (argc > 1) {
arg.s = g_strdup(argv[argc - 1]);
} else {
- arg.s = g_strdup(vp.config.home_page);
+ arg.s = g_strdup(core.config.home_page);
}
vp_load_uri(&arg);
g_free(arg.s);
gboolean is_inspecting;
SearchDirection search_dir;
char* search_query;
- GList* history;
- int history_pointer;
+ GList* downloads;
} State;
/* behaviour */
GSList* keys;
GString* modkeys;
GSList* searchengines;
+ GList* history;
+ int history_pointer;
} Behaviour;
-typedef struct {
- SoupSession* soup_session;
- GList* downloads;
-} Network;
-
typedef struct {
time_t cookie_timeout;
int scrollstep;
typedef struct {
Gui gui;
State state;
- Behaviour behave;
+ Completions comps;
+ Hints hints;
+} VpClient;
+
+typedef struct {
char* files[FILES_LAST];
- Network net;
Config config;
- Completions comps;
Style style;
+ Behaviour behave;
GHashTable* settings;
- Hints hints;
+ SoupSession* soup_session;
} VpCore;
/* main object */
-extern VpCore vp;
+extern VpClient vp;
+extern VpCore core;
/* functions */
void vp_update_statusbar(void);
void searchengine_cleanup(void)
{
- if (vp.behave.searchengines) {
- g_slist_free_full(vp.behave.searchengines, (GDestroyNotify)searchengine_free);
+ if (core.behave.searchengines) {
+ g_slist_free_full(core.behave.searchengines, (GDestroyNotify)searchengine_free);
}
}
s->handle = g_strdup(handle);
s->uri = g_strdup(uri);
- vp.behave.searchengines = g_slist_prepend(vp.behave.searchengines, s);
+ core.behave.searchengines = g_slist_prepend(core.behave.searchengines, s);
return TRUE;
}
g_free(s->handle);
g_free(s->uri);
- vp.behave.searchengines = g_slist_delete_link(vp.behave.searchengines, list);
+ core.behave.searchengines = g_slist_delete_link(core.behave.searchengines, list);
return TRUE;
}
static GSList* searchengine_find(const char* handle)
{
GSList* s;
- for (s = vp.behave.searchengines; s != NULL; s = s->next) {
+ for (s = core.behave.searchengines; s != NULL; s = s->next) {
if (!strcmp(((Searchengine*)s->data)->handle, handle)) {
return s;
}
{
Setting* s;
guint i;
- vp.settings = g_hash_table_new(g_str_hash, g_str_equal);
+ core.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(vp.settings, (gpointer)s->alias != NULL ? s->alias : s->name, s);
+ g_hash_table_insert(core.settings, (gpointer)s->alias != NULL ? s->alias : s->name, s);
/* set the default settings */
s->func(s, FALSE);
void setting_cleanup(void)
{
- if (vp.settings) {
- g_hash_table_destroy(vp.settings);
+ if (core.settings) {
+ g_hash_table_destroy(core.settings);
}
}
type = SETTING_GET;
}
- Setting* s = g_hash_table_lookup(vp.settings, name);
+ Setting* s = g_hash_table_lookup(core.settings, name);
if (!s) {
vp_echo(VP_MSG_ERROR, TRUE, "Config '%s' not found", name);
return FALSE;
static gboolean setting_cookie_timeout(const Setting* s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, &vp.config.cookie_timeout);
+ setting_print_value(s, &core.config.cookie_timeout);
} else {
- vp.config.cookie_timeout = s->arg.i;
+ core.config.cookie_timeout = s->arg.i;
}
return TRUE;
static gboolean setting_scrollstep(const Setting* s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, &vp.config.scrollstep);
+ setting_print_value(s, &core.config.scrollstep);
} else {
- vp.config.scrollstep = s->arg.i;
+ core.config.scrollstep = s->arg.i;
}
return TRUE;
}
if (type == SETTING_GET) {
- setting_print_value(s, &vp.style.status_bg[stype]);
+ setting_print_value(s, &core.style.status_bg[stype]);
} else {
- VP_COLOR_PARSE(&vp.style.status_bg[stype], s->arg.s);
+ VP_COLOR_PARSE(&core.style.status_bg[stype], s->arg.s);
vp_update_status_style();
}
}
if (type == SETTING_GET) {
- setting_print_value(s, &vp.style.status_fg[stype]);
+ setting_print_value(s, &core.style.status_fg[stype]);
} else {
- VP_COLOR_PARSE(&vp.style.status_fg[stype], s->arg.s);
+ VP_COLOR_PARSE(&core.style.status_fg[stype], s->arg.s);
vp_update_status_style();
}
}
if (type == SETTING_GET) {
- setting_print_value(s, vp.style.status_font[stype]);
+ setting_print_value(s, core.style.status_font[stype]);
} else {
- if (vp.style.status_font[stype]) {
+ if (core.style.status_font[stype]) {
/* free previous font description */
- pango_font_description_free(vp.style.status_font[stype]);
+ pango_font_description_free(core.style.status_font[stype]);
}
- vp.style.status_font[stype] = pango_font_description_from_string(s->arg.s);
+ core.style.status_font[stype] = pango_font_description_from_string(s->arg.s);
vp_update_status_style();
}
static gboolean setting_input_style(const Setting* s, const SettingType type)
{
- Style* style = &vp.style;
+ Style* style = &core.style;
MessageType itype = g_str_has_suffix(s->name, "normal") ? VP_MSG_NORMAL : VP_MSG_ERROR;
if (s->type == TYPE_FONT) {
static gboolean setting_completion_style(const Setting* s, const SettingType type)
{
- Style* style = &vp.style;
+ Style* style = &core.style;
CompletionStyle ctype = g_str_has_suffix(s->name, "normal") ? VP_COMP_NORMAL : VP_COMP_ACTIVE;
if (s->type == TYPE_INTEGER) {
/* max completion items */
if (type == SETTING_GET) {
- setting_print_value(s, &vp.config.max_completion_items);
+ setting_print_value(s, &core.config.max_completion_items);
} else {
- vp.config.max_completion_items = s->arg.i;
+ core.config.max_completion_items = s->arg.i;
}
} else if (s->type == TYPE_FONT) {
if (type == SETTING_GET) {
static gboolean setting_hint_style(const Setting* s, const SettingType type)
{
- Style* style = &vp.style;
+ Style* style = &core.style;
if (!g_strcmp0(s->name, "hint-bg")) {
if (type == SETTING_GET) {
setting_print_value(s, style->hint_bg);
{
gboolean value;
if (type != SETTING_SET) {
- g_object_get(vp.net.soup_session, "ssl-strict", &value, NULL);
+ g_object_get(core.soup_session, "ssl-strict", &value, NULL);
if (type == SETTING_GET) {
setting_print_value(s, &value);
value = type == SETTING_TOGGLE ? !value : (s->arg.i ? TRUE : FALSE);
- g_object_set(vp.net.soup_session, "ssl-strict", value, NULL);
+ g_object_set(core.soup_session, "ssl-strict", value, NULL);
return TRUE;
}
{
if (type == SETTING_GET) {
char* value = NULL;
- g_object_get(vp.net.soup_session, "ssl-ca-file", &value, NULL);
+ g_object_get(core.soup_session, "ssl-ca-file", &value, NULL);
setting_print_value(s, value);
g_free(value);
} else {
- g_object_set(vp.net.soup_session, "ssl-ca-file", s->arg.s, NULL);
+ g_object_set(core.soup_session, "ssl-ca-file", s->arg.s, NULL);
}
return TRUE;
static gboolean setting_home_page(const Setting* s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, vp.config.home_page);
+ setting_print_value(s, core.config.home_page);
} else {
- OVERWRITE_STRING(vp.config.home_page, s->arg.s);
+ OVERWRITE_STRING(core.config.home_page, s->arg.s);
}
return TRUE;
static gboolean setting_download_path(const Setting* s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, vp.config.download_dir);
+ setting_print_value(s, core.config.download_dir);
} else {
- if (vp.config.download_dir) {
- g_free(vp.config.download_dir);
- vp.config.download_dir = NULL;
+ if (core.config.download_dir) {
+ g_free(core.config.download_dir);
+ core.config.download_dir = NULL;
}
/* if path is not absolute create it in the home directory */
if (s->arg.s[0] != '/') {
- vp.config.download_dir = g_build_filename(util_get_home_dir(), s->arg.s, NULL);
+ core.config.download_dir = g_build_filename(util_get_home_dir(), s->arg.s, NULL);
} else {
- vp.config.download_dir = g_strdup(s->arg.s);
+ core.config.download_dir = g_strdup(s->arg.s);
}
/* create the path if it does not exist */
- util_create_dir_if_not_exists(vp.config.download_dir);
+ util_create_dir_if_not_exists(core.config.download_dir);
}
return TRUE;
/* get the current status */
if (type != SETTING_SET) {
- g_object_get(vp.net.soup_session, "proxy-uri", &proxy_uri, NULL);
+ g_object_get(core.soup_session, "proxy-uri", &proxy_uri, NULL);
enabled = (proxy_uri != NULL);
if (type == SETTING_GET) {
: g_strdup_printf("http://%s", proxy);
proxy_uri = soup_uri_new(proxy_new);
- g_object_set(vp.net.soup_session, "proxy-uri", proxy_uri, NULL);
+ g_object_set(core.soup_session, "proxy-uri", proxy_uri, NULL);
soup_uri_free(proxy_uri);
g_free(proxy_new);
}
} else {
- g_object_set(vp.net.soup_session, "proxy-uri", NULL, NULL);
+ g_object_set(core.soup_session, "proxy-uri", NULL, NULL);
}
return TRUE;