gui: Listen for current library callbacks
This adds support for callbacks telling us when a new library path is added and when a path has been updated. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
c2e7772ebe
commit
4c16f8370b
|
@ -18,10 +18,10 @@
|
|||
<column type="guint"/>
|
||||
<!-- column-name enabled -->
|
||||
<column type="gboolean"/>
|
||||
<!-- column-name path -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name size -->
|
||||
<column type="guint"/>
|
||||
<!-- column-name path -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="o_progress">
|
||||
|
@ -101,7 +101,7 @@
|
|||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext1"/>
|
||||
<attributes>
|
||||
<attribute name="text">3</attribute>
|
||||
<attribute name="text">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -112,7 +112,7 @@
|
|||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext2"/>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
<attribute name="text">3</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <callback.h>
|
||||
#include <idle.h>
|
||||
#include <library.h>
|
||||
|
||||
|
@ -10,9 +11,22 @@
|
|||
static Glib::RefPtr<Gtk::Builder> builder;
|
||||
void enable_idle();
|
||||
|
||||
|
||||
/*
|
||||
* Collection manager functions
|
||||
*/
|
||||
class CollectionColumns : public Gtk::TreeModelColumnRecord {
|
||||
public:
|
||||
CollectionColumns()
|
||||
{ add(c_col_id); add(c_col_enabled); add(c_col_size); add(c_col_path); }
|
||||
|
||||
Gtk::TreeModelColumn<unsigned int> c_col_id;
|
||||
Gtk::TreeModelColumn<bool> c_col_enabled;
|
||||
Gtk::TreeModelColumn<unsigned int> c_col_size;
|
||||
Gtk::TreeModelColumn<Glib::ustring> c_col_path;
|
||||
};
|
||||
static CollectionColumns collection_cols;
|
||||
|
||||
static void on_collection_ok()
|
||||
{
|
||||
std::string path;
|
||||
|
@ -36,6 +50,34 @@ static void on_collection_import()
|
|||
enable_idle();
|
||||
}
|
||||
|
||||
static void on_library_add(unsigned int id, library :: Library *path)
|
||||
{
|
||||
Gtk::TreeModel::Row row;
|
||||
Glib::RefPtr<Gtk::ListStore> list;
|
||||
|
||||
list = Glib::RefPtr<Gtk::ListStore>::cast_static(builder->get_object("o_collection_dirs"));
|
||||
|
||||
row = *(list->append());
|
||||
row[collection_cols.c_col_id] = id;
|
||||
row[collection_cols.c_col_enabled] = path->enabled;
|
||||
row[collection_cols.c_col_size] = path->size;
|
||||
row[collection_cols.c_col_path] = path->root_path;
|
||||
}
|
||||
|
||||
static void on_library_update(unsigned int id, library :: Library *path)
|
||||
{
|
||||
Gtk::TreeModel::Row row;
|
||||
Glib::RefPtr<Gtk::ListStore> list = Glib::RefPtr<Gtk::ListStore>::cast_static(builder->get_object("o_collection_dirs"));
|
||||
Gtk::TreeModel::Children children = list->children();
|
||||
|
||||
for (Gtk::TreeModel::Children::iterator it = children.begin();
|
||||
it != children.end(); it++) {
|
||||
row = *it;
|
||||
if (row[collection_cols.c_col_id] == id)
|
||||
row[collection_cols.c_col_size] = path->size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -85,11 +127,15 @@ static void connect_button(const std::string &name, void (*func)())
|
|||
Gtk::Window *connect_wires()
|
||||
{
|
||||
Gtk::Window *window;
|
||||
struct Callbacks *cb = get_callbacks();
|
||||
|
||||
builder = Gtk::Builder::create();
|
||||
builder->add_from_file("gui/ocarina6.glade");
|
||||
builder->get_widget("o_window", window);
|
||||
|
||||
/* Collection manager */
|
||||
cb->on_library_add = on_library_add;
|
||||
cb->on_library_update = on_library_update;
|
||||
connect_button("o_collection_ok", on_collection_ok);
|
||||
connect_button("o_collection_update", on_collection_update);
|
||||
connect_button("o_collection_import", on_collection_import);
|
||||
|
|
Loading…
Reference in New Issue