2014-01-05 22:10:02 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2016-03-01 08:27:13 -05:00
|
|
|
extern "C" {
|
2015-12-17 10:32:01 -05:00
|
|
|
#include <core/core.h>
|
2016-03-01 08:27:13 -05:00
|
|
|
#include <core/idle.h>
|
2015-12-24 13:05:20 -05:00
|
|
|
#include <gui/audio.h>
|
2015-12-24 09:35:36 -05:00
|
|
|
#include <gui/builder.h>
|
2015-12-29 09:45:15 -05:00
|
|
|
#include <gui/collection.h>
|
2016-01-20 16:27:14 -05:00
|
|
|
#include <gui/history.h>
|
2016-01-01 19:58:30 -05:00
|
|
|
#include <gui/playlist.h>
|
2015-12-24 13:05:20 -05:00
|
|
|
#include <gui/settings.h>
|
2015-12-29 09:11:51 -05:00
|
|
|
#include <gui/sidebar.h>
|
2016-01-21 10:29:16 -05:00
|
|
|
#include <gui/tempq.h>
|
2016-01-19 10:16:26 -05:00
|
|
|
#include <gui/view.h>
|
2015-12-26 18:03:45 -05:00
|
|
|
#include <gui/window.h>
|
2016-03-01 08:27:13 -05:00
|
|
|
}
|
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
|
|
|
|
{
|
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
|
|
|
|
2015-12-24 09:35:36 -05:00
|
|
|
gui_builder_init(gui :: share_file("ocarina6.glade").c_str());
|
2015-12-21 11:14:30 -05:00
|
|
|
|
2015-12-17 10:00:42 -05:00
|
|
|
core_init(&argc, &argv, &init_data);
|
2015-12-21 11:14:30 -05:00
|
|
|
gui_settings_init();
|
2016-01-19 10:16:26 -05:00
|
|
|
gui_view_init();
|
2015-12-26 12:29:24 -05:00
|
|
|
gui_window_init(gui :: share_file("ocarina.png").c_str());
|
2015-12-29 09:11:51 -05:00
|
|
|
gui_sidebar_init();
|
2015-12-29 09:45:15 -05:00
|
|
|
gui_collection_init();
|
2016-01-01 19:58:30 -05:00
|
|
|
gui_playlist_init();
|
2015-12-24 12:55:31 -05:00
|
|
|
gui_audio_init();
|
2014-01-24 23:01:02 -05:00
|
|
|
|
2015-01-15 09:39:52 -05:00
|
|
|
init_tabs();
|
2014-02-21 22:06:42 -05:00
|
|
|
post_init_tabs();
|
2014-10-29 18:07:43 -04:00
|
|
|
|
2015-12-26 12:29:24 -05:00
|
|
|
window = Glib :: wrap(GTK_WINDOW(gui_builder_widget("o_window")), false);
|
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);
|
2015-12-26 18:16:11 -05:00
|
|
|
|
2015-12-17 10:06:40 -05:00
|
|
|
core_deinit();
|
2014-01-20 20:14:22 -05:00
|
|
|
cleanup_tabs();
|
2015-12-26 18:16:11 -05:00
|
|
|
gui_window_deinit();
|
|
|
|
gui_settings_deinit();
|
|
|
|
//gui_builder_deinit();
|
2015-11-12 10:45:30 -05:00
|
|
|
|
2014-01-05 22:10:02 -05:00
|
|
|
return 0;
|
|
|
|
}
|