gui/playlist: Store the playlist type in the sidebar treemodel
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
871bf88b94
commit
8abc45b1ae
|
@ -10,16 +10,27 @@
|
|||
enum playlist_sidebar_columns {
|
||||
P_SB_IMAGE,
|
||||
P_SB_NAME,
|
||||
P_SB_TYPE,
|
||||
};
|
||||
|
||||
static GtkTreeStore *p_store;
|
||||
static gchar *p_name = NULL;
|
||||
|
||||
static void __playlist_set(GtkTreeIter *iter, const gchar *name,
|
||||
const gchar *image)
|
||||
|
||||
static inline enum playlist_type_t __playlist_type(GtkTreeIter *iter)
|
||||
{
|
||||
gtk_tree_store_set(p_store, iter, P_SB_NAME, name,
|
||||
P_SB_IMAGE, image, -1);
|
||||
enum playlist_type_t type;
|
||||
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(p_store), iter, P_SB_TYPE, &type, -1);
|
||||
return (type < PL_MAX_TYPE) ? type : PL_SYSTEM;
|
||||
}
|
||||
|
||||
static void __playlist_set(GtkTreeIter *iter, const gchar *name,
|
||||
const gchar *image, enum playlist_type_t type)
|
||||
{
|
||||
gtk_tree_store_set(p_store, iter, P_SB_NAME, name,
|
||||
P_SB_IMAGE, image,
|
||||
P_SB_TYPE, type, -1);
|
||||
}
|
||||
|
||||
static void __playlist_set_size(GtkTreeIter *iter, const gchar *name)
|
||||
|
@ -40,11 +51,11 @@ static void __playlist_set_size(GtkTreeIter *iter, const gchar *name)
|
|||
}
|
||||
|
||||
static void __playlist_add(GtkTreeIter *parent, const gchar *name,
|
||||
const gchar *image)
|
||||
const gchar *image, enum playlist_type_t type)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gtk_tree_store_insert(p_store, &iter, parent, -1);
|
||||
__playlist_set(&iter, name, image);
|
||||
__playlist_set(&iter, name, image, type);
|
||||
__playlist_set_size(&iter, name);
|
||||
}
|
||||
|
||||
|
@ -101,9 +112,12 @@ gboolean __playlist_on_select(GtkTreeSelection *selection, GtkTreeModel *model,
|
|||
|
||||
static bool __playlist_queue_set_size(struct queue *queue, GtkTreeIter *iter)
|
||||
{
|
||||
struct gui_queue *gq = gui_queue(queue);
|
||||
bool match = (__playlist_type(iter) == gq->gq_playlist->pl_type);
|
||||
gchar *name = __playlist_name(iter);
|
||||
bool match = string_match(name, gui_queue(queue)->gq_text);
|
||||
|
||||
if (match)
|
||||
match = string_match(name, gq->gq_text);
|
||||
if (match)
|
||||
__playlist_set_size(iter, name);
|
||||
g_free(name);
|
||||
|
@ -175,7 +189,7 @@ void gui_playlist_init()
|
|||
selection = gtk_tree_view_get_selection(treeview);
|
||||
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
__playlist_set(&parent, "Collection", "media-optical");
|
||||
__playlist_set(&parent, "Collection", "media-optical", PL_SYSTEM);
|
||||
__playlist_set_size(&parent, "Collection");
|
||||
|
||||
path = gtk_tree_model_get_path(GTK_TREE_MODEL(p_store), &parent);
|
||||
|
@ -183,20 +197,20 @@ void gui_playlist_init()
|
|||
gtk_tree_path_free(path);
|
||||
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
__playlist_set(&parent, "History", "document-open-recent");
|
||||
__playlist_set(&parent, "History", "document-open-recent", PL_SYSTEM);
|
||||
__playlist_set_size(&parent, "History");
|
||||
|
||||
/* Add "Playlist" header. */
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
gtk_tree_store_insert(p_store, &parent, NULL, -1);
|
||||
__playlist_set(&parent, "<big>Playlists</big>", "emblem-documents");
|
||||
__playlist_set(&parent, "<big>Playlists</big>", "emblem-documents", 0);
|
||||
|
||||
/* Add playlists. */
|
||||
__playlist_add(&parent, "Favorites", "emblem-favorite");
|
||||
__playlist_add(&parent, "Hidden", "window-close");
|
||||
__playlist_add(&parent, "Most Played", "go-up");
|
||||
__playlist_add(&parent, "Least Played", "go-down");
|
||||
__playlist_add(&parent, "Unplayed", "audio-x-generic");
|
||||
__playlist_add(&parent, "Favorites", "emblem-favorite", PL_SYSTEM);
|
||||
__playlist_add(&parent, "Hidden", "window-close", PL_SYSTEM);
|
||||
__playlist_add(&parent, "Most Played", "go-up", PL_SYSTEM);
|
||||
__playlist_add(&parent, "Least Played", "go-down", PL_SYSTEM);
|
||||
__playlist_add(&parent, "Unplayed", "audio-x-generic", PL_SYSTEM);
|
||||
|
||||
gtk_tree_view_expand_all(treeview);
|
||||
gtk_tree_selection_set_select_function(
|
||||
|
|
|
@ -256,6 +256,8 @@
|
|||
<column type="gchararray"/>
|
||||
<!-- column-name Name -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Type -->
|
||||
<column type="guint"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="o_progress">
|
||||
|
|
Loading…
Reference in New Issue