ocarina: Pass a playlist to set_length_label()

current_widgets() works based on the current tab number, and the
"switch-page" signal is triggered BEFORE the current page is updated in
the GtkNotebook structure.  This means that I was actually setting the
length based on the previous tab, and not the new one.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-09-05 09:15:58 -04:00
parent 5f1fb2290a
commit 097b157c10
3 changed files with 5 additions and 5 deletions

View File

@ -59,7 +59,7 @@ static void playlist_rm(libsaria::Playlist *plist, unsigned int index)
PlaylistWidgets *widgets = find_playlist_widgets(plist);
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(widgets->liststore), &iter, NULL, index);
gtk_list_store_remove(widgets->liststore, &iter);
update_length_label();
update_length_label(current_playlist());
}
static void playlist_update(libsaria::Playlist *plist, libsaria::Track *track,
@ -80,7 +80,7 @@ static void set_playlist_size(libsaria::Playlist *plist)
sprintf(buf, "%u", plist->get_size());
gtk_label_set_text(widgets->size_label, buf);
update_length_label();
update_length_label(current_playlist());
}
static void playlist_goto_index(libsaria::Playlist *playlist, unsigned int index)

View File

@ -143,10 +143,9 @@ bool update_idle_bar(int size)
return true;
}
void update_length_label()
void update_length_label(libsaria::Playlist *playlist)
{
stringstream stream;
libsaria::Playlist *playlist = current_playlist();
unsigned int size = playlist->get_size();
GtkWidget *label = get_widget("LengthLabel");
if (!label)

View File

@ -127,7 +127,8 @@ void playlist_focus_treeview()
static void on_switch_page(GtkNotebook *tabs, gpointer page,
unsigned int page_num, gpointer data)
{
update_length_label();
struct PlaylistWidgets *widgets = find_nth_widgets(page_num);
update_length_label(widgets->playlist);
}
static void on_page_reordered(GtkWidget *notebook, GtkWidget *page, guint num, gpointer d)