patch for libgnome help-stuff



Hi!

Attached is a patch that makes libgnome always call the help-browsers
with 

ghelp://absolute-path-to/doc.xml?section

instead of using a number of different schemes. I think this will solve
the problems for application to get there documents shown in Yelp.

The reason I suggest this solution rather than putting code in Yelp to
calculate the absolute URI from a relative is that the absolute uri is
calculated in libgnome to see if the document exists before sending it
to the help browser (as relative).

The reason why libgnome tries to send it as a relative uri is (from what
I can understand) so that the help browser can display "ghelp:gfloppy"
instead of "ghelp:///path/to/gfloppy/C/gfloppy.xml" which is nicer. Yelp
however don't show the uri to the document so this doesn't matter to
Yelp.

In the longer run we might want to extract the code used to calculate
the absolute uri so that it can be called from the helpbrowser (thus not
all help browser need to duplicate the code that is already in
libgnome). Either that or rethink the help stuff with Scrollkeeper in
mind. With scrollkeeper we could obsolete the entire ghelp:// scheme and
instead use show_help ("/GNOME/Applications/myapplication") (where this
is the key registered in scrollkeeper).

So, what do you think, can I apply this patch?





-- 
Mikael Hallendal                micke codefactory se
CodeFactory AB                  http://www.codefactory.se/
Office: +46 (0)8 587 583 05     Cell: +46 (0)709 718 918
cvs server: Diffing .
cvs server: Diffing doc
cvs server: Diffing doc/reference
cvs server: Diffing doc/reference/tmpl
cvs server: Diffing gnome-data
cvs server: Diffing help-converters
cvs server: Diffing help-converters/docbook
cvs server: Diffing help-converters/docbook/docbook
cvs server: Diffing help-converters/docbook/docbook/common
cvs server: Diffing help-converters/docbook/docbook/html
cvs server: Diffing help-converters/docbook/docbook/lib
cvs server: Diffing help-converters/docbook/gnome-customization
cvs server: Diffing help-converters/gnome-vfs-module
cvs server: Diffing help-converters/info
cvs server: Diffing help-converters/man
cvs server: Diffing libgnome
Index: libgnome/gnome-help.c
===================================================================
RCS file: /cvs/gnome/libgnome/libgnome/gnome-help.c,v
retrieving revision 1.35
diff -u -r1.35 gnome-help.c
--- libgnome/gnome-help.c	20 Mar 2002 16:10:57 -0000	1.35
+++ libgnome/gnome-help.c	1 May 2002 14:43:03 -0000
@@ -125,7 +125,6 @@
 	gchar *local_help_path;
 	gchar *global_help_path;
 	gchar *file;
-	gboolean absolute_uri;
 	struct stat local_help_st;
 	struct stat global_help_st;
 	gchar *uri;
@@ -166,7 +165,6 @@
 
 	stat (local_help_path, &local_help_st);
 	stat (global_help_path, &global_help_st);
-	g_free (global_help_path);
 
 	if (! S_ISDIR (local_help_st.st_mode)) {
 		g_set_error (error,
@@ -178,15 +176,21 @@
 		return FALSE;
 	}
 
-	if (local_help_st.st_ino == global_help_st.st_ino)
-		absolute_uri = FALSE;
-	else
-		absolute_uri = TRUE;
-
 	file = locate_help_file (local_help_path, file_name);
 	g_free (local_help_path);
 
 	if (file == NULL) {
+		if (local_help_st.st_ino != global_help_st.st_ino) {
+			/* Couldn't find it in local path, so we'll look in *
+			 * the global path                                  */
+			file = locate_help_file (local_help_path, file_name);
+			return FALSE;
+		} 
+	}
+	
+	g_free (global_help_path);
+
+	if (file == NULL) {
 		g_set_error (error,
 			     GNOME_HELP_ERROR,
 			     GNOME_HELP_ERROR_NOT_FOUND,
@@ -196,18 +200,12 @@
 		return FALSE;
 	}
 
-	if (absolute_uri) {
-		if (link_id)
-			uri = g_strconcat ("ghelp://", file, "?", link_id, NULL);
-		else
-			uri = g_strconcat ("ghelp://", file, NULL);
+	if (link_id) {
+		uri = g_strconcat ("ghelp://", file, "?", link_id, NULL);
 	} else {
-		if (link_id)
-			uri = g_strconcat ("ghelp://", doc_id, "/", file_name, "?", link_id, NULL);
-		else
-			uri = g_strconcat ("ghelp://", doc_id, "/", file_name, NULL);
+		uri = g_strconcat ("ghelp://", file, NULL);
 	}
-
+	
 	retval = gnome_help_display_uri (uri, error);
 
 	g_free (file);
@@ -295,10 +293,11 @@
 	}
 	g_free (file);
 
-	if (link_id != NULL)
-		url = g_strdup_printf ("ghelp://%s/%s?%s", doc_id, file_name, link_id);
-	else
-		url = g_strdup_printf ("ghelp://%s/%s", doc_id, file_name);
+	if (link_id != NULL) {
+		url = g_strconcat ("ghelp://", file, "?", link_id, NULL); 
+	} else {
+		url = g_strconcat ("ghelp://", file, NULL);
+	}
 
 	retval = gnome_help_display_uri (url, error);
 
@@ -348,7 +347,7 @@
 	static GQuark error_quark = 0;
 
 	if (error_quark == 0)
-		error_quark =
+		error_quark =	
 			g_quark_from_static_string ("gnome-help-error-quark");
 
 	return error_quark;
Index: libgnome/gnome-help.h
===================================================================
RCS file: /cvs/gnome/libgnome/libgnome/gnome-help.h,v
retrieving revision 1.16
diff -u -r1.16 gnome-help.h
--- libgnome/gnome-help.h	1 Nov 2001 00:08:32 -0000	1.16
+++ libgnome/gnome-help.h	1 May 2002 14:43:03 -0000
@@ -60,7 +60,7 @@
 gboolean gnome_help_display_uri         (const char    *help_uri,
 					 GError       **error);
 
-
+ 
 G_END_DECLS
 
 #endif /* GNOME_HELP_H */
cvs server: Diffing monikers
cvs server: Diffing po
cvs server: Diffing schemas
cvs server: Diffing tests


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]