ocarina: Refresh path list when library is updated
I respond to the LIBRARY_REFRESH callback by creating new path panels to show the updated information.
This commit is contained in:
parent
61153a0580
commit
83719838aa
|
@ -10,5 +10,6 @@ void settings_init();
|
||||||
void add_settings_page(string, GtkWidget *);
|
void add_settings_page(string, GtkWidget *);
|
||||||
|
|
||||||
void library_settings_init();
|
void library_settings_init();
|
||||||
|
void library_settings_refresh();
|
||||||
|
|
||||||
#endif /* OCARINA_SETTINGS_H */
|
#endif /* OCARINA_SETTINGS_H */
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <ocarina/ocarina.h>
|
#include <ocarina/ocarina.h>
|
||||||
#include <ocarina/button.h>
|
#include <ocarina/button.h>
|
||||||
#include <ocarina/library.h>
|
#include <ocarina/library.h>
|
||||||
|
#include <ocarina/settings.h>
|
||||||
|
|
||||||
void cb_play()
|
void cb_play()
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,7 @@ void cb_library_refresh()
|
||||||
{
|
{
|
||||||
println("Ocarina LIBRARY_REFRESH callback!");
|
println("Ocarina LIBRARY_REFRESH callback!");
|
||||||
ocarina_library_refresh();
|
ocarina_library_refresh();
|
||||||
|
library_settings_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_callbacks()
|
void setup_callbacks()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <list>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include <ocarina/settings.h>
|
#include <ocarina/settings.h>
|
||||||
|
@ -12,6 +13,8 @@ using namespace std;
|
||||||
|
|
||||||
/* This is a gtk vbox */
|
/* This is a gtk vbox */
|
||||||
static GtkWidget *library_settings = NULL;
|
static GtkWidget *library_settings = NULL;
|
||||||
|
static GtkWidget *path_panels = NULL;
|
||||||
|
static list<GtkWidget *> path_widgets;
|
||||||
|
|
||||||
static void on_click_add(GtkWidget *b, GdkEvent *e, gpointer d)
|
static void on_click_add(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||||
{
|
{
|
||||||
|
@ -75,9 +78,8 @@ static void add_library_panel(GtkWidget *content)
|
||||||
|
|
||||||
box_pack_start(panel_box, content, TRUE, TRUE, 0);
|
box_pack_start(panel_box, content, TRUE, TRUE, 0);
|
||||||
box_pack_start(panel_box, sep, TRUE, TRUE, 0);
|
box_pack_start(panel_box, sep, TRUE, TRUE, 0);
|
||||||
box_pack_start(library_settings, panel_box, FALSE, FALSE, 0);
|
box_pack_start(path_panels, panel_box, FALSE, FALSE, 0);
|
||||||
|
path_widgets.push_back(panel_box);
|
||||||
gtk_widget_show_all(panel_box);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_library_path(struct libsaria::library::PathInfo &info)
|
static void add_library_path(struct libsaria::library::PathInfo &info)
|
||||||
|
@ -88,18 +90,30 @@ static void add_library_path(struct libsaria::library::PathInfo &info)
|
||||||
add_library_panel(main_box);
|
add_library_panel(main_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void library_settings_refresh()
|
||||||
|
{
|
||||||
|
while (path_widgets.size() != 0) {
|
||||||
|
gtk_widget_destroy(path_widgets.front());
|
||||||
|
path_widgets.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
|
libsaria::library::for_each_path(add_library_path);
|
||||||
|
gtk_widget_show_all(library_settings);
|
||||||
|
}
|
||||||
|
|
||||||
void library_settings_init()
|
void library_settings_init()
|
||||||
{
|
{
|
||||||
GtkWidget *button_row = gtk_hbox_new(FALSE, 0);
|
GtkWidget *button_row = gtk_hbox_new(FALSE, 0);
|
||||||
library_settings = gtk_vbox_new(FALSE, 0);
|
library_settings = gtk_vbox_new(FALSE, 0);
|
||||||
|
path_panels = gtk_vbox_new(FALSE, 0);
|
||||||
|
|
||||||
libsaria::library::for_each_path(add_library_path);
|
libsaria::library::for_each_path(add_library_path);
|
||||||
|
|
||||||
|
box_pack_start(library_settings, path_panels, FALSE, FALSE, 0);
|
||||||
box_pack_start(library_settings, button_row, FALSE, FALSE, 0);
|
box_pack_start(library_settings, button_row, FALSE, FALSE, 0);
|
||||||
box_pack_end(button_row, make_add_button(), FALSE, FALSE, 0);
|
box_pack_end(button_row, make_add_button(), FALSE, FALSE, 0);
|
||||||
box_pack_end(button_row, make_update_button(), FALSE, FALSE, 0);
|
box_pack_end(button_row, make_update_button(), FALSE, FALSE, 0);
|
||||||
|
|
||||||
gtk_widget_show(library_settings);
|
gtk_widget_show_all(library_settings);
|
||||||
gtk_widget_show(button_row);
|
|
||||||
add_settings_page("Library", library_settings);
|
add_settings_page("Library", library_settings);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue