{"searchengine-remove", command_searchengine,{0}},
};
-static void command_write_input(const gchar* str);
+static void command_write_input(const char* str);
void command_init(void)
}
}
-gboolean command_exists(const gchar* name)
+gboolean command_exists(const char* name)
{
return g_hash_table_contains(vp.behave.commands, name);
}
-gboolean command_run(const gchar* name, const gchar* param)
+gboolean command_run(const char* name, const char* param)
{
CommandInfo* c = NULL;
gboolean result;
gboolean command_open(const Arg* arg)
{
- gchar* uri = NULL;
+ char* uri = NULL;
gboolean result;
/* check for searchengine handles */
/* split into handle and searchterms */
if (g_strv_length(string) == 2
&& (uri = searchengine_get_uri(string[0]))
) {
- gchar* term = soup_uri_encode(string[1], "&");
+ char* term = soup_uri_encode(string[1], "&");
Arg a = {arg->i, g_strdup_printf(uri, term)};
result = vp_load_uri(&a);
g_free(term);
gboolean command_input(const Arg* arg)
{
- const gchar* url;
+ const char* url;
/* add current url if requested */
if (VP_INPUT_CURRENT_URI == arg->i
&& (url = CURRENT_URL())
) {
/* append the current url to the input message */
- gchar* input = g_strconcat(arg->s, url, NULL);
+ char* input = g_strconcat(arg->s, url, NULL);
command_write_input(input);
g_free(input);
} else {
gboolean command_navigate(const Arg* arg)
{
if (arg->i <= VP_NAVIG_FORWARD) {
- gint count = vp.state.count ? vp.state.count : 1;
+ int count = vp.state.count ? vp.state.count : 1;
webkit_web_view_go_back_or_forward(
vp.gui.webview, (arg->i == VP_NAVIG_BACK ? -count : count)
);
{
GtkAdjustment *adjust = (arg->i & VP_SCROLL_AXIS_H) ? vp.gui.adjust_h : vp.gui.adjust_v;
- gint direction = (arg->i & (1 << 2)) ? 1 : -1;
+ int direction = (arg->i & (1 << 2)) ? 1 : -1;
/* type scroll */
if (arg->i & VP_SCROLL_TYPE_SCROLL) {
gdouble value;
- gint count = vp.state.count ? vp.state.count : 1;
+ int count = vp.state.count ? vp.state.count : 1;
if (arg->i & VP_SCROLL_UNIT_LINE) {
value = vp.config.scrollstep;
} else if (arg->i & VP_SCROLL_UNIT_HALFPAGE) {
gboolean result;
vp_set_mode(VP_MODE_NORMAL, FALSE);
- gchar **string = g_strsplit(arg->s, "=", 2);
+ char **string = g_strsplit(arg->s, "=", 2);
if (g_strv_length(string) != 2) {
return FALSE;
}
gboolean command_set(const Arg* arg)
{
gboolean success;
- gchar* line = NULL;
- gchar** token;
+ char* line = NULL;
+ char** token;
if (!arg->s || !strlen(arg->s)) {
return FALSE;
vp_set_mode(VP_MODE_NORMAL, TRUE);
if (arg->i & COMMAND_YANK_SELECTION) {
- gchar* text = NULL;
+ char* text = NULL;
/* copy current selection to clipboard */
webkit_web_view_copy_clipboard(vp.gui.webview);
text = gtk_clipboard_wait_for_text(PRIMARY_CLIPBOARD());
gboolean result;
if (arg->i) {
/* add the searchengine */
- gchar **string = g_strsplit(arg->s, "=", 2);
+ char **string = g_strsplit(arg->s, "=", 2);
if (g_strv_length(string) != 2) {
return FALSE;
}
return result;
}
-static void command_write_input(const gchar* str)
+static void command_write_input(const char* str)
{
- gint pos = 0;
+ int pos = 0;
/* reset the colors and fonts to defalts */
vp_set_widget_font(
vp.gui.inputbox,
typedef gboolean (*Command)(const Arg* arg);
typedef struct {
- const gchar* name;
+ 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 gchar* name);
-gboolean command_run(const gchar* name, const gchar* 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);
typedef struct {
GtkWidget* label;
GtkWidget* event;
- gchar* prefix;
+ char* prefix;
} Completion;
-static GList* completion_init_completion(GList* target, GList* source, const gchar* prefix);
+static GList* completion_init_completion(GList* target, GList* source, const char* prefix);
static GList* completion_update(GList* completion, GList* active, gboolean back);
static void completion_show(gboolean back);
static void completion_set_color(Completion* completion, const VpColor* fg, const VpColor* bg, PangoFontDescription* font);
static void completion_set_entry_text(Completion* completion);
-static Completion* completion_get_new(const gchar* label, const gchar* prefix);
+static Completion* completion_get_new(const char* label, const char* prefix);
gboolean completion_complete(gboolean back)
{
- const gchar* input = NULL;
+ const char* input = NULL;
GList* source = NULL;
if (vp.comps.completions
vp.state.mode &= ~VP_MODE_COMPLETE;
}
-static GList* completion_init_completion(GList* target, GList* source, const gchar* prefix)
+static GList* completion_init_completion(GList* target, GList* source, const char* prefix)
{
- const gchar* input = GET_TEXT();
- gchar* command = NULL;
- gchar* data = NULL;
+ const char* input = GET_TEXT();
+ char* command = NULL;
+ char* data = NULL;
gboolean match;
- gchar **token = NULL;
+ char **token = NULL;
/* skip prefix for completion */
if (g_str_has_prefix(input, prefix)) {
if (*command == 0) {
match = TRUE;
} else {
- for (gint i = 0; token[i]; i++) {
+ for (int i = 0; token[i]; i++) {
if (g_str_has_prefix(data, token[i])) {
match = TRUE;
} else {
GList *old, *new;
Completion *c;
- gint length = g_list_length(completion);
- gint max = vp.config.max_completion_items;
- gint items = MAX(length, max);
- gint r = (max) % 2;
- gint offset = max / 2 - 1 + r;
+ int length = g_list_length(completion);
+ int max = vp.config.max_completion_items;
+ int items = MAX(length, max);
+ int r = (max) % 2;
+ int offset = max / 2 - 1 + r;
old = active;
int position = g_list_position(completion, active) + 1;
static void completion_show(gboolean back)
{
guint max = vp.config.max_completion_items;
- gint i = 0;
+ int i = 0;
if (back) {
vp.comps.active = g_list_last(vp.comps.completions);
for (GList *l = vp.comps.active; l && i < max; l = l->prev, i++) {
static void completion_set_entry_text(Completion* completion)
{
GString* string = g_string_new(completion->prefix);
- const gchar* text;
+ const char* text;
text = gtk_label_get_text(GTK_LABEL(completion->label));
g_string_free(string, TRUE);
}
-static Completion* completion_get_new(const gchar* label, const gchar* prefix)
+static Completion* completion_get_new(const char* label, const char* prefix)
{
- const gint padding = 2;
+ const int padding = 2;
Completion* c = g_new0(Completion, 1);
c->label = gtk_label_new(label);
}
}
-void dom_element_set_style(Element* element, const gchar* format, ...)
+void dom_element_set_style(Element* element, const char* format, ...)
{
va_list args;
va_start(args, format);
- gchar* value = g_strdup_vprintf(format, args);
+ char* value = g_strdup_vprintf(format, args);
CssDeclaration* css = webkit_dom_element_get_style(element);
if (css) {
webkit_dom_css_style_declaration_set_css_text(css, value, NULL);
g_free(value);
}
-void dom_element_style_set_property(Element* element, const gchar* property, const gchar* style)
+void dom_element_style_set_property(Element* element, const char* property, const char* style)
{
CssDeclaration* css = webkit_dom_element_get_style(element);
if (css) {
return rect;
}
-void dom_dispatch_mouse_event(Document* doc, Element* element, gchar* type, gushort button)
+void dom_dispatch_mouse_event(Document* doc, Element* element, char* type, gushort button)
{
Event* event = webkit_dom_document_create_event(doc, "MouseEvents", NULL);
webkit_dom_mouse_event_init_mouse_event(
return FALSE;
}
- gchar* tagname = webkit_dom_element_get_tag_name(element);
+ char* tagname = webkit_dom_element_get_tag_name(element);
if (!g_ascii_strcasecmp(tagname, "textarea")) {
return TRUE;
}
- gchar *type = webkit_dom_element_get_attribute(element, "type");
+ char *type = webkit_dom_element_get_attribute(element, "type");
if (!g_ascii_strcasecmp(tagname, "input")
|| !g_ascii_strcasecmp(type, "text")
|| !g_ascii_strcasecmp(type, "password")
/**
* Retrieves the src or href attribute of the given element.
*/
-gchar* dom_element_get_source(Element* elem)
+char* dom_element_get_source(Element* elem)
{
- gchar* url = NULL;
+ char* url = NULL;
url = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(elem));
if (!url) {
{
Document* d = NULL;
Element* active = webkit_dom_html_document_get_active_element((void*)doc);
- gchar* tagname = webkit_dom_element_get_tag_name(active);
+ char* tagname = webkit_dom_element_get_tag_name(active);
if (!g_strcmp0(tagname, "FRAME")) {
d = webkit_dom_html_frame_element_get_content_document(WEBKIT_DOM_HTML_FRAME_ELEMENT(active));
} DomBoundingRect;
void dom_check_auto_insert(void);
-void dom_element_set_style(Element* element, const gchar* format, ...);
-void dom_element_style_set_property(Element* element, const gchar* property, const gchar* style);
+void dom_element_set_style(Element* element, const char* format, ...);
+void dom_element_style_set_property(Element* element, const char* property, const char* style);
gboolean dom_element_is_visible(Window* win, Element* element);
DomBoundingRect dom_elemen_get_bounding_rect(Element* element);
-void dom_dispatch_mouse_event(Document* doc, Element* element, gchar* type, gushort button);
+void dom_dispatch_mouse_event(Document* doc, Element* element, char* type, gushort button);
gboolean dom_is_editable(Element* element);
-gchar* dom_element_get_source(Element* elem);
+char* dom_element_get_source(Element* elem);
#endif /* end of include guard: _DOM_H */
typedef struct {
gulong num;
Element* elem; /* hinted element */
- gchar* elemColor; /* element color */
- gchar* elemBackgroundColor; /* element background color */
+ char* elemColor; /* element color */
+ char* elemBackgroundColor; /* element background color */
Element* hint; /* numbered hint element */
Element* container;
} Hint;
static Element* hints_get_hint_container(Document* doc);
-static void hints_create_for_window(const gchar* input, Window* win, gulong hintCount);
+static void hints_create_for_window(const char* input, Window* win, gulong hintCount);
static void hints_focus(const gulong num);
static void hints_fire(const gulong num);
static void hints_click_fired_hint(guint mode, Element* elem);
-static void hints_process_fired_hint(guint mode, const gchar* uri);
+static void hints_process_fired_hint(guint mode, const char* uri);
static Hint* hints_get_hint_by_number(const gulong num);
static GList* hints_get_hint_list_by_number(const gulong num);
-static gchar* hints_get_xpath(const gchar* input);
+static char* hints_get_xpath(const char* input);
static void hints_observe_input(gboolean observe);
static gboolean hints_changed_callback(GtkEditable *entry, gpointer data);
static gboolean hints_keypress_callback(WebKitWebView* webview, GdkEventKey* event);
g_signal_emit_by_name(vp.gui.webview, "hovering-over-link", NULL, NULL);
}
-void hints_create(const gchar* input, guint mode, const guint prefixLength)
+void hints_create(const char* input, guint mode, const guint prefixLength)
{
Hints* hints = &vp.hints;
Document* doc;
return container;
}
-static void hints_create_for_window(const gchar* input, Window* win, gulong hintCount)
+static void hints_create_for_window(const char* input, Window* win, gulong hintCount)
{
Hints* hints = &vp.hints;
Element* container = NULL;
return;
}
- gchar* xpath = hints_get_xpath(input);
+ char* xpath = hints_get_xpath(input);
WebKitDOMXPathResult* result = webkit_dom_document_evaluate(
doc, xpath, WEBKIT_DOM_NODE(doc), ns_resolver, 7, NULL, NULL
);
gulong top = rect.top - 3;
dom_element_set_style(hint, HINT_STYLE, left, top, vp.style.hint_style);
- gchar* num = g_strdup_printf("%li", newHint->num);
+ char* num = g_strdup_printf("%li", newHint->num);
webkit_dom_html_element_set_inner_text(WEBKIT_DOM_HTML_ELEMENT(hint), num, NULL);
webkit_dom_html_element_set_class_name(WEBKIT_DOM_HTML_ELEMENT(hint), HINT_CLASS);
g_free(num);
dom_dispatch_mouse_event(doc, hint->elem, "mouseover", 0);
webkit_dom_element_blur(hint->elem);
- const gchar* tag = webkit_dom_element_get_tag_name(hint->elem);
+ const char* tag = webkit_dom_element_get_tag_name(hint->elem);
if (!g_ascii_strcasecmp(tag, "a")) {
/* simulate the hovering over the hinted element this is done to show
* the hinted elements url in the url bar */
*/
static void hints_click_fired_hint(guint mode, Element* elem)
{
- gchar* target = webkit_dom_element_get_attribute(elem, "target");
+ char* target = webkit_dom_element_get_attribute(elem, "target");
if (mode & HINTS_TARGET_BLANK) { /* open in new window */
webkit_dom_element_set_attribute(elem, "target", "_blank", NULL);
} else if (g_strcmp0(target, "_blank") == 0) { /* remove possible target attribute */
/**
* Handle fired hints that are not opened via simulated mouse click.
*/
-static void hints_process_fired_hint(guint mode, const gchar* uri)
+static void hints_process_fired_hint(guint mode, const char* uri)
{
HintsProcess type = HINTS_GET_PROCESSING(mode);
Arg a = {0};
*
* The returned string have to be freed.
*/
-static gchar* hints_get_xpath(const gchar* input)
+static char* hints_get_xpath(const char* input)
{
- gchar* xpath = NULL;
+ char* xpath = NULL;
switch (HINTS_GET_TYPE(vp.hints.mode)) {
case HINTS_TYPE_LINK:
static gboolean hints_changed_callback(GtkEditable *entry, gpointer data)
{
- const gchar* text = GET_TEXT();
+ const char* text = GET_TEXT();
/* skip hinting prefixes like '.', ',', ';y' ... */
hints_create(text + vp.hints.prefixLength, vp.hints.mode, vp.hints.prefixLength);
static gboolean hints_keypress_callback(WebKitWebView* webview, GdkEventKey* event)
{
Hints* hints = &vp.hints;
- gint numval;
+ int numval;
guint keyval = event->keyval;
guint state = CLEAN_STATE_WITH_SHIFT(event);
} HintsProcess;
void hints_init(void);
-void hints_create(const gchar* input, guint mode, const guint prefixLength);
+void hints_create(const char* input, guint mode, const guint prefixLength);
void hints_update(const gulong num);
void hints_clear(void);
void hints_focus_next(const gboolean back);
static void keybind_rebuild_modkeys(void);
static GSList* keybind_find(int mode, guint modkey, guint modmask, guint keyval);
-static void keybind_str_to_keybind(gchar* str, Keybind* key);
-static guint keybind_str_to_modmask(const gchar* str);
-static guint keybind_str_to_value(const gchar* str);
+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);
}
}
-gboolean keybind_add_from_string(gchar* keys, const gchar* 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 */
- gchar** token = g_strsplit(command, " ", 2);
+ char** token = g_strsplit(command, " ", 2);
if (!token[0] || !command_exists(token[0])) {
g_strfreev(token);
return FALSE;
return TRUE;
}
-gboolean keybind_remove_from_string(gchar* str, const Mode mode)
+gboolean keybind_remove_from_string(char* str, const Mode mode)
{
Keybind keybind = {.mode = mode};
/**
* Configures the given keybind by also given string.
*/
-static void keybind_str_to_keybind(gchar* str, Keybind* keybind)
+static void keybind_str_to_keybind(char* str, Keybind* keybind)
{
- gchar** string = NULL;
+ char** string = NULL;
guint len = 0;
g_strstrip(str);
}
}
-static guint keybind_str_to_modmask(const gchar* str)
+static guint keybind_str_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 gchar* str)
+static guint keybind_str_to_value(const char* str)
{
if (g_ascii_strcasecmp(str, "tab") == 0) {
return GDK_Tab;
return TRUE;
}
if (strchr(vp.behave.modkeys->str, keyval) && vp.state.modkey != keyval) {
- vp.state.modkey = (gchar)keyval;
+ vp.state.modkey = (char)keyval;
vp_update_statusbar();
return TRUE;
guint modkey;
guint modmask; /* modemask for the kayval */
guint keyval;
- gchar* command; /* command to run */
- gchar* param;
+ char* command; /* command to run */
+ char* param;
} Keybind;
void keybind_init(void);
void keybind_cleanup(void);
-gboolean keybind_add_from_string(gchar* keys, const gchar* command, const Mode mode);
-gboolean keybind_remove_from_string(gchar* 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 */
#include "searchengine.h"
/* variables */
-static gchar **args;
+static char **args;
VpCore vp;
/* callbacks */
WebKitWebNavigationAction* navig, WebKitWebPolicyDecision* policy, gpointer data);
static WebKitWebView* vp_create_new_webview_cb(WebKitWebView* webview, WebKitWebFrame* frame, gpointer data);
static void vp_create_new_webview_uri_cb(WebKitWebView* view, GParamSpec param_spec);
-static void vp_hover_link_cb(WebKitWebView* webview, const gchar* title, const char* link, gpointer data);
-static void vp_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const gchar* title, gpointer data);
+static void vp_hover_link_cb(WebKitWebView* webview, const char* title, const char* link, gpointer data);
+static void vp_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const char* title, gpointer data);
static gboolean vp_mimetype_decision_cb(WebKitWebView* webview,
- WebKitWebFrame* frame, WebKitNetworkRequest* request, gchar*
+ WebKitWebFrame* frame, WebKitNetworkRequest* request, char*
mime_type, WebKitWebPolicyDecision* decision, gpointer data);
static gboolean vp_download_requested_cb(WebKitWebView* view, WebKitDownload* download, gpointer data);
static void vp_download_progress_cp(WebKitDownload* download, GParamSpec* pspec);
static void vp_setup_signals(void);
static void vp_setup_settings(void);
static void vp_set_cookie(SoupCookie* cookie);
-static const gchar* vp_get_cookies(SoupURI *uri);
+static const char* vp_get_cookies(SoupURI *uri);
static gboolean vp_hide_message(void);
static void vp_set_status(const StatusType status);
static void vp_inputbox_activate_cb(GtkEntry *entry, gpointer user_data)
{
gboolean success = FALSE;
- const gchar *text;
+ const char *text;
guint16 length = gtk_entry_get_text_length(entry);
Gui* gui = &vp.gui;
{
SoupMessageHeaders* header = message->request_headers;
SoupURI* uri;
- const gchar* cookie;
+ const char* cookie;
soup_message_headers_remove(header, "Cookie");
uri = soup_message_get_uri(message);
static gboolean vp_inspector_show(WebKitWebInspector* inspector)
{
WebKitWebView* webview;
- gint height;
+ int height;
if (vp.state.is_inspecting) {
return FALSE;
static gboolean vp_process_input(const char* input)
{
gboolean success;
- gchar* line = NULL;
- gchar* command = NULL;
- gchar** token;
+ char* line = NULL;
+ char* command = NULL;
+ char** token;
if (!input || !strlen(input)) {
return FALSE;
uri = g_strrstr(line, "://") ? g_strdup(line) : g_strdup_printf("http://%s", line);
if (arg->i == VP_TARGET_NEW) {
- gchar *argv[64];
+ char *argv[64];
argv[0] = *args;
if (vp.state.embed) {
- gchar tmp[64];
- snprintf(tmp, LENGTH(tmp), "%u", (gint)vp.state.embed);
+ char tmp[64];
+ snprintf(tmp, LENGTH(tmp), "%u", (int)vp.state.embed);
argv[1] = "-e";
argv[2] = tmp;
argv[3] = uri;
g_object_unref(jar);
}
-static const gchar* vp_get_cookies(SoupURI *uri)
+static const char* vp_get_cookies(SoupURI *uri)
{
- const gchar* cookie;
+ const char* cookie;
SoupCookieJar* jar = soup_cookie_jar_text_new(vp.files[FILES_COOKIE], TRUE);
cookie = soup_cookie_jar_get_cookies(jar, uri, TRUE);
void vp_clean_up(void)
{
- const gchar* uri = CURRENT_URL();
+ const char* uri = CURRENT_URL();
/* write last URL into file for recreation */
if (uri) {
g_file_set_contents(vp.files[FILES_CLOSED], uri, -1, NULL);
return TRUE;
}
-void vp_update_urlbar(const gchar* uri)
+void vp_update_urlbar(const char* uri)
{
gtk_label_set_text(GTK_LABEL(vp.gui.statusbar.left), uri);
}
/* show the active downloads */
if (vp.net.downloads) {
- gint num = g_list_length(vp.net.downloads);
+ int num = g_list_length(vp.net.downloads);
g_string_append_printf(status, " %d %s", num, num == 1 ? "download" : "downloads");
}
}
/* show the scroll status */
- gint max = gtk_adjustment_get_upper(vp.gui.adjust_v) - gtk_adjustment_get_page_size(vp.gui.adjust_v);
- gint val = (int)(gtk_adjustment_get_value(vp.gui.adjust_v) / max * 100);
+ int max = gtk_adjustment_get_upper(vp.gui.adjust_v) - gtk_adjustment_get_page_size(vp.gui.adjust_v);
+ int val = (int)(gtk_adjustment_get_value(vp.gui.adjust_v) / max * 100);
if (max == 0) {
g_string_append(status, " All");
}
/* read config from config files */
- gchar **lines = util_get_lines(vp.files[FILES_CONFIG]);
- gchar *line;
+ char **lines = util_get_lines(vp.files[FILES_CONFIG]);
+ char *line;
if (lines) {
- gint length = g_strv_length(lines) - 1;
- for (gint i = 0; i < length; i++) {
+ int length = g_strv_length(lines) - 1;
+ for (int i = 0; i < length; i++) {
line = lines[i];
g_strstrip(line);
static void vp_init_files(void)
{
- gchar* path = util_get_config_dir();
+ char* path = util_get_config_dir();
vp.files[FILES_CONFIG] = g_build_filename(path, "config", NULL);
util_create_file_if_not_exists(vp.files[FILES_CONFIG]);
{
if (webkit_web_navigation_action_get_reason(navig) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
/* open in a new window */
- Arg a = {VP_TARGET_NEW, (gchar*)webkit_network_request_get_uri(request)};
+ Arg a = {VP_TARGET_NEW, (char*)webkit_network_request_get_uri(request)};
vp_load_uri(&a);
webkit_web_policy_decision_ignore(policy);
return TRUE;
static void vp_create_new_webview_uri_cb(WebKitWebView* view, GParamSpec param_spec)
{
- Arg a = {VP_TARGET_NEW, (gchar*)webkit_web_view_get_uri(view)};
+ Arg a = {VP_TARGET_NEW, (char*)webkit_web_view_get_uri(view)};
/* clean up */
webkit_web_view_stop_loading(view);
gtk_widget_destroy(GTK_WIDGET(view));
vp_load_uri(&a);
}
-static void vp_hover_link_cb(WebKitWebView* webview, const gchar* title, const char* link, gpointer data)
+static void vp_hover_link_cb(WebKitWebView* webview, const char* title, const char* link, gpointer data)
{
if (link) {
- gchar* message = g_strdup_printf("Link: %s", link);
+ char* message = g_strdup_printf("Link: %s", link);
gtk_label_set_text(GTK_LABEL(vp.gui.statusbar.left), message);
g_free(message);
} else {
}
}
-static void vp_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const gchar* title, gpointer data)
+static void vp_title_changed_cb(WebKitWebView* webview, WebKitWebFrame* frame, const char* title, gpointer data)
{
gtk_window_set_title(GTK_WINDOW(vp.gui.window), title);
}
static gboolean vp_mimetype_decision_cb(WebKitWebView* webview,
- WebKitWebFrame* frame, WebKitNetworkRequest* request, gchar*
+ WebKitWebFrame* frame, WebKitNetworkRequest* request, char*
mime_type, WebKitWebPolicyDecision* decision, gpointer data)
{
if (webkit_web_view_can_show_mime_type(webview, mime_type) == FALSE) {
static gboolean vp_download_requested_cb(WebKitWebView* view, WebKitDownload* download, gpointer data)
{
WebKitDownloadStatus status;
- gchar* uri = NULL;
+ char* uri = NULL;
- const gchar* filename = webkit_download_get_suggested_filename(download);
+ const char* filename = webkit_download_get_suggested_filename(download);
if (!filename) {
filename = "vimp_donwload";
}
WebKitWebResource* resource, WebKitNetworkRequest* request,
WebKitNetworkResponse* response, gpointer data)
{
- const gchar* 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");
}
return;
}
- gchar* 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) {
vp_echo(VP_MSG_ERROR, FALSE, "Error downloading %s", file);
} else {
int main(int argc, char* argv[])
{
- static gchar* winid = NULL;
+ static char* winid = NULL;
static gboolean ver = false;
static GError* err;
static GOptionEntry opts[] = {
/* structs */
typedef struct {
- gint i;
- gchar* s;
+ int i;
+ char* s;
} Arg;
/* statusbar */
/* state */
typedef struct {
Mode mode;
- gchar modkey;
+ char modkey;
guint count;
#ifdef HAS_GTK3
Window embed;
StatusType status;
gboolean is_inspecting;
SearchDirection search_dir;
- gchar* search_query;
+ char* search_query;
} State;
/* behaviour */
typedef struct {
time_t cookie_timeout;
- gint scrollstep;
+ int scrollstep;
guint max_completion_items;
- gchar* home_page;
- gchar* download_dir;
+ char* home_page;
+ char* download_dir;
} Config;
typedef struct {
GList* completions;
GList* active;
- gint count;
+ int count;
} Completions;
typedef struct {
VpColor comp_bg[VP_COMP_LAST];
PangoFontDescription* comp_font[VP_COMP_LAST];
/* hint style */
- gchar* hint_bg;
- gchar* hint_bg_focus;
- gchar* hint_fg;
- gchar* hint_style;
+ char* hint_bg;
+ char* hint_bg_focus;
+ char* hint_fg;
+ char* hint_style;
/* status bar */
VpColor status_bg[VP_STATUS_LAST];
VpColor status_fg[VP_STATUS_LAST];
Gui gui;
State state;
Behaviour behave;
- gchar* files[FILES_LAST];
+ char* files[FILES_LAST];
Network net;
Config config;
Completions comps;
/* functions */
void vp_update_statusbar(void);
-void vp_update_urlbar(const gchar* uri);
+void vp_update_urlbar(const char* uri);
void vp_update_status_style(void);
void vp_echo(const MessageType type, gboolean hide, const char *error, ...);
gboolean vp_set_mode(Mode mode, gboolean clean);
#include "main.h"
#include "searchengine.h"
-static GSList* searchengine_find(const gchar* handle);
-static gboolean searchengine_is_valid_uri(const gchar* uri);
+static GSList* searchengine_find(const char* handle);
+static gboolean searchengine_is_valid_uri(const char* uri);
void searchengine_cleanup(void)
}
}
-gboolean searchengine_add(const gchar* handle, const gchar* 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 TRUE;
}
-gboolean searchengine_remove(const gchar* handle)
+gboolean searchengine_remove(const char* handle)
{
GSList* list = searchengine_find(handle);
return FALSE;
}
-gchar* searchengine_get_uri(const gchar* handle)
+char* searchengine_get_uri(const char* handle)
{
GSList* list = searchengine_find(handle);
return NULL;
}
-static GSList* searchengine_find(const gchar* handle)
+static GSList* searchengine_find(const char* handle)
{
GSList* s;
for (s = vp.behave.searchengines; s != NULL; s = s->next) {
return NULL;
}
-static gboolean searchengine_is_valid_uri(const gchar* uri)
+static gboolean searchengine_is_valid_uri(const char* uri)
{
- gint count = 0;
+ int count = 0;
for (; *uri; uri++) {
if (*uri == '%') {
#define _SEARCHENGINE_H
typedef struct {
- gchar* handle;
- gchar* uri;
+ char* handle;
+ char* uri;
} Searchengine;
void searchengine_cleanup(void);
-gboolean searchengine_add(const gchar* handle, const gchar* uri);
-gboolean searchengine_remove(const gchar* handle);
-gchar* searchengine_get_uri(const gchar* handle);
+gboolean searchengine_add(const char* handle, const char* uri);
+gboolean searchengine_remove(const char* handle);
+char* searchengine_get_uri(const char* handle);
#endif /* end of include guard: _SEARCHENGINE_H */
#include "setting.h"
#include "util.h"
-static Arg* setting_char_to_arg(const gchar* str, const Type 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 gboolean get);
static gboolean setting_cookie_timeout(const Setting* s, const gboolean get);
}
}
-gboolean setting_run(gchar* name, const gchar* param)
+gboolean setting_run(char* name, const char* param)
{
Arg* a = NULL;
gboolean result = FALSE;
gboolean get = FALSE;
/* check if we should display current value */
- gint len = strlen(name);
+ int len = strlen(name);
if (name[len - 1] == '?') {
/* remove the last ? char from setting name */
name[len - 1] = '\0';
/**
* Converts string representing also given data type into and Arg.
*/
-static Arg* setting_char_to_arg(const gchar* str, const Type type)
+static Arg* setting_char_to_arg(const char* str, const Type type)
{
if (!str) {
return NULL;
break;
case TYPE_INTEGER:
- arg->i = g_ascii_strtoull(str, (gchar**)NULL, 10);
+ arg->i = g_ascii_strtoull(str, (char**)NULL, 10);
break;
case TYPE_FLOAT:
- arg->i = (1000000 * g_ascii_strtod(str, (gchar**)NULL));
+ arg->i = (1000000 * g_ascii_strtod(str, (char**)NULL));
break;
case TYPE_CHAR:
*/
static void setting_print_value(const Setting* s, void* value)
{
- const gchar* name = s->alias ? s->alias : s->name;
- gchar* string = NULL;
+ const char* name = s->alias ? s->alias : s->name;
+ char* string = NULL;
switch (s->type) {
case TYPE_BOOLEAN:
break;
case TYPE_INTEGER:
- vp_echo(VP_MSG_NORMAL, FALSE, " %s=%d", name, *(gint*)value);
+ vp_echo(VP_MSG_NORMAL, FALSE, " %s=%d", name, *(int*)value);
break;
case TYPE_FLOAT:
break;
case TYPE_CHAR:
- vp_echo(VP_MSG_NORMAL, FALSE, " %s=%s", name, (gchar*)value);
+ vp_echo(VP_MSG_NORMAL, FALSE, " %s=%s", name, (char*)value);
break;
case TYPE_COLOR:
case TYPE_INTEGER:
if (get) {
- gint value;
+ int value;
g_object_get(G_OBJECT(web_setting), s->name, &value, NULL);
setting_print_value(s, &value);
} else {
case TYPE_COLOR:
case TYPE_FONT:
if (get) {
- gchar* value = NULL;
+ char* value = NULL;
g_object_get(G_OBJECT(web_setting), s->name, value, NULL);
setting_print_value(s, value);
} else {
static gboolean setting_ca_bundle(const Setting* s, const gboolean get)
{
if (get) {
- gchar* value = NULL;
+ char* value = NULL;
g_object_get(vp.net.soup_session, "ssl-ca-file", &value, NULL);
setting_print_value(s, value);
g_free(value);
gboolean value = (proxy_uri != NULL);
setting_print_value(s, &value);
} else if (s->arg.i) {
- gchar* proxy = (gchar *)g_getenv("http_proxy");
+ char* proxy = (char *)g_getenv("http_proxy");
if (proxy != NULL && strlen(proxy)) {
- gchar* 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);
typedef gboolean (*SettingFunc)(const Setting*, const gboolean get);
struct _Setting {
- gchar* alias;
- gchar* name;
+ char* alias;
+ char* name;
Type type;
SettingFunc func;
Arg arg;
void setting_init(void);
void setting_cleanup(void);
-gboolean setting_run(gchar* name, const gchar* param);
+gboolean setting_run(char* name, const char* param);
#endif /* end of include guard: _SETTING_H */
#include "util.h"
#include <stdio.h>
-gchar* util_get_config_dir(void)
+char* util_get_config_dir(void)
{
- gchar *path = g_build_filename(g_get_user_config_dir(), "vimp", NULL);
+ char *path = g_build_filename(g_get_user_config_dir(), "vimp", NULL);
util_create_dir_if_not_exists(path);
return path;
}
-gchar* util_get_cache_dir(void)
+char* util_get_cache_dir(void)
{
- gchar *path = g_build_filename(g_get_user_cache_dir(), "vimp", NULL);
+ char *path = g_build_filename(g_get_user_cache_dir(), "vimp", NULL);
util_create_dir_if_not_exists(path);
return path;
}
-const gchar* util_get_home_dir(void)
+const char* util_get_home_dir(void)
{
- const gchar* dir = g_getenv("HOME");
+ const char* dir = g_getenv("HOME");
if (!dir) {
dir = g_get_home_dir();
return dir;
}
-void util_create_dir_if_not_exists(const gchar* 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);
*
* The memory of returned string have to be freed!
*/
-gchar* util_get_file_contents(const gchar* filename, gsize* length)
+char* util_get_file_contents(const char* filename, gsize* length)
{
GError* error = NULL;
- gchar* content = NULL;
+ char* content = NULL;
if (!(g_file_test(filename, G_FILE_TEST_IS_REGULAR)
&& g_file_get_contents(filename, &content, length, &error))
) {
*
* The result have to be freed by g_strfreev().
*/
-gchar** util_get_lines(const gchar* filename)
+char** util_get_lines(const char* filename)
{
- gchar* content = util_get_file_contents(filename, NULL);
- gchar** 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);
#include "main.h"
-gchar* util_get_config_dir(void);
-gchar* util_get_cache_dir(void);
-const gchar* util_get_home_dir(void);
-void util_create_dir_if_not_exists(const gchar* dirpath);
-void util_create_file_if_not_exists(const gchar* filename);
-gchar* util_get_file_contents(const gchar* filename, gsize* length);
-gchar** util_get_lines(const gchar* filename);
+char* util_get_config_dir(void);
+char* util_get_cache_dir(void);
+const char* util_get_home_dir(void);
+void util_create_dir_if_not_exists(const char* dirpath);
+void util_create_file_if_not_exists(const char* filename);
+char* util_get_file_contents(const char* filename, gsize* length);
+char** util_get_lines(const char* filename);
#endif /* end of include guard: _UTIL_H */