2014-01-05 22:10:02 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2015-12-17 10:32:01 -05:00
|
|
|
#include <core/core.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-02-26 10:24:02 -05:00
|
|
|
#include <gui/idle.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>
|
2015-01-21 08:38:00 -05:00
|
|
|
|
2016-01-23 09:30:56 -05:00
|
|
|
#define OCARINA_FLAGS (G_APPLICATION_FLAGS_NONE)
|
2015-11-24 08:18:31 -05:00
|
|
|
|
2016-02-26 10:24:02 -05:00
|
|
|
#ifndef CONFIG_DEBUG
|
|
|
|
const static gchar *OCARINA_NAME = "org.gtk.ocarina";
|
|
|
|
#else
|
|
|
|
const static gchar *OCARINA_NAME = "org.gtk.ocarina-debug";
|
|
|
|
#endif
|
|
|
|
|
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-02-26 10:24:02 -05:00
|
|
|
static int startup_argc;
|
|
|
|
static char **startup_argv;
|
|
|
|
|
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-01-23 09:30:56 -05:00
|
|
|
static void __ocarina_activate(GApplication *application, gpointer data)
|
|
|
|
{
|
|
|
|
gtk_application_add_window(GTK_APPLICATION(application),
|
|
|
|
GTK_WINDOW(gui_builder_widget("o_window")));
|
|
|
|
}
|
|
|
|
|
2016-02-26 10:24:02 -05:00
|
|
|
static void __ocarina_startup(GApplication *application, gpointer data)
|
2014-01-20 20:14:22 -05:00
|
|
|
{
|
2016-01-22 16:36:06 -05:00
|
|
|
gchar *ui = find_file_path("ocarina6.glade");
|
|
|
|
gchar *icon = find_file_path("ocarina.png");
|
2015-01-21 08:29:46 -05:00
|
|
|
|
2016-01-22 16:36:06 -05:00
|
|
|
gui_builder_init(ui);
|
2016-02-26 10:24:02 -05:00
|
|
|
core_init(&startup_argc, &startup_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-02-26 10:24:02 -05:00
|
|
|
gui_idle_enable();
|
|
|
|
gui_sidebar_select_first();
|
|
|
|
|
2016-01-22 16:36:06 -05:00
|
|
|
g_free(ui);
|
|
|
|
g_free(icon);
|
2016-02-26 10:24:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __ocarina_shutdown(GApplication *application, gpointer data)
|
|
|
|
{
|
2016-02-26 10:43:07 -05:00
|
|
|
gui_idle_disable();
|
2016-02-26 10:33:59 -05:00
|
|
|
core_deinit();
|
|
|
|
|
|
|
|
gui_window_deinit();
|
|
|
|
gui_settings_deinit();
|
|
|
|
gui_builder_deinit();
|
2016-02-26 10:24:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2016-02-26 10:33:59 -05:00
|
|
|
GtkApplication *ocarina = gtk_application_new(OCARINA_NAME, OCARINA_FLAGS);
|
2016-02-26 10:24:02 -05:00
|
|
|
|
|
|
|
startup_argc = argc;
|
|
|
|
startup_argv = argv;
|
2016-01-22 16:36:06 -05:00
|
|
|
|
2016-01-23 09:30:56 -05:00
|
|
|
g_signal_connect(G_APPLICATION(ocarina), "activate", (GCallback)__ocarina_activate, NULL);
|
2016-02-26 10:24:02 -05:00
|
|
|
g_signal_connect(G_APPLICATION(ocarina), "startup", (GCallback)__ocarina_startup, NULL);
|
2016-01-23 09:30:56 -05:00
|
|
|
g_signal_connect(G_APPLICATION(ocarina), "shutdown", (GCallback)__ocarina_shutdown, NULL);
|
2016-02-26 10:33:59 -05:00
|
|
|
return g_application_run(G_APPLICATION(ocarina), argc, argv);
|
2014-01-05 22:10:02 -05:00
|
|
|
}
|