/**
* 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;
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;
}
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 */
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;
}
gboolean command_queue(const Arg *arg)
{
gboolean res = false;
+ int count = 0;
char *uri;
vb_set_mode(VB_MODE_NORMAL, false);
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