From b390ec8695afd018ae80ae818b779c7637e4c2d1 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 22 Jan 2004 02:03:21 +0000 Subject: [PATCH] * src/grampslib_wrap.c: check the known mime types before calling the gnome functions svn: r2693 --- gramps2/src/grampslib_wrap.c | 51 +++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/gramps2/src/grampslib_wrap.c b/gramps2/src/grampslib_wrap.c index 616188c9b..481060c6b 100644 --- a/gramps2/src/grampslib_wrap.c +++ b/gramps2/src/grampslib_wrap.c @@ -33,6 +33,10 @@ * and things like that. * * $Log$ + * Revision 1.3 2004/01/22 02:03:21 dallingham + * * src/grampslib_wrap.c: check the known mime types before calling the + * gnome functions + * * Revision 1.2 2004/01/09 03:12:28 dallingham * * src/docgen/KwordDoc.py (KwordDoc.close): handle KWord mime type * * src/grampslib_wrap.c: handle NULL pointers @@ -561,27 +565,54 @@ char *SWIG_GetPtr(char *_c, void **ptr, char *_t) #define SWIG_name "grampslib" #include +GList *gnome_vfs_get_registered_mime_types(void); +void gnome_vfs_mime_registered_mime_type_list_free(GList*); + extern const char *gnome_vfs_mime_get_icon(const char *); extern const char *gnome_vfs_mime_type_from_name(const char *); extern const char *gnome_vfs_mime_get_description(const char *); extern const char *gnome_vfs_mime_get_value(const char *,const char *); const char* default_application_name(const char* type) { - GnomeVFSMimeApplication *a = gnome_vfs_mime_get_default_application(type); - if (a) { - return a->name; - } else { - return (char*)0; + + GList *node; + char* value; + char* retval = NULL; + + GList *s = gnome_vfs_get_registered_mime_types(); + + for (node = g_list_first(s); node != NULL; node = g_list_next(node)) { + if (!strcmp((char*)node->data,type)) { + GnomeVFSMimeApplication *a = gnome_vfs_mime_get_default_application(type); + if (a) { + retval = a->name; + break; + } + } } + gnome_vfs_mime_registered_mime_type_list_free(s); + return retval; } const char* default_application_command(const char* type) { - GnomeVFSMimeApplication *a = gnome_vfs_mime_get_default_application(type); - if (a) { - return a->command; - } else { - return (char*)0; + + GList *node; + char* value; + char* retval = NULL; + + GList *s = gnome_vfs_get_registered_mime_types(); + + for (node = g_list_first(s); node != NULL; node = g_list_next(node)) { + if (!strcmp((char*)node->data,type)) { + GnomeVFSMimeApplication *a = gnome_vfs_mime_get_default_application(type); + if (a) { + retval = a->command; + break; + } + } } + gnome_vfs_mime_registered_mime_type_list_free(s); + return retval; } static PyObject *_wrap_gnome_vfs_mime_get_icon(PyObject *self, PyObject *args) {