Re: getting the list of all gnome-vfs modules
- From: Christophe Fergeau <teuf users sourceforge net>
- To: Michael Meeks <michael ximian com>, gnome-vfs-list gnome org, gnome-vfs ximian com
- Subject: Re: getting the list of all gnome-vfs modules
- Date: Fri, 23 Aug 2002 18:26:44 +0200
Here comes an updated version of the patch, I hope I didn't forget any change.
Christophe
Index: libgnomevfs/gnome-vfs-application-registry.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-application-registry.c,v
retrieving revision 1.21
diff -u -r1.21 gnome-vfs-application-registry.c
--- libgnomevfs/gnome-vfs-application-registry.c 29 May 2002 00:43:47 -0000 1.21
+++ libgnomevfs/gnome-vfs-application-registry.c 23 Aug 2002 16:19:59 -0000
@@ -705,7 +705,7 @@
Application *application;
char *key;
char *lang;
-
+
fp = fopen (filename, "r");
if (fp == NULL)
return;
@@ -1594,7 +1594,8 @@
const char *uri_scheme)
{
Application *application;
-
+ gboolean uses_gnomevfs;
+
g_return_val_if_fail (app_id != NULL, FALSE);
g_return_val_if_fail (uri_scheme != NULL, FALSE);
@@ -1604,7 +1605,10 @@
if (application == NULL)
return FALSE;
+ uses_gnomevfs = real_get_bool_value (application, GNOME_VFS_APPLICATION_REGISTRY_USES_GNOMEVFS, NULL);
+
if (strcmp (uri_scheme, "file") == 0 &&
+ uses_gnomevfs == FALSE &&
application->supported_uri_schemes == NULL &&
application->user_application->supported_uri_schemes == NULL) {
return TRUE;
@@ -1624,6 +1628,21 @@
(GCompareFunc) strcmp) != NULL)) {
return TRUE;
}
+ /* check in the list of uris supported by gnome-vfs if necessary */
+ else if (uses_gnomevfs) {
+ GList *supported_uris;
+ gboolean res;
+
+ supported_uris = gnome_vfs_configuration_get_methods_list();
+ res = (g_list_find_custom(supported_uris,
+ /*glib is const incorrect*/(gpointer) uri_scheme,
+ (GCompareFunc) strcmp) != NULL);
+
+ g_list_foreach(supported_uris, (GFunc) g_free, NULL);
+ g_list_free(supported_uris);
+
+ return res;
+ }
return FALSE;
}
@@ -1851,6 +1870,7 @@
{
Application *i_application;
GnomeVFSMimeApplication *application;
+ gboolean uses_gnomevfs = FALSE;
g_return_val_if_fail (app_id != NULL, NULL);
@@ -1888,6 +1908,29 @@
(i_application,
GNOME_VFS_APPLICATION_REGISTRY_REQUIRES_TERMINAL,
NULL);
+
+ uses_gnomevfs = real_get_bool_value (i_application, GNOME_VFS_APPLICATION_REGISTRY_USES_GNOMEVFS, NULL);
+
+ if (uses_gnomevfs) {
+ GList *methods_list =
+ gnome_vfs_configuration_get_methods_list();
+ GList *l;
+ if (application->expects_uris == GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_PATHS) {
+ application->expects_uris = GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS;
+ }
+ for (l = methods_list; l != NULL; l = l->next) {
+ if (g_list_find_custom (application->supported_uri_schemes,
+ /*glib is const incorrect*/(gpointer) l->data,
+ (GCompareFunc) strcmp) == NULL) {
+ application->supported_uri_schemes =
+ g_list_prepend(application->supported_uri_schemes,
+ l->data);
+ } else {
+ g_free(l->data);
+ }
+ }
+ g_list_free(methods_list);
+ }
return application;
}
Index: libgnomevfs/gnome-vfs-application-registry.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-application-registry.h,v
retrieving revision 1.9
diff -u -r1.9 gnome-vfs-application-registry.h
--- libgnomevfs/gnome-vfs-application-registry.h 3 Aug 2001 00:39:58 -0000 1.9
+++ libgnomevfs/gnome-vfs-application-registry.h 23 Aug 2002 16:19:59 -0000
@@ -39,6 +39,7 @@
/* These are the standard boolean keys to get */
#define GNOME_VFS_APPLICATION_REGISTRY_CAN_OPEN_MULTIPLE_FILES "can_open_multiple_files"
#define GNOME_VFS_APPLICATION_REGISTRY_REQUIRES_TERMINAL "requires_terminal"
+#define GNOME_VFS_APPLICATION_REGISTRY_USES_GNOMEVFS "uses_gnomevfs"
/*
* Existance check
Index: libgnomevfs/gnome-vfs-configuration.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-configuration.c,v
retrieving revision 1.18
diff -u -r1.18 gnome-vfs-configuration.c
--- libgnomevfs/gnome-vfs-configuration.c 28 Jan 2002 19:10:07 -0000 1.18
+++ libgnomevfs/gnome-vfs-configuration.c 23 Aug 2002 16:19:59 -0000
@@ -554,3 +554,28 @@
*args = element->args;
return element->path;
}
+
+static void
+add_method_to_list(const gchar *key, gpointer value, GList **methods_list)
+{
+ *methods_list = g_list_append(*methods_list, g_strdup(key));
+}
+
+GList *
+gnome_vfs_configuration_get_methods_list (void)
+{
+ GList *methods_list = NULL;
+
+ G_LOCK (configuration);
+ if (configuration != NULL) {
+ maybe_reload ();
+ g_hash_table_foreach(configuration->method_to_module_path,
+ (GHFunc)add_method_to_list, &methods_list);
+ } else {
+ /* This should never happen. */
+ methods_list = NULL;
+ }
+
+ G_UNLOCK (configuration);
+ return methods_list;
+}
Index: libgnomevfs/gnome-vfs-configuration.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-configuration.h,v
retrieving revision 1.4
diff -u -r1.4 gnome-vfs-configuration.h
--- libgnomevfs/gnome-vfs-configuration.h 3 Aug 2001 00:39:58 -0000 1.4
+++ libgnomevfs/gnome-vfs-configuration.h 23 Aug 2002 16:19:59 -0000
@@ -25,6 +25,7 @@
#define GNOME_VFS_CONFIGURATION_H
#include <glib/gtypes.h>
+#include <glib/glist.h>
G_BEGIN_DECLS
@@ -32,6 +33,8 @@
gboolean gnome_vfs_configuration_init (void);
void gnome_vfs_configuration_uninit (void);
const gchar *gnome_vfs_configuration_get_module_path (const gchar *method_name, const char ** args);
+GList *gnome_vfs_configuration_get_methods_list(void);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]