Arg a = {VB_CLIPBOARD_PRIMARY|VB_CLIPBOARD_SECONDARY};
if (arg->i == COMMAND_YANK_URI) {
/* yank current uri */
- a.s = (char*)GET_URI();
+ a.s = vb.state.uri;
} else {
/* use current arg.s as new clipboard content */
a.s = arg->s;
const char *uri, *path = NULL;
if (arg->i == COMMAND_SAVE_CURRENT) {
- uri = GET_URI();
+ uri = vb.state.uri;
/* given string is the path to save the download to */
if (arg->s && *(arg->s) != '\0') {
path = arg->s;
break;
case COMMAND_QUEUE_PUSH:
- res = bookmark_queue_push(arg->s ? arg->s : GET_URI());
+ res = bookmark_queue_push(arg->s ? arg->s : vb.state.uri);
if (res) {
vb_echo(VB_MSG_NORMAL, false, "Pushed to queue");
}
break;
case COMMAND_QUEUE_UNSHIFT:
- res = bookmark_queue_unshift(arg->s ? arg->s : GET_URI());
+ res = bookmark_queue_unshift(arg->s ? arg->s : vb.state.uri);
if (res) {
vb_echo(VB_MSG_NORMAL, false, "Pushed to queue");
}
static gboolean ex_bookmark(const ExArg *arg)
{
if (arg->code == EX_BMR) {
- if (bookmark_remove(*arg->rhs->str ? arg->rhs->str : GET_URI())) {
+ if (bookmark_remove(*arg->rhs->str ? arg->rhs->str : vb.state.uri)) {
vb_echo_force(VB_MSG_NORMAL, false, " Bookmark removed");
return true;
}
- } else if (bookmark_add(GET_URI(), webkit_web_view_get_title(vb.gui.webview), arg->rhs->str)) {
+ } else if (bookmark_add(vb.state.uri, webkit_web_view_get_title(vb.gui.webview), arg->rhs->str)) {
vb_echo_force(VB_MSG_NORMAL, false, " Bookmark added");
return true;
static void context_menu_cb(WebKitWebView *view, GtkMenu *menu, gpointer data);
#endif
static void context_menu_activate_cb(GtkMenuItem *item, gpointer data);
-static void uri_change_cb(WebKitWebView *view, GParamSpec param_spec);
static void webview_progress_cb(WebKitWebView *view, GParamSpec *pspec);
static void webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec);
static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec);
void vb_quit(void)
{
- 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);
+ if (vb.state.uri) {
+ g_file_set_contents(vb.files[FILES_CLOSED], vb.state.uri, -1, NULL);
}
completion_clean();
#endif
}
-static void uri_change_cb(WebKitWebView *view, GParamSpec param_spec)
-{
- g_free(vb.state.uri);
- g_object_get(view, "uri", &vb.state.uri, NULL);
- vb_update_urlbar(vb.state.uri);
-}
-
static void webview_progress_cb(WebKitWebView *view, GParamSpec *pspec)
{
vb.state.progress = webkit_web_view_get_progress(view) * 100;
static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
{
- const char *uri = GET_URI();
-
switch (webkit_web_view_get_load_status(view)) {
case WEBKIT_LOAD_PROVISIONAL:
/* update load progress in statusbar */
case WEBKIT_LOAD_COMMITTED:
{
+ /* save the current uri */
+ g_free(vb.state.uri);
+ g_object_get(view, "uri", &vb.state.uri, NULL);
+
WebKitWebFrame *frame = webkit_web_view_get_main_frame(view);
/* set the status */
- if (g_str_has_prefix(uri, "https://")) {
+ if (g_str_has_prefix(vb.state.uri, "https://")) {
WebKitWebDataSource *src = webkit_web_frame_get_data_source(frame);
WebKitNetworkRequest *request = webkit_web_data_source_get_request(src);
SoupMessage *msg = webkit_network_request_get_message(request);
}
vb_update_statusbar();
- vb_update_urlbar(uri);
+ vb_update_urlbar(vb.state.uri);
/* save the current URI in register % */
- vb_register_add('%', uri);
+ vb_register_add('%', vb.state.uri);
/* clear possible set marks */
marks_clear();
vb_update_statusbar();
update_title();
- if (strncmp(uri, "about:", 6)) {
+ if (strncmp(vb.state.uri, "about:", 6)) {
dom_check_auto_insert(view);
- history_add(HISTORY_URL, uri, webkit_web_view_get_title(view));
+ history_add(HISTORY_URL, vb.state.uri, webkit_web_view_get_title(view));
}
break;
#else
"signal::populate-popup", G_CALLBACK(context_menu_cb), NULL,
#endif
- "signal::notify::uri", G_CALLBACK(uri_change_cb), NULL,
"signal::notify::progress", G_CALLBACK(webview_progress_cb), NULL,
"signal::notify::load-status", G_CALLBACK(webview_load_status_cb), NULL,
"signal::button-release-event", G_CALLBACK(button_relase_cb), NULL,
int count = info->count ? info->count : 1;
const char *uri, *p = NULL, *domain = NULL;
- uri = GET_URI();
+ uri = vb.state.uri;
/* get domain part */
if (!uri || !*uri
if (strchr("ot", info->key)) {
vb_set_input_text(info->key == 't' ? ":tabopen " : ":open ");
} else {
- vb_echo(VB_MSG_NORMAL, false, ":%s %s", info->key == 'T' ? "tabopen" : "open", GET_URI());
+ vb_echo(
+ VB_MSG_NORMAL, false,
+ ":%s %s", info->key == 'T' ? "tabopen" : "open", vb.state.uri
+ );
}
/* switch mode after setting the input text to not trigger the
* commands modes input change handler */