Subject: Re: Why does gnumeric depend on xscreensaver-gnome?
To: David Brownlee <abs@netbsd.org>
From: Dan Winship <danw@ximian.com>
List: tech-pkg
Date: 02/13/2001 10:21:19
> Presumably that means the ghelp: -> file: trickery in gnome-lib
> is probably going to be the best option? :)
Yeah. Looks like it's not even quite as bad as I thought: the ghelp
URLs have full paths now, and gnome-moz-remote will rewrite "ghelp" to
"file" if it gets it. So all we need to do is make gnome-libs fall
back to the default handler (gnome-moz-remote, which in turn launches
mozilla or netscape) if it can't execute the one it originally wanted:
--- gnome-libs-1.2.11/libgnome/gnome-url.c~ Mon May 22 17:24:03 2000
+++ gnome-libs-1.2.11/libgnome/gnome-url.c Tue Feb 13 10:09:23 2001
@@ -68,6 +68,8 @@
return default_handler;
}
+static int gnome_url_show_with_handler (const gchar *url, const gchar *template);
+
/**
* gnome_url_show
* @url: URL to show
@@ -93,11 +95,9 @@
void
gnome_url_show(const gchar *url)
{
- gint i;
gchar *pos, *template;
gboolean free_template = FALSE;
- int argc;
- char **argv;
+ int status;
g_return_if_fail (url != NULL);
pos = strchr (url, ':');
@@ -123,12 +123,26 @@
} else /* no : ? -- this shouldn't happen. Use default handler */
template = gnome_url_default_handler ();
+ status = gnome_url_show_with_handler (url, template);
+ if (status == -1 && free_template)
+ gnome_url_show_with_handler (url, gnome_url_default_handler ());
+
+ if (free_template)
+ g_free (template);
+}
+
+static int
+gnome_url_show_with_handler (const gchar *url, const gchar *template)
+{
+ int argc, i, status;
+ char **argv;
+
/* we use a popt function as it does exactly what we want to do and
gnome already uses popt */
if(poptParseArgvString(template, &argc, &argv) != 0) {
/* can't parse */
g_warning("Parse error of '%s'", template);
- return;
+ return -1;
}
/* we can just replace the entry in the array since the
@@ -142,13 +156,12 @@
/* use execute async, and not the shell, shell is evil and a
* security hole */
- gnome_execute_async (NULL, argc, argv);
-
- if (free_template)
- g_free (template);
+ status = gnome_execute_async (NULL, argc, argv);
/* the way the poptParseArgvString works is that the entire thing
* is allocated as one buffer, so just free will suffice, also
* it must be free and not g_free */
free(argv);
+
+ return status;
}