6 activate (GApplication
*application
)
8 g_print ("activated\n");
10 /* Note: when doing a longer-lasting action here that returns
11 * to the mainloop, you should use g_application_hold() and
12 * g_application_release() to keep the application alive until
13 * the action is completed.
17 typedef GApplication TestApplication
;
18 typedef GApplicationClass TestApplicationClass
;
20 static GType
test_application_get_type (void);
21 G_DEFINE_TYPE (TestApplication
, test_application
, G_TYPE_APPLICATION
)
24 test_application_dbus_register (GApplication
*application
,
25 GDBusConnection
*connection
,
26 const gchar
*object_path
,
29 /* We must chain up to the parent class */
30 if (!G_APPLICATION_CLASS (test_application_parent_class
)->dbus_register (application
,
36 /* Now we can do our own stuff here. For example, we could export some D-Bus objects */
41 test_application_dbus_unregister (GApplication
*application
,
42 GDBusConnection
*connection
,
43 const gchar
*object_path
)
45 /* Do our own stuff here, e.g. unexport any D-Bus objects we exported in the dbus_register
46 * hook above. Be sure to check that we actually did export them, since the hook
47 * above might have returned early due to the parent class' hook returning FALSE!
50 /* Lastly, we must chain up to the parent class */
51 G_APPLICATION_CLASS (test_application_parent_class
)->dbus_unregister (application
,
57 test_application_init (TestApplication
*app
)
62 test_application_class_init (TestApplicationClass
*class)
64 GApplicationClass
*g_application_class
= G_APPLICATION_CLASS (class);
66 g_application_class
->dbus_register
= test_application_dbus_register
;
67 g_application_class
->dbus_unregister
= test_application_dbus_unregister
;
71 test_application_new (const gchar
*application_id
,
72 GApplicationFlags flags
)
74 g_return_val_if_fail (g_application_id_is_valid (application_id
), NULL
);
76 return g_object_new (test_application_get_type (),
77 "application-id", application_id
,
83 main (int argc
, char **argv
)
88 app
= test_application_new ("org.gtk.TestApplication", 0);
89 g_signal_connect (app
, "activate", G_CALLBACK (activate
), NULL
);
90 g_application_set_inactivity_timeout (app
, 10000);
92 status
= g_application_run (app
, argc
, argv
);