Remove obsolete GET_URI() macro.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 6 Jun 2014 00:08:38 +0000 (02:08 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 6 Jun 2014 00:10:47 +0000 (02:10 +0200)
Removed also the changed-uri signal observer. We get the new URI in the load
status callback right before the event is triggered.

src/command.c
src/ex.c
src/main.c
src/main.h
src/normal.c
src/util.c

index 88a9c70..4134ccb 100644 (file)
@@ -115,7 +115,7 @@ gboolean command_yank(const Arg *arg, char buf)
     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;
@@ -138,7 +138,7 @@ gboolean command_save(const Arg *arg)
     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;
@@ -174,14 +174,14 @@ gboolean command_queue(const Arg *arg)
             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");
             }
index 8596a45..7fe8804 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -702,12 +702,12 @@ static void free_cmdarg(ExArg *arg)
 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;
index 46cb0ba..f4fb029 100644 (file)
@@ -53,7 +53,6 @@ static gboolean context_menu_cb(WebKitWebView *view, GtkWidget *menu,
 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);
@@ -369,10 +368,9 @@ void vb_update_urlbar(const char *uri)
 
 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();
@@ -451,13 +449,6 @@ static void context_menu_activate_cb(GtkMenuItem *item, gpointer data)
 #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;
@@ -481,8 +472,6 @@ static void webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec)
 
 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 */
@@ -493,9 +482,13 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
 
         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);
@@ -520,9 +513,9 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
             }
 
             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();
@@ -537,9 +530,9 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
             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;
 
@@ -853,7 +846,6 @@ static void setup_signals()
 #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,
index 512bdea..1107d16 100644 (file)
@@ -63,7 +63,6 @@
 #define TIMER_END
 #endif
 
-#define GET_URI() (vb.state.uri)
 #define PRIMARY_CLIPBOARD() gtk_clipboard_get(GDK_SELECTION_PRIMARY)
 #define SECONDARY_CLIPBOARD() gtk_clipboard_get(GDK_NONE)
 
index 9ffe4c8..8877987 100644 (file)
@@ -364,7 +364,7 @@ static VbResult normal_descent(const NormalCmdInfo *info)
     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
@@ -497,7 +497,10 @@ static VbResult normal_input_open(const NormalCmdInfo *info)
     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 */
index 94edd7c..dba1c75 100644 (file)
@@ -457,10 +457,9 @@ gboolean util_parse_expansion(const char **input, GString *str, int flags,
         expanded = true;
         g_string_free(name, true);
     } else if (flags & UTIL_EXP_SPECIAL && **input == '%') {
-        const char *uri;
-        if ((uri = GET_URI())) {
+        if (*vb.state.uri) {
             /* TODO check for modifiers like :h:t:r:e */
-            g_string_append(str, uri);
+            g_string_append(str, vb.state.uri);
             expanded = true;
         }
     }