From: Daniel Carl Date: Wed, 31 Jul 2013 20:56:07 +0000 (+0200) Subject: Added feedback about number of left queue items. X-Git-Url: https://git.owens.tech/assets/me.png/assets/me.png/git?a=commitdiff_plain;h=08176d6f1bda6ef89de64cc91991bdea0a53eaba;p=vimb.git Added feedback about number of left queue items. --- 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