From 4fee5f85f0be940b245d834edf7673833355edc0 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 31 Aug 2016 11:48:09 -0400 Subject: [PATCH] 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 --- gui/playlist.c | 6 ++++++ gui/playlists/library.c | 12 ++++++++++++ include/gui/playlists/library.h | 3 +++ 3 files changed, 21 insertions(+) diff --git a/gui/playlist.c b/gui/playlist.c index 7644d49a..f801abc8 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -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; diff --git a/gui/playlists/library.c b/gui/playlists/library.c index e2d9592f..b656fc67 100644 --- a/gui/playlists/library.c +++ b/gui/playlists/library.c @@ -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); +} diff --git a/include/gui/playlists/library.h b/include/gui/playlists/library.h index 0c2c0fe8..3e9f9bd2 100644 --- a/include/gui/playlists/library.h +++ b/include/gui/playlists/library.h @@ -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 */