From b8bc5c84dc6a365c4f30eef63924664001d577a2 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Mon, 24 Dec 2012 00:58:11 +0100 Subject: [PATCH] Added macro to get current url. --- src/command.c | 14 +++++++++++++- src/main.c | 4 ++-- src/main.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 60f5ace..69a362c 100644 --- a/src/command.c +++ b/src/command.c @@ -129,7 +129,7 @@ gboolean command_input(const Arg* arg) /* add current url if requested */ if (VP_INPUT_CURRENT_URI == arg->i - && (url = webkit_web_view_get_uri(vp.gui.webview)) + && (url = CURRENT_URL()) ) { /* append the current url to the input message */ gchar* input = g_strconcat(arg->s, url, NULL); @@ -287,6 +287,18 @@ gboolean command_hints_focus(const Arg* arg) return TRUE; } +gboolean command_yank(const Arg* arg) +{ + const gchar* uri = CURRENT_URL(); + if (!uri) { + return TRUE; + } + + vp_set_clipboard(uri, arg->i); + + return TRUE; +} + static void command_write_input(const gchar* str) { gint pos = 0; diff --git a/src/main.c b/src/main.c index 6023a47..5ea7371 100644 --- a/src/main.c +++ b/src/main.c @@ -66,7 +66,7 @@ static gboolean vp_hide_message(void); static void vp_webview_load_status_cb(WebKitWebView* view, GParamSpec* pspec, gpointer user_data) { Gui* gui = &vp.gui; - const char* uri = webkit_web_view_get_uri(gui->webview); + const char* uri = CURRENT_URL(); switch (webkit_web_view_get_load_status(gui->webview)) { case WEBKIT_LOAD_PROVISIONAL: @@ -166,7 +166,7 @@ static WebKitWebView* vp_inspect_web_view_cb(gpointer inspector, WebKitWebView* GtkWidget* window; GtkWidget* view; - title = g_strdup_printf("Inspect page - %s", webkit_web_view_get_uri(web_view)); + title = g_strdup_printf("Inspect page - %s", CURRENT_URL()); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_wmclass(GTK_WINDOW(window), PROJECT, PROJECT); gtk_window_set_title(GTK_WINDOW(window), title); diff --git a/src/main.h b/src/main.h index 2d5236e..1571af4 100644 --- a/src/main.h +++ b/src/main.h @@ -46,6 +46,7 @@ #define CLEAN_MODE(mode) ((mode) & ~(VP_MODE_COMPLETE)) #define GET_CLEAN_MODE() (CLEAN_MODE(vp.state.mode)) #define CLEAR_INPUT() (vp_echo(VP_MSG_NORMAL, "")) +#define CURRENT_URL() webkit_web_view_get_uri(vp.gui.webview) #define IS_ESCAPE_KEY(k, s) ((k == GDK_Escape && s == 0) || (k == GDK_c && s == GDK_CONTROL_MASK)) #define CLEAN_STATE_WITH_SHIFT(e) ((e)->state & (GDK_MOD1_MASK|GDK_MOD4_MASK|GDK_SHIFT_MASK|GDK_CONTROL_MASK)) -- 2.20.1