gui/playlist: Add library playlists to the playlist sidebar
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
8abc45b1ae
commit
f2597a8e6c
|
@ -8,6 +8,7 @@
|
|||
#include <gui/builder.h>
|
||||
#include <gui/collection.h>
|
||||
#include <gui/idle.h>
|
||||
#include <gui/playlist.h>
|
||||
#include <gui/sidebar.h>
|
||||
|
||||
enum collection_sidebar_columns {
|
||||
|
@ -137,6 +138,7 @@ bool __collection_buttonpress(GtkWidget *widget, GdkEventButton *event, gpointer
|
|||
void __collection_add(GtkButton *button, GtkFileChooser *chooser)
|
||||
{
|
||||
gchar *filename = gtk_file_chooser_get_filename(chooser);
|
||||
struct library *library;
|
||||
GtkTreeIter iter, last;
|
||||
|
||||
gtk_tree_model_get_iter_first(c_model, &iter);
|
||||
|
@ -144,8 +146,10 @@ void __collection_add(GtkButton *button, GtkFileChooser *chooser)
|
|||
while (__collection_get_library(&last) != NULL)
|
||||
gtk_tree_model_iter_next(c_model, &last);
|
||||
|
||||
library = collection_add(filename);
|
||||
gtk_tree_store_insert_before(GTK_TREE_STORE(c_model), &iter, NULL, &last);
|
||||
__collection_set_library(&iter, collection_add(filename));
|
||||
__collection_set_library(&iter, library);
|
||||
gui_playlist_add_library(library);
|
||||
|
||||
gui_idle_enable();
|
||||
g_free(filename);
|
||||
|
@ -184,6 +188,7 @@ bool __gui_collection_init_idle()
|
|||
db_for_each(library, next, library_db_get()) {
|
||||
gtk_tree_store_insert_before(GTK_TREE_STORE(c_model), &iter, &parent, &last);
|
||||
__collection_set_library(&iter, LIBRARY(library));
|
||||
gui_playlist_add_library(LIBRARY(library));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ static void __playlist_set(GtkTreeIter *iter, const gchar *name,
|
|||
static void __playlist_set_size(GtkTreeIter *iter, const gchar *name)
|
||||
{
|
||||
GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(p_store), iter);
|
||||
unsigned int size = playlist_size(PL_SYSTEM, name);
|
||||
unsigned int size = playlist_size(__playlist_type(iter), name);
|
||||
const gchar *fmt = "%s\n%d track%s";
|
||||
gchar *text;
|
||||
|
||||
|
@ -81,6 +81,7 @@ void __playlist_selection_changed(GtkTreeSelection *selection, gpointer data)
|
|||
{
|
||||
GtkStack *stack = GTK_STACK(gui_builder_widget("o_stack"));
|
||||
GtkTreeModel *model = GTK_TREE_MODEL(p_store);
|
||||
struct queue *queue;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
|
||||
|
@ -89,8 +90,8 @@ void __playlist_selection_changed(GtkTreeSelection *selection, gpointer data)
|
|||
p_name = __playlist_name(&iter);
|
||||
|
||||
gtk_stack_set_visible_child_name(stack, "queues");
|
||||
gui_sidebar_selected(SB_PLAYLIST,
|
||||
gui_queue(playlist_get_queue(PL_SYSTEM, p_name)));
|
||||
queue = playlist_get_queue(__playlist_type(&iter), p_name);
|
||||
gui_sidebar_selected(SB_PLAYLIST, gui_queue(queue));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,7 @@ gboolean __playlist_on_select(GtkTreeSelection *selection, GtkTreeModel *model,
|
|||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
|
||||
name = __playlist_name(&iter);
|
||||
queue = playlist_get_queue(PL_SYSTEM, name);
|
||||
queue = playlist_get_queue(__playlist_type(&iter), name);
|
||||
g_free(name);
|
||||
|
||||
return queue != NULL;
|
||||
|
@ -212,12 +213,15 @@ void gui_playlist_init()
|
|||
__playlist_add(&parent, "Least Played", "go-down", PL_SYSTEM);
|
||||
__playlist_add(&parent, "Unplayed", "audio-x-generic", PL_SYSTEM);
|
||||
|
||||
/* Add "Library" header. */
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
__playlist_set(&parent, "<big>Library</big>", "system-file-manager", 0);
|
||||
|
||||
gtk_tree_view_expand_all(treeview);
|
||||
gtk_tree_selection_set_select_function(
|
||||
gtk_tree_view_get_selection(treeview),
|
||||
__playlist_on_select, NULL, NULL);
|
||||
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
}
|
||||
|
||||
gchar *gui_playlist_cur()
|
||||
|
@ -225,6 +229,23 @@ gchar *gui_playlist_cur()
|
|||
return p_name;
|
||||
}
|
||||
|
||||
void gui_playlist_add_library(struct library *library)
|
||||
{
|
||||
GtkTreeIter parent;
|
||||
gchar *name;
|
||||
|
||||
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(p_store), &parent);
|
||||
while (gtk_tree_model_iter_next(GTK_TREE_MODEL(p_store), &parent)) {
|
||||
name = __playlist_name(&parent);
|
||||
if (string_match(name, "Library"))
|
||||
__playlist_add(&parent, library->li_path, "folder", PL_LIBRARY);
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
gtk_tree_view_expand_all(
|
||||
GTK_TREE_VIEW(gui_builder_widget("o_playlist_view")));
|
||||
}
|
||||
|
||||
struct queue_ops playlist_ops = {
|
||||
.qop_init = __playlist_init,
|
||||
.qop_deinit = gui_queue_free,
|
||||
|
|
|
@ -12,6 +12,9 @@ void gui_playlist_init();
|
|||
/* Called to get the currently selected playlist. */
|
||||
gchar *gui_playlist_cur();
|
||||
|
||||
/* Called to add a library playlist. */
|
||||
void gui_playlist_add_library(struct library *);
|
||||
|
||||
/* Playlist operations passed to core_init() */
|
||||
extern struct queue_ops playlist_ops;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ void __sidebar_selection_changed() {}
|
|||
void __collection_activated() {}
|
||||
void __collection_add() {}
|
||||
void __collection_buttonpress() {}
|
||||
void __collection_choose() {}
|
||||
void __collection_keypress() {}
|
||||
void __collection_selection_changed() {}
|
||||
void __collection_toggled() {}
|
||||
|
|
|
@ -6,6 +6,6 @@ queue
|
|||
window
|
||||
idle
|
||||
sidebar
|
||||
collection
|
||||
playlist
|
||||
collection
|
||||
audio
|
||||
|
|
|
@ -32,8 +32,8 @@ res += [ GuiTest("queue") ]
|
|||
res += [ GuiTest("window") ]
|
||||
res += [ GuiTest("idle") ]
|
||||
res += [ GuiTest("sidebar") ]
|
||||
res += [ GuiTest("collection") ]
|
||||
res += [ GuiTest("playlist") ]
|
||||
res += [ GuiTest("collection") ]
|
||||
gui_objs += [ env.Object("../../gui/artwork.c") ]
|
||||
res += [ GuiTest("audio") ]
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#define TEST_NEED_AUDIO
|
||||
#define TEST_NEED_PLAYLIST
|
||||
#include <core/core.h>
|
||||
#include <core/idle.h>
|
||||
#include <gui/builder.h>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#define TEST_NEED_AUDIO
|
||||
#define TEST_NEED_COLLECTION
|
||||
#include <core/core.h>
|
||||
#include <gui/builder.h>
|
||||
#include <gui/playlist.h>
|
||||
|
|
Loading…
Reference in New Issue