Added feedback about number of left queue items.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 31 Jul 2013 20:56:07 +0000 (22:56 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 31 Jul 2013 21:01:11 +0000 (23:01 +0200)
src/bookmark.c
src/bookmark.h
src/command.c

index 330e196..dc85139 100644 (file)
@@ -161,9 +161,11 @@ gboolean bookmark_queue_push(const char *uri)
 
 /**
  * Retrieves the oldest entry from queue.
+ *
+ * @item_count: will be filled with the number of remaining items in queue.
  * Retruned uri must be freed with g_free.
  */
-char *bookmark_queue_pop(void)
+char *bookmark_queue_pop(int *item_count)
 {
     int len, i;
     char **lines, *uri = NULL;
@@ -182,6 +184,10 @@ char *bookmark_queue_pop(void)
         g_strfreev(lines);
         g_file_set_contents(vb.files[FILES_QUEUE], new->str, -1, NULL);
         g_string_free(new, true);
+
+        *item_count = len - 1;
+    } else {
+        *item_count = 0;
     }
     return uri;
 }
index 8ecf929..5aed68b 100644 (file)
@@ -25,7 +25,7 @@ gboolean bookmark_remove(const char *uri);
 gboolean bookmark_fill_completion(GtkListStore *store, const char *input);
 #ifdef FEATURE_QUEUE
 gboolean bookmark_queue_push(const char *uri);
-char *bookmark_queue_pop(void);
+char *bookmark_queue_pop(int *item_count);
 #endif
 
 #endif /* end of include guard: _BOOKMARK_H */
index a770b2d..4f7997e 100644 (file)
@@ -890,7 +890,7 @@ gboolean command_shellcmd(const Arg *arg)
     g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &out, &error, &status, NULL);
     g_strfreev(argv);
     if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
-        vb_echo(VB_MSG_NORMAL, true, "  %s", out);
+        vb_echo(VB_MSG_NORMAL, true, "%s", out);
         return true;
     }
 
@@ -902,6 +902,7 @@ gboolean command_shellcmd(const Arg *arg)
 gboolean command_queue(const Arg *arg)
 {
     gboolean res = false;
+    int count = 0;
     char *uri;
 
     vb_set_mode(VB_MODE_NORMAL, false);
@@ -909,18 +910,18 @@ gboolean command_queue(const Arg *arg)
     if (arg->i == COMMAND_QUEUE_PUSH) {
         res = bookmark_queue_push(arg->s ? arg->s : GET_URI());
         if (res) {
-            vb_echo(VB_MSG_NORMAL, false, "  Pushed to queue");
+            vb_echo(VB_MSG_NORMAL, false, "Pushed to queue");
         }
         return res;
     }
 
     /* pop last added url from queue and open it */
-    if ((uri = bookmark_queue_pop())) {
+    if ((uri = bookmark_queue_pop(&count))) {
         res = vb_load_uri(&(Arg){VB_TARGET_CURRENT, uri});
         g_free(uri);
-    } else {
-        vb_echo(VB_MSG_NORMAL, false, "  Queue is empty");
     }
+    vb_echo(VB_MSG_NORMAL, false, "Queue length %d", count);
+
     return res;
 }
 #endif