mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-21 14:49:16 +02:00
apps test: add new "monitor" subcommand
Waits until something modifies a desktop directory, then exits. https://bugzilla.gnome.org/show_bug.cgi?id=736350
This commit is contained in:
parent
9ac7d51a80
commit
2f55c66c64
@ -1,6 +1,7 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gio/gdesktopappinfo.h>
|
#include <gio/gdesktopappinfo.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print (const gchar *str)
|
print (const gchar *str)
|
||||||
@ -20,6 +21,13 @@ print_app_list (GList *list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
quit (gpointer user_data)
|
||||||
|
{
|
||||||
|
g_print ("appinfo database changed.\n");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -119,5 +127,21 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (g_str_equal (argv[1], "monitor"))
|
||||||
|
{
|
||||||
|
GAppInfoMonitor *monitor;
|
||||||
|
GAppInfo *info;
|
||||||
|
|
||||||
|
monitor = g_app_info_monitor_get ();
|
||||||
|
|
||||||
|
info = (GAppInfo *) g_desktop_app_info_new ("this-desktop-file-does-not-exist");
|
||||||
|
g_assert (!info);
|
||||||
|
|
||||||
|
g_signal_connect (monitor, "changed", G_CALLBACK (quit), NULL);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user