summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2013-07-31 22:56:07 +0200
committerDaniel Carl <danielcarl@gmx.de>2013-07-31 23:01:11 +0200
commit08176d6f1bda6ef89de64cc91991bdea0a53eaba (patch)
tree3b6111592b7fbfb737b9c094e1da69ca64c91e32
parentcc8c970e9f6f13851708ea7ae4cf3318e9a5623b (diff)
Added feedback about number of left queue items.
-rw-r--r--src/bookmark.c8
-rw-r--r--src/bookmark.h2
-rw-r--r--src/command.c11
3 files changed, 14 insertions, 7 deletions
diff --git a/src/bookmark.c b/src/bookmark.c
index 330e196..dc85139 100644
--- a/src/bookmark.c
+++ b/src/bookmark.c
@@ -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;
}
diff --git a/src/bookmark.h b/src/bookmark.h
index 8ecf929..5aed68b 100644
--- a/src/bookmark.h
+++ b/src/bookmark.h
@@ -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 */
diff --git a/src/command.c b/src/command.c
index a770b2d..4f7997e 100644
--- a/src/command.c
+++ b/src/command.c
@@ -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