2014-01-05 22:10:02 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-12-20 15:01:10 -05:00
|
|
|
#include <core/core.h>
|
2016-03-01 08:27:13 -05:00
|
|
|
extern "C" {
|
|
|
|
#include <core/idle.h>
|
|
|
|
}
|
2014-06-04 13:59:15 -04:00
|
|
|
#include <gui/ocarina.h>
|
|
|
|
#include <gui/tabs.h>
|
2014-01-05 22:10:02 -05:00
|
|
|
|
2015-01-21 08:29:46 -05:00
|
|
|
|
2015-01-21 09:08:34 -05:00
|
|
|
static std::string ocarina_dir = "";
|
|
|
|
static Glib::RefPtr<Gtk::Application> ocarina_app;
|
2015-01-21 08:38:00 -05:00
|
|
|
|
2015-11-24 08:18:31 -05:00
|
|
|
|
|
|
|
struct core_init_data init_data = {
|
|
|
|
&collection_ops,
|
2015-11-29 19:45:39 -05:00
|
|
|
&history_ops,
|
|
|
|
&playlist_ops,
|
2015-11-24 09:08:20 -05:00
|
|
|
&tempq_ops,
|
2015-12-15 10:23:15 -05:00
|
|
|
&audio_ops,
|
2015-11-24 08:18:31 -05:00
|
|
|
};
|
|
|
|
|
2015-01-21 08:29:46 -05:00
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
Glib::RefPtr<Gtk::Builder> __O_BUILDER;
|
2015-01-21 08:38:00 -05:00
|
|
|
|
|
|
|
const std::string share_file(const std::string &f)
|
|
|
|
{
|
2015-01-21 09:08:34 -05:00
|
|
|
return ocarina_dir + f;
|
2015-01-21 08:38:00 -05:00
|
|
|
}
|
2015-01-21 08:29:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-21 08:38:00 -05:00
|
|
|
static void setup_share(const std::string &path)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
|
|
|
|
|
|
|
|
if (len == -1)
|
|
|
|
return;
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
2015-01-21 09:08:34 -05:00
|
|
|
ocarina_dir = std::string(buf);
|
|
|
|
ocarina_dir = ocarina_dir.substr(0, ocarina_dir.size() - 11);
|
|
|
|
ocarina_dir = ocarina_dir + "share/ocarina/";
|
2015-01-21 08:38:00 -05:00
|
|
|
}
|
|
|
|
|
2016-03-01 08:27:13 -05:00
|
|
|
static void on_window_removed(Gtk::Window *window)
|
|
|
|
{
|
|
|
|
idle_cancel();
|
|
|
|
}
|
|
|
|
|
2015-01-21 09:08:34 -05:00
|
|
|
int main(int argc, char **argv)
|
2014-01-20 20:14:22 -05:00
|
|
|
{
|
2015-01-15 09:39:52 -05:00
|
|
|
Gtk::Window *window;
|
|
|
|
|
2015-01-21 09:08:34 -05:00
|
|
|
setup_share(argv[0]);
|
2015-01-26 17:12:39 -05:00
|
|
|
ocarina_app = Gtk::Application::create(argc, argv, "org.gtkmm.ocarina");
|
2015-01-21 08:29:46 -05:00
|
|
|
|
|
|
|
gui :: __O_BUILDER = Gtk::Builder::create();
|
2015-01-21 08:38:00 -05:00
|
|
|
if (!gui::__O_BUILDER->add_from_file(gui::share_file("ocarina6.glade")))
|
2015-01-21 08:29:46 -05:00
|
|
|
exit(1);
|
2015-01-15 09:06:59 -05:00
|
|
|
|
2015-12-15 08:16:06 -05:00
|
|
|
gst :: init_pre();
|
2015-12-17 10:00:42 -05:00
|
|
|
core_init(&argc, &argv, &init_data);
|
2014-01-24 23:01:02 -05:00
|
|
|
|
2015-12-15 10:23:15 -05:00
|
|
|
gst :: init();
|
2015-11-23 08:36:29 -05:00
|
|
|
plist :: init();
|
2015-01-17 12:12:07 -05:00
|
|
|
manager :: init();
|
2015-01-15 09:39:52 -05:00
|
|
|
init_tabs();
|
|
|
|
window = window_init();
|
2014-02-21 22:06:42 -05:00
|
|
|
post_init_tabs();
|
2014-10-29 18:07:43 -04:00
|
|
|
|
2016-03-01 08:27:13 -05:00
|
|
|
ocarina_app->signal_window_removed().connect(sigc::ptr_fun(on_window_removed));
|
|
|
|
ocarina_app->run(*window, argc, argv);
|
2016-03-09 09:59:06 -05:00
|
|
|
core :: deinit();
|
2014-01-20 20:14:22 -05:00
|
|
|
cleanup_tabs();
|
2015-11-12 10:45:30 -05:00
|
|
|
|
2014-01-05 22:10:02 -05:00
|
|
|
return 0;
|
|
|
|
}
|