gui/sidebar: Add a function for updating playlist text
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
b3efd9d84d
commit
1291a0d139
|
@ -10,12 +10,6 @@
|
||||||
#include <gui/queue.h>
|
#include <gui/queue.h>
|
||||||
#include <gui/sidebar.h>
|
#include <gui/sidebar.h>
|
||||||
|
|
||||||
enum playlist_sidebar_columns {
|
|
||||||
P_SB_IMAGE,
|
|
||||||
P_SB_NAME,
|
|
||||||
P_SB_TYPE,
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool p_filter_enable = true;
|
static bool p_filter_enable = true;
|
||||||
static bool p_init_done = false;
|
static bool p_init_done = false;
|
||||||
|
|
||||||
|
@ -27,22 +21,6 @@ static inline void __playlist_filter_get_iter(GtkTreeIter *iter, GtkTreeIter *ch
|
||||||
child, iter);
|
child, iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __playlist_set_size(GtkTreeIter *iter, const gchar *name)
|
|
||||||
{
|
|
||||||
enum playlist_type_t type = gui_sidebar_iter_type(iter);
|
|
||||||
unsigned int size = playlist_size(type, name);
|
|
||||||
const gchar *fmt = "%s\n%d track%s";
|
|
||||||
gchar *text;
|
|
||||||
|
|
||||||
if (playlist_cur() == playlist_get(type, name))
|
|
||||||
fmt = "<b>%s\n%d track%s</b>";
|
|
||||||
|
|
||||||
text = g_markup_printf_escaped(fmt, name, size, (size == 1) ? "" : "s");
|
|
||||||
gtk_tree_store_set(gui_sidebar_store(), iter, P_SB_NAME, text, -1);
|
|
||||||
|
|
||||||
g_free(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void __playlist_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
void __playlist_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
||||||
GtkTreeViewColumn *col, gpointer data)
|
GtkTreeViewColumn *col, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +40,7 @@ void __playlist_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
||||||
|
|
||||||
name = gui_sidebar_iter_name(&child);
|
name = gui_sidebar_iter_name(&child);
|
||||||
playlist_select(gui_sidebar_iter_type(&child), name);
|
playlist_select(gui_sidebar_iter_type(&child), name);
|
||||||
__playlist_set_size(&child, name);
|
gui_sidebar_iter_update(&child);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
name = playlist_get_name(type, id);
|
name = playlist_get_name(type, id);
|
||||||
|
@ -80,7 +58,7 @@ static bool __playlist_queue_set_size(struct queue *queue, GtkTreeIter *iter)
|
||||||
if (match)
|
if (match)
|
||||||
match = string_match(name, gq->gq_text);
|
match = string_match(name, gq->gq_text);
|
||||||
if (match)
|
if (match)
|
||||||
__playlist_set_size(iter, name);
|
gui_sidebar_iter_update(iter);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
|
|
|
@ -281,6 +281,22 @@ void gui_sidebar_iter_append_child(GtkTreeIter *iter, struct playlist *playlist,
|
||||||
__gui_sidebar_set_playlist(&new, playlist, image);
|
__gui_sidebar_set_playlist(&new, playlist, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gui_sidebar_iter_update(GtkTreeIter *iter)
|
||||||
|
{
|
||||||
|
enum playlist_type_t type = gui_sidebar_iter_type(iter);
|
||||||
|
gchar *name, *text;
|
||||||
|
|
||||||
|
if (type >= PL_MAX_TYPE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
name = gui_sidebar_iter_name(iter);
|
||||||
|
text = __gui_sidebar_size_str(playlist_get(type, name));
|
||||||
|
gtk_tree_store_set(gui_sidebar_store(), iter, SB_NAME, text, -1);
|
||||||
|
|
||||||
|
g_free(name);
|
||||||
|
g_free(text);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean gui_sidebar_iter_find(GtkTreeIter *iter, const gchar *name,
|
gboolean gui_sidebar_iter_find(GtkTreeIter *iter, const gchar *name,
|
||||||
enum playlist_type_t type)
|
enum playlist_type_t type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,9 @@ void gui_sidebar_iter_sort_child(GtkTreeIter *, struct playlist *,
|
||||||
void gui_sidebar_iter_append_child(GtkTreeIter *, struct playlist *,
|
void gui_sidebar_iter_append_child(GtkTreeIter *, struct playlist *,
|
||||||
const gchar *);
|
const gchar *);
|
||||||
|
|
||||||
|
/* Called to update the playlist at the current iterator. */
|
||||||
|
void gui_sidebar_iter_update(GtkTreeIter *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called to find a playlist with the given name and type,
|
* Called to find a playlist with the given name and type,
|
||||||
* starting from the current iterator position.
|
* starting from the current iterator position.
|
||||||
|
|
Loading…
Reference in New Issue