char *prefix;
} Completion;
-static GList *completion_init_completion(GList *target, GList *source,
+static GList *init_completion(GList *target, GList *source,
Comp_Func func, const char *input, const char *prefix);
-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);
+static GList *update(GList *completion, GList *active, gboolean back);
+static void show(gboolean back);
+static void set_entry_text(Completion *completion);
+static char *get_text(Completion *completion);
+static Completion *get_new(const char *label, const char *prefix);
+static void free_completion(Completion *completion);
gboolean completion_complete(gboolean back)
{
&& vb.comps.active
&& (vb.state.mode & VB_MODE_COMPLETE)
) {
- char *text = completion_get_text((Completion*)vb.comps.active->data);
+ char *text = get_text((Completion*)vb.comps.active->data);
if (!strcmp(input, text)) {
/* updatecompletions */
- vb.comps.active = completion_update(vb.comps.completions, vb.comps.active, back);
+ vb.comps.active = update(vb.comps.completions, vb.comps.active, back);
g_free(text);
return TRUE;
} else {
if (!strncmp(input, ":set ", 5)) {
source = g_hash_table_get_keys(vb.settings);
source = g_list_sort(source, (GCompareFunc)g_strcmp0);
- vb.comps.completions = completion_init_completion(
+ vb.comps.completions = init_completion(
vb.comps.completions, source, (Comp_Func)g_str_has_prefix, &input[5], ":set "
);
g_list_free(source);
} else if (!strncmp(input, ":open ", 6)) {
source = history_get_all(HISTORY_URL);
- vb.comps.completions = completion_init_completion(
+ vb.comps.completions = init_completion(
vb.comps.completions, source, (Comp_Func)util_strcasestr, &input[6], ":open "
);
history_list_free(&source);
} else if (!strncmp(input, ":tabopen ", 9)) {
source = history_get_all(HISTORY_URL);
- vb.comps.completions = completion_init_completion(
+ vb.comps.completions = init_completion(
vb.comps.completions, source, (Comp_Func)util_strcasestr, &input[9], ":tabopen "
);
history_list_free(&source);
} else {
source = g_hash_table_get_keys(vb.behave.commands);
source = g_list_sort(source, (GCompareFunc)g_strcmp0);
- vb.comps.completions = completion_init_completion(
+ vb.comps.completions = init_completion(
vb.comps.completions, source, (Comp_Func)g_str_has_prefix, &input[1], ":"
);
g_list_free(source);
if (!vb.comps.completions) {
return false;
}
- completion_show(back);
+ show(back);
return TRUE;
}
void completion_clean()
{
- g_list_free_full(vb.comps.completions, (GDestroyNotify)completion_free);
+ g_list_free_full(vb.comps.completions, (GDestroyNotify)free_completion);
vb.comps.completions = NULL;
if (vb.gui.compbox) {
vb.state.mode &= ~VB_MODE_COMPLETE;
}
-static GList *completion_init_completion(GList *target, GList *source,
+static GList *init_completion(GList *target, GList *source,
Comp_Func func, const char *input, const char *prefix)
{
char *command = NULL, *data = NULL, **token = NULL;
}
}
if (match) {
- Completion *completion = completion_get_new(data, prefix);
+ Completion *completion = get_new(data, prefix);
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);
return target;
}
-static GList *completion_update(GList *completion, GList *active, gboolean back)
+static GList *update(GList *completion, GList *active, gboolean back)
{
GList *old, *new;
Completion *comp;
VB_WIDGET_SET_STATE(((Completion*)new->data)->event, VB_GTK_STATE_ACTIVE);
active = new;
- completion_set_entry_text(active->data);
+ set_entry_text(active->data);
return active;
}
/* allow to chenge the direction of display */
-static void completion_show(gboolean back)
+static void show(gboolean back)
{
guint max = vb.config.max_completion_items;
int i = 0;
VB_WIDGET_SET_STATE(active->label, VB_GTK_STATE_ACTIVE);
VB_WIDGET_SET_STATE(active->event, VB_GTK_STATE_ACTIVE);
- completion_set_entry_text(active);
+ set_entry_text(active);
gtk_widget_show(vb.gui.compbox);
}
}
-static void completion_set_entry_text(Completion *completion)
+static void set_entry_text(Completion *completion)
{
- char *text = completion_get_text(completion);
+ char *text = 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(Completion *completion)
+static char *get_text(Completion *completion)
{
char *text = NULL;
return text;
}
-static Completion *completion_get_new(const char *label, const char *prefix)
+static Completion *get_new(const char *label, const char *prefix)
{
const int padding = 2;
Completion *c = g_new0(Completion, 1);
return c;
}
-static void completion_free(Completion *completion)
+static void free_completion(Completion *completion)
{
gtk_widget_destroy(completion->event);
g_free(completion->prefix);
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);
+static gboolean auto_insert(Element *element);
+static gboolean editable_focus_cb(Element *element, Event *event);
+static Element *get_active_element(Document *doc);
void dom_check_auto_insert(void)
{
Document *doc = webkit_web_view_get_dom_document(vb.gui.webview);
- Element *active = dom_get_active_element(doc);
+ Element *active = get_active_element(doc);
/* the focus was not set automatically - add event listener to track focus
* events on the document */
- if (!dom_auto_insert(active)) {
+ if (!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, NULL
+ WEBKIT_DOM_EVENT_TARGET(element), "focus", G_CALLBACK(editable_focus_cb), true, NULL
);
}
}
void dom_clear_focus(void)
{
Document *doc = webkit_web_view_get_dom_document(vb.gui.webview);
- Element *active = dom_get_active_element(doc);
+ Element *active = get_active_element(doc);
if (active) {
webkit_dom_element_blur(active);
return result;
}
-static gboolean dom_auto_insert(Element *element)
+static gboolean auto_insert(Element *element)
{
if (dom_is_editable(element)) {
vb_set_mode(VB_MODE_INSERT, false);
return false;
}
-static gboolean dom_editable_focus_cb(Element *element, Event *event)
+static gboolean 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
+ WEBKIT_DOM_EVENT_TARGET(element), "focus", G_CALLBACK(editable_focus_cb), true
);
if (CLEAN_MODE(vb.state.mode) != VB_MODE_INSERT) {
EventTarget *target = webkit_dom_event_get_target(event);
- dom_auto_insert((void*)target);
+ auto_insert((void*)target);
}
return false;
}
-static Element *dom_get_active_element(Document *doc)
+static Element *get_active_element(Document *doc)
{
char *tagname;
Document *d = NULL;
if (!g_strcmp0(tagname, "FRAME")) {
d = webkit_dom_html_frame_element_get_content_document(WEBKIT_DOM_HTML_FRAME_ELEMENT(active));
- result = dom_get_active_element(d);
+ result = get_active_element(d);
} else if (!g_strcmp0(tagname, "IFRAME")) {
d = webkit_dom_html_iframe_element_get_content_document(WEBKIT_DOM_HTML_IFRAME_ELEMENT(active));
- result = dom_get_active_element(d);
+ result = get_active_element(d);
}
g_free(tagname);
extern VbCore vb;
extern const unsigned int MAXIMUM_HINTS;
-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);
+static void run_script(char *js);
+static void fire();
+static void observe_input(gboolean observe);
+static gboolean changed_cb(GtkEditable *entry);
+static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event);
void hints_init(WebKitWebFrame *frame)
{
{
char *js, *value = NULL;
- hints_observe_input(false);
+ observe_input(false);
if (CLEAN_MODE(vb.state.mode) == VB_MODE_HINTING) {
js = g_strdup_printf("%s.clear();", HINT_VAR);
vb_eval_script(webkit_web_view_get_main_frame(vb.gui.webview), js, HINT_FILE, &value);
MAXIMUM_HINTS
);
- hints_observe_input(TRUE);
+ observe_input(TRUE);
- hints_run_script(js);
+ run_script(js);
g_free(js);
}
js = g_strdup_printf("%s.create('%s');", HINT_VAR, input ? input : "");
- hints_run_script(js);
+ run_script(js);
g_free(js);
}
void hints_update(const gulong num)
{
char *js = g_strdup_printf("%s.update(%lu);", HINT_VAR, num);
- hints_run_script(js);
+ run_script(js);
g_free(js);
}
void hints_focus_next(const gboolean back)
{
char *js = g_strdup_printf(back ? "%s.focusPrev()" : "%s.focusNext();", HINT_VAR);
- hints_run_script(js);
+ run_script(js);
g_free(js);
}
-static void hints_run_script(char *js)
+static void run_script(char *js)
{
char *value = NULL;
int mode = vb.hints.mode;
g_free(value);
}
-static void hints_fire()
+static void fire()
{
char *js = g_strdup_printf("%s.fire();", HINT_VAR);
- hints_run_script(js);
+ run_script(js);
g_free(js);
}
-static void hints_observe_input(gboolean observe)
+static void observe_input(gboolean observe)
{
if (observe) {
vb.hints.change_handler = g_signal_connect(
- G_OBJECT(vb.gui.inputbox), "changed", G_CALLBACK(hints_changed_callback), NULL
+ G_OBJECT(vb.gui.inputbox), "changed", G_CALLBACK(changed_cb), NULL
);
vb.hints.keypress_handler = g_signal_connect(
- G_OBJECT(vb.gui.inputbox), "key-press-event", G_CALLBACK(hints_keypress_callback), NULL
+ G_OBJECT(vb.gui.inputbox), "key-press-event", G_CALLBACK(keypress_cb), NULL
);
} else if (vb.hints.change_handler && vb.hints.keypress_handler) {
g_signal_handler_disconnect(G_OBJECT(vb.gui.inputbox), vb.hints.change_handler);
}
}
-static gboolean hints_changed_callback(GtkEditable *entry)
+static gboolean changed_cb(GtkEditable *entry)
{
const char *text = GET_TEXT();
return TRUE;
}
-static gboolean hints_keypress_callback(WebKitWebView *webview, GdkEventKey *event)
+static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event)
{
int numval;
guint keyval = event->keyval;
guint state = CLEAN_STATE_WITH_SHIFT(event);
if (keyval == GDK_Return) {
- hints_fire();
+ fire();
return TRUE;
}
if (keyval == GDK_BackSpace && (state & GDK_SHIFT_MASK) && (state & GDK_CONTROL_MASK)) {
GList *active;
} history;
-static GList *history_get_list(const char *input);
-static const char *history_get_file_by_type(HistoryType type);
-static GList *history_load(const char *file);
-static void history_write_to_file(GList *list, const char *file);
+static GList *get_list(const char *input);
+static const char *get_file_by_type(HistoryType type);
+static GList *load(const char *file);
+static void write_to_file(GList *list, const char *file);
/**
{
const char *file;
for (HistoryType i = HISTORY_FIRST; i < HISTORY_LAST; i++) {
- file = history_get_file_by_type(i);
- history_write_to_file(history_load(file), file);
+ file = get_file_by_type(i);
+ write_to_file(load(file), file);
}
}
void history_add(HistoryType type, const char *value)
{
FILE *f;
- const char *file = history_get_file_by_type(type);
+ const char *file = get_file_by_type(type);
if ((f = fopen(file, "a+"))) {
file_lock_set(fileno(f), F_WRLCK);
*/
GList *history_get_all(HistoryType type)
{
- return history_load(history_get_file_by_type(type));
+ return load(get_file_by_type(type));
}
/**
GList *new = NULL;
if (!history.active) {
- history.active = history_get_list(input);
+ history.active = get_list(input);
history.active = g_list_append(history.active, g_strdup(""));
/* start with latest added items */
history.active = g_list_last(history.active);
* Retrieves the list of matching history items.
* The list must be freed.
*/
-static GList *history_get_list(const char *input)
+static GList *get_list(const char *input)
{
HistoryType type;
GList *result = NULL;
return NULL;
}
- GList *src = history_load(history_get_file_by_type(type));
+ GList *src = load(get_file_by_type(type));
/* generate new history list with the matching items */
for (GList *l = src; l; l = l->next) {
return result;
}
-static const char *history_get_file_by_type(HistoryType type)
+static const char *get_file_by_type(HistoryType type)
{
return vb.files[file_map[type]];
}
* Loads history items form file but eleminate duplicates.
* Oldest entries first.
*/
-static GList *history_load(const char *file)
+static GList *load(const char *file)
{
/* read the history items from file */
GList *list = NULL;
/**
* Loads the entries from file, make them unique and write them back to file.
*/
-static void history_write_to_file(GList *list, const char *file)
+static void write_to_file(GList *list, const char *file)
{
FILE *f;
if ((f = fopen(file, "w"))) {
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);
-static void keybind_free(Keybind *keybind);
+static void rebuild_modkeys(void);
+static GSList *find(int mode, guint modkey, guint modmask, guint keyval);
+static void string_to_keybind(char *str, Keybind *key);
+static guint string_to_modmask(const char *str);
+static guint string_to_value(const char *str);
+static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event);
+static void free_keybind(Keybind *keybind);
void keybind_init(void)
{
vb.behave.modkeys = g_string_new("");
- g_signal_connect(G_OBJECT(vb.gui.box), "key-press-event", G_CALLBACK(keybind_keypress_callback), NULL);
+ g_signal_connect(G_OBJECT(vb.gui.box), "key-press-event", G_CALLBACK(keypress_cb), NULL);
}
void keybind_cleanup(void)
{
if (vb.behave.keys) {
- g_slist_free_full(vb.behave.keys, (GDestroyNotify)keybind_free);
+ g_slist_free_full(vb.behave.keys, (GDestroyNotify)free_keybind);
}
if (vb.behave.modkeys) {
g_string_free(vb.behave.modkeys, TRUE);
keybind->param = g_strdup(token[1]);
g_strfreev(token);
- keybind_str_to_keybind(keys, keybind);
+ string_to_keybind(keys, keybind);
/* add the keybinding to the list */
vb.behave.keys = g_slist_prepend(vb.behave.keys, keybind);
g_strstrip(str);
/* fill the keybind with data from given string */
- keybind_str_to_keybind(str, &keybind);
+ string_to_keybind(str, &keybind);
- GSList *link = keybind_find(keybind.mode, keybind.modkey, keybind.modmask, keybind.keyval);
+ GSList *link = find(keybind.mode, keybind.modkey, keybind.modmask, keybind.keyval);
if (link) {
- keybind_free((Keybind*)link->data);
+ free_keybind((Keybind*)link->data);
vb.behave.keys = g_slist_delete_link(vb.behave.keys, link);
}
if (keybind.modkey && strchr(vb.behave.modkeys->str, keybind.modkey) != NULL) {
/* remove eventually no more used modkeys */
- keybind_rebuild_modkeys();
+ rebuild_modkeys();
}
return TRUE;
}
* Discard all knows modkeys and walk through all keybindings to aggregate
* them new.
*/
-static void keybind_rebuild_modkeys(void)
+static void rebuild_modkeys(void)
{
GSList *link;
/* remove previous modkeys */
}
}
-static GSList *keybind_find(int mode, guint modkey, guint modmask, guint keyval)
+static GSList *find(int mode, guint modkey, guint modmask, guint keyval)
{
GSList *link;
for (link = vb.behave.keys; link != NULL; link = link->next) {
/**
* Configures the given keybind by also given string.
*/
-static void keybind_str_to_keybind(char *str, Keybind *keybind)
+static void string_to_keybind(char *str, Keybind *keybind)
{
char **string = NULL;
guint len = 0;
len = g_strv_length(string);
if (len == 4) {
/* key with modmask like <ctrl-tab> */
- keybind->modmask = keybind_str_to_modmask(string[1]);
- keybind->keyval = keybind_str_to_value(string[2]);
+ keybind->modmask = string_to_modmask(string[1]);
+ keybind->keyval = string_to_value(string[2]);
} else if (len == 3) {
/* key without modmask like <tab> */
- keybind->keyval = keybind_str_to_value(string[1]);
+ keybind->keyval = string_to_value(string[1]);
}
g_strfreev(string);
}
}
}
-static guint keybind_str_to_modmask(const char *str)
+static guint string_to_modmask(const char *str)
{
if (g_ascii_strcasecmp(str, "ctrl") == 0) {
return GDK_CONTROL_MASK;
return 0;
}
-static guint keybind_str_to_value(const char *str)
+static guint string_to_value(const char *str)
{
if (!strcmp(str, "tab")) {
return GDK_Tab;
return str[0];
}
-static gboolean keybind_keypress_callback(WebKitWebView *webview, GdkEventKey *event)
+static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event)
{
guint keyval = event->keyval;
guint state = CLEAN_STATE_WITH_SHIFT(event);
}
/* check for keybinding */
- GSList *link = keybind_find(CLEAN_MODE(vb.state.mode), vb.state.modkey, state, keyval);
+ GSList *link = find(CLEAN_MODE(vb.state.mode), vb.state.modkey, state, keyval);
if (link) {
Keybind *keybind = (Keybind*)link->data;
return false;
}
-static void keybind_free(Keybind *keybind)
+static void free_keybind(Keybind *keybind)
{
g_free(keybind->command);
g_free(keybind->param);
VbCore vb;
/* callbacks */
-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 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(
+static void webview_progress_cb(WebKitWebView *view, GParamSpec *pspec);
+static void webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec);
+static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec);
+static void destroy_window_cb(GtkWidget *widget);
+static void inputbox_activate_cb(GtkEntry *entry);
+static gboolean inputbox_keyrelease_cb(GtkEntry *entry, GdkEventKey *event);
+static void scroll_cb(GtkAdjustment *adjustment);
+static WebKitWebView *inspector_new(WebKitWebInspector *inspector, WebKitWebView *webview);
+static gboolean inspector_show(WebKitWebInspector *inspector);
+static gboolean inspector_close(WebKitWebInspector *inspector);
+static void inspector_finished(WebKitWebInspector *inspector);
+static gboolean button_relase_cb(WebKitWebView *webview, GdkEventButton *event);
+static gboolean new_window_policy_cb(
WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *request,
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,
+static void hover_link_cb(WebKitWebView *webview, const char *title, const char *link);
+static void title_changed_cb(WebKitWebView *webview, WebKitWebFrame *frame, const char *title);
+static gboolean mimetype_decision_cb(WebKitWebView *webview,
WebKitWebFrame *frame, WebKitNetworkRequest *request, char*
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,
+static gboolean download_requested_cb(WebKitWebView *view, WebKitDownload *download);
+static void download_progress_cp(WebKitDownload *download, GParamSpec *pspec);
+static void request_start_cb(WebKitWebView *webview, WebKitWebFrame *frame,
WebKitWebResource *resource, WebKitNetworkRequest *request,
WebKitNetworkResponse *response);
/* functions */
-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_config(void);
-static void vb_setup_signals();
-static void vb_init_files(void);
-static gboolean vb_hide_message();
-static void vb_set_status(const StatusType status);
-void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, const char *message);
-static void vb_destroy_client();
+static void run_user_script(WebKitWebFrame *frame);
+static char *jsref_to_string(JSContextRef context, JSValueRef ref);
+static void init_core(void);
+static void read_config(void);
+static void setup_signals();
+static void init_files(void);
+static gboolean hide_message();
+static void set_status(const StatusType status);
+void inputbox_print(gboolean force, const MessageType type, gboolean hide, const char *message);
+static void destroy_client();
void vb_echo_force(const MessageType type,gboolean hide, const char *error, ...)
{
vsnprintf(message, 255, error, arg_list);
va_end(arg_list);
- vb_inputbox_print(TRUE, type, hide, message);
+ inputbox_print(TRUE, type, hide, message);
}
void vb_echo(const MessageType type, gboolean hide, const char *error, ...)
vsnprintf(message, 255, error, arg_list);
va_end(arg_list);
- vb_inputbox_print(false, type, hide, message);
+ inputbox_print(false, type, hide, message);
}
gboolean vb_eval_script(WebKitWebFrame *frame, char *script, char *file, char **value)
JSStringRelease(str);
if (result) {
- *value = vb_jsref_to_string(js, result);
+ *value = jsref_to_string(js, result);
return TRUE;
}
- *value = vb_jsref_to_string(js, exception);
+ *value = jsref_to_string(js, exception);
return false;
}
gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), uri);
}
-static gboolean vb_hide_message()
+static gboolean hide_message()
{
- vb_inputbox_print(false, VB_MSG_NORMAL, false, "");
+ inputbox_print(false, VB_MSG_NORMAL, false, "");
return false;
}
-static void vb_webview_progress_cb(WebKitWebView *view, GParamSpec *pspec)
+static void webview_progress_cb(WebKitWebView *view, GParamSpec *pspec)
{
vb.state.progress = webkit_web_view_get_progress(view) * 100;
vb_update_statusbar();
}
-static void vb_webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec)
+static void webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec)
{
if (vb.state.downloads) {
vb.state.progress = 0;
vb_update_statusbar();
}
-static void vb_webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
+static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
{
const char *uri = webkit_web_view_get_uri(vb.gui.webview);
WebKitNetworkRequest *request = webkit_web_data_source_get_request(src);
SoupMessage *msg = webkit_network_request_get_message(request);
SoupMessageFlags flags = soup_message_get_flags(msg);
- vb_set_status(
+ set_status(
(flags & SOUP_MESSAGE_CERTIFICATE_TRUSTED) ? VB_STATUS_SSL_VALID : VB_STATUS_SSL_INVALID
);
} else {
- vb_set_status(VB_STATUS_NORMAL);
+ set_status(VB_STATUS_NORMAL);
}
/* inject the hinting javascript */
hints_init(frame);
/* run user script file */
- vb_run_user_script(frame);
+ run_user_script(frame);
}
/* status bar is updated by vb_set_mode */
}
}
-static void vb_destroy_window_cb(GtkWidget *widget)
+static void destroy_window_cb(GtkWidget *widget)
{
- vb_destroy_client();
+ destroy_client();
}
-static void vb_inputbox_activate_cb(GtkEntry *entry)
+static void inputbox_activate_cb(GtkEntry *entry)
{
const char *text;
char *command = NULL;
g_free(command);
}
-static gboolean vb_inputbox_keyrelease_cb(GtkEntry *entry, GdkEventKey *event)
+static gboolean inputbox_keyrelease_cb(GtkEntry *entry, GdkEventKey *event)
{
return false;
}
-static void vb_scroll_cb(GtkAdjustment *adjustment)
+static void scroll_cb(GtkAdjustment *adjustment)
{
vb_update_statusbar();
}
-static WebKitWebView *vb_inspector_new(WebKitWebInspector *inspector, WebKitWebView *webview)
+static WebKitWebView *inspector_new(WebKitWebInspector *inspector, WebKitWebView *webview)
{
return WEBKIT_WEB_VIEW(webkit_web_view_new());
}
-static gboolean vb_inspector_show(WebKitWebInspector *inspector)
+static gboolean inspector_show(WebKitWebInspector *inspector)
{
WebKitWebView *webview;
int height;
return TRUE;
}
-static gboolean vb_inspector_close(WebKitWebInspector *inspector)
+static gboolean inspector_close(WebKitWebInspector *inspector)
{
WebKitWebView *webview;
return TRUE;
}
-static void vb_inspector_finished(WebKitWebInspector *inspector)
+static void inspector_finished(WebKitWebInspector *inspector)
{
g_free(vb.gui.inspector);
}
-static void vb_set_status(const StatusType status)
+static void set_status(const StatusType status)
{
if (vb.state.status_type != status) {
vb.state.status_type = status;
}
}
-void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, const char *message)
+void inputbox_print(gboolean force, const MessageType type, gboolean hide, const char *message)
{
/* don't print message if the input is focussed */
if (!force && gtk_widget_is_focus(GTK_WIDGET(vb.gui.inputbox))) {
gtk_entry_set_text(GTK_ENTRY(vb.gui.inputbox), message);
gtk_editable_set_position(GTK_EDITABLE(vb.gui.inputbox), strlen(message) > INPUT_LENGTH ? 0 : -1);
if (hide) {
- g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)vb_hide_message, NULL);
+ g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)hide_message, NULL);
}
}
-static void vb_run_user_script(WebKitWebFrame *frame)
+static void run_user_script(WebKitWebFrame *frame)
{
char *js = NULL, *value = NULL;
GError *error = NULL;
}
}
-static char *vb_jsref_to_string(JSContextRef context, JSValueRef ref)
+static char *jsref_to_string(JSContextRef context, JSValueRef ref)
{
char *string;
JSStringRef str_ref = JSValueToStringCopy(context, ref, NULL);
return string;
}
-static void vb_init_core(void)
+static void init_core(void)
{
Gui *gui = &vb.gui;
gtk_paned_pack1(GTK_PANED(gui->pane), GTK_WIDGET(gui->box), TRUE, TRUE);
- vb_setup_signals();
+ setup_signals();
/* Put all part together */
gtk_container_add(GTK_CONTAINER(gui->scroll), GTK_WIDGET(gui->webview));
* and keyboard events */
gtk_widget_grab_focus(GTK_WIDGET(gui->webview));
- vb_init_files();
+ init_files();
session_init();
setting_init();
command_init();
keybind_init();
- vb_read_config();
+ read_config();
/* initially apply input style */
vb_update_input_style();
gtk_widget_show_all(gui->window);
}
-static void vb_read_config(void)
+static void read_config(void)
{
char *line, **lines;
g_strfreev(lines);
}
-static void vb_setup_signals()
+static void setup_signals()
{
WebKitWebFrame *frame = webkit_web_view_get_main_frame(vb.gui.webview);
/* Set up callbacks so that if either the main window or the browser
* instance is closed, the program will exit */
- g_signal_connect(vb.gui.window, "destroy", G_CALLBACK(vb_destroy_window_cb), NULL);
+ g_signal_connect(vb.gui.window, "destroy", G_CALLBACK(destroy_window_cb), NULL);
g_object_connect(
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,
+ "signal::notify::progress", G_CALLBACK(webview_progress_cb), NULL,
+ "signal::notify::load-status", G_CALLBACK(webview_load_status_cb), NULL,
+ "signal::button-release-event", G_CALLBACK(button_relase_cb), NULL,
+ "signal::new-window-policy-decision-requested", G_CALLBACK(new_window_policy_cb), NULL,
+ "signal::hovering-over-link", G_CALLBACK(hover_link_cb), NULL,
+ "signal::title-changed", G_CALLBACK(title_changed_cb), NULL,
+ "signal::mime-type-policy-decision-requested", G_CALLBACK(mimetype_decision_cb), NULL,
+ "signal::download-requested", G_CALLBACK(download_requested_cb), NULL,
+ "signal::resource-request-starting", G_CALLBACK(request_start_cb), NULL,
NULL
);
g_object_connect(
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,
+ "signal::activate", G_CALLBACK(inputbox_activate_cb), NULL,
+ "signal::key-release-event", G_CALLBACK(inputbox_keyrelease_cb), NULL,
NULL
);
/* webview adjustment */
g_object_connect(G_OBJECT(vb.gui.adjust_v),
- "signal::value-changed", G_CALLBACK(vb_scroll_cb), NULL,
+ "signal::value-changed", G_CALLBACK(scroll_cb), NULL,
NULL
);
/* inspector */
g_object_connect(
G_OBJECT(vb.gui.inspector),
- "signal::inspect-web-view", G_CALLBACK(vb_inspector_new), NULL,
- "signal::show-window", G_CALLBACK(vb_inspector_show), NULL,
- "signal::close-window", G_CALLBACK(vb_inspector_close), NULL,
- "signal::finished", G_CALLBACK(vb_inspector_finished), NULL,
+ "signal::inspect-web-view", G_CALLBACK(inspector_new), NULL,
+ "signal::show-window", G_CALLBACK(inspector_show), NULL,
+ "signal::close-window", G_CALLBACK(inspector_close), NULL,
+ "signal::finished", G_CALLBACK(inspector_finished), NULL,
NULL
);
}
-static void vb_init_files(void)
+static void init_files(void)
{
char *path = util_get_config_dir();
g_free(path);
}
-static gboolean vb_button_relase_cb(WebKitWebView *webview, GdkEventButton *event)
+static gboolean button_relase_cb(WebKitWebView *webview, GdkEventButton *event)
{
gboolean propagate = false;
WebKitHitTestResultContext context;
return propagate;
}
-static gboolean vb_new_window_policy_cb(
+static gboolean new_window_policy_cb(
WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *request,
WebKitWebNavigationAction *navig, WebKitWebPolicyDecision *policy)
{
return false;
}
-static void vb_hover_link_cb(WebKitWebView *webview, const char *title, const char *link)
+static void hover_link_cb(WebKitWebView *webview, const char *title, const char *link)
{
char *message;
if (link) {
}
}
-static void vb_title_changed_cb(WebKitWebView *webview, WebKitWebFrame *frame, const char *title)
+static void title_changed_cb(WebKitWebView *webview, WebKitWebFrame *frame, const char *title)
{
gtk_window_set_title(GTK_WINDOW(vb.gui.window), title);
}
-static gboolean vb_mimetype_decision_cb(WebKitWebView *webview,
+static gboolean mimetype_decision_cb(WebKitWebView *webview,
WebKitWebFrame *frame, WebKitNetworkRequest *request, char *mime_type,
WebKitWebPolicyDecision *decision)
{
return false;
}
-static gboolean vb_download_requested_cb(WebKitWebView *view, WebKitDownload *download)
+static gboolean download_requested_cb(WebKitWebView *view, WebKitDownload *download)
{
WebKitDownloadStatus status;
char *uri = NULL;
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), NULL);
- g_signal_connect(download, "notify::progress", G_CALLBACK(vb_webview_download_progress_cb), NULL);
+ g_signal_connect(download, "notify::status", G_CALLBACK(download_progress_cp), NULL);
+ g_signal_connect(download, "notify::progress", G_CALLBACK(webview_download_progress_cb), NULL);
vb_update_statusbar();
/**
* Callback to filter started resource request.
*/
-static void vb_request_start_cb(WebKitWebView *webview, WebKitWebFrame *frame,
+static void request_start_cb(WebKitWebView *webview, WebKitWebFrame *frame,
WebKitWebResource *resource, WebKitNetworkRequest *request,
WebKitNetworkResponse *response)
{
}
}
-static void vb_download_progress_cp(WebKitDownload *download, GParamSpec *pspec)
+static void download_progress_cp(WebKitDownload *download, GParamSpec *pspec)
{
WebKitDownloadStatus status = webkit_download_get_status(download);
vb_update_statusbar();
}
-static void vb_destroy_client()
+static void destroy_client()
{
const char *uri = webkit_web_view_get_uri(vb.gui.webview);
/* write last URL into file for recreation */
vb.embed = strtol(winid, NULL, 0);
}
- vb_init_core();
+ init_core();
/* command line argument: URL */
Arg arg = {VB_TARGET_CURRENT};
char *uri;
} Searchengine;
-static GSList *searchengine_find(const char *handle);
-static gboolean searchengine_is_valid_uri(const char *uri);
-static void searchengine_free(Searchengine *se);
+static GSList *find(const char *handle);
+static gboolean is_valid_uri(const char *uri);
+static void free_searchengine(Searchengine *se);
void searchengine_cleanup(void)
{
if (vb.behave.searchengines) {
- g_slist_free_full(vb.behave.searchengines, (GDestroyNotify)searchengine_free);
+ g_slist_free_full(vb.behave.searchengines, (GDestroyNotify)free_searchengine);
}
}
gboolean searchengine_add(const char *handle, const char *uri)
{
/* validate if the uri contains only one %s sequence */
- if (!searchengine_is_valid_uri(uri)) {
+ if (!is_valid_uri(uri)) {
return false;
}
Searchengine *s = g_new0(Searchengine, 1);
gboolean searchengine_remove(const char *handle)
{
- GSList *list = searchengine_find(handle);
+ GSList *list = find(handle);
if (list) {
- searchengine_free((Searchengine*)list->data);
+ free_searchengine((Searchengine*)list->data);
vb.behave.searchengines = g_slist_delete_link(vb.behave.searchengines, list);
return TRUE;
if ((p = strchr(string, ' '))) {
*p = '\0';
/* is the first word the handle? */
- if ((l = searchengine_find(string))) {
+ if ((l = find(string))) {
tmpl = ((Searchengine*)l->data)->uri;
query = soup_uri_encode(p + 1, "&");
} else {
}
}
- if (!tmpl && (l = searchengine_find(vb.behave.searchengine_default))) {
+ if (!tmpl && (l = find(vb.behave.searchengine_default))) {
tmpl = ((Searchengine*)l->data)->uri;
query = soup_uri_encode(string, "&");
}
return NULL;
}
-static GSList *searchengine_find(const char *handle)
+static GSList *find(const char *handle)
{
GSList *s;
for (s = vb.behave.searchengines; s != NULL; s = s->next) {
return NULL;
}
-static gboolean searchengine_is_valid_uri(const char *uri)
+static gboolean is_valid_uri(const char *uri)
{
int count = 0;
return count == 1;
}
-static void searchengine_free(Searchengine *se)
+static void free_searchengine(Searchengine *se)
{
g_free(se->uri);
g_free(se->handle);
#include "main.h"
#include "session.h"
-G_DEFINE_TYPE(SessionCookieJar, session_cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
-
-static SoupCookieJar *session_cookiejar_new(const char *file, gboolean ro);
-static void session_cookiejar_changed(SoupCookieJar *self, SoupCookie *old, SoupCookie *new);
-static void session_cookiejar_class_init(SessionCookieJarClass *class);
-static void session_cookiejar_finalize(GObject *self);
-static void session_cookiejar_init(SessionCookieJar *self);
-static void session_cookiejar_set_property(GObject *self, guint prop_id,
+#define COOKIEJAR_TYPE (cookiejar_get_type())
+#define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), COOKIEJAR_TYPE, CookieJar))
+
+typedef struct {
+ SoupCookieJarText parent_instance;
+ int lock;
+} CookieJar;
+
+typedef struct {
+ SoupCookieJarTextClass parent_class;
+} CookieJarClass;
+
+static GType cookiejar_get_type(void);
+
+G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+
+static SoupCookieJar *cookiejar_new(const char *file, gboolean ro);
+static void cookiejar_changed(SoupCookieJar *self, SoupCookie *old, SoupCookie *new);
+static void cookiejar_class_init(CookieJarClass *class);
+static void cookiejar_finalize(GObject *self);
+static void cookiejar_init(CookieJar *self);
+static void cookiejar_set_property(GObject *self, guint prop_id,
const GValue *value, GParamSpec *pspec);
extern VbCore vb;
vb.soup_session = webkit_get_default_session();
soup_session_add_feature(
vb.soup_session,
- SOUP_SESSION_FEATURE(session_cookiejar_new(vb.files[FILES_COOKIE], false))
+ SOUP_SESSION_FEATURE(cookiejar_new(vb.files[FILES_COOKIE], false))
);
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);
}
-static SoupCookieJar *session_cookiejar_new(const char *file, gboolean ro)
+static SoupCookieJar *cookiejar_new(const char *file, gboolean ro)
{
return g_object_new(
- SESSION_COOKIEJAR_TYPE, SOUP_COOKIE_JAR_TEXT_FILENAME, file, SOUP_COOKIE_JAR_READ_ONLY, ro, NULL
+ COOKIEJAR_TYPE, SOUP_COOKIE_JAR_TEXT_FILENAME, file, SOUP_COOKIE_JAR_READ_ONLY, ro, NULL
);
}
-static void session_cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie, SoupCookie *new_cookie)
+static void cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie, SoupCookie *new_cookie)
{
- flock(SESSION_COOKIEJAR(self)->lock, LOCK_EX);
+ flock(COOKIEJAR(self)->lock, LOCK_EX);
if (new_cookie && !new_cookie->expires) {
soup_cookie_set_expires(new_cookie, soup_date_new_from_now(vb.config.cookie_timeout));
}
- SOUP_COOKIE_JAR_CLASS(session_cookiejar_parent_class)->changed(self, old_cookie, new_cookie);
- flock(SESSION_COOKIEJAR(self)->lock, LOCK_UN);
+ SOUP_COOKIE_JAR_CLASS(cookiejar_parent_class)->changed(self, old_cookie, new_cookie);
+ flock(COOKIEJAR(self)->lock, LOCK_UN);
}
-static void session_cookiejar_class_init(SessionCookieJarClass *class)
+static void cookiejar_class_init(CookieJarClass *class)
{
- SOUP_COOKIE_JAR_CLASS(class)->changed = session_cookiejar_changed;
- G_OBJECT_CLASS(class)->get_property = G_OBJECT_CLASS(session_cookiejar_parent_class)->get_property;
- G_OBJECT_CLASS(class)->set_property = session_cookiejar_set_property;
- G_OBJECT_CLASS(class)->finalize = session_cookiejar_finalize;
+ SOUP_COOKIE_JAR_CLASS(class)->changed = cookiejar_changed;
+ G_OBJECT_CLASS(class)->get_property = G_OBJECT_CLASS(cookiejar_parent_class)->get_property;
+ G_OBJECT_CLASS(class)->set_property = cookiejar_set_property;
+ G_OBJECT_CLASS(class)->finalize = cookiejar_finalize;
g_object_class_override_property(G_OBJECT_CLASS(class), 1, "filename");
}
-static void session_cookiejar_finalize(GObject *self)
+static void cookiejar_finalize(GObject *self)
{
- close(SESSION_COOKIEJAR(self)->lock);
- G_OBJECT_CLASS(session_cookiejar_parent_class)->finalize(self);
+ close(COOKIEJAR(self)->lock);
+ G_OBJECT_CLASS(cookiejar_parent_class)->finalize(self);
}
-static void session_cookiejar_init(SessionCookieJar *self)
+static void cookiejar_init(CookieJar *self)
{
self->lock = open(vb.files[FILES_COOKIE], 0);
}
-static void session_cookiejar_set_property(GObject *self, guint prop_id, const
+static void cookiejar_set_property(GObject *self, guint prop_id, const
GValue *value, GParamSpec *pspec)
{
- flock(SESSION_COOKIEJAR(self)->lock, LOCK_SH);
- G_OBJECT_CLASS(session_cookiejar_parent_class)->set_property(self, prop_id, value, pspec);
- flock(SESSION_COOKIEJAR(self)->lock, LOCK_UN);
+ flock(COOKIEJAR(self)->lock, LOCK_SH);
+ G_OBJECT_CLASS(cookiejar_parent_class)->set_property(self, prop_id, value, pspec);
+ flock(COOKIEJAR(self)->lock, LOCK_UN);
}
#ifndef _SESSION_H
#define _SESSION_H
-#include <glib.h>
-#include <libsoup/soup.h>
-
-#define SESSION_COOKIEJAR_TYPE (session_cookiejar_get_type())
-#define SESSION_COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SESSION_COOKIEJAR_TYPE, SessionCookieJar))
-
-typedef struct {
- SoupCookieJarText parent_instance;
- int lock;
-} SessionCookieJar;
-
-typedef struct {
- SoupCookieJarTextClass parent_class;
-} SessionCookieJarClass;
-
-GType session_cookiejar_get_type(void);
-
void session_init(void);
#endif /* end of include guard: _SESSION_H */
extern VbCore vb;
-static Arg *setting_char_to_arg(const char *str, const Type 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 Arg *char_to_arg(const char *str, const Type type);
+static void print_value(const Setting *s, void *value);
+static gboolean webkit(const Setting *s, const SettingType type);
+static gboolean cookie_timeout(const Setting *s, const SettingType type);
+static gboolean scrollstep(const Setting *s, const SettingType type);
+static gboolean status_color_bg(const Setting *s, const SettingType type);
+static gboolean status_color_fg(const Setting *s, const SettingType type);
+static gboolean status_font(const Setting *s, const SettingType type);
+static gboolean input_style(const Setting *s, const SettingType type);
+static gboolean completion_style(const Setting *s, const SettingType type);
+static gboolean hint_style(const Setting *s, const SettingType type);
+static gboolean strict_ssl(const Setting *s, const SettingType type);
+static gboolean ca_bundle(const Setting *s, const SettingType type);
+static gboolean home_page(const Setting *s, const SettingType type);
+static gboolean download_path(const Setting *s, const SettingType type);
+static gboolean proxy(const Setting *s, const SettingType type);
+static gboolean user_style(const Setting *s, const SettingType type);
+static gboolean history_max_items(const Setting *s, const SettingType type);
static Setting default_settings[] = {
/* webkit settings */
/* alias, name, type, func, arg */
- {"images", "auto-load-images", TYPE_BOOLEAN, setting_webkit, {0}},
- {"cursivfont", "cursive-font-family", TYPE_CHAR, setting_webkit, {0}},
- {"defaultencondig", "default-encoding", TYPE_CHAR, setting_webkit, {0}},
- {"defaultfont", "default-font-family", TYPE_CHAR, setting_webkit, {0}},
- {"fontsize", "default-font-size", TYPE_INTEGER, setting_webkit, {0}},
- {"monofontsize", "default-monospace-font-size", TYPE_INTEGER, setting_webkit, {0}},
- {"caret", "enable-caret-browsing", TYPE_BOOLEAN, setting_webkit, {0}},
- {"webinspector", "enable-developer-extras", TYPE_BOOLEAN, setting_webkit, {0}},
- {"offlinecache", "enable-offline-web-application-cache", TYPE_BOOLEAN, setting_webkit, {0}},
- {"pagecache", "enable-page-cache", TYPE_BOOLEAN, setting_webkit, {0}},
- {"plugins", "enable-plugins", TYPE_BOOLEAN, setting_webkit, {0}},
- {"scripts", "enable-scripts", TYPE_BOOLEAN, setting_webkit, {0}},
- {"xssauditor", "enable-xss-auditor", TYPE_BOOLEAN, setting_webkit, {0}},
- {"minimumfontsize", "minimum-font-size", TYPE_INTEGER, setting_webkit, {0}},
- {"monofont", "monospace-font-family", TYPE_CHAR, setting_webkit, {0}},
- {"backgrounds", "print-backgrounds", TYPE_BOOLEAN, setting_webkit, {0}},
- {"sansfont", "sans-serif-font-family", TYPE_CHAR, setting_webkit, {0}},
- {"seriffont", "serif-font-family", TYPE_CHAR, setting_webkit, {0}},
- {"useragent", "user-agent", TYPE_CHAR, setting_webkit, {0}},
+ {"images", "auto-load-images", TYPE_BOOLEAN, webkit, {0}},
+ {"cursivfont", "cursive-font-family", TYPE_CHAR, webkit, {0}},
+ {"defaultencondig", "default-encoding", TYPE_CHAR, webkit, {0}},
+ {"defaultfont", "default-font-family", TYPE_CHAR, webkit, {0}},
+ {"fontsize", "default-font-size", TYPE_INTEGER, webkit, {0}},
+ {"monofontsize", "default-monospace-font-size", TYPE_INTEGER, webkit, {0}},
+ {"caret", "enable-caret-browsing", TYPE_BOOLEAN, webkit, {0}},
+ {"webinspector", "enable-developer-extras", TYPE_BOOLEAN, webkit, {0}},
+ {"offlinecache", "enable-offline-web-application-cache", TYPE_BOOLEAN, webkit, {0}},
+ {"pagecache", "enable-page-cache", TYPE_BOOLEAN, webkit, {0}},
+ {"plugins", "enable-plugins", TYPE_BOOLEAN, webkit, {0}},
+ {"scripts", "enable-scripts", TYPE_BOOLEAN, webkit, {0}},
+ {"xssauditor", "enable-xss-auditor", TYPE_BOOLEAN, webkit, {0}},
+ {"minimumfontsize", "minimum-font-size", TYPE_INTEGER, webkit, {0}},
+ {"monofont", "monospace-font-family", TYPE_CHAR, webkit, {0}},
+ {"backgrounds", "print-backgrounds", TYPE_BOOLEAN, webkit, {0}},
+ {"sansfont", "sans-serif-font-family", TYPE_CHAR, webkit, {0}},
+ {"seriffont", "serif-font-family", TYPE_CHAR, webkit, {0}},
+ {"useragent", "user-agent", TYPE_CHAR, webkit, {0}},
/* internal variables */
- {NULL, "stylesheet", TYPE_BOOLEAN, setting_user_style, {0}},
-
- {NULL, "proxy", TYPE_BOOLEAN, setting_proxy, {0}},
- {NULL, "cookie-timeout", TYPE_INTEGER, setting_cookie_timeout, {0}},
- {NULL, "strict-ssl", TYPE_BOOLEAN, setting_strict_ssl, {0}},
-
- {NULL, "scrollstep", TYPE_INTEGER, setting_scrollstep, {0}},
- {NULL, "status-color-bg", TYPE_COLOR, setting_status_color_bg, {0}},
- {NULL, "status-color-fg", TYPE_COLOR, setting_status_color_fg, {0}},
- {NULL, "status-font", TYPE_FONT, setting_status_font, {0}},
- {NULL, "status-ssl-color-bg", TYPE_COLOR, setting_status_color_bg, {0}},
- {NULL, "status-ssl-color-fg", TYPE_COLOR, setting_status_color_fg, {0}},
- {NULL, "status-ssl-font", TYPE_FONT, setting_status_font, {0}},
- {NULL, "status-sslinvalid-color-bg", TYPE_COLOR, setting_status_color_bg, {0}},
- {NULL, "status-sslinvalid-color-fg", TYPE_COLOR, setting_status_color_fg, {0}},
- {NULL, "status-sslinvalid-font", TYPE_FONT, setting_status_font, {0}},
- {NULL, "input-bg-normal", TYPE_COLOR, setting_input_style, {0}},
- {NULL, "input-bg-error", TYPE_COLOR, setting_input_style, {0}},
- {NULL, "input-fg-normal", TYPE_COLOR, setting_input_style, {0}},
- {NULL, "input-fg-error", TYPE_COLOR, setting_input_style, {0}},
- {NULL, "input-font-normal", TYPE_FONT, setting_input_style, {0}},
- {NULL, "input-font-error", TYPE_FONT, setting_input_style, {0}},
- {NULL, "completion-font", TYPE_FONT, setting_completion_style, {0}},
- {NULL, "completion-fg-normal", TYPE_COLOR, setting_completion_style, {0}},
- {NULL, "completion-fg-active", TYPE_COLOR, setting_completion_style, {0}},
- {NULL, "completion-bg-normal", TYPE_COLOR, setting_completion_style, {0}},
- {NULL, "completion-bg-active", TYPE_COLOR, setting_completion_style, {0}},
- {NULL, "max-completion-items", TYPE_INTEGER, setting_completion_style, {0}},
- {NULL, "hint-bg", TYPE_CHAR, setting_hint_style, {0}},
- {NULL, "hint-bg-focus", TYPE_CHAR, setting_hint_style, {0}},
- {NULL, "hint-fg", TYPE_CHAR, setting_hint_style, {0}},
- {NULL, "hint-style", TYPE_CHAR, setting_hint_style, {0}},
- {NULL, "ca-bundle", TYPE_CHAR, setting_ca_bundle, {0}},
- {NULL, "home-page", TYPE_CHAR, setting_home_page, {0}},
- {NULL, "download-path", TYPE_CHAR, setting_download_path, {0}},
- {NULL, "history-max-items", TYPE_INTEGER, setting_history_max_items, {0}},
+ {NULL, "stylesheet", TYPE_BOOLEAN, user_style, {0}},
+
+ {NULL, "proxy", TYPE_BOOLEAN, proxy, {0}},
+ {NULL, "cookie-timeout", TYPE_INTEGER, cookie_timeout, {0}},
+ {NULL, "strict-ssl", TYPE_BOOLEAN, strict_ssl, {0}},
+
+ {NULL, "scrollstep", TYPE_INTEGER, scrollstep, {0}},
+ {NULL, "status-color-bg", TYPE_COLOR, status_color_bg, {0}},
+ {NULL, "status-color-fg", TYPE_COLOR, status_color_fg, {0}},
+ {NULL, "status-font", TYPE_FONT, status_font, {0}},
+ {NULL, "status-ssl-color-bg", TYPE_COLOR, status_color_bg, {0}},
+ {NULL, "status-ssl-color-fg", TYPE_COLOR, status_color_fg, {0}},
+ {NULL, "status-ssl-font", TYPE_FONT, status_font, {0}},
+ {NULL, "status-sslinvalid-color-bg", TYPE_COLOR, status_color_bg, {0}},
+ {NULL, "status-sslinvalid-color-fg", TYPE_COLOR, status_color_fg, {0}},
+ {NULL, "status-sslinvalid-font", TYPE_FONT, status_font, {0}},
+ {NULL, "input-bg-normal", TYPE_COLOR, input_style, {0}},
+ {NULL, "input-bg-error", TYPE_COLOR, input_style, {0}},
+ {NULL, "input-fg-normal", TYPE_COLOR, input_style, {0}},
+ {NULL, "input-fg-error", TYPE_COLOR, input_style, {0}},
+ {NULL, "input-font-normal", TYPE_FONT, input_style, {0}},
+ {NULL, "input-font-error", TYPE_FONT, input_style, {0}},
+ {NULL, "completion-font", TYPE_FONT, completion_style, {0}},
+ {NULL, "completion-fg-normal", TYPE_COLOR, completion_style, {0}},
+ {NULL, "completion-fg-active", TYPE_COLOR, completion_style, {0}},
+ {NULL, "completion-bg-normal", TYPE_COLOR, completion_style, {0}},
+ {NULL, "completion-bg-active", TYPE_COLOR, completion_style, {0}},
+ {NULL, "max-completion-items", TYPE_INTEGER, completion_style, {0}},
+ {NULL, "hint-bg", TYPE_CHAR, hint_style, {0}},
+ {NULL, "hint-bg-focus", TYPE_CHAR, hint_style, {0}},
+ {NULL, "hint-fg", TYPE_CHAR, hint_style, {0}},
+ {NULL, "hint-style", TYPE_CHAR, hint_style, {0}},
+ {NULL, "ca-bundle", TYPE_CHAR, ca_bundle, {0}},
+ {NULL, "home-page", TYPE_CHAR, home_page, {0}},
+ {NULL, "download-path", TYPE_CHAR, download_path, {0}},
+ {NULL, "history-max-items", TYPE_INTEGER, history_max_items, {0}},
};
void setting_init(void)
if (type == SETTING_SET) {
/* if string param is given convert it to the required data type and set
* it to the arg of the setting */
- a = setting_char_to_arg(param, s->type);
+ a = char_to_arg(param, s->type);
if (a == NULL) {
vb_echo(VB_MSG_ERROR, TRUE, "No valid value");
return false;
/**
* Converts string representing also given data type into and Arg.
*/
-static Arg *setting_char_to_arg(const char *str, const Type type)
+static Arg *char_to_arg(const char *str, const Type type)
{
if (!str) {
return NULL;
/**
* Print the setting value to the input box.
*/
-static void setting_print_value(const Setting *s, void *value)
+static void print_value(const Setting *s, void *value)
{
const char *name = s->alias ? s->alias : s->name;
char *string = NULL;
}
}
-static gboolean setting_webkit(const Setting *s, const SettingType type)
+static gboolean webkit(const Setting *s, const SettingType type)
{
WebKitWebSettings *web_setting = webkit_web_view_get_settings(vb.gui.webview);
}
/* print the new value */
- setting_print_value(s, &value);
+ print_value(s, &value);
} else {
g_object_set(G_OBJECT(web_setting), s->name, s->arg.i ? TRUE : false, NULL);
}
if (type == SETTING_GET) {
int value;
g_object_get(G_OBJECT(web_setting), s->name, &value, NULL);
- setting_print_value(s, &value);
+ print_value(s, &value);
} else {
g_object_set(G_OBJECT(web_setting), s->name, s->arg.i, NULL);
}
if (type == SETTING_GET) {
gfloat value;
g_object_get(G_OBJECT(web_setting), s->name, &value, NULL);
- setting_print_value(s, &value);
+ print_value(s, &value);
} else {
g_object_set(G_OBJECT(web_setting), s->name, (gfloat)(s->arg.i / 1000000.0), NULL);
}
if (type == SETTING_GET) {
char *value = NULL;
g_object_get(G_OBJECT(web_setting), s->name, &value, NULL);
- setting_print_value(s, value);
+ print_value(s, value);
} else {
g_object_set(G_OBJECT(web_setting), s->name, s->arg.s, NULL);
}
return TRUE;
}
-static gboolean setting_cookie_timeout(const Setting *s, const SettingType type)
+static gboolean cookie_timeout(const Setting *s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, &vb.config.cookie_timeout);
+ print_value(s, &vb.config.cookie_timeout);
} else {
vb.config.cookie_timeout = s->arg.i;
}
return TRUE;
}
-static gboolean setting_scrollstep(const Setting *s, const SettingType type)
+static gboolean scrollstep(const Setting *s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, &vb.config.scrollstep);
+ print_value(s, &vb.config.scrollstep);
} else {
vb.config.scrollstep = s->arg.i;
}
return TRUE;
}
-static gboolean setting_status_color_bg(const Setting *s, const SettingType type)
+static gboolean status_color_bg(const Setting *s, const SettingType type)
{
StatusType stype;
if (g_str_has_prefix(s->name, "status-sslinvalid")) {
}
if (type == SETTING_GET) {
- setting_print_value(s, &vb.style.status_bg[stype]);
+ print_value(s, &vb.style.status_bg[stype]);
} else {
VB_COLOR_PARSE(&vb.style.status_bg[stype], s->arg.s);
vb_update_status_style();
return TRUE;
}
-static gboolean setting_status_color_fg(const Setting *s, const SettingType type)
+static gboolean status_color_fg(const Setting *s, const SettingType type)
{
StatusType stype;
if (g_str_has_prefix(s->name, "status-sslinvalid")) {
}
if (type == SETTING_GET) {
- setting_print_value(s, &vb.style.status_fg[stype]);
+ print_value(s, &vb.style.status_fg[stype]);
} else {
VB_COLOR_PARSE(&vb.style.status_fg[stype], s->arg.s);
vb_update_status_style();
return TRUE;
}
-static gboolean setting_status_font(const Setting *s, const SettingType type)
+static gboolean status_font(const Setting *s, const SettingType type)
{
StatusType stype;
if (g_str_has_prefix(s->name, "status-sslinvalid")) {
}
if (type == SETTING_GET) {
- setting_print_value(s, vb.style.status_font[stype]);
+ print_value(s, vb.style.status_font[stype]);
} else {
if (vb.style.status_font[stype]) {
/* free previous font description */
return TRUE;
}
-static gboolean setting_input_style(const Setting *s, const SettingType type)
+static gboolean input_style(const Setting *s, const SettingType type)
{
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(s, style->input_font[itype]);
+ print_value(s, style->input_font[itype]);
} else {
if (style->input_font[itype]) {
pango_font_description_free(style->input_font[itype]);
}
if (type == SETTING_GET) {
- setting_print_value(s, color);
+ print_value(s, color);
} else {
VB_COLOR_PARSE(color, s->arg.s);
}
return TRUE;
}
-static gboolean setting_completion_style(const Setting *s, const SettingType type)
+static gboolean completion_style(const Setting *s, const SettingType type)
{
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(s, &vb.config.max_completion_items);
+ print_value(s, &vb.config.max_completion_items);
} else {
vb.config.max_completion_items = s->arg.i;
}
} else if (s->type == TYPE_FONT) {
if (type == SETTING_GET) {
- setting_print_value(s, style->comp_font);
+ print_value(s, style->comp_font);
} else {
if (style->comp_font) {
pango_font_description_free(style->comp_font);
}
if (type == SETTING_GET) {
- setting_print_value(s, color);
+ print_value(s, color);
} else {
VB_COLOR_PARSE(color, s->arg.s);
}
return TRUE;
}
-static gboolean setting_hint_style(const Setting *s, const SettingType type)
+static gboolean hint_style(const Setting *s, const SettingType type)
{
Style *style = &vb.style;
if (!g_strcmp0(s->name, "hint-bg")) {
if (type == SETTING_GET) {
- setting_print_value(s, style->hint_bg);
+ 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(s, style->hint_bg_focus);
+ 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(s, style->hint_fg);
+ print_value(s, style->hint_fg);
} else {
OVERWRITE_STRING(style->hint_fg, s->arg.s)
}
} else {
if (type == SETTING_GET) {
- setting_print_value(s, style->hint_style);
+ print_value(s, style->hint_style);
} else {
OVERWRITE_STRING(style->hint_style, s->arg.s);
}
return TRUE;
}
-static gboolean setting_strict_ssl(const Setting *s, const SettingType type)
+static gboolean strict_ssl(const Setting *s, const SettingType type)
{
gboolean value;
if (type != SETTING_SET) {
g_object_get(vb.soup_session, "ssl-strict", &value, NULL);
if (type == SETTING_GET) {
- setting_print_value(s, &value);
+ print_value(s, &value);
return TRUE;
}
return TRUE;
}
-static gboolean setting_ca_bundle(const Setting *s, const SettingType type)
+static gboolean ca_bundle(const Setting *s, const SettingType type)
{
char *value;
if (type == SETTING_GET) {
g_object_get(vb.soup_session, "ssl-ca-file", &value, NULL);
- setting_print_value(s, value);
+ print_value(s, value);
g_free(value);
} else {
g_object_set(vb.soup_session, "ssl-ca-file", s->arg.s, NULL);
return TRUE;
}
-static gboolean setting_home_page(const Setting *s, const SettingType type)
+static gboolean home_page(const Setting *s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, vb.config.home_page);
+ print_value(s, vb.config.home_page);
} else {
OVERWRITE_STRING(vb.config.home_page, s->arg.s);
}
return TRUE;
}
-static gboolean setting_download_path(const Setting *s, const SettingType type)
+static gboolean download_path(const Setting *s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, vb.config.download_dir);
+ print_value(s, vb.config.download_dir);
} else {
if (vb.config.download_dir) {
g_free(vb.config.download_dir);
return TRUE;
}
-static gboolean setting_proxy(const Setting *s, const SettingType type)
+static gboolean proxy(const Setting *s, const SettingType type)
{
gboolean enabled;
char *proxy, *proxy_new;
enabled = (proxy_uri != NULL);
if (type == SETTING_GET) {
- setting_print_value(s, &enabled);
+ print_value(s, &enabled);
return TRUE;
}
if (type == SETTING_TOGGLE) {
enabled = !enabled;
/* print the new value */
- setting_print_value(s, &enabled);
+ print_value(s, &enabled);
} else {
enabled = s->arg.i;
}
return TRUE;
}
-static gboolean setting_user_style(const Setting *s, const SettingType type)
+static gboolean user_style(const Setting *s, const SettingType type)
{
gboolean enabled = false;
char *uri = NULL;
enabled = (uri != NULL);
if (type == SETTING_GET) {
- setting_print_value(s, &enabled);
+ print_value(s, &enabled);
return TRUE;
}
if (type == SETTING_TOGGLE) {
enabled = !enabled;
/* print the new value */
- setting_print_value(s, &enabled);
+ print_value(s, &enabled);
} else {
enabled = s->arg.i;
}
return TRUE;
}
-static gboolean setting_history_max_items(const Setting *s, const SettingType type)
+static gboolean history_max_items(const Setting *s, const SettingType type)
{
if (type == SETTING_GET) {
- setting_print_value(s, &vb.config.history_max);
+ print_value(s, &vb.config.history_max);
return TRUE;
}