diff options
author | Bastian Ilsø <bastianilso@src.gnome.org> | 2015-01-28 11:39:01 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-01-28 16:31:12 -0500 |
commit | e9ddff907f0c016e881a2254e82730ece2e36066 (patch) | |
tree | 3706058e9910522b814bc79b52c29c9bea53597a /examples | |
parent | 066646c96d4df25ff4d5ba1776d29e814334306c (diff) | |
download | gtk+-e9ddff907f0c016e881a2254e82730ece2e36066.tar.gz |
Get started: port example-0.c to GtkApplication
https://bugzilla.gnome.org/show_bug.cgi?id=743638
Diffstat (limited to 'examples')
-rw-r--r-- | examples/window-default.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/examples/window-default.c b/examples/window-default.c index 4b7a22f785..3bb80f5105 100644 --- a/examples/window-default.c +++ b/examples/window-default.c @@ -1,21 +1,28 @@ #include <gtk/gtk.h> -int -main (int argc, - char *argv[]) +static void +activate (GtkApplication* app, + gpointer user_data) { GtkWidget *window; - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Window"); + gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); + gtk_widget_show_all (window); +} - g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); - - gtk_widget_show (window); +int +main (int argc, + char **argv) +{ + GtkApplication *app; + int status; - gtk_main (); + app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE); + g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); + status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); - return 0; + return status; } |