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:
parent
0b5478c591
commit
5eeebe7854
|
@ -2,6 +2,7 @@
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <core/callback.h>
|
#include <core/callback.h>
|
||||||
|
#include <core/idle.h>
|
||||||
#include <core/index.h>
|
#include <core/index.h>
|
||||||
#include <core/library.h>
|
#include <core/library.h>
|
||||||
#include <lib/colmgr.h>
|
#include <lib/colmgr.h>
|
||||||
|
@ -9,6 +10,7 @@
|
||||||
|
|
||||||
|
|
||||||
static Gtk::FileChooserWidget *c_chooser;
|
static Gtk::FileChooserWidget *c_chooser;
|
||||||
|
static Gtk::ProgressBar *c_progress;
|
||||||
static Gtk::TreeView *c_treeview;
|
static Gtk::TreeView *c_treeview;
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,23 +27,37 @@ static bool find_cur_path(Gtk::TreePath &path)
|
||||||
return !path.empty();
|
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()
|
static void on_ok()
|
||||||
{
|
{
|
||||||
colmgr :: add_path(c_chooser->get_filename());
|
colmgr :: add_path(c_chooser->get_filename());
|
||||||
enable_idle();
|
lib :: idle(on_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_update()
|
static void on_update()
|
||||||
{
|
{
|
||||||
library :: update_all();
|
library :: update_all();
|
||||||
enable_idle();
|
lib :: idle(on_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col)
|
static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col)
|
||||||
{
|
{
|
||||||
colmgr :: update_path(path);
|
colmgr :: update_path(path);
|
||||||
enable_idle();
|
lib :: idle(on_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_cursor_changed()
|
static void on_cursor_changed()
|
||||||
|
@ -73,6 +89,7 @@ void collection_mgr_init()
|
||||||
Glib::RefPtr<Gtk::CellRendererToggle> toggle;
|
Glib::RefPtr<Gtk::CellRendererToggle> toggle;
|
||||||
|
|
||||||
c_treeview = lib :: get_widget<Gtk::TreeView>("colmgr_treeview");
|
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");
|
c_chooser = lib :: get_widget<Gtk::FileChooserWidget>("colmgr_chooser");
|
||||||
toggle = lib :: get_object<Gtk::CellRendererToggle>("colmgr_toggle");
|
toggle = lib :: get_object<Gtk::CellRendererToggle>("colmgr_toggle");
|
||||||
|
|
||||||
|
|
27
gui/gui.cpp
27
gui/gui.cpp
|
@ -5,7 +5,6 @@
|
||||||
#include <core/callback.h>
|
#include <core/callback.h>
|
||||||
#include <core/deck.h>
|
#include <core/deck.h>
|
||||||
#include <core/driver.h>
|
#include <core/driver.h>
|
||||||
#include <core/idle.h>
|
|
||||||
#include <core/playlist.h>
|
#include <core/playlist.h>
|
||||||
#include <core/print.h>
|
#include <core/print.h>
|
||||||
#include <lib/colmgr.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
|
* Ocarina functions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,7 +17,6 @@ Gtk::Window *ocarina_init(int *, char ***);
|
||||||
|
|
||||||
|
|
||||||
/* gui.cpp */
|
/* gui.cpp */
|
||||||
void enable_idle();
|
|
||||||
void connect_button(const std::string &, void (*func)());
|
void connect_button(const std::string &, void (*func)());
|
||||||
Gtk::Window *setup_gui();
|
Gtk::Window *setup_gui();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user