Started porting to GApplication

This commit is contained in:
Gergely Polonkai 2013-09-07 23:17:59 +02:00
parent 5481385474
commit 14241d6545

View File

@ -1,5 +1,6 @@
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <swe-glib.h> #include <swe-glib.h>
@ -480,14 +481,12 @@ action_new_activate_cb(GtkAction *action, gpointer user_data)
gtk_widget_hide(GTK_WIDGET(dialog_new)); gtk_widget_hide(GTK_WIDGET(dialog_new));
} }
int static void
main(int argc, char *argv[]) application_activate_cb(GtkApplication *app, gpointer user_data)
{ {
GError *err = NULL; GError *err = NULL;
GtkWidget *window_main; GtkWidget *window,
*grid;
gswe_init();
gtk_init(&argc, &argv);
builder = gtk_builder_new(); builder = gtk_builder_new();
@ -495,6 +494,17 @@ main(int argc, char *argv[])
g_error("Builder error: %s", err->message); g_error("Builder error: %s", err->message);
} }
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), _("Astrognome"));
grid = gtk_grid_new();
gtk_container_add(GTK_CONTAINER(window), grid);
gtk_widget_show_all(window);
/*
gtk_init(&argc, &argv);
window_main = GTK_WIDGET(gtk_builder_get_object(builder, "window_main")); window_main = GTK_WIDGET(gtk_builder_get_object(builder, "window_main"));
gtk_window_set_title(GTK_WINDOW(window_main), "Astrognome"); gtk_window_set_title(GTK_WINDOW(window_main), "Astrognome");
gtk_builder_connect_signals(builder, NULL); gtk_builder_connect_signals(builder, NULL);
@ -502,8 +512,26 @@ main(int argc, char *argv[])
gtk_widget_show(window_main); gtk_widget_show(window_main);
gtk_main(); gtk_main();
g_object_unref(G_OBJECT(builder));
return 0; return 0;
*/
}
int
main(int argc, char *argv[])
{
gint status;
GtkApplication *app;
gswe_init();
app = gtk_application_new("eu.polonkai.gergely.astrognome", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(application_activate_cb), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
g_object_unref(G_OBJECT(builder));
return status;
} }