diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 72 | ||||
-rw-r--r-- | src/command.h | 56 | ||||
-rw-r--r-- | src/completion.c | 56 | ||||
-rw-r--r-- | src/config.h | 2 | ||||
-rw-r--r-- | src/dom.c | 36 | ||||
-rw-r--r-- | src/dom.h | 2 | ||||
-rw-r--r-- | src/hints.c | 34 | ||||
-rw-r--r-- | src/hints.h | 4 | ||||
-rw-r--r-- | src/history.c | 58 | ||||
-rw-r--r-- | src/history.h | 8 | ||||
-rw-r--r-- | src/keybind.c | 48 | ||||
-rw-r--r-- | src/keybind.h | 8 | ||||
-rw-r--r-- | src/main.c | 226 | ||||
-rw-r--r-- | src/main.h | 88 | ||||
-rw-r--r-- | src/searchengine.c | 34 | ||||
-rw-r--r-- | src/searchengine.h | 8 | ||||
-rw-r--r-- | src/setting.c | 112 | ||||
-rw-r--r-- | src/util.c | 28 |
18 files changed, 440 insertions, 440 deletions
diff --git a/src/command.c b/src/command.c index e282614..1591369 100644 --- a/src/command.c +++ b/src/command.c @@ -116,14 +116,14 @@ void command_cleanup(void) } } -gboolean command_exists(const char* name) +gboolean command_exists(const char *name) { return g_hash_table_contains(vb.behave.commands, name); } -gboolean command_run(const char* name, const char* param) +gboolean command_run(const char *name, const char *param) { - CommandInfo* command = NULL; + CommandInfo *command = NULL; gboolean result; Arg a; command = g_hash_table_lookup(vb.behave.commands, name); @@ -141,7 +141,7 @@ gboolean command_run(const char* name, const char* param) return result; } -gboolean command_open(const Arg* arg) +gboolean command_open(const Arg *arg) { return vb_load_uri(arg); } @@ -149,7 +149,7 @@ gboolean command_open(const Arg* arg) /** * Reopens the last closed page. */ -gboolean command_open_closed(const Arg* arg) +gboolean command_open_closed(const Arg *arg) { gboolean result; @@ -161,16 +161,16 @@ gboolean command_open_closed(const Arg* arg) return result; } -gboolean command_input(const Arg* arg) +gboolean command_input(const Arg *arg) { - const char* url; + const char *url; /* add current url if requested */ if (VB_INPUT_CURRENT_URI == arg->i && (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); + char *input = g_strconcat(arg->s, url, NULL); vb_echo_force(VB_MSG_NORMAL, FALSE, input); g_free(input); } else { @@ -182,14 +182,14 @@ gboolean command_input(const Arg* arg) return TRUE; } -gboolean command_close(const Arg* arg) +gboolean command_close(const Arg *arg) { gtk_widget_destroy(GTK_WIDGET(vb.gui.window)); return TRUE; } -gboolean command_view_source(const Arg* arg) +gboolean command_view_source(const Arg *arg) { gboolean mode = webkit_web_view_get_view_source_mode(vb.gui.webview); webkit_web_view_set_view_source_mode(vb.gui.webview, !mode); @@ -200,9 +200,9 @@ gboolean command_view_source(const Arg* arg) return TRUE; } -gboolean command_navigate(const Arg* arg) +gboolean command_navigate(const Arg *arg) { - WebKitWebView* view = vb.gui.webview; + WebKitWebView *view = vb.gui.webview; if (arg->i <= VB_NAVIG_FORWARD) { int count = vb.state.count ? vb.state.count : 1; webkit_web_view_go_back_or_forward( @@ -221,7 +221,7 @@ gboolean command_navigate(const Arg* arg) return TRUE; } -gboolean command_scroll(const Arg* arg) +gboolean command_scroll(const Arg *arg) { GtkAdjustment *adjust = (arg->i & VB_SCROLL_AXIS_H) ? vb.gui.adjust_h : vb.gui.adjust_v; @@ -256,9 +256,9 @@ gboolean command_scroll(const Arg* arg) return TRUE; } -gboolean command_map(const Arg* arg) +gboolean command_map(const Arg *arg) { - char* key; + char *key; vb_set_mode(VB_MODE_NORMAL, FALSE); @@ -271,18 +271,18 @@ gboolean command_map(const Arg* arg) return FALSE; } -gboolean command_unmap(const Arg* arg) +gboolean command_unmap(const Arg *arg) { vb_set_mode(VB_MODE_NORMAL, FALSE); return keybind_remove_from_string(arg->s, arg->i); } -gboolean command_set(const Arg* arg) +gboolean command_set(const Arg *arg) { gboolean success; - char* line = NULL; - char* param; + char *line = NULL; + char *param; if (!arg->s || !strlen(arg->s)) { return FALSE; @@ -306,7 +306,7 @@ gboolean command_set(const Arg* arg) return success; } -gboolean command_complete(const Arg* arg) +gboolean command_complete(const Arg *arg) { completion_complete(arg->i ? TRUE : FALSE); @@ -315,10 +315,10 @@ gboolean command_complete(const Arg* arg) return TRUE; } -gboolean command_inspect(const Arg* arg) +gboolean command_inspect(const Arg *arg) { gboolean enabled; - WebKitWebSettings* settings = NULL; + WebKitWebSettings *settings = NULL; vb_set_mode(VB_MODE_NORMAL, FALSE); @@ -338,7 +338,7 @@ gboolean command_inspect(const Arg* arg) return FALSE; } -gboolean command_hints(const Arg* arg) +gboolean command_hints(const Arg *arg) { vb_echo_force(VB_MSG_NORMAL, FALSE, arg->s); /* mode will be set in hints_create - so we don't neet to do it here */ @@ -347,19 +347,19 @@ gboolean command_hints(const Arg* arg) return TRUE; } -gboolean command_hints_focus(const Arg* arg) +gboolean command_hints_focus(const Arg *arg) { hints_focus_next(arg->i ? TRUE : FALSE); return TRUE; } -gboolean command_yank(const Arg* arg) +gboolean command_yank(const Arg *arg) { vb_set_mode(VB_MODE_NORMAL, TRUE); if (arg->i & COMMAND_YANK_SELECTION) { - char* text = NULL; + char *text = NULL; /* copy current selection to clipboard */ webkit_web_view_copy_clipboard(vb.gui.webview); text = gtk_clipboard_wait_for_text(PRIMARY_CLIPBOARD()); @@ -394,7 +394,7 @@ gboolean command_yank(const Arg* arg) return FALSE; } -gboolean command_paste(const Arg* arg) +gboolean command_paste(const Arg *arg) { Arg a = {.i = arg->i & VB_TARGET_NEW}; if (arg->i & VB_CLIPBOARD_PRIMARY) { @@ -413,7 +413,7 @@ gboolean command_paste(const Arg* arg) return FALSE; } -gboolean command_search(const Arg* arg) +gboolean command_search(const Arg *arg) { gboolean forward = !(arg->i ^ vb.state.search_dir); @@ -450,11 +450,11 @@ gboolean command_search(const Arg* arg) return TRUE; } -gboolean command_searchengine(const Arg* arg) +gboolean command_searchengine(const Arg *arg) { gboolean result; if (arg->i) { - char* handle; + char *handle; if ((handle = strchr(arg->s, '='))) { *handle = '\0'; @@ -473,14 +473,14 @@ gboolean command_searchengine(const Arg* arg) return result; } -gboolean command_searchengine_default(const Arg* arg) +gboolean command_searchengine_default(const Arg *arg) { vb_set_mode(VB_MODE_NORMAL, FALSE); return searchengine_set_default(arg->s); } -gboolean command_zoom(const Arg* arg) +gboolean command_zoom(const Arg *arg) { float step, level; int count; @@ -495,7 +495,7 @@ gboolean command_zoom(const Arg* arg) 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(vb.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( @@ -513,10 +513,10 @@ gboolean command_zoom(const Arg* arg) } -gboolean command_history(const Arg* arg) +gboolean command_history(const Arg *arg) { - const char* input = GET_TEXT(); - char* entry = history_get(input, arg->i); + const char *input = GET_TEXT(); + char *entry = history_get(input, arg->i); if (!entry) { return FALSE; diff --git a/src/command.h b/src/command.h index 15e8e1f..d952cd8 100644 --- a/src/command.h +++ b/src/command.h @@ -34,41 +34,41 @@ enum { COMMAND_ZOOM_RESET = (1<<2) }; -typedef gboolean (*Command)(const Arg* arg); +typedef gboolean (*Command)(const Arg *arg); typedef struct { - const char* name; - Command function; - const Arg arg; /* arguments to call the command with */ + const char *name; + Command function; + const Arg arg; /* arguments to call the command with */ } CommandInfo; void command_init(void); void command_cleanup(void); -gboolean command_exists(const char* name); -gboolean command_run(const char* name, const char* param); +gboolean command_exists(const char *name); +gboolean command_run(const char *name, const char *param); -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_searchengine_default(const Arg* arg); -gboolean command_zoom(const Arg* arg); -gboolean command_history(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_searchengine_default(const Arg *arg); +gboolean command_zoom(const Arg *arg); +gboolean command_history(const Arg *arg); #endif /* end of include guard: _COMMAND_H */ diff --git a/src/completion.c b/src/completion.c index 7835f45..2db1e4e 100644 --- a/src/completion.c +++ b/src/completion.c @@ -25,30 +25,30 @@ extern VbCore vb; typedef gboolean (*Comp_Func)(char*, const char*); typedef struct { - GtkWidget* label; - GtkWidget* event; - char* prefix; + GtkWidget *label; + GtkWidget *event; + char *prefix; } Completion; -static GList* completion_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 GList *completion_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 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(gboolean back) { - const char* input = GET_TEXT(); - GList* source = NULL; + const char *input = GET_TEXT(); + GList *source = NULL; if (vb.comps.completions && vb.comps.active && (vb.state.mode & VB_MODE_COMPLETE) ) { - char* text = completion_get_text((Completion*)vb.comps.active->data); + char *text = completion_get_text((Completion*)vb.comps.active->data); if (!strcmp(input, text)) { /* updatecompletions */ vb.comps.active = completion_update(vb.comps.completions, vb.comps.active, back); @@ -124,11 +124,11 @@ void completion_clean() vb.state.mode &= ~VB_MODE_COMPLETE; } -static GList* completion_init_completion(GList* target, GList* source, - Comp_Func func, const char* input, const char* prefix) +static GList *completion_init_completion(GList *target, GList *source, + Comp_Func func, const char *input, const char *prefix) { - char* command = NULL; - char* data = NULL; + char *command = NULL; + char *data = NULL; gboolean match; char **token = NULL; @@ -138,7 +138,7 @@ static GList* completion_init_completion(GList* target, GList* source, token = g_strsplit(command, " ", -1); - for (GList* l = source; l; l = l->next) { + for (GList *l = source; l; l = l->next) { data = l->data; match = FALSE; if (*command == 0) { @@ -154,7 +154,7 @@ static GList* completion_init_completion(GList* target, GList* source, } } if (match) { - Completion* completion = completion_get_new(data, prefix); + Completion *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); @@ -167,7 +167,7 @@ static GList* completion_init_completion(GList* target, GList* source, return target; } -static GList* completion_update(GList* completion, GList* active, gboolean back) +static GList *completion_update(GList *completion, GList *active, gboolean back) { GList *old, *new; Completion *comp; @@ -248,7 +248,7 @@ static void completion_show(gboolean back) } } if (vb.comps.active != NULL) { - Completion* active = (Completion*)vb.comps.active->data; + 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); @@ -257,9 +257,9 @@ static void completion_show(gboolean back) } } -static void completion_set_entry_text(Completion* completion) +static void completion_set_entry_text(Completion *completion) { - char* text = completion_get_text(completion); + 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); @@ -268,9 +268,9 @@ static void completion_set_entry_text(Completion* completion) /** * Retrieves the full new allocated entry text for given completion item. */ -static char* completion_get_text(Completion* completion) +static char *completion_get_text(Completion *completion) { - char* text = NULL; + char *text = NULL; /* print the previous typed command count into inputbox too */ if (vb.comps.count) { @@ -286,10 +286,10 @@ static char* completion_get_text(Completion* completion) return text; } -static Completion* completion_get_new(const char* label, const char* prefix) +static Completion *completion_get_new(const char *label, const char *prefix) { const int padding = 2; - Completion* c = g_new0(Completion, 1); + Completion *c = g_new0(Completion, 1); c->label = gtk_label_new(label); c->event = gtk_event_box_new(); @@ -323,7 +323,7 @@ static Completion* completion_get_new(const char* label, const char* prefix) return c; } -static void completion_free(Completion* completion) +static void completion_free(Completion *completion) { gtk_widget_destroy(completion->event); g_free(completion->prefix); diff --git a/src/config.h b/src/config.h index 55f8869..f762a92 100644 --- a/src/config.h +++ b/src/config.h @@ -35,7 +35,7 @@ const unsigned int INPUT_LENGTH = 120; const unsigned int MAXIMUM_HINTS = 500; const struct { - char* command; + char *command; } default_config[] = { {"nmap gf=source"}, {"nmap gF=inspect"}, @@ -22,20 +22,20 @@ 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 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(void) { - Document* doc = webkit_web_view_get_dom_document(vb.gui.webview); - Element* active = dom_get_active_element(doc); + Document *doc = webkit_web_view_get_dom_document(vb.gui.webview); + Element *active = dom_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)) { - HtmlElement* element = webkit_dom_document_get_body(doc); + HtmlElement *element = webkit_dom_document_get_body(doc); if (!element) { element = WEBKIT_DOM_HTML_ELEMENT(webkit_dom_document_get_document_element(doc)); } @@ -50,8 +50,8 @@ void dom_check_auto_insert(void) */ void dom_clear_focus(void) { - Document* doc = webkit_web_view_get_dom_document(vb.gui.webview); - Element* active = dom_get_active_element(doc); + Document *doc = webkit_web_view_get_dom_document(vb.gui.webview); + Element *active = dom_get_active_element(doc); if (active) { webkit_dom_element_blur(active); @@ -62,14 +62,14 @@ void dom_clear_focus(void) * Indicates if the given dom element is an editable element like text input, * password or textarea. */ -gboolean dom_is_editable(Element* element) +gboolean dom_is_editable(Element *element) { gboolean result = FALSE; if (!element) { return result; } - char* tagname = webkit_dom_element_get_tag_name(element); + char *tagname = webkit_dom_element_get_tag_name(element); char *type = webkit_dom_element_get_attribute(element, "type"); if (!g_ascii_strcasecmp(tagname, "textarea")) { result = TRUE; @@ -88,7 +88,7 @@ gboolean dom_is_editable(Element* element) return result; } -static gboolean dom_auto_insert(Element* element) +static gboolean dom_auto_insert(Element *element) { if (dom_is_editable(element)) { vb_set_mode(VB_MODE_INSERT, FALSE); @@ -97,24 +97,24 @@ static gboolean dom_auto_insert(Element* element) return FALSE; } -static gboolean dom_editable_focus_cb(Element* element, Event* event) +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(vb.state.mode) != VB_MODE_INSERT) { - EventTarget* target = webkit_dom_event_get_target(event); + EventTarget *target = webkit_dom_event_get_target(event); dom_auto_insert((void*)target); } return FALSE; } -static Element* dom_get_active_element(Document* doc) +static Element *dom_get_active_element(Document *doc) { - Document* d = NULL; - Element* active = webkit_dom_html_document_get_active_element((void*)doc); - char* tagname = webkit_dom_element_get_tag_name(active); - Element* result = NULL; + Document *d = NULL; + Element *active = webkit_dom_html_document_get_active_element((void*)doc); + char *tagname = webkit_dom_element_get_tag_name(active); + Element *result = NULL; if (!g_strcmp0(tagname, "FRAME")) { d = webkit_dom_html_frame_element_get_content_document(WEBKIT_DOM_HTML_FRAME_ELEMENT(active)); @@ -41,6 +41,6 @@ typedef struct { void dom_check_auto_insert(void); void dom_clear_focus(void); -gboolean dom_is_editable(Element* element); +gboolean dom_is_editable(Element *element); #endif /* end of include guard: _DOM_H */ diff --git a/src/hints.c b/src/hints.c index 173da0e..161033e 100644 --- a/src/hints.c +++ b/src/hints.c @@ -30,15 +30,15 @@ extern VbCore vb; extern const unsigned int MAXIMUM_HINTS; -static void hints_run_script(char* js); +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 gboolean hints_keypress_callback(WebKitWebView *webview, GdkEventKey *event); -void hints_init(WebKitWebFrame* frame) +void hints_init(WebKitWebFrame *frame) { - char* value = NULL; + char *value = NULL; vb_eval_script(frame, HINTS_JS, HINT_FILE, &value); g_free(value); } @@ -47,8 +47,8 @@ void hints_clear() { 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; + char *js = g_strdup_printf("%s.clear();", HINT_VAR); + char *value = NULL; vb_eval_script(webkit_web_view_get_main_frame(vb.gui.webview), js, HINT_FILE, &value); g_free(value); g_free(js); @@ -57,13 +57,13 @@ void hints_clear() } } -void hints_create(const char* input, guint mode, const guint prefixLength) +void hints_create(const char *input, guint mode, const guint prefixLength) { - char* js = NULL; + char *js = NULL; if (CLEAN_MODE(vb.state.mode) != VB_MODE_HINTING) { vb_set_mode(VB_MODE_HINTING, FALSE); - Style* style = &vb.style; + Style *style = &vb.style; vb.hints.prefixLength = prefixLength; vb.hints.mode = mode; vb.hints.num = 0; @@ -102,21 +102,21 @@ void hints_create(const char* input, guint mode, const guint prefixLength) void hints_update(const gulong num) { - char* js = g_strdup_printf("%s.update(%lu);", HINT_VAR, num); + char *js = g_strdup_printf("%s.update(%lu);", HINT_VAR, num); hints_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); + char *js = g_strdup_printf(back ? "%s.focusPrev()" : "%s.focusNext();", HINT_VAR); hints_run_script(js); g_free(js); } -static void hints_run_script(char* js) +static void hints_run_script(char *js) { - char* value = NULL; + char *value = NULL; int mode = vb.hints.mode; gboolean success = vb_eval_script( @@ -141,7 +141,7 @@ static void hints_run_script(char* js) vb_set_mode(VB_MODE_INSERT, FALSE); } else if (!strncmp(value, "DATA:", 5)) { Arg a = {0}; - char* v = (value + 5); + char *v = (value + 5); if (mode & HINTS_PROCESS_INPUT) { a.s = g_strconcat((mode & HINTS_OPEN_NEW) ? ":tabopen " : ":open ", v, NULL); command_input(&a); @@ -157,7 +157,7 @@ static void hints_run_script(char* js) static void hints_fire() { - char* js = g_strdup_printf("%s.fire();", HINT_VAR); + char *js = g_strdup_printf("%s.fire();", HINT_VAR); hints_run_script(js); g_free(js); } @@ -181,7 +181,7 @@ static void hints_observe_input(gboolean observe) static gboolean hints_changed_callback(GtkEditable *entry) { - const char* text = GET_TEXT(); + const char *text = GET_TEXT(); /* skip hinting prefixes like '.', ',', ';y' ... */ hints_create(text + vb.hints.prefixLength, vb.hints.mode, vb.hints.prefixLength); @@ -189,7 +189,7 @@ static gboolean hints_changed_callback(GtkEditable *entry) return TRUE; } -static gboolean hints_keypress_callback(WebKitWebView* webview, GdkEventKey* event) +static gboolean hints_keypress_callback(WebKitWebView *webview, GdkEventKey *event) { int numval; guint keyval = event->keyval; diff --git a/src/hints.h b/src/hints.h index c96dd8e..17ef146 100644 --- a/src/hints.h +++ b/src/hints.h @@ -33,8 +33,8 @@ enum { HINTS_OPEN_NEW = (1 << 5), }; -void hints_init(WebKitWebFrame* frame); -void hints_create(const char* input, guint mode, const guint prefixLength); +void hints_init(WebKitWebFrame *frame); +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); diff --git a/src/history.c b/src/history.c index b17f391..aa016bf 100644 --- a/src/history.c +++ b/src/history.c @@ -30,15 +30,15 @@ static const VbFile file_map[HISTORY_LAST] = { }; static struct { - char* prefix; - char* query; - GList* active; + char *prefix; + char *query; + 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 *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); /** @@ -48,7 +48,7 @@ static void history_write_to_file(GList* list, const char* file); void history_cleanup(void) { for (HistoryType i = HISTORY_FIRST; i < HISTORY_LAST; i++) { - const char* file = history_get_file_by_type(i); + const char *file = history_get_file_by_type(i); history_write_to_file(history_load(file), file); } } @@ -56,10 +56,10 @@ void history_cleanup(void) /** * Write a new history entry to the end of history file. */ -void history_add(HistoryType type, const char* value) +void history_add(HistoryType type, const char *value) { - const char* file = history_get_file_by_type(type); - FILE* f; + const char *file = history_get_file_by_type(type); + FILE *f; if ((f = fopen(file, "a+"))) { file_lock_set(fileno(f), F_WRLCK); @@ -73,7 +73,7 @@ void history_add(HistoryType type, const char* value) /** * Retrieves all history entries for given history type. */ -GList* history_get_all(HistoryType type) +GList *history_get_all(HistoryType type) { return history_load(history_get_file_by_type(type)); } @@ -82,9 +82,9 @@ GList* history_get_all(HistoryType type) * Retrieves the command from history to be shown in input box. * The result must be freed by the caller. */ -char* history_get(const char* input, gboolean prev) +char *history_get(const char *input, gboolean prev) { - GList* new = NULL; + GList *new = NULL; if (!history.active) { history.active = history_get_list(input); @@ -115,7 +115,7 @@ void history_rewind(void) } } -void history_list_free(GList** list) +void history_list_free(GList **list) { if (*list) { g_list_free_full(*list, (GDestroyNotify)g_free); @@ -127,10 +127,10 @@ void history_list_free(GList** list) * Retrieves the list of matching history items. * The list must be freed. */ -static GList* history_get_list(const char* input) +static GList *history_get_list(const char *input) { HistoryType type; - GList* result = NULL; + GList *result = NULL; /* get the right history type and command prefix */ if (!strncmp(input, ":open ", 6)) { @@ -153,11 +153,11 @@ static GList* history_get_list(const char* input) return NULL; } - GList* src = history_load(history_get_file_by_type(type)); + GList *src = history_load(history_get_file_by_type(type)); /* generate new history list with the matching items */ - for (GList* l = src; l; l = l->next) { - char* value = (char*)l->data; + for (GList *l = src; l; l = l->next) { + char *value = (char*)l->data; if (g_str_has_prefix(value, history.query)) { result = g_list_prepend(result, g_strdup(value)); } @@ -166,7 +166,7 @@ static GList* history_get_list(const char* input) return result; } -static const char* history_get_file_by_type(HistoryType type) +static const char *history_get_file_by_type(HistoryType type) { return vb.files[file_map[type]]; } @@ -175,12 +175,12 @@ static const char* history_get_file_by_type(HistoryType type) * Loads history items form file but eleminate duplicates. * Oldest entries first. */ -static GList* history_load(const char* file) +static GList *history_load(const char *file) { /* read the history items from file */ - GList* list = NULL; + GList *list = NULL; char buf[512] = {0}; - FILE* f; + FILE *f; if (!(f = fopen(file, "r"))) { return list; @@ -195,7 +195,7 @@ static GList* history_load(const char* file) continue; } /* if the value is already in history, remove this entry */ - for (GList* l = list; l; l = l->next) { + for (GList *l = list; l; l = l->next) { if (*buf && !g_strcmp0(buf, (char*)l->data)) { g_free(l->data); list = g_list_delete_link(list, l); @@ -213,7 +213,7 @@ static GList* history_load(const char* file) /* reverse to not use the slow g_list_last */ list = g_list_reverse(list); while (vb.config.history_max < g_list_length(list)) { - GList* last = g_list_first(list); + GList *last = g_list_first(list); g_free(last->data); list = g_list_delete_link(list, last); } @@ -225,14 +225,14 @@ static GList* history_load(const char* file) /** * 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 history_write_to_file(GList *list, const char *file) { - FILE* f; + FILE *f; if ((f = fopen(file, "w"))) { file_lock_set(fileno(f), F_WRLCK); /* overwrite the history file with new unique history items */ - for (GList* link = g_list_reverse(list); link; link = link->next) { + for (GList *link = g_list_reverse(list); link; link = link->next) { fprintf(f, "%s\n", (char*)link->data); } diff --git a/src/history.h b/src/history.h index f2cc7f9..e2e711a 100644 --- a/src/history.h +++ b/src/history.h @@ -29,10 +29,10 @@ typedef enum { } HistoryType; void history_cleanup(void); -void history_add(HistoryType type, const char* value); -GList* history_get_all(HistoryType type); -char* history_get(const char* input, gboolean prev); +void history_add(HistoryType type, const char *value); +GList *history_get_all(HistoryType type); +char *history_get(const char *input, gboolean prev); void history_rewind(void); -void history_list_free(GList** list); +void history_list_free(GList **list); #endif /* end of include guard: _HISTORY_H */ diff --git a/src/keybind.c b/src/keybind.c index f9b941e..712153f 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -25,12 +25,12 @@ 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 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); void keybind_init(void) @@ -49,20 +49,20 @@ void keybind_cleanup(void) } } -gboolean keybind_add_from_string(char* keys, const char* command, const Mode mode) +gboolean keybind_add_from_string(char *keys, const char *command, const Mode mode) { if (keys == NULL || *keys == '\0') { return FALSE; } /* split the input string into command and parameter part */ - char** token = g_strsplit(command, " ", 2); + char **token = g_strsplit(command, " ", 2); if (!token[0] || !command_exists(token[0])) { g_strfreev(token); return FALSE; } - Keybind* keybind = g_new0(Keybind, 1); + Keybind *keybind = g_new0(Keybind, 1); keybind->mode = mode; keybind->command = g_strdup(token[0]); keybind->param = g_strdup(token[1]); @@ -81,7 +81,7 @@ gboolean keybind_add_from_string(char* keys, const char* command, const Mode mod return TRUE; } -gboolean keybind_remove_from_string(char* str, const Mode mode) +gboolean keybind_remove_from_string(char *str, const Mode mode) { Keybind keybind = {.mode = mode}; @@ -93,7 +93,7 @@ gboolean keybind_remove_from_string(char* str, const Mode mode) /* fill the keybind with data from given string */ keybind_str_to_keybind(str, &keybind); - GSList* link = keybind_find(keybind.mode, keybind.modkey, keybind.modmask, keybind.keyval); + GSList *link = keybind_find(keybind.mode, keybind.modkey, keybind.modmask, keybind.keyval); if (link) { keybind_free((Keybind*)link->data); vb.behave.keys = g_slist_delete_link(vb.behave.keys, link); @@ -112,7 +112,7 @@ gboolean keybind_remove_from_string(char* str, const Mode mode) */ static void keybind_rebuild_modkeys(void) { - GSList* link; + GSList *link; /* remove previous modkeys */ if (vb.behave.modkeys) { g_string_free(vb.behave.modkeys, TRUE); @@ -121,7 +121,7 @@ static void keybind_rebuild_modkeys(void) /* regenerate the modekeys */ for (link = vb.behave.keys; link != NULL; link = link->next) { - Keybind* keybind = (Keybind*)link->data; + Keybind *keybind = (Keybind*)link->data; /* if not not exists - add it */ if (keybind->modkey && strchr(vb.behave.modkeys->str, keybind->modkey) == NULL) { g_string_append_c(vb.behave.modkeys, keybind->modkey); @@ -129,11 +129,11 @@ static void keybind_rebuild_modkeys(void) } } -static GSList* keybind_find(int mode, guint modkey, guint modmask, guint keyval) +static GSList *keybind_find(int mode, guint modkey, guint modmask, guint keyval) { - GSList* link; + GSList *link; for (link = vb.behave.keys; link != NULL; link = link->next) { - Keybind* keybind = (Keybind*)link->data; + Keybind *keybind = (Keybind*)link->data; if (keybind->keyval == keyval && keybind->modmask == modmask && keybind->modkey == modkey @@ -149,9 +149,9 @@ static GSList* keybind_find(int mode, guint modkey, guint modmask, guint keyval) /** * Configures the given keybind by also given string. */ -static void keybind_str_to_keybind(char* str, Keybind* keybind) +static void keybind_str_to_keybind(char *str, Keybind *keybind) { - char** string = NULL; + char **string = NULL; guint len = 0; g_strstrip(str); @@ -204,7 +204,7 @@ static void keybind_str_to_keybind(char* str, Keybind* keybind) } } -static guint keybind_str_to_modmask(const char* str) +static guint keybind_str_to_modmask(const char *str) { if (g_ascii_strcasecmp(str, "ctrl") == 0) { return GDK_CONTROL_MASK; @@ -216,7 +216,7 @@ static guint keybind_str_to_modmask(const char* str) return 0; } -static guint keybind_str_to_value(const char* str) +static guint keybind_str_to_value(const char *str) { if (!strcmp(str, "tab")) { return GDK_Tab; @@ -233,7 +233,7 @@ static guint keybind_str_to_value(const char* str) return str[0]; } -static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* event) +static gboolean keybind_keypress_callback(WebKitWebView *webview, GdkEventKey *event) { guint keyval = event->keyval; guint state = CLEAN_STATE_WITH_SHIFT(event); @@ -264,10 +264,10 @@ static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* e } /* check for keybinding */ - GSList* link = keybind_find(CLEAN_MODE(vb.state.mode), vb.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; + Keybind *keybind = (Keybind*)link->data; command_run(keybind->command, keybind->param); return TRUE; @@ -276,7 +276,7 @@ static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* e return FALSE; } -static void keybind_free(Keybind* keybind) +static void keybind_free(Keybind *keybind) { g_free(keybind->command); g_free(keybind->param); diff --git a/src/keybind.h b/src/keybind.h index c9164c1..d337113 100644 --- a/src/keybind.h +++ b/src/keybind.h @@ -28,13 +28,13 @@ typedef struct { guint modkey; guint modmask; /* modemask for the kayval */ guint keyval; - char* command; /* command to run */ - char* param; + char *command; /* command to run */ + char *param; } Keybind; void keybind_init(void); 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); +gboolean keybind_add_from_string(char *keys, const char *command, const Mode mode); +gboolean keybind_remove_from_string(char *str, const Mode mode); #endif /* end of include guard: _KEYBIND_H */ @@ -35,47 +35,47 @@ static char **args; 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 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 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); -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); -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); + 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, + 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, + WebKitWebResource *resource, WebKitNetworkRequest *request, + WebKitNetworkResponse *response); /* functions */ -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 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_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 void vb_set_cookie(SoupCookie *cookie); +static const char *vb_get_cookies(SoupURI *uri); 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); +void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, const char *message); static void vb_destroy_client(); void vb_echo_force(const MessageType type,gboolean hide, const char *error, ...) @@ -102,7 +102,7 @@ void vb_echo(const MessageType type, gboolean hide, const char *error, ...) vb_inputbox_print(FALSE, type, hide, message); } -gboolean vb_eval_script(WebKitWebFrame* frame, char* script, char* file, char** value) +gboolean vb_eval_script(WebKitWebFrame *frame, char *script, char *file, char **value) { JSStringRef str, file_name; JSValueRef exception = NULL, result = NULL; @@ -125,10 +125,10 @@ gboolean vb_eval_script(WebKitWebFrame* frame, char* script, char* file, char** return FALSE; } -gboolean vb_load_uri(const Arg* arg) +gboolean vb_load_uri(const Arg *arg) { - char* uri; - char* path = arg->s; + char *uri; + char *path = arg->s; struct stat st; if (!path) { @@ -142,12 +142,12 @@ gboolean vb_load_uri(const Arg* arg) /* check if the path is a file path */ if (stat(path, &st) == 0) { - char* rp = realpath(path, NULL); + char *rp = realpath(path, NULL); uri = g_strdup_printf("file://%s", rp); } else if (!strchr(path, '.')) { - char* part = NULL; - char* tmpl = NULL; - char* query = NULL; + char *part = NULL; + char *tmpl = NULL; + char *query = NULL; /* look up for a searchengine with handle */ if ((part = strchr(path, ' '))) { @@ -174,7 +174,7 @@ gboolean vb_load_uri(const Arg* arg) if (arg->i == VB_TARGET_NEW) { guint i = 0; - char* cmd[5]; + char *cmd[5]; char xid[64]; cmd[i++] = *args; @@ -197,7 +197,7 @@ gboolean vb_load_uri(const Arg* arg) return TRUE; } -gboolean vb_set_clipboard(const Arg* arg) +gboolean vb_set_clipboard(const Arg *arg) { gboolean result = FALSE; if (!arg->s) { @@ -276,7 +276,7 @@ gboolean vb_set_mode(Mode mode, gboolean clean) return TRUE; } -void vb_set_widget_font(GtkWidget* widget, const VbColor* fg, const VbColor* bg, PangoFontDescription* font) +void vb_set_widget_font(GtkWidget *widget, const VbColor *fg, const VbColor *bg, PangoFontDescription *font) { VB_WIDGET_OVERRIDE_FONT(widget, font); VB_WIDGET_OVERRIDE_TEXT(widget, GTK_STATE_NORMAL, fg); @@ -287,7 +287,7 @@ void vb_set_widget_font(GtkWidget* widget, const VbColor* fg, const VbColor* bg, void vb_update_statusbar() { - GString* status = g_string_new(""); + GString *status = g_string_new(""); /* show current count */ g_string_append_printf(status, "%.0d", vb.state.count); @@ -347,7 +347,7 @@ void vb_update_input_style(void) ); } -void vb_update_urlbar(const char* uri) +void vb_update_urlbar(const char *uri) { gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), uri); } @@ -359,17 +359,17 @@ static gboolean vb_hide_message() return FALSE; } -static void vb_webview_progress_cb(WebKitWebView* view, GParamSpec* pspec) +static void vb_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 vb_webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec) { if (vb.state.downloads) { vb.state.progress = 0; - GList* ptr; + GList *ptr; for (ptr = vb.state.downloads; ptr; ptr = g_list_next(ptr)) { vb.state.progress += 100 * webkit_download_get_progress(ptr->data); } @@ -378,9 +378,9 @@ static void vb_webview_download_progress_cb(WebKitWebView* view, GParamSpec* psp vb_update_statusbar(); } -static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec) +static void vb_webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) { - const char* uri = webkit_web_view_get_uri(vb.gui.webview); + const char *uri = webkit_web_view_get_uri(vb.gui.webview); switch (webkit_web_view_get_load_status(vb.gui.webview)) { case WEBKIT_LOAD_PROVISIONAL: @@ -391,12 +391,12 @@ static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec) case WEBKIT_LOAD_COMMITTED: { - WebKitWebFrame* frame = webkit_web_view_get_main_frame(vb.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); - WebKitNetworkRequest* request = webkit_web_data_source_get_request(src); - SoupMessage* msg = webkit_network_request_get_message(request); + WebKitWebDataSource *src = webkit_web_frame_get_data_source(frame); + 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( (flags & SOUP_MESSAGE_CERTIFICATE_TRUSTED) ? VB_STATUS_SSL_VALID : VB_STATUS_SSL_INVALID @@ -436,15 +436,15 @@ static void vb_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec) } } -static void vb_destroy_window_cb(GtkWidget* widget) +static void vb_destroy_window_cb(GtkWidget *widget) { vb_destroy_client(); } static void vb_inputbox_activate_cb(GtkEntry *entry) { - const char* text; - char* command = NULL; + const char *text; + char *command = NULL; guint16 length = gtk_entry_get_text_length(entry); if (0 == length) { @@ -485,21 +485,21 @@ static void vb_inputbox_activate_cb(GtkEntry *entry) g_free(command); } -static gboolean vb_inputbox_keyrelease_cb(GtkEntry* entry, GdkEventKey* event) +static gboolean vb_inputbox_keyrelease_cb(GtkEntry *entry, GdkEventKey *event) { return FALSE; } -static void vb_scroll_cb(GtkAdjustment* adjustment) +static void vb_scroll_cb(GtkAdjustment *adjustment) { vb_update_statusbar(); } -static void vb_new_request_cb(SoupSession* session, SoupMessage *message) +static void vb_new_request_cb(SoupSession *session, SoupMessage *message) { - SoupMessageHeaders* header = message->request_headers; - SoupURI* uri; - const char* cookie; + SoupMessageHeaders *header = message->request_headers; + SoupURI *uri; + const char *cookie; soup_message_headers_remove(header, "Cookie"); uri = soup_message_get_uri(message); @@ -509,25 +509,25 @@ static void vb_new_request_cb(SoupSession* session, SoupMessage *message) g_signal_connect_after(G_OBJECT(message), "got-headers", G_CALLBACK(vb_gotheaders_cb), NULL); } -static void vb_gotheaders_cb(SoupMessage* message) +static void vb_gotheaders_cb(SoupMessage *message) { - GSList* list = NULL; - GSList* p = NULL; + GSList *list = NULL; + GSList *p = NULL; for(p = list = soup_cookies_from_response(message); p; p = g_slist_next(p)) { - vb_set_cookie((SoupCookie *)p->data); + vb_set_cookie((SoupCookie*)p->data); } soup_cookies_free(list); } -static WebKitWebView* vb_inspector_new(WebKitWebInspector* inspector, WebKitWebView* webview) +static WebKitWebView *vb_inspector_new(WebKitWebInspector *inspector, WebKitWebView *webview) { return WEBKIT_WEB_VIEW(webkit_web_view_new()); } -static gboolean vb_inspector_show(WebKitWebInspector* inspector) +static gboolean vb_inspector_show(WebKitWebInspector *inspector) { - WebKitWebView* webview; + WebKitWebView *webview; int height; if (vb.state.is_inspecting) { @@ -548,9 +548,9 @@ static gboolean vb_inspector_show(WebKitWebInspector* inspector) return TRUE; } -static gboolean vb_inspector_close(WebKitWebInspector* inspector) +static gboolean vb_inspector_close(WebKitWebInspector *inspector) { - WebKitWebView* webview; + WebKitWebView *webview; if (!vb.state.is_inspecting) { return FALSE; @@ -564,7 +564,7 @@ static gboolean vb_inspector_close(WebKitWebInspector* inspector) return TRUE; } -static void vb_inspector_finished(WebKitWebInspector* inspector) +static void vb_inspector_finished(WebKitWebInspector *inspector) { g_free(vb.gui.inspector); } @@ -573,11 +573,11 @@ static void vb_inspector_finished(WebKitWebInspector* inspector) * Processed input from input box without trailing : or ? /, input from config * file and default config. */ -static gboolean vb_process_input(const char* input) +static gboolean vb_process_input(const char *input) { gboolean success; - char* command = NULL; - char** token; + char *command = NULL; + char **token; if (!input || !strlen(input)) { return FALSE; @@ -600,11 +600,11 @@ static gboolean vb_process_input(const char* input) } #ifdef FEATURE_COOKIE -static void vb_set_cookie(SoupCookie* cookie) +static void vb_set_cookie(SoupCookie *cookie) { - SoupDate* date; + SoupDate *date; - SoupCookieJar* jar = soup_cookie_jar_text_new(vb.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 && vb.config.cookie_timeout) { date = soup_date_new_from_time_t(time(NULL) + vb.config.cookie_timeout); @@ -614,11 +614,11 @@ static void vb_set_cookie(SoupCookie* cookie) g_object_unref(jar); } -static const char* vb_get_cookies(SoupURI *uri) +static const char *vb_get_cookies(SoupURI *uri) { - const char* cookie; + const char *cookie; - SoupCookieJar* jar = soup_cookie_jar_text_new(vb.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); @@ -635,7 +635,7 @@ static void vb_set_status(const StatusType status) } } -void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, const char* message) +void vb_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))) { @@ -654,15 +654,15 @@ void vb_inputbox_print(gboolean force, const MessageType type, gboolean hide, co } } -static void vb_run_user_script(WebKitWebFrame* frame) +static void vb_run_user_script(WebKitWebFrame *frame) { - char* js = NULL; - GError* error = NULL; + char *js = NULL; + GError *error = NULL; 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; + char *value = NULL; gboolean success = vb_eval_script(frame, js, vb.files[FILES_SCRIPT], &value); if (!success) { fprintf(stderr, "%s", value); @@ -672,9 +672,9 @@ static void vb_run_user_script(WebKitWebFrame* frame) } } -static char* vb_jsref_to_string(JSContextRef context, JSValueRef ref) +static char *vb_jsref_to_string(JSContextRef context, JSValueRef ref) { - char* string; + char *string; JSStringRef str_ref = JSValueToStringCopy(context, ref, NULL); size_t len = JSStringGetMaximumUTF8CStringSize(str_ref); @@ -687,7 +687,7 @@ static char* vb_jsref_to_string(JSContextRef context, JSValueRef ref) static void vb_init_core(void) { - Gui* gui = &vb.gui; + Gui *gui = &vb.gui; if (vb.embed) { gui->window = gtk_plug_new(vb.embed); @@ -850,7 +850,7 @@ static void vb_setup_signals() static void vb_init_files(void) { - char* path = util_get_config_dir(); + char *path = util_get_config_dir(); vb.files[FILES_CONFIG] = g_build_filename(path, "config", NULL); util_create_file_if_not_exists(vb.files[FILES_CONFIG]); @@ -877,7 +877,7 @@ static void vb_init_files(void) g_free(path); } -static gboolean vb_button_relase_cb(WebKitWebView* webview, GdkEventButton* event) +static gboolean vb_button_relase_cb(WebKitWebView *webview, GdkEventButton *event) { gboolean propagate = FALSE; WebKitHitTestResultContext context; @@ -905,8 +905,8 @@ 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) + WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *request, + WebKitWebNavigationAction *navig, WebKitWebPolicyDecision *policy) { if (webkit_web_navigation_action_get_reason(navig) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { webkit_web_policy_decision_ignore(policy); @@ -918,10 +918,10 @@ static gboolean vb_new_window_policy_cb( return FALSE; } -static void vb_hover_link_cb(WebKitWebView* webview, const char* title, const char* link) +static void vb_hover_link_cb(WebKitWebView *webview, const char *title, const char *link) { if (link) { - char* message = g_strdup_printf("Link: %s", link); + char *message = g_strdup_printf("Link: %s", link); gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), message); g_free(message); } else { @@ -929,14 +929,14 @@ static void vb_hover_link_cb(WebKitWebView* webview, const char* title, const ch } } -static void vb_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const char* title) +static void vb_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, - WebKitWebFrame* frame, WebKitNetworkRequest* request, char* - mime_type, WebKitWebPolicyDecision* decision) +static gboolean vb_mimetype_decision_cb(WebKitWebView *webview, + WebKitWebFrame *frame, WebKitNetworkRequest *request, char *mime_type, + WebKitWebPolicyDecision *decision) { if (webkit_web_view_can_show_mime_type(webview, mime_type) == FALSE) { webkit_web_policy_decision_download(decision); @@ -946,12 +946,12 @@ static gboolean vb_mimetype_decision_cb(WebKitWebView* webview, return FALSE; } -static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* download) +static gboolean vb_download_requested_cb(WebKitWebView *view, WebKitDownload *download) { WebKitDownloadStatus status; - char* uri = NULL; + char *uri = NULL; - const char* filename = webkit_download_get_suggested_filename(download); + const char *filename = webkit_download_get_suggested_filename(download); if (!filename) { filename = "vimb_donwload"; } @@ -988,17 +988,17 @@ static gboolean vb_download_requested_cb(WebKitWebView* view, WebKitDownload* do /** * Callback to filter started resource request. */ -static void vb_request_start_cb(WebKitWebView* webview, WebKitWebFrame* frame, - WebKitWebResource* resource, WebKitNetworkRequest* request, - WebKitNetworkResponse* response) +static void vb_request_start_cb(WebKitWebView *webview, WebKitWebFrame *frame, + WebKitWebResource *resource, WebKitNetworkRequest *request, + WebKitNetworkResponse *response) { - const char* uri = webkit_network_request_get_uri(request); + const char *uri = webkit_network_request_get_uri(request); if (g_str_has_suffix(uri, "/favicon.ico")) { webkit_network_request_set_uri(request, "about:blank"); } } -static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec) +static void vb_download_progress_cp(WebKitDownload *download, GParamSpec *pspec) { WebKitDownloadStatus status = webkit_download_get_status(download); @@ -1006,7 +1006,7 @@ static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec) return; } - char* file = g_path_get_basename(webkit_download_get_destination_uri(download)); + char *file = g_path_get_basename(webkit_download_get_destination_uri(download)); if (status != WEBKIT_DOWNLOAD_STATUS_FINISHED) { vb_echo(VB_MSG_ERROR, FALSE, "Error downloading %s", file); } else { @@ -1022,7 +1022,7 @@ static void vb_download_progress_cp(WebKitDownload* download, GParamSpec* pspec) static void vb_destroy_client() { - const char* uri = webkit_web_view_get_uri(vb.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(vb.files[FILES_CLOSED], uri, -1, NULL); @@ -1049,12 +1049,12 @@ static void vb_destroy_client() gtk_main_quit(); } -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - static char* winid = NULL; + static char *winid = NULL; static gboolean ver = false; static gboolean dump = false; - static GError* err; + static GError *err; static GOptionEntry opts[] = { {"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL}, {"embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "Reparents to window specified by xid", NULL}, @@ -205,32 +205,32 @@ enum { /* structs */ typedef struct { int i; - char* s; + char * s; } Arg; /* statusbar */ typedef struct { - GtkBox* box; - GtkWidget* left; - GtkWidget* right; + GtkBox * box; + GtkWidget * left; + GtkWidget * right; } StatusBar; /* gui */ typedef struct { - GtkWidget* window; - GtkWidget* scroll; - WebKitWebView* webview; - WebKitWebInspector* inspector; - GtkBox* box; - GtkWidget* eventbox; - GtkWidget* inputbox; - GtkWidget* compbox; - GtkWidget* pane; + GtkWidget * window; + GtkWidget * scroll; + WebKitWebView * webview; + WebKitWebInspector *inspector; + GtkBox * box; + GtkWidget * eventbox; + GtkWidget * inputbox; + GtkWidget * compbox; + GtkWidget * pane; StatusBar statusbar; - GtkScrollbar* sb_h; - GtkScrollbar* sb_v; - GtkAdjustment* adjust_h; - GtkAdjustment* adjust_v; + GtkScrollbar * sb_h; + GtkScrollbar * sb_v; + GtkAdjustment * adjust_h; + GtkAdjustment * adjust_v; } Gui; /* state */ @@ -243,52 +243,52 @@ typedef struct { MessageType input_type; gboolean is_inspecting; SearchDirection search_dir; - char* search_query; - GList* downloads; + char * search_query; + GList * downloads; } State; /* behaviour */ typedef struct { - GHashTable* commands; - GSList* keys; - GString* modkeys; - GSList* searchengines; - char* searchengine_default; /* handle of the default search engine */ + GHashTable *commands; + GSList * keys; + GString * modkeys; + GSList * searchengines; + char * searchengine_default; /* handle of the default search engine */ } Behaviour; typedef struct { time_t cookie_timeout; int scrollstep; guint max_completion_items; - char* home_page; - char* download_dir; + char * home_page; + char * download_dir; guint history_max; } Config; typedef struct { - GList* completions; - GList* active; + GList *completions; + GList *active; int count; - char* prefix; + char * prefix; } Completions; typedef struct { VbColor input_fg[VB_MSG_LAST]; VbColor input_bg[VB_MSG_LAST]; - PangoFontDescription* input_font[VB_MSG_LAST]; + PangoFontDescription *input_font[VB_MSG_LAST]; /* completion */ VbColor comp_fg[VB_COMP_LAST]; VbColor comp_bg[VB_COMP_LAST]; - PangoFontDescription* comp_font; + PangoFontDescription *comp_font; /* hint style */ - char* hint_bg; - char* hint_bg_focus; - char* hint_fg; - char* hint_style; + char * hint_bg; + char * hint_bg_focus; + char * hint_fg; + char * hint_style; /* status bar */ VbColor status_bg[VB_STATUS_LAST]; VbColor status_fg[VB_STATUS_LAST]; - PangoFontDescription* status_font[VB_STATUS_LAST]; + PangoFontDescription *status_font[VB_STATUS_LAST]; } Style; typedef struct { @@ -305,12 +305,12 @@ typedef struct { Completions comps; Hints hints; - char* files[FILES_LAST]; + char * files[FILES_LAST]; Config config; Style style; Behaviour behave; - GHashTable* settings; - SoupSession* soup_session; + GHashTable * settings; + SoupSession * soup_session; #ifdef HAS_GTK3 Window embed; #else @@ -324,14 +324,14 @@ extern VbCore core; /* functions */ void vb_echo_force(const MessageType type,gboolean hide, const char *error, ...); 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(const Arg* arg); -gboolean vb_set_clipboard(const Arg* arg); +gboolean vb_eval_script(WebKitWebFrame *frame, char *script, char *file, char **value); +gboolean vb_load_uri(const Arg *arg); +gboolean vb_set_clipboard(const Arg *arg); gboolean vb_set_mode(Mode mode, gboolean clean); -void vb_set_widget_font(GtkWidget* widget, const VbColor* fg, const VbColor* bg, PangoFontDescription* font); +void vb_set_widget_font(GtkWidget *widget, const VbColor *fg, const VbColor *bg, PangoFontDescription *font); void vb_update_statusbar(void); void vb_update_status_style(void); void vb_update_input_style(void); -void vb_update_urlbar(const char* uri); +void vb_update_urlbar(const char *uri); #endif /* end of include guard: _MAIN_H */ diff --git a/src/searchengine.c b/src/searchengine.c index cabbc76..a7d79f5 100644 --- a/src/searchengine.c +++ b/src/searchengine.c @@ -23,13 +23,13 @@ extern VbCore vb; typedef struct { - char* handle; - char* uri; + char *handle; + 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 *searchengine_find(const char *handle); +static gboolean searchengine_is_valid_uri(const char *uri); +static void searchengine_free(Searchengine *se); void searchengine_cleanup(void) @@ -39,13 +39,13 @@ void searchengine_cleanup(void) } } -gboolean searchengine_add(const char* handle, const char* uri) +gboolean searchengine_add(const char *handle, const char *uri) { /* validate if the uri contains only one %s sequence */ if (!searchengine_is_valid_uri(uri)) { return FALSE; } - Searchengine* s = g_new0(Searchengine, 1); + Searchengine *s = g_new0(Searchengine, 1); s->handle = g_strdup(handle); s->uri = g_strdup(uri); @@ -55,9 +55,9 @@ gboolean searchengine_add(const char* handle, const char* uri) return TRUE; } -gboolean searchengine_remove(const char* handle) +gboolean searchengine_remove(const char *handle) { - GSList* list = searchengine_find(handle); + GSList *list = searchengine_find(handle); if (list) { searchengine_free((Searchengine*)list->data); @@ -69,7 +69,7 @@ gboolean searchengine_remove(const char* handle) return FALSE; } -gboolean searchengine_set_default(const char* handle) +gboolean searchengine_set_default(const char *handle) { /* do not check if the search engin exists to be able to set the default * before defining the search engines */ @@ -78,10 +78,10 @@ gboolean searchengine_set_default(const char* handle) return TRUE; } -char* searchengine_get_uri(const char* handle) +char *searchengine_get_uri(const char *handle) { - const char* def = vb.behave.searchengine_default; - GSList* l = NULL; + const char *def = vb.behave.searchengine_default; + GSList *l = NULL; if (handle && (l = searchengine_find(handle))) { return ((Searchengine*)l->data)->uri; @@ -92,9 +92,9 @@ char* searchengine_get_uri(const char* handle) return NULL; } -static GSList* searchengine_find(const char* handle) +static GSList *searchengine_find(const char *handle) { - GSList* s; + GSList *s; for (s = vb.behave.searchengines; s != NULL; s = s->next) { if (!strcmp(((Searchengine*)s->data)->handle, handle)) { return s; @@ -104,7 +104,7 @@ static GSList* searchengine_find(const char* handle) return NULL; } -static gboolean searchengine_is_valid_uri(const char* uri) +static gboolean searchengine_is_valid_uri(const char *uri) { int count = 0; @@ -120,7 +120,7 @@ static gboolean searchengine_is_valid_uri(const char* uri) return count == 1; } -static void searchengine_free(Searchengine* se) +static void searchengine_free(Searchengine *se) { g_free(se->uri); g_free(se->handle); diff --git a/src/searchengine.h b/src/searchengine.h index 4645c66..a0b876b 100644 --- a/src/searchengine.h +++ b/src/searchengine.h @@ -21,9 +21,9 @@ #define _SEARCHENGINE_H void searchengine_cleanup(void); -gboolean searchengine_add(const char* handle, const char* uri); -gboolean searchengine_remove(const char* handle); -gboolean searchengine_set_default(const char* handle); -char* searchengine_get_uri(const char* handle); +gboolean searchengine_add(const char *handle, const char *uri); +gboolean searchengine_remove(const char *handle); +gboolean searchengine_set_default(const char *handle); +char *searchengine_get_uri(const char *handle); #endif /* end of include guard: _SEARCHENGINE_H */ diff --git a/src/setting.c b/src/setting.c index 2594965..a2d8aac 100644 --- a/src/setting.c +++ b/src/setting.c @@ -22,24 +22,24 @@ 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 *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 Setting default_settings[] = { /* webkit settings */ @@ -105,7 +105,7 @@ static Setting default_settings[] = { void setting_init(void) { - Setting* s; + Setting *s; unsigned int i; vb.settings = g_hash_table_new(g_str_hash, g_str_equal); @@ -123,9 +123,9 @@ void setting_cleanup(void) } } -gboolean setting_run(char* name, const char* param) +gboolean setting_run(char *name, const char *param) { - Arg* a = NULL; + Arg *a = NULL; gboolean result = FALSE; gboolean get = FALSE; SettingType type = SETTING_SET; @@ -142,7 +142,7 @@ gboolean setting_run(char* name, const char* param) type = SETTING_GET; } - Setting* s = g_hash_table_lookup(vb.settings, name); + Setting *s = g_hash_table_lookup(vb.settings, name); if (!s) { vb_echo(VB_MSG_ERROR, TRUE, "Config '%s' not found", name); return FALSE; @@ -198,13 +198,13 @@ gboolean setting_run(char* name, const char* param) /** * Converts string representing also given data type into and Arg. */ -static Arg* setting_char_to_arg(const char* str, const Type type) +static Arg *setting_char_to_arg(const char *str, const Type type) { if (!str) { return NULL; } - Arg* arg = g_new0(Arg, 1); + Arg *arg = g_new0(Arg, 1); switch (type) { case TYPE_BOOLEAN: arg->i = g_ascii_strncasecmp(str, "true", 4) == 0 @@ -232,10 +232,10 @@ 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(const Setting* s, void* value) +static void setting_print_value(const Setting *s, void *value) { - const char* name = s->alias ? s->alias : s->name; - char* string = NULL; + const char *name = s->alias ? s->alias : s->name; + char *string = NULL; switch (s->type) { case TYPE_BOOLEAN: @@ -268,9 +268,9 @@ static void setting_print_value(const Setting* s, void* value) } } -static gboolean setting_webkit(const Setting* s, const SettingType type) +static gboolean setting_webkit(const Setting *s, const SettingType type) { - WebKitWebSettings* web_setting = webkit_web_view_get_settings(vb.gui.webview); + WebKitWebSettings *web_setting = webkit_web_view_get_settings(vb.gui.webview); switch (s->type) { case TYPE_BOOLEAN: @@ -316,7 +316,7 @@ static gboolean setting_webkit(const Setting* s, const SettingType type) case TYPE_COLOR: case TYPE_FONT: if (type == SETTING_GET) { - char* value = NULL; + char *value = NULL; g_object_get(G_OBJECT(web_setting), s->name, &value, NULL); setting_print_value(s, value); } else { @@ -327,7 +327,7 @@ static gboolean setting_webkit(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_cookie_timeout(const Setting* s, const SettingType type) +static gboolean setting_cookie_timeout(const Setting *s, const SettingType type) { if (type == SETTING_GET) { setting_print_value(s, &vb.config.cookie_timeout); @@ -338,7 +338,7 @@ static gboolean setting_cookie_timeout(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_scrollstep(const Setting* s, const SettingType type) +static gboolean setting_scrollstep(const Setting *s, const SettingType type) { if (type == SETTING_GET) { setting_print_value(s, &vb.config.scrollstep); @@ -349,7 +349,7 @@ static gboolean setting_scrollstep(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_status_color_bg(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")) { @@ -370,7 +370,7 @@ static gboolean setting_status_color_bg(const Setting* s, const SettingType type return TRUE; } -static gboolean setting_status_color_fg(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")) { @@ -391,7 +391,7 @@ static gboolean setting_status_color_fg(const Setting* s, const SettingType type return TRUE; } -static gboolean setting_status_font(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")) { @@ -416,9 +416,9 @@ static gboolean setting_status_font(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_input_style(const Setting* s, const SettingType type) +static gboolean setting_input_style(const Setting *s, const SettingType type) { - Style* style = &vb.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) { @@ -432,7 +432,7 @@ static gboolean setting_input_style(const Setting* s, const SettingType type) style->input_font[itype] = pango_font_description_from_string(s->arg.s); } } else { - VbColor* color = NULL; + VbColor *color = NULL; if (g_str_has_prefix(s->name, "input-bg")) { /* background color */ color = &style->input_bg[itype]; @@ -454,9 +454,9 @@ static gboolean setting_input_style(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_completion_style(const Setting* s, const SettingType type) +static gboolean setting_completion_style(const Setting *s, const SettingType type) { - Style* style = &vb.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) { @@ -476,7 +476,7 @@ static gboolean setting_completion_style(const Setting* s, const SettingType typ style->comp_font = pango_font_description_from_string(s->arg.s); } } else { - VbColor* color = NULL; + VbColor *color = NULL; if (g_str_has_prefix(s->name, "completion-bg")) { /* completion background color */ color = &style->comp_bg[ctype]; @@ -495,9 +495,9 @@ static gboolean setting_completion_style(const Setting* s, const SettingType typ return TRUE; } -static gboolean setting_hint_style(const Setting* s, const SettingType type) +static gboolean setting_hint_style(const Setting *s, const SettingType type) { - Style* style = &vb.style; + Style *style = &vb.style; if (!g_strcmp0(s->name, "hint-bg")) { if (type == SETTING_GET) { setting_print_value(s, style->hint_bg); @@ -527,7 +527,7 @@ static gboolean setting_hint_style(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_strict_ssl(const Setting* s, const SettingType type) +static gboolean setting_strict_ssl(const Setting *s, const SettingType type) { gboolean value; if (type != SETTING_SET) { @@ -546,10 +546,10 @@ static gboolean setting_strict_ssl(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_ca_bundle(const Setting* s, const SettingType type) +static gboolean setting_ca_bundle(const Setting *s, const SettingType type) { if (type == SETTING_GET) { - char* value = NULL; + char *value = NULL; g_object_get(vb.soup_session, "ssl-ca-file", &value, NULL); setting_print_value(s, value); g_free(value); @@ -560,7 +560,7 @@ static gboolean setting_ca_bundle(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_home_page(const Setting* s, const SettingType type) +static gboolean setting_home_page(const Setting *s, const SettingType type) { if (type == SETTING_GET) { setting_print_value(s, vb.config.home_page); @@ -571,7 +571,7 @@ static gboolean setting_home_page(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_download_path(const Setting* s, const SettingType type) +static gboolean setting_download_path(const Setting *s, const SettingType type) { if (type == SETTING_GET) { setting_print_value(s, vb.config.download_dir); @@ -593,10 +593,10 @@ static gboolean setting_download_path(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_proxy(const Setting* s, const SettingType type) +static gboolean setting_proxy(const Setting *s, const SettingType type) { gboolean enabled; - SoupURI* proxy_uri = NULL; + SoupURI *proxy_uri = NULL; /* get the current status */ if (type != SETTING_SET) { @@ -619,9 +619,9 @@ static gboolean setting_proxy(const Setting* s, const SettingType type) } if (enabled) { - char* proxy = (char *)g_getenv("http_proxy"); + char *proxy = (char *)g_getenv("http_proxy"); if (proxy != NULL && strlen(proxy)) { - char* proxy_new = g_strrstr(proxy, "http://") + char *proxy_new = g_strrstr(proxy, "http://") ? g_strdup(proxy) : g_strdup_printf("http://%s", proxy); proxy_uri = soup_uri_new(proxy_new); @@ -638,11 +638,11 @@ static gboolean setting_proxy(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_user_style(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(vb.gui.webview); + char *uri = NULL; + 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); @@ -673,7 +673,7 @@ static gboolean setting_user_style(const Setting* s, const SettingType type) return TRUE; } -static gboolean setting_history_max_items(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(s, &vb.config.history_max); @@ -21,7 +21,7 @@ #include "ctype.h" #include "util.h" -char* util_get_config_dir(void) +char *util_get_config_dir(void) { char *path = g_build_filename(g_get_user_config_dir(), "vimb", NULL); util_create_dir_if_not_exists(path); @@ -29,7 +29,7 @@ char* util_get_config_dir(void) return path; } -char* util_get_cache_dir(void) +char *util_get_cache_dir(void) { char *path = g_build_filename(g_get_user_cache_dir(), "vimb", NULL); util_create_dir_if_not_exists(path); @@ -37,9 +37,9 @@ char* util_get_cache_dir(void) return path; } -const char* util_get_home_dir(void) +const char *util_get_home_dir(void) { - const char* dir = g_getenv("HOME"); + const char *dir = g_getenv("HOME"); if (!dir) { dir = g_get_home_dir(); @@ -48,17 +48,17 @@ const char* util_get_home_dir(void) return dir; } -void util_create_dir_if_not_exists(const char* dirpath) +void util_create_dir_if_not_exists(const char *dirpath) { if (!g_file_test(dirpath, G_FILE_TEST_IS_DIR)) { g_mkdir_with_parents(dirpath, 0755); } } -void util_create_file_if_not_exists(const char* filename) +void util_create_file_if_not_exists(const char *filename) { if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { - FILE* f = fopen(filename, "a"); + FILE *f = fopen(filename, "a"); fclose(f); } } @@ -68,10 +68,10 @@ void util_create_file_if_not_exists(const char* filename) * * The memory of returned string have to be freed! */ -char* util_get_file_contents(const char* filename, gsize* length) +char *util_get_file_contents(const char *filename, gsize *length) { - GError* error = NULL; - char* content = NULL; + GError *error = NULL; + char *content = NULL; if (!(g_file_test(filename, G_FILE_TEST_IS_REGULAR) && g_file_get_contents(filename, &content, length, &error)) ) { @@ -86,10 +86,10 @@ char* util_get_file_contents(const char* filename, gsize* length) * * The result have to be freed by g_strfreev(). */ -char** util_get_lines(const char* filename) +char **util_get_lines(const char *filename) { - char* content = util_get_file_contents(filename, NULL); - char** lines = NULL; + char *content = util_get_file_contents(filename, NULL); + char **lines = NULL; if (content) { /* split the file content into lines */ lines = g_strsplit(content, "\n", -1); @@ -98,7 +98,7 @@ char** util_get_lines(const char* filename) return lines; } -char* util_strcasestr(const char* haystack, const char* needle) +char *util_strcasestr(const char *haystack, const char *needle) { int nlen = strlen(needle); int hlen = strlen(haystack) - nlen + 1; |