gui/playlist: Add 5 playlists to the sidebar
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
be6895630d
commit
fde59a1868
|
@ -10,7 +10,22 @@ enum playlist_sidebar_columns {
|
|||
P_SB_NAME,
|
||||
};
|
||||
|
||||
static GtkTreeModel *p_model;
|
||||
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);
|
||||
}
|
||||
|
||||
static gboolean __playlist_select(GtkTreeSelection *selection,
|
||||
GtkTreeModel *model, GtkTreePath *path,
|
||||
|
@ -22,20 +37,27 @@ static gboolean __playlist_select(GtkTreeSelection *selection,
|
|||
void gui_playlist_init()
|
||||
{
|
||||
GtkTreeView *treeview;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeIter parent;
|
||||
|
||||
p_model = GTK_TREE_MODEL(gui_builder_object("o_playlist_store"));
|
||||
p_store = GTK_TREE_STORE(gui_builder_object("o_playlist_store"));
|
||||
|
||||
/* Add "Playlist" header. */
|
||||
gtk_tree_store_insert(GTK_TREE_STORE(p_model), &iter, NULL, -1);
|
||||
gtk_tree_store_set(GTK_TREE_STORE(p_model), &iter,
|
||||
P_SB_IMAGE, "emblem-documents",
|
||||
P_SB_IMAGE_SZ, GTK_ICON_SIZE_LARGE_TOOLBAR,
|
||||
P_SB_NAME, "<span size='large'>Playlists</span>",
|
||||
-1);
|
||||
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");
|
||||
|
||||
treeview = GTK_TREE_VIEW(gui_builder_widget("o_playlist_view"));
|
||||
gtk_tree_view_expand_all(treeview);
|
||||
gtk_tree_selection_set_select_function(
|
||||
gtk_tree_view_get_selection(treeview),
|
||||
__playlist_select, NULL, NULL);
|
||||
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,10 @@ static void test_playlist_sidebar()
|
|||
path = gtk_tree_model_get_path(model, &iter);
|
||||
gtk_tree_view_set_cursor(treeview, path, NULL, false);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
test_equal(gtk_tree_selection_count_selected_rows(selection), 0);
|
||||
|
||||
test_equal(gtk_tree_model_iter_n_children(model, &iter), 5);
|
||||
|
||||
gui_builder_deinit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue