1 | #include <unistd.h> |
---|
2 | #include <libgnomevfs/gnome-vfs.h> |
---|
3 | #include <libgnomevfs/gnome-vfs-mime-info-cache.h> |
---|
4 | #include <libgnomevfs/gnome-vfs-mime-handlers.h> |
---|
5 | #include <libgnomevfs/gnome-vfs-mime-monitor.h> |
---|
6 | |
---|
7 | void mime_cache_info_reload (void); |
---|
8 | |
---|
9 | gpointer foo (const char *mime_type); |
---|
10 | |
---|
11 | void mime_cache_info_reload (void) |
---|
12 | { |
---|
13 | g_print ("mime cache reloaded...\n"); |
---|
14 | } |
---|
15 | |
---|
16 | gpointer foo (const char *mime_type) { |
---|
17 | GList *desktop_file_apps, *tmp; |
---|
18 | |
---|
19 | while (1) { |
---|
20 | g_print ("Default: %s\n", |
---|
21 | gnome_vfs_mime_get_default_desktop_entry (mime_type)); |
---|
22 | |
---|
23 | desktop_file_apps = gnome_vfs_mime_get_all_applications (mime_type); |
---|
24 | |
---|
25 | g_print ("All:\n"); |
---|
26 | tmp = desktop_file_apps; |
---|
27 | while (tmp != NULL) { |
---|
28 | GnomeVFSMimeApplication *application; |
---|
29 | |
---|
30 | application = (GnomeVFSMimeApplication *) tmp->data; |
---|
31 | g_print ("%s, %s\n", application->id, application->name); |
---|
32 | tmp = tmp->next; |
---|
33 | } |
---|
34 | sleep (1); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | int main (int argc, char **argv) |
---|
39 | { |
---|
40 | GMainLoop *main_loop; |
---|
41 | char *mime_type; |
---|
42 | int i; |
---|
43 | |
---|
44 | gnome_vfs_init (); |
---|
45 | |
---|
46 | if (argc > 1) { |
---|
47 | mime_type = argv[1]; |
---|
48 | } else { |
---|
49 | mime_type = "text/plain"; |
---|
50 | } |
---|
51 | |
---|
52 | i = 1; |
---|
53 | while (i--) { |
---|
54 | (void) g_thread_create ((GThreadFunc) foo, mime_type, FALSE, NULL); |
---|
55 | } |
---|
56 | |
---|
57 | g_signal_connect (G_OBJECT (gnome_vfs_mime_monitor_get ()), |
---|
58 | "data_changed", |
---|
59 | (GCallback) mime_cache_info_reload, |
---|
60 | NULL); |
---|
61 | |
---|
62 | main_loop = g_main_loop_new (NULL, FALSE); |
---|
63 | |
---|
64 | g_main_loop_run (main_loop); |
---|
65 | |
---|
66 | return 0; |
---|
67 | } |
---|