gui: Move idle function into the collection manager

The collection manager is the only thing that uses the idle queue, so
let's keep all this code together.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-09-12 08:15:17 -04:00
parent 0b5478c591
commit 5eeebe7854
3 changed files with 20 additions and 31 deletions

View File

@ -2,6 +2,7 @@
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/callback.h>
#include <core/idle.h>
#include <core/index.h>
#include <core/library.h>
#include <lib/colmgr.h>
@ -9,6 +10,7 @@
static Gtk::FileChooserWidget *c_chooser;
static Gtk::ProgressBar *c_progress;
static Gtk::TreeView *c_treeview;
@ -25,23 +27,37 @@ static bool find_cur_path(Gtk::TreePath &path)
return !path.empty();
}
static bool on_idle()
{
bool ret = idle :: run_task();
if (ret) {
c_progress->show();
c_progress->set_fraction(idle :: get_progress());
} else
c_progress->hide();
colmgr :: update_paths();
return ret;
}
static void on_ok()
{
colmgr :: add_path(c_chooser->get_filename());
enable_idle();
lib :: idle(on_idle);
}
static void on_update()
{
library :: update_all();
enable_idle();
lib :: idle(on_idle);
}
static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col)
{
colmgr :: update_path(path);
enable_idle();
lib :: idle(on_idle);
}
static void on_cursor_changed()
@ -73,6 +89,7 @@ void collection_mgr_init()
Glib::RefPtr<Gtk::CellRendererToggle> toggle;
c_treeview = lib :: get_widget<Gtk::TreeView>("colmgr_treeview");
c_progress = lib :: get_widget<Gtk::ProgressBar>("o_idle_progress");
c_chooser = lib :: get_widget<Gtk::FileChooserWidget>("colmgr_chooser");
toggle = lib :: get_object<Gtk::CellRendererToggle>("colmgr_toggle");

View File

@ -5,7 +5,6 @@
#include <core/callback.h>
#include <core/deck.h>
#include <core/driver.h>
#include <core/idle.h>
#include <core/playlist.h>
#include <core/print.h>
#include <lib/colmgr.h>
@ -99,32 +98,6 @@ static void on_fav_toggled()
/*
* Idle func
*/
bool on_idle()
{
Gtk::ProgressBar *prog = lib :: get_widget<Gtk::ProgressBar>("o_idle_progress");
bool ret = idle::run_task();
if (ret == false)
prog->hide();
else {
prog->show();
prog->set_fraction(idle::get_progress());
}
colmgr :: update_paths();
return ret;
}
void enable_idle()
{
lib :: idle(on_idle);
}
/*
* Ocarina functions
*/

View File

@ -17,7 +17,6 @@ Gtk::Window *ocarina_init(int *, char ***);
/* gui.cpp */
void enable_idle();
void connect_button(const std::string &, void (*func)());
Gtk::Window *setup_gui();