From: Daniel Carl Date: Mon, 10 Jun 2013 20:59:08 +0000 (+0200) Subject: Added macro GET_URI() to shorten the code. X-Git-Url: https://git.owens.tech/assets/static/gitweb.css/assets/static/gitweb.css/git?a=commitdiff_plain;h=0a13db75be823f15fe4e5b4eacd604718968c111;p=vimb.git Added macro GET_URI() to shorten the code. --- diff --git a/src/command.c b/src/command.c index 9f77e0b..3788410 100644 --- a/src/command.c +++ b/src/command.c @@ -293,9 +293,7 @@ gboolean command_input(const Arg *arg) const char *url; /* add current url if requested */ - if (VB_INPUT_CURRENT_URI == arg->i - && (url = webkit_web_view_get_uri(vb.gui.webview)) - ) { + if (VB_INPUT_CURRENT_URI == arg->i && (url = GET_URI())) { /* append the current url to the input message */ char *input = g_strconcat(arg->s, url, NULL); vb_echo_force(VB_MSG_NORMAL, false, "%s", input); @@ -491,7 +489,7 @@ gboolean command_yank(const Arg *arg) Arg a = {arg->i}; if (arg->i & COMMAND_YANK_URI) { /* yank current url */ - a.s = g_strdup(webkit_web_view_get_uri(vb.gui.webview)); + a.s = g_strdup(GET_URI()); } else { a.s = arg->s ? g_strdup(arg->s) : NULL; } @@ -640,7 +638,7 @@ gboolean command_bookmark(const Arg *arg) { vb_set_mode(VB_MODE_NORMAL, false); - bookmark_add(webkit_web_view_get_uri(vb.gui.webview), arg->s); + bookmark_add(GET_URI(), arg->s); return true; } @@ -682,7 +680,7 @@ gboolean command_descent(const Arg *arg) int count = vb.state.count ? vb.state.count : 1; const char *uri, *p = NULL, *domain = NULL; - uri = webkit_web_view_get_uri(vb.gui.webview); + uri = GET_URI(); vb_set_mode(VB_MODE_NORMAL, false); if (!uri || *uri == '\0') { @@ -735,7 +733,7 @@ gboolean command_save(const Arg *arg) vb_set_mode(VB_MODE_NORMAL, false); if (arg->i == COMMAND_SAVE_CURRENT) { - uri = webkit_web_view_get_uri(vb.gui.webview); + uri = GET_URI(); /* given string is the path to save the download to */ if (arg->s && *(arg->s) != '\0') { path = arg->s; @@ -888,5 +886,5 @@ static char *expand_string(const char *str) if (!str) { return NULL; } - return util_str_replace("%", webkit_web_view_get_uri(vb.gui.webview), str); + return util_str_replace("%", GET_URI(), str); } diff --git a/src/main.c b/src/main.c index 00dda90..4fc3921 100644 --- a/src/main.c +++ b/src/main.c @@ -389,7 +389,7 @@ static void webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec) static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) { - const char *uri = webkit_web_view_get_uri(vb.gui.webview); + const char *uri = GET_URI(); switch (webkit_web_view_get_load_status(vb.gui.webview)) { case WEBKIT_LOAD_PROVISIONAL: @@ -869,7 +869,7 @@ static WebKitWebView *create_web_view_cb(WebKitWebView *view, WebKitWebFrame *fr static void create_web_view_received_uri_cb(WebKitWebView *view) { - Arg a = {VB_TARGET_NEW, (char*)webkit_web_view_get_uri(view)}; + Arg a = {VB_TARGET_NEW, (char*)GET_URI()}; /* destroy temporary webview */ webkit_web_view_stop_loading(view); gtk_widget_destroy(GTK_WIDGET(view)); @@ -988,7 +988,7 @@ static void download_progress_cp(WebKitDownload *download, GParamSpec *pspec) static void destroy_client() { - const char *uri = webkit_web_view_get_uri(vb.gui.webview); + const char *uri = GET_URI(); /* write last URL into file for recreation */ if (uri) { g_file_set_contents(vb.files[FILES_CLOSED], uri, -1, NULL); diff --git a/src/main.h b/src/main.h index 07ab814..c84469f 100644 --- a/src/main.h +++ b/src/main.h @@ -52,6 +52,7 @@ #endif #define GET_TEXT() (gtk_entry_get_text(GTK_ENTRY(vb.gui.inputbox))) +#define GET_URI() (webkit_web_view_get_uri(vb.gui.webview)) #define CLEAN_MODE(mode) ((mode) & ~(VB_MODE_COMPLETE | VB_MODE_SEARCH | VB_MODE_HINTING)) #define CLEAR_INPUT() (vb_echo(VB_MSG_NORMAL, "")) #define PRIMARY_CLIPBOARD() gtk_clipboard_get(GDK_SELECTION_PRIMARY)