ocarina: Display library paths
Right now I simply create a list during startup. I still need to clear this list and refill it whenever the library is updated.
This commit is contained in:
parent
2a6d05ebee
commit
60dc610195
|
@ -1,4 +1,7 @@
|
|||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#include <ocarina/settings.h>
|
||||
#include <ocarina/chooser.h>
|
||||
#include <ocarina/button.h>
|
||||
|
@ -27,16 +30,62 @@ static GtkWidget *make_add_button()
|
|||
true);
|
||||
}
|
||||
|
||||
static GtkWidget *markup_label(string markup)
|
||||
{
|
||||
GtkWidget *label = gtk_label_new("");
|
||||
gtk_label_set_markup(GTK_LABEL(label), markup.c_str());
|
||||
return label;
|
||||
}
|
||||
|
||||
static GtkWidget *make_path_info(string path, unsigned int size)
|
||||
{
|
||||
stringstream stream;
|
||||
GtkWidget *path_label, *size_label;
|
||||
GtkWidget *box = gtk_vbox_new(FALSE, 0);
|
||||
|
||||
stream << "<span size='xx-large' weight='bold'>" << path << "</span>";
|
||||
path_label = markup_label(stream.str());
|
||||
stream.str("");
|
||||
|
||||
stream << "<span size='large'>" << size << " files</span>";
|
||||
size_label = markup_label(stream.str());
|
||||
|
||||
box_pack_start(box, path_label, TRUE, TRUE, 0);
|
||||
box_pack_start(box, size_label, TRUE, TRUE, 0);
|
||||
return box;
|
||||
}
|
||||
|
||||
static void add_library_panel(GtkWidget *content)
|
||||
{
|
||||
GtkWidget *panel_box = gtk_vbox_new(FALSE, 0);
|
||||
GtkWidget *sep = gtk_hseparator_new();
|
||||
|
||||
box_pack_start(panel_box, content, TRUE, TRUE, 0);
|
||||
box_pack_start(panel_box, sep, TRUE, TRUE, 0);
|
||||
box_pack_start(library_settings, panel_box, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show_all(panel_box);
|
||||
}
|
||||
|
||||
static void add_library_path(struct libsaria::library::PathInfo &info)
|
||||
{
|
||||
GtkWidget *main_box = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *info_box = make_path_info(info.path, info.size);
|
||||
box_pack_start(main_box, info_box, TRUE, TRUE, 0);
|
||||
add_library_panel(main_box);
|
||||
}
|
||||
|
||||
void library_settings_init()
|
||||
{
|
||||
GtkWidget *add_button = gtk_hbox_new(FALSE, 0);
|
||||
library_settings = gtk_vbox_new(FALSE, 0);
|
||||
|
||||
libsaria::library::for_each_path(add_library_path);
|
||||
|
||||
box_pack_start(library_settings, add_button, FALSE, FALSE, 0);
|
||||
box_pack_end(add_button, make_add_button(), FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show(library_settings);
|
||||
gtk_widget_show(add_button);
|
||||
add_settings_page("Library", library_settings);
|
||||
println(libsaria::library::size());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue