1 #include <gtk/gtk.h>
2 #include <adwaita.h>
3 
4 #include "adw-demo-preferences-window.h"
5 #include "adw-demo-window.h"
6 
7 static void
show_preferences(GSimpleAction * action,GVariant * state,gpointer user_data)8 show_preferences (GSimpleAction *action,
9                   GVariant      *state,
10                   gpointer       user_data)
11 {
12   GtkApplication *app = GTK_APPLICATION (user_data);
13   GtkWindow *window = gtk_application_get_active_window (app);
14   AdwDemoPreferencesWindow *preferences = adw_demo_preferences_window_new ();
15 
16   gtk_window_set_transient_for (GTK_WINDOW (preferences), window);
17   gtk_window_present (GTK_WINDOW (preferences));
18 }
19 
20 static void
show_window(GtkApplication * app)21 show_window (GtkApplication *app)
22 {
23   AdwDemoWindow *window;
24 
25   window = adw_demo_window_new (app);
26 
27   gtk_window_present (GTK_WINDOW (window));
28 }
29 
30 int
main(int argc,char ** argv)31 main (int    argc,
32       char **argv)
33 {
34   AdwApplication *app;
35   int status;
36   static GActionEntry app_entries[] = {
37     { "preferences", show_preferences, NULL, NULL, NULL },
38   };
39 
40   app = adw_application_new ("org.gnome.Adwaita.Demo", G_APPLICATION_FLAGS_NONE);
41   g_action_map_add_action_entries (G_ACTION_MAP (app),
42                                    app_entries, G_N_ELEMENTS (app_entries),
43                                    app);
44   g_signal_connect (app, "activate", G_CALLBACK (show_window), NULL);
45   status = g_application_run (G_APPLICATION (app), argc, argv);
46   g_object_unref (app);
47 
48   return status;
49 }
50