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
|
|
|
}
|
2016-01-22 16:36:06 -05:00
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <glib.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 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
|
|
|
};
|
|
|
|
|
2016-01-22 16:36:06 -05:00
|
|
|
static gchar *find_file_path(const gchar *file)
|
2015-01-21 08:29:46 -05:00
|
|
|
{
|
2016-01-22 16:36:06 -05:00
|
|
|
gchar *path = g_strjoin("/", "share", "ocarina", file, NULL);
|
2015-01-21 08:38:00 -05:00
|
|
|
|
2016-01-22 16:36:06 -05:00
|
|
|
if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
|
|
|
|
return path;
|
|
|
|
g_free(path);
|
2015-01-21 08:38:00 -05:00
|
|
|
|
2016-01-22 16:36:06 -05:00
|
|
|
return g_strjoin("/", "/usr", "share", "ocarina", file, NULL);
|
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;
|
2016-01-22 16:36:06 -05:00
|
|
|
gchar *ui = find_file_path("ocarina6.glade");
|
|
|
|
gchar *icon = find_file_path("ocarina.png");
|
2015-01-15 09:39:52 -05:00
|
|
|
|
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
|
|
|
|
2016-01-22 16:36:06 -05:00
|
|
|
gui_builder_init(ui);
|
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();
|
2016-01-22 16:36:06 -05:00
|
|
|
gui_window_init(icon);
|
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
|
|
|
|
2016-01-22 16:36:06 -05:00
|
|
|
g_free(ui);
|
|
|
|
g_free(icon);
|
|
|
|
|
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();
|
2015-12-26 18:16:11 -05:00
|
|
|
gui_window_deinit();
|
|
|
|
gui_settings_deinit();
|
2016-01-21 11:37:56 -05:00
|
|
|
gui_builder_deinit();
|
2015-11-12 10:45:30 -05:00
|
|
|
|
2014-01-05 22:10:02 -05:00
|
|
|
return 0;
|
|
|
|
}
|