#include "main.h"
#include <webkit/webkit.h>
-typedef void (*Command)(const Arg* arg);
+typedef gboolean (*Command)(const Arg* arg);
typedef struct {
const gchar* name;
g_signal_connect(G_OBJECT(vp.gui.window), "key-press-event", G_CALLBACK(keybind_keypress_callback), NULL);
}
-void keybind_add_from_string(const gchar* str, const Mode mode)
+gboolean keybind_add_from_string(const gchar* str, const Mode mode)
{
if (str == NULL || *str == '\0') {
- return;
+ return FALSE;
}
+ gboolean result;
gchar* line = g_strdup(str);
g_strstrip(line);
if (keybind->modkey) {
g_string_append_c(modkeys, keybind->modkey);
}
+ result = TRUE;
} else {
- fprintf(stderr, "could not add keybind from '%s'", line);
+ result = FALSE;
}
g_strfreev(string);
g_free(line);
+
+ return result;
}
-void keybind_remove_from_string(const gchar* str, const Mode mode)
+gboolean keybind_remove_from_string(const gchar* str, const Mode mode)
{
gchar* line = NULL;
Keybind keybind = {0};
if (str == NULL || *str == '\0') {
- return;
+ return FALSE;
}
line = g_strdup(str);
g_strstrip(line);
keys = g_slist_delete_link(keys, link);
}
/* TODO remove eventually no more used modkeys */
+ return TRUE;
}
static GSList* keybind_find(int mode, guint modkey, guint modmask, guint keyval)
} Keybind;
void keybind_init(void);
-void keybind_add_from_string(const gchar* str, const Mode mode);
-void keybind_remove_from_string(const gchar* str, const Mode mode);
+gboolean keybind_add_from_string(const gchar* str, const Mode mode);
+gboolean keybind_remove_from_string(const gchar* str, const Mode mode);
#endif /* end of include guard: KEYBIND_H */
static void vp_setup_settings(void);
static void vp_setup_signals(void);
static gboolean vp_load_uri(const Arg* arg);
+static void vp_clean_up(void);
static void vp_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, gpointer user_data)
{
return TRUE;
}
-void vp_navigate(const Arg* arg)
+gboolean vp_navigate(const Arg* arg)
{
if (arg->i <= VP_NAVIG_FORWARD) {
/* TODO allow to set a count for the navigation */
} else {
webkit_web_view_stop_loading(vp.gui.webview);
}
+
+ return TRUE;
}
-void vp_scroll(const Arg* arg)
+gboolean vp_scroll(const Arg* arg)
{
GtkAdjustment *adjust = (arg->i & VP_SCROLL_AXIS_H) ? vp.gui.adjust_h : vp.gui.adjust_v;
/* jump to bottom */
gtk_adjustment_set_value(adjust, gtk_adjustment_get_lower(adjust));
}
+
+ return TRUE;
}
-void vp_close_browser(const Arg* arg)
+gboolean vp_close_browser(const Arg* arg)
{
vp_clean_up();
gtk_main_quit();
+
+ return TRUE;
}
-void vp_clean_up(void)
+static void vp_clean_up(void)
{
if (vp.behave.commands) {
g_hash_table_destroy(vp.behave.commands);
}
}
-void vp_view_source(const Arg* arg)
+gboolean vp_view_source(const Arg* arg)
{
gboolean mode = webkit_web_view_get_view_source_mode(vp.gui.webview);
webkit_web_view_set_view_source_mode(vp.gui.webview, !mode);
webkit_web_view_reload(vp.gui.webview);
+
+ return TRUE;
}
-void vp_map(const Arg* arg)
+gboolean vp_map(const Arg* arg)
{
- keybind_add_from_string(arg->s, arg->i);
+ return keybind_add_from_string(arg->s, arg->i);
}
-void vp_unmap(const Arg* arg)
+gboolean vp_unmap(const Arg* arg)
{
- keybind_remove_from_string(arg->s, arg->i);
+ return keybind_remove_from_string(arg->s, arg->i);
}
-void vp_set_mode(const Arg* arg)
+gboolean vp_set_mode(const Arg* arg)
{
vp.state.mode = arg->i;
vp.state.modkey = vp.state.count = 0;
}
vp_update_statusbar();
+
+ return TRUE;
}
-void vp_input(const Arg* arg)
+gboolean vp_input(const Arg* arg)
{
gint pos = 0;
const gchar* url;
gtk_editable_set_position(GTK_EDITABLE(vp.gui.inputbox), -1);
Arg a = {VP_MODE_COMMAND};
- vp_set_mode(&a);
+ return vp_set_mode(&a);
}
-void vp_open(const Arg* arg)
+gboolean vp_open(const Arg* arg)
{
- vp_load_uri(arg);
+ return vp_load_uri(arg);
}
void vp_update_urlbar(const gchar* uri)
void vp_update_statusbar(void);
void vp_update_urlbar(const gchar* uri);
void vp_echo(const MessageType type, const gchar *message);
-void vp_navigate(const Arg* arg);
-void vp_scroll(const Arg* arg);
-void vp_close_browser(const Arg* arg);
-void vp_clean_up(void);
-void vp_view_source(const Arg* arg);
-void vp_map(const Arg* arg);
-void vp_unmap(const Arg* arg);
-void vp_set_mode(const Arg* arg);
-void vp_input(const Arg* arg);
-void vp_open(const Arg* arg);
+gboolean vp_navigate(const Arg* arg);
+gboolean vp_scroll(const Arg* arg);
+gboolean vp_close_browser(const Arg* arg);
+gboolean vp_view_source(const Arg* arg);
+gboolean vp_map(const Arg* arg);
+gboolean vp_unmap(const Arg* arg);
+gboolean vp_set_mode(const Arg* arg);
+gboolean vp_input(const Arg* arg);
+gboolean vp_open(const Arg* arg);
#endif /* end of include guard: MAIN_H */