From: Daniel Carl Date: Sat, 5 Jan 2013 14:57:01 +0000 (+0100) Subject: Allow to set a home page. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=3383b7a711e942301a96a6a43b0d2e5232a26173;p=vimb.git Allow to set a home page. Added also commands and keybinds to easily open the home page into current or new window. --- diff --git a/src/command.c b/src/command.c index 80ba1dc..10801a6 100644 --- a/src/command.c +++ b/src/command.c @@ -28,6 +28,8 @@ static CommandInfo cmd_list[] = { /* command function arg mode */ {"open", command_open, {VP_TARGET_CURRENT, ""}, VP_MODE_NORMAL}, {"tabopen", command_open, {VP_TARGET_NEW, ""}, VP_MODE_NORMAL}, + {"open-home", command_open_home, {VP_TARGET_CURRENT, ""}, VP_MODE_NORMAL}, + {"tabopen-home", command_open_home, {VP_TARGET_NEW, ""}, VP_MODE_NORMAL}, {"input", command_input, {0, ":"}, VP_MODE_COMMAND}, {"inputopen", command_input, {0, ":open "}, VP_MODE_COMMAND}, {"inputtabopen", command_input, {0, ":tabopen "}, VP_MODE_COMMAND}, @@ -126,6 +128,16 @@ gboolean command_open(const Arg* arg) return vp_load_uri(arg); } +gboolean command_open_home(const Arg* arg) +{ + gboolean result; + + Arg a = {.i = arg->i, .s = vp.config.home_page}; + result = vp_load_uri(&a); + + return result; +} + gboolean command_input(const Arg* arg) { const gchar* url; diff --git a/src/command.h b/src/command.h index 3a6fa10..62fc6d7 100644 --- a/src/command.h +++ b/src/command.h @@ -43,6 +43,7 @@ gboolean command_exists(const gchar* name); gboolean command_run(const gchar* name, const gchar* param); gboolean command_open(const Arg* arg); +gboolean command_open_home(const Arg* arg); gboolean command_input(const Arg* arg); gboolean command_close(const Arg* arg); gboolean command_view_source(const Arg* arg); diff --git a/src/config.h b/src/config.h index 2a6b992..045ed54 100644 --- a/src/config.h +++ b/src/config.h @@ -22,9 +22,6 @@ #include "stdlib.h" -#define START_PAGE "https://github.com/fanglingsu/vimp" - -#define SETTING_DEFAUL_FONT_SIZE 12 #define SETTING_MAX_CONNS 25 #define SETTING_MAX_CONNS_PER_HOST 5 @@ -37,6 +34,8 @@ const struct { {"nmap t=inputtabopen"}, {"nmap O=inputopencurrent"}, {"nmap T=inputtabopencurrent"}, + {"nmap gh=open-home"}, + {"nmap gH=tabopen-home"}, {"nmap d=quit"}, {"nmap =back"}, {"nmap =forward"}, diff --git a/src/main.c b/src/main.c index 27165a0..538e2c9 100644 --- a/src/main.c +++ b/src/main.c @@ -814,7 +814,7 @@ int main(int argc, char* argv[]) if (argc > 1) { arg.s = g_strdup(argv[argc - 1]); } else { - arg.s = g_strdup(START_PAGE); + arg.s = g_strdup(vp.config.home_page); } vp_load_uri(&arg); g_free(arg.s); diff --git a/src/main.h b/src/main.h index 54bf697..298841c 100644 --- a/src/main.h +++ b/src/main.h @@ -223,6 +223,7 @@ typedef struct { time_t cookie_timeout; gint scrollstep; guint max_completion_items; + gchar* home_page; } Config; typedef struct { diff --git a/src/setting.c b/src/setting.c index 36621e6..317bce6 100644 --- a/src/setting.c +++ b/src/setting.c @@ -35,6 +35,7 @@ static gboolean setting_completion_style(const Setting* s, const gboolean get); static gboolean setting_hint_style(const Setting* s, const gboolean get); static gboolean setting_strict_ssl(const Setting* s, const gboolean get); static gboolean setting_ca_bundle(const Setting* s, const gboolean get); +static gboolean setting_home_page(const Setting* s, const gboolean get); static Setting default_settings[] = { /* webkit settings */ @@ -114,6 +115,7 @@ static Setting default_settings[] = { {NULL, "hint-style", TYPE_CHAR, setting_hint_style, {.s = "font-family:monospace;font-weight:bold;color:#000;background-color:#fff;margin:0;padding:0px 1px;border:1px solid #444;opacity:0.7;"}}, {NULL, "strict-ssl", TYPE_BOOLEAN, setting_strict_ssl, {.i = 1}}, {NULL, "ca-bundle", TYPE_CHAR, setting_ca_bundle, {.s = "/etc/ssl/certs/ca-certificates.crt"}}, + {NULL, "home-page", TYPE_CHAR, setting_home_page, {.s = "https://github.com/fanglingsu/vimp"}}, }; @@ -542,3 +544,14 @@ static gboolean setting_ca_bundle(const Setting* s, const gboolean get) return TRUE; } + +static gboolean setting_home_page(const Setting* s, const gboolean get) +{ + if (get) { + setting_print_value(s, vp.config.home_page); + } else { + OVERWRITE_STRING(vp.config.home_page, s->arg.s); + } + + return TRUE; +}