gui/ocarina: Switch to C-style GtkApplication
The right way to do this would be to respond to the "activate", "startup", and "shutdown" signals. I can't to this easily, because gstreamer needs argc and argv. Let's fake things up now and sort it out later. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
108dbacf41
commit
4dbaf12701
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
Import("env")
|
||||
|
||||
env.UsePackage("gtkmm-3.0")
|
||||
env.UsePackage("gmodule-export-2.0")
|
||||
env.UsePackage("gtk+-3.0")
|
||||
env.UsePackage("gmodule-export-2.0");
|
||||
|
||||
res = Glob("*.c") + Glob("*.cpp")
|
||||
Return("res")
|
||||
|
|
|
@ -15,12 +15,8 @@ extern "C" {
|
|||
#include <gui/view.h>
|
||||
#include <gui/window.h>
|
||||
}
|
||||
#include <gtkmm.h>
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
static Glib::RefPtr<Gtk::Application> ocarina_app;
|
||||
|
||||
#define OCARINA_FLAGS (G_APPLICATION_FLAGS_NONE)
|
||||
|
||||
struct core_init_data init_data = {
|
||||
&collection_ops,
|
||||
|
@ -41,19 +37,31 @@ static gchar *find_file_path(const gchar *file)
|
|||
return g_strjoin("/", "/usr", "share", "ocarina", file, NULL);
|
||||
}
|
||||
|
||||
static void on_window_removed(Gtk::Window *window)
|
||||
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)
|
||||
{
|
||||
Gtk::Window *window;
|
||||
gchar *ui = find_file_path("ocarina6.glade");
|
||||
gchar *icon = find_file_path("ocarina.png");
|
||||
GtkApplication *ocarina;
|
||||
int ret;
|
||||
|
||||
ocarina_app = Gtk::Application::create(argc, argv, "org.gtkmm.ocarina");
|
||||
#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();
|
||||
|
@ -67,14 +75,14 @@ int main(int argc, char **argv)
|
|||
g_free(ui);
|
||||
g_free(icon);
|
||||
|
||||
window = Glib :: wrap(GTK_WINDOW(gui_builder_widget("o_window")), false);
|
||||
ocarina_app->signal_window_removed().connect(sigc::ptr_fun(on_window_removed));
|
||||
ocarina_app->run(*window, argc, argv);
|
||||
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 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue