gui/playlists/library: Add a function for updating library paths

Finding the header first makes a lot of sense, and avoids iterating
through every playlist while trying to find the library playlist to
update.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-08-31 11:48:09 -04:00
parent ab47a7ac88
commit 4fee5f85f0
3 changed files with 21 additions and 0 deletions

View File

@ -39,9 +39,15 @@ static bool __playlist_queue_set_size(struct queue *queue, GtkTreeIter *iter)
static void __playlist_update_sizes(struct queue *queue)
{
struct playlist *playlist = queue->q_private;
GtkTreeModelFilter *filter;
GtkTreeIter parent, iter;
if (playlist->pl_type == PL_LIBRARY) {
gui_pl_library_update(playlist);
return;
}
if (!gui_sidebar_iter_first(&parent))
return;

View File

@ -92,3 +92,15 @@ bool gui_pl_library_add(const gchar *filename)
gui_idle_enable();
return true;
}
void gui_pl_library_update(struct playlist *playlist)
{
GtkTreeIter iter, child;
if (!__gui_pl_library_header(&iter))
return;
if (!gui_sidebar_iter_down(&iter, &child))
return;
if (gui_sidebar_iter_find(&child, playlist->pl_name, playlist->pl_type))
gui_sidebar_iter_update(&child);
}

View File

@ -10,4 +10,7 @@ void gui_pl_library_init();
/* Called to add a library path. */
bool gui_pl_library_add(const gchar *);
/* Called to update a library path. */
void gui_pl_library_update(struct playlist *);
#endif /* OCARINA_GUI_PLAYLISTS_LIBRARY_H */