colmgr: Add a function for updating a specific path
On the gui end, call this function when a row in the "collected paths" list is double-clicked. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
42ec504b90
commit
3d067878f2
|
@ -26,7 +26,8 @@ static void on_collection_update()
|
|||
static void on_collection_row_activated(const Gtk::TreePath &path,
|
||||
Gtk::TreeViewColumn *col)
|
||||
{
|
||||
c_chooser->set_current_folder(colmgr :: get_path(path));
|
||||
colmgr :: update_path(path);
|
||||
enable_idle();
|
||||
}
|
||||
|
||||
static void do_collection_delete()
|
||||
|
|
|
@ -12,10 +12,11 @@ namespace colmgr
|
|||
|
||||
void init();
|
||||
void add_path(const std::string &);
|
||||
void del_path(Gtk::TreePath &);
|
||||
Glib::ustring get_path(const Gtk::TreePath &);
|
||||
void del_path(const Gtk::TreePath &);
|
||||
void update_path(const Gtk::TreePath &);
|
||||
void update_paths();
|
||||
|
||||
Glib::ustring get_path(const Gtk::TreePath &);
|
||||
void toggle_path_enabled(const Gtk::TreePath &);
|
||||
};
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void colmgr :: add_path(const std::string &path)
|
|||
list_path(library :: add(path));
|
||||
}
|
||||
|
||||
void colmgr :: del_path(Gtk::TreePath &path)
|
||||
void colmgr :: del_path(const Gtk::TreePath &path)
|
||||
{
|
||||
Gtk::TreeModel::Row row = *(c_list->get_iter(path));
|
||||
Library *lib = find_library(row);
|
||||
|
@ -69,10 +69,10 @@ void colmgr :: del_path(Gtk::TreePath &path)
|
|||
c_list->erase(row);
|
||||
}
|
||||
|
||||
Glib::ustring colmgr :: get_path(const Gtk::TreePath &path)
|
||||
void colmgr :: update_path(const Gtk::TreePath &path)
|
||||
{
|
||||
Gtk::TreeModel::Row row = *(c_list->get_iter(path));
|
||||
return row[c_cols.c_path];
|
||||
library :: update(find_library(row));
|
||||
}
|
||||
|
||||
void colmgr :: update_paths()
|
||||
|
@ -87,6 +87,12 @@ void colmgr :: update_paths()
|
|||
}
|
||||
}
|
||||
|
||||
Glib::ustring colmgr :: get_path(const Gtk::TreePath &path)
|
||||
{
|
||||
Gtk::TreeModel::Row row = *(c_list->get_iter(path));
|
||||
return row[c_cols.c_path];
|
||||
}
|
||||
|
||||
void colmgr :: toggle_path_enabled(const Gtk::TreePath &path)
|
||||
{
|
||||
Gtk::TreeModel::Row row = *(c_list->get_iter(path));
|
||||
|
|
|
@ -43,6 +43,9 @@ void test_colmgr()
|
|||
colmgr :: toggle_path_enabled(path);
|
||||
test_equal(library->enabled, false);
|
||||
|
||||
colmgr :: update_path(path);
|
||||
test_equal(idle :: run_task(), true);
|
||||
|
||||
colmgr :: del_path(path);
|
||||
test_equal((size_t)list->children().size(), (size_t)1);
|
||||
}
|
||||
|
@ -51,6 +54,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
Gtk::Main ocarina(&argc, &argv);
|
||||
test :: cp_data_dir();
|
||||
test :: gen_library();
|
||||
lib :: init(&argc, &argv, "ocarina6.glade");
|
||||
|
||||
run_test("Collection Manager Test", test_colmgr);
|
||||
|
|
Loading…
Reference in New Issue