2016-01-01 19:58:30 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#include <gui/builder.h>
|
|
|
|
#include <gui/playlist.h>
|
|
|
|
|
|
|
|
enum playlist_sidebar_columns {
|
|
|
|
P_SB_IMAGE,
|
|
|
|
P_SB_IMAGE_SZ,
|
|
|
|
P_SB_NAME,
|
|
|
|
};
|
|
|
|
|
2016-01-04 07:55:10 -05:00
|
|
|
static GtkTreeStore *p_store;
|
|
|
|
|
|
|
|
static void __playlist_set(GtkTreeIter *iter, const gchar *name,
|
|
|
|
const gchar *image, GtkIconSize size)
|
|
|
|
{
|
|
|
|
gtk_tree_store_set(p_store, iter, P_SB_NAME, name, P_SB_IMAGE, image,
|
|
|
|
P_SB_IMAGE_SZ, size, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __playlist_add(GtkTreeIter *parent, const gchar *name,
|
|
|
|
const gchar *image)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gtk_tree_store_insert(p_store, &iter, parent, -1);
|
|
|
|
__playlist_set(&iter, name, image, GTK_ICON_SIZE_MENU);
|
|
|
|
}
|
2016-01-01 19:58:30 -05:00
|
|
|
|
|
|
|
static gboolean __playlist_select(GtkTreeSelection *selection,
|
|
|
|
GtkTreeModel *model, GtkTreePath *path,
|
|
|
|
gboolean selected, gpointer data)
|
|
|
|
{
|
|
|
|
return gtk_tree_path_get_depth(path) != 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_playlist_init()
|
|
|
|
{
|
|
|
|
GtkTreeView *treeview;
|
2016-01-04 07:55:10 -05:00
|
|
|
GtkTreeIter parent;
|
2016-01-01 19:58:30 -05:00
|
|
|
|
2016-01-04 07:55:10 -05:00
|
|
|
p_store = GTK_TREE_STORE(gui_builder_object("o_playlist_store"));
|
2016-01-01 19:58:30 -05:00
|
|
|
|
|
|
|
/* Add "Playlist" header. */
|
2016-01-04 07:55:10 -05:00
|
|
|
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
|
|
|
__playlist_set(&parent, "<span size='large'>Playlists</span>",
|
|
|
|
"emblem-documents", GTK_ICON_SIZE_LARGE_TOOLBAR);
|
|
|
|
|
|
|
|
/* Add playlists. */
|
|
|
|
__playlist_add(&parent, "Favorites", "emblem-favorite");
|
|
|
|
__playlist_add(&parent, "Banned", "face-sad");
|
|
|
|
__playlist_add(&parent, "Most Played", "go-up");
|
|
|
|
__playlist_add(&parent, "Least Played", "go-down");
|
|
|
|
__playlist_add(&parent, "Unplayed", "audio-x-generic");
|
2016-01-01 19:58:30 -05:00
|
|
|
|
|
|
|
treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"));
|
2016-01-04 07:55:10 -05:00
|
|
|
gtk_tree_view_expand_all(treeview);
|
2016-01-01 19:58:30 -05:00
|
|
|
gtk_tree_selection_set_select_function(
|
|
|
|
gtk_tree_view_get_selection(treeview),
|
|
|
|
__playlist_select, NULL, NULL);
|
2016-01-04 07:55:10 -05:00
|
|
|
|
|
|
|
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
2016-01-01 19:58:30 -05:00
|
|
|
}
|