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

Revision 20794, 1.8 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20793, 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
38int 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}
Note: See TracBrowser for help on using the repository browser.