source: trunk/third/gnome-vfs2/test/test-mime-info-cache.c @ 21416

Revision 21416, 1.8 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21415, which included commits to RCS files with non-trunk default branches.
Line 
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
7void mime_cache_info_reload (void);
8
9gpointer foo (const char *mime_type);
10
11void mime_cache_info_reload (void)
12{
13        g_print ("mime cache reloaded...\n");
14}
15
16gpointer 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        return NULL;
38}
39
40int main (int argc, char **argv)
41{
42        GMainLoop *main_loop;
43        char *mime_type;
44        int i;
45
46        gnome_vfs_init ();
47
48        if (argc > 1) {
49                mime_type = argv[1];
50        } else {
51                mime_type = "text/plain";
52        }
53
54        i = 1;
55        while (i--) {
56                (void) g_thread_create ((GThreadFunc) foo, mime_type, FALSE, NULL);
57        }
58
59        g_signal_connect (G_OBJECT (gnome_vfs_mime_monitor_get ()),
60                          "data_changed",
61                           (GCallback) mime_cache_info_reload,
62                           NULL);
63
64        main_loop = g_main_loop_new (NULL, FALSE);
65
66        g_main_loop_run (main_loop);
67
68        return 0;
69}
Note: See TracBrowser for help on using the repository browser.