|
Packit |
ae235b |
#include <gio/gio.h>
|
|
Packit |
ae235b |
#include <stdlib.h>
|
|
Packit |
ae235b |
#include <string.h>
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
static void
|
|
Packit |
ae235b |
activate (GApplication *application)
|
|
Packit |
ae235b |
{
|
|
Packit |
ae235b |
g_print ("activated\n");
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* Note: when doing a longer-lasting action here that returns
|
|
Packit |
ae235b |
* to the mainloop, you should use g_application_hold() and
|
|
Packit |
ae235b |
* g_application_release() to keep the application alive until
|
|
Packit |
ae235b |
* the action is completed.
|
|
Packit |
ae235b |
*/
|
|
Packit |
ae235b |
}
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
static void
|
|
Packit |
ae235b |
open (GApplication *application,
|
|
Packit |
ae235b |
GFile **files,
|
|
Packit |
ae235b |
gint n_files,
|
|
Packit |
ae235b |
const gchar *hint)
|
|
Packit |
ae235b |
{
|
|
Packit |
ae235b |
gint i;
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
for (i = 0; i < n_files; i++)
|
|
Packit |
ae235b |
{
|
|
Packit |
ae235b |
gchar *uri = g_file_get_uri (files[i]);
|
|
Packit |
ae235b |
g_print ("open %s\n", uri);
|
|
Packit |
ae235b |
g_free (uri);
|
|
Packit |
ae235b |
}
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
/* Note: when doing a longer-lasting action here that returns
|
|
Packit |
ae235b |
* to the mainloop, you should use g_application_hold() and
|
|
Packit |
ae235b |
* g_application_release() to keep the application alive until
|
|
Packit |
ae235b |
* the action is completed.
|
|
Packit |
ae235b |
*/
|
|
Packit |
ae235b |
}
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
int
|
|
Packit |
ae235b |
main (int argc, char **argv)
|
|
Packit |
ae235b |
{
|
|
Packit |
ae235b |
GApplication *app;
|
|
Packit |
ae235b |
int status;
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
app = g_application_new ("org.gtk.TestApplication",
|
|
Packit |
ae235b |
G_APPLICATION_HANDLES_OPEN);
|
|
Packit |
ae235b |
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
|
Packit |
ae235b |
g_signal_connect (app, "open", G_CALLBACK (open), NULL);
|
|
Packit |
ae235b |
g_application_set_inactivity_timeout (app, 10000);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
status = g_application_run (app, argc, argv);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
g_object_unref (app);
|
|
Packit |
ae235b |
|
|
Packit |
ae235b |
return status;
|
|
Packit |
ae235b |
}
|