6 activate (GApplication *application)
8 g_application_hold (application);
9 g_print ("activated\n");
10 g_application_release (application);
14 show_help (GSimpleAction *action,
18 g_print ("Want help, eh ?!\n");
22 show_about (GSimpleAction *action,
26 g_print ("Not much to say, really.\nJust a stupid example\n");
30 quit_app (GSimpleAction *action,
34 g_print ("Quitting...\n");
35 g_application_release (g_application_get_default ());
38 static GActionEntry entries[] = {
39 { "help", show_help, NULL, NULL, NULL },
40 { "about", show_about, NULL, NULL, NULL },
41 { "quit", quit_app, NULL, NULL, NULL }
45 add_actions (GApplication *app)
47 GSimpleActionGroup *actions;
49 actions = g_simple_action_group_new ();
51 g_simple_action_group_add_entries (actions,
52 entries, G_N_ELEMENTS (entries),
55 g_application_set_action_group (app, G_ACTION_GROUP (actions));
57 g_object_unref (actions);
61 add_menu (GApplication *app)
67 g_menu_append (menu, "Help", "help");
68 g_menu_append (menu, "About Example", "about");
69 g_menu_append (menu, "Quit", "quit");
71 g_application_set_menu (app, G_MENU_MODEL (menu));
73 g_object_unref (menu);
77 main (int argc, char **argv)
82 app = g_application_new ("org.gtk.TestApplication", 0);
83 g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
88 g_application_hold (app);
90 status = g_application_run (app, argc, argv);