88 lines
2.0 KiB
C
88 lines
2.0 KiB
C
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/core.h>
|
|
#include <core/idle.h>
|
|
#include <gui/audio.h>
|
|
#include <gui/builder.h>
|
|
#include <gui/collection.h>
|
|
#include <gui/history.h>
|
|
#include <gui/playlist.h>
|
|
#include <gui/settings.h>
|
|
#include <gui/sidebar.h>
|
|
#include <gui/tempq.h>
|
|
#include <gui/view.h>
|
|
#include <gui/window.h>
|
|
|
|
#define OCARINA_FLAGS (G_APPLICATION_FLAGS_NONE)
|
|
|
|
struct core_init_data init_data = {
|
|
&collection_ops,
|
|
&history_ops,
|
|
&playlist_ops,
|
|
&tempq_ops,
|
|
&audio_ops,
|
|
};
|
|
|
|
static gchar *find_file_path(const gchar *file)
|
|
{
|
|
gchar *path = g_strjoin("/", "share", "ocarina", file, NULL);
|
|
|
|
if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
|
|
return path;
|
|
g_free(path);
|
|
|
|
return g_strjoin("/", "/usr", "share", "ocarina", file, NULL);
|
|
}
|
|
|
|
static void __ocarina_activate(GApplication *application, gpointer data)
|
|
{
|
|
gtk_application_add_window(GTK_APPLICATION(application),
|
|
GTK_WINDOW(gui_builder_widget("o_window")));
|
|
}
|
|
|
|
static void __ocarina_shutdown(GApplication *application, gpointer data)
|
|
{
|
|
idle_cancel();
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
gchar *ui = find_file_path("ocarina6.glade");
|
|
gchar *icon = find_file_path("ocarina.png");
|
|
GtkApplication *ocarina;
|
|
int ret;
|
|
|
|
#ifndef CONFIG_DEBUG
|
|
ocarina = gtk_application_new("org.gtk.ocarina", OCARINA_FLAGS);
|
|
#else
|
|
ocarina = gtk_application_new("org.gtk.ocarina-debug", OCARINA_FLAGS);
|
|
#endif
|
|
|
|
gtk_init(&argc, &argv);
|
|
gui_builder_init(ui);
|
|
core_init(&argc, &argv, &init_data);
|
|
gui_settings_init();
|
|
gui_view_init();
|
|
gui_window_init(icon);
|
|
gui_sidebar_init();
|
|
gui_collection_init();
|
|
gui_playlist_init();
|
|
gui_audio_init();
|
|
|
|
g_free(ui);
|
|
g_free(icon);
|
|
gui_sidebar_select_first();
|
|
|
|
g_signal_connect(G_APPLICATION(ocarina), "activate", (GCallback)__ocarina_activate, NULL);
|
|
g_signal_connect(G_APPLICATION(ocarina), "shutdown", (GCallback)__ocarina_shutdown, NULL);
|
|
ret = g_application_run(G_APPLICATION(ocarina), argc, argv);
|
|
|
|
core_deinit();
|
|
gui_window_deinit();
|
|
gui_settings_deinit();
|
|
gui_builder_deinit();
|
|
|
|
return ret;
|
|
}
|