gui/sidebar: Add support for adding temporary queues
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
c663f287d4
commit
839f4c4aa1
|
@ -88,5 +88,6 @@ void TempLabel :: set_size()
|
|||
{
|
||||
gchar *size = g_strdup_printf("%u", queue_size(_queue));
|
||||
temp_size->set_text(size);
|
||||
gui_sidebar_set_size(_queue);
|
||||
g_free(size);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <core/collection.h>
|
||||
#include <core/history.h>
|
||||
#include <core/queue.h>
|
||||
#include <core/tempq.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/sidebar.h>
|
||||
|
@ -90,7 +91,7 @@ void gui_sidebar_init()
|
|||
{
|
||||
GtkPaned *pane = GTK_PANED(gui_builder_widget("o_sidebar"));
|
||||
GtkTreeIter iter;
|
||||
int pos;
|
||||
int pos, i;
|
||||
|
||||
/* Set up entries in the liststore. */
|
||||
sb_store = GTK_LIST_STORE(gui_builder_object("o_sidebar_store"));
|
||||
|
@ -101,6 +102,9 @@ void gui_sidebar_init()
|
|||
gtk_tree_model_iter_next(GTK_TREE_MODEL(sb_store), &iter);
|
||||
__sidebar_set_queue(&iter, history_get_queue());
|
||||
|
||||
for (i = 0; i < tempq_count(); i++)
|
||||
gui_sidebar_add(tempq_get(i));
|
||||
|
||||
/* Set sidebar width. */
|
||||
pos = gui_settings_get(SIDEBAR_SETTING);
|
||||
if (pos > 0)
|
||||
|
@ -124,15 +128,32 @@ void gui_sidebar_selected(enum sidebar_selection_t selected)
|
|||
__sidebar_deselect("o_sidebar_view");
|
||||
}
|
||||
|
||||
void gui_sidebar_add(struct queue *queue)
|
||||
{
|
||||
const gchar *text = "<big>Queued Tracks</big>\n0 tracks";
|
||||
GtkTreeIter iter, sibling;
|
||||
|
||||
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(sb_store),
|
||||
&sibling, NULL, tempq_count() - 1);
|
||||
|
||||
gtk_list_store_insert_before(sb_store, &iter, &sibling);
|
||||
gtk_list_store_set(sb_store, &iter, SB_IMAGE, "audio-x-generic",
|
||||
SB_IMAGE_SZ, GTK_ICON_SIZE_BUTTON,
|
||||
SB_TEXT, text,
|
||||
SB_QUEUE, queue, -1);
|
||||
}
|
||||
|
||||
void gui_sidebar_set_size(struct queue *queue)
|
||||
{
|
||||
const gchar *name = "Collection";
|
||||
const gchar *name = "Queued Tracks";
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (!__sidebar_find_queue(queue, &iter))
|
||||
return;
|
||||
|
||||
if (queue == history_get_queue())
|
||||
if (queue == collection_get_queue())
|
||||
name = "Collection";
|
||||
else if (queue == history_get_queue())
|
||||
name = "History";
|
||||
|
||||
__sidebar_set_size(&iter, name, queue_size(queue));
|
||||
|
|
|
@ -7,6 +7,7 @@ extern "C" {
|
|||
#include <core/string.h>
|
||||
#include <core/tempq.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/sidebar.h>
|
||||
}
|
||||
#include <gui/tabs.h>
|
||||
|
||||
|
@ -210,6 +211,7 @@ bool Tab :: tab_queue_selected(bool random)
|
|||
|
||||
queue *pq = tempq_alloc(&tempq_ops, flags);
|
||||
on_pq_created(pq, tempq_count() - 1);
|
||||
gui_sidebar_add(pq);
|
||||
tab_queue_add(pq);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ gboolean gui_sidebar_on_select(GtkTreeSelection *, GtkTreeModel *,
|
|||
/* Called to tell the sidebar that the selection has changed. */
|
||||
void gui_sidebar_selected(enum sidebar_selection_t);
|
||||
|
||||
/* Called to add a queue to the sidebar. */
|
||||
void gui_sidebar_add(struct queue *);
|
||||
|
||||
/* Called to set the size of sidebar entries. */
|
||||
void gui_sidebar_set_size(struct queue *);
|
||||
|
||||
|
|
Loading…
Reference in New Issue