diff options
author | Mikael Hallendal <micke@codefactory.se> | 2002-06-01 21:04:23 +0000 |
---|---|---|
committer | Mikael Hallendal <hallski@src.gnome.org> | 2002-06-01 21:04:23 +0000 |
commit | 24fbe2fd2cbfcd1114b68610bd7a4f4dcdaa3daf (patch) | |
tree | 4b03849c2a7ea1966eff9d30d64c2fef907d44a9 | |
parent | e2052b715c32872569e8ef0988dfe85d1c457d73 (diff) | |
download | yelp-24fbe2fd2cbfcd1114b68610bd7a4f4dcdaa3daf.tar.gz |
show error dialog if URI doesn't exist. (yelp_window_open_uri): don't
2002-06-01 Mikael Hallendal <micke@codefactory.se>
* src/yelp-window.c (window_handle_uri): show error dialog if URI
doesn't exist.
(yelp_window_open_uri): don't return if URI doesn't exist.
* src/yelp-uri.c:
- Added a type YELP_URI_TYPE_GHELP_OTHER so that I can recreate a
URI for error messaging.
(yelp_uri_exists): do a check rather then just a look at the type.
(uri_get_doc_type): don't check if URI exists here.
(yelp_uri_to_string): handle GHELP_OTHER.
* src/yelp-reader.c (reader_start): return if URI doesn't exists,
shouldn't happen.
* src/yelp-uri.h: removed YELP_URI_TYPE_NON_EXIST, use
yelp_uri_exists.
* stylesheets/docbook/Makefile.am: Install the images
* stylesheets/docbook/images/*: Added some of the images from XSL
stylesheets.
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | src/yelp-main.c | 18 | ||||
-rw-r--r-- | src/yelp-reader.c | 7 | ||||
-rw-r--r-- | src/yelp-uri.c | 37 | ||||
-rw-r--r-- | src/yelp-uri.h | 2 | ||||
-rw-r--r-- | src/yelp-window.c | 18 | ||||
-rw-r--r-- | stylesheets/docbook/Makefile.am | 5 | ||||
-rw-r--r-- | stylesheets/docbook/images/blank.png | bin | 0 -> 374 bytes | |||
-rw-r--r-- | stylesheets/docbook/images/caution.png | bin | 0 -> 1250 bytes | |||
-rw-r--r-- | stylesheets/docbook/images/important.png | bin | 0 -> 722 bytes | |||
-rw-r--r-- | stylesheets/docbook/images/note.png | bin | 0 -> 490 bytes | |||
-rw-r--r-- | stylesheets/docbook/images/tip.png | bin | 0 -> 449 bytes | |||
-rw-r--r-- | stylesheets/docbook/images/warning.png | bin | 0 -> 1241 bytes |
13 files changed, 76 insertions, 33 deletions
@@ -1,5 +1,27 @@ 2002-06-01 Mikael Hallendal <micke@codefactory.se> + * src/yelp-window.c (window_handle_uri): show error dialog if URI + doesn't exist. + (yelp_window_open_uri): don't return if URI doesn't exist. + + * src/yelp-uri.c: + - Added a type YELP_URI_TYPE_GHELP_OTHER so that I can recreate a + URI for error messaging. + (yelp_uri_exists): do a check rather then just a look at the type. + (uri_get_doc_type): don't check if URI exists here. + (yelp_uri_to_string): handle GHELP_OTHER. + + * src/yelp-reader.c (reader_start): return if URI doesn't exists, + shouldn't happen. + + * src/yelp-uri.h: removed YELP_URI_TYPE_NON_EXIST, use + yelp_uri_exists. + + * stylesheets/docbook/Makefile.am: Install the images + + * stylesheets/docbook/images/*: Added some of the images from XSL + stylesheets. + * Fixes #83156 * src/yelp-index-model.c: diff --git a/src/yelp-main.c b/src/yelp-main.c index 2afa5102..39e285f8 100644 --- a/src/yelp-main.c +++ b/src/yelp-main.c @@ -50,16 +50,16 @@ gint next_opt; struct poptOption options[] = { { - "url", - 'u', - POPT_ARG_STRING, - NULL, - 1, - NULL, - NULL, + "url", + 'u', + POPT_ARG_STRING, + NULL, + 1, + NULL, + NULL, }, - NULL - }; + NULL +}; static BonoboObject * yelp_base_factory (BonoboGenericFactory *factory, const gchar *iid, diff --git a/src/yelp-reader.c b/src/yelp-reader.c index 78fbe1b7..83844538 100644 --- a/src/yelp-reader.c +++ b/src/yelp-reader.c @@ -440,6 +440,10 @@ reader_start (ReaderThreadData *th_data) d(g_print ("reader_start\n")); + if (!yelp_uri_exists (uri)) { + return NULL; + } + STAMP_MUTEX_LOCK; if (reader_check_cancelled (reader, th_data->stamp)) { @@ -472,9 +476,6 @@ reader_start (ReaderThreadData *th_data) case YELP_URI_TYPE_TOC: /* Should this be handled here?? */ break; - case YELP_URI_TYPE_NON_EXISTENT: - /* Set GError and signal error */ - break; case YELP_URI_TYPE_INDEX: case YELP_URI_TYPE_PATH: /* Hmm .. is this wrong or what?? */ diff --git a/src/yelp-uri.c b/src/yelp-uri.c index 692abb64..35c6498e 100644 --- a/src/yelp-uri.c +++ b/src/yelp-uri.c @@ -37,6 +37,7 @@ struct _YelpURI { gchar *path; gchar *section; gint ref_count; + gboolean exists; }; static gchar * uri_get_doc_path (const gchar *str_uri); @@ -131,18 +132,14 @@ uri_get_doc_type (const gchar *str_uri, const gchar *doc_path) docpath = uri_get_doc_path (str_uri); } - if (!g_file_test (docpath, G_FILE_TEST_EXISTS)) { - return YELP_URI_TYPE_NON_EXISTENT; - } - mime_type = gnome_vfs_get_mime_type (docpath); if (mime_type) { if (!g_strcasecmp (mime_type, "text/xml")) { - ret_val = YELP_URI_TYPE_DOCBOOK_XML; + ret_val = YELP_URI_TYPE_DOCBOOK_XML; } else if (!g_strcasecmp (mime_type, "text/sgml")) { - ret_val = YELP_URI_TYPE_DOCBOOK_SGML; + ret_val = YELP_URI_TYPE_DOCBOOK_SGML; } else if (!g_strcasecmp (mime_type, "text/html")) { ret_val = YELP_URI_TYPE_HTML; @@ -154,6 +151,10 @@ uri_get_doc_type (const gchar *str_uri, const gchar *doc_path) if (docpath != doc_path) { g_free (docpath); } + + if (ret_val == YELP_URI_TYPE_UNKNOWN) { + ret_val = YELP_URI_TYPE_GHELP_OTHER; + } } return ret_val; @@ -365,11 +366,24 @@ yelp_uri_exists (YelpURI *uri) return FALSE; } - if (uri->type == YELP_URI_TYPE_NON_EXISTENT) { + switch (uri->type) { + case YELP_URI_TYPE_TOC: + case YELP_URI_TYPE_MAN: + case YELP_URI_TYPE_INFO: + case YELP_URI_TYPE_PATH: + case YELP_URI_TYPE_INDEX: + case YELP_URI_TYPE_UNKNOWN: + return TRUE; + break; + case YELP_URI_TYPE_DOCBOOK_XML: + case YELP_URI_TYPE_DOCBOOK_SGML: + case YELP_URI_TYPE_HTML: + case YELP_URI_TYPE_FILE: + return g_file_test (uri->path, G_FILE_TEST_EXISTS); + break; + default: return FALSE; } - - return TRUE; } YelpURIType @@ -542,10 +556,6 @@ yelp_uri_to_string (YelpURI *uri) g_return_val_if_fail (uri != NULL, NULL); - if (uri->type == YELP_URI_TYPE_NON_EXISTENT) { - return NULL; - } - if (uri->type == YELP_URI_TYPE_UNKNOWN) { if (uri->path) { return g_strdup (uri->path); @@ -564,6 +574,7 @@ yelp_uri_to_string (YelpURI *uri) case YELP_URI_TYPE_DOCBOOK_XML: case YELP_URI_TYPE_DOCBOOK_SGML: case YELP_URI_TYPE_HTML: + case YELP_URI_TYPE_GHELP_OTHER: type = g_strdup ("ghelp:"); break; case YELP_URI_TYPE_TOC: diff --git a/src/yelp-uri.h b/src/yelp-uri.h index 85a40900..a1ac1e34 100644 --- a/src/yelp-uri.h +++ b/src/yelp-uri.h @@ -28,10 +28,10 @@ #define YELP_URI(x) ((YelpURI *) x) typedef enum { - YELP_URI_TYPE_NON_EXISTENT, YELP_URI_TYPE_UNKNOWN, YELP_URI_TYPE_DOCBOOK_XML, YELP_URI_TYPE_DOCBOOK_SGML, + YELP_URI_TYPE_GHELP_OTHER, YELP_URI_TYPE_HTML, YELP_URI_TYPE_MAN, YELP_URI_TYPE_INFO, diff --git a/src/yelp-window.c b/src/yelp-window.c index 4d90c27c..f4e1f9cc 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -34,6 +34,7 @@ #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-url.h> #include <string.h> +#include "yelp-error.h" #include "yelp-html.h" #include "yelp-util.h" #include "yelp-section.h" @@ -327,7 +328,16 @@ window_handle_uri (YelpWindow *window, YelpURI *uri) d(g_print ("Handling URL: %s\n", yelp_uri_to_string (uri))); - if (yelp_uri_get_type (uri) == YELP_URI_TYPE_TOC) { + if (!yelp_uri_exists (uri)) { + gchar *str_uri = yelp_uri_to_string (uri); + + g_set_error (&error, + YELP_ERROR, + YELP_ERROR_URI_NOT_EXIST, + _("The document '%s' does not exist"), str_uri); + g_free (str_uri); + } + else if (yelp_uri_get_type (uri) == YELP_URI_TYPE_TOC) { d(g_print ("[TOC]\n")); yelp_view_toc_open_uri (YELP_VIEW_TOC (priv->toc_view), uri); @@ -335,7 +345,7 @@ window_handle_uri (YelpWindow *window, YelpURI *uri) gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), PAGE_TOC_VIEW); handled = TRUE; - } + } else if (yelp_uri_get_type (uri) == YELP_URI_TYPE_INDEX) { gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), PAGE_INDEX_VIEW); @@ -760,9 +770,7 @@ yelp_window_open_uri (YelpWindow *window, uri = yelp_uri_new (str_uri); - if (yelp_uri_exists (uri)) { - window_handle_uri (window, uri); - } + window_handle_uri (window, uri); yelp_uri_unref (uri); } diff --git a/stylesheets/docbook/Makefile.am b/stylesheets/docbook/Makefile.am index 6b8c7d69..b0544422 100644 --- a/stylesheets/docbook/Makefile.am +++ b/stylesheets/docbook/Makefile.am @@ -1,6 +1,7 @@ DIRECTORIES= \ common \ html \ + images \ lib DOCBOOK_DIR=$(datadir)/sgml/docbook/yelp/docbook @@ -12,7 +13,7 @@ install-data-local: for DIR in $(DIRECTORIES); do \ echo '-- Installing '$$DIR; \ $(mkinstalldirs) $(DESTDIR)$(DOCBOOK_DIR)/$$DIR; \ - (installfiles=`find $(srcdir)/$$DIR -name "*.xml" -o -name "*.xsl" -o -name "*.dtd"`; \ + (installfiles=`find $(srcdir)/$$DIR -name "*.xml" -o -name "*.xsl" -o -name "*.dtd" -o -name "*.png"`; \ for i in $$installfiles; do \ echo '-- Installing '$$i; \ $(INSTALL_DATA) $$i $(DESTDIR)$(DOCBOOK_DIR)/$$DIR; \ @@ -26,7 +27,7 @@ dist-hook: for DIR in $(DIRECTORIES); do \ echo '-- Disting '$$DIR; \ mkdir $(distdir)/$$DIR; \ - (installfiles=`find $(srcdir)/$$DIR -name "*.xml" -o -name "*.xsl" -o -name "*.dtd"`; \ + (installfiles=`find $(srcdir)/$$DIR -name "*.xml" -o -name "*.xsl" -o -name "*.dtd" -o -name "*.png"`; \ for i in $$installfiles; do \ echo '-- Disting '$$i; \ cp $$i $(distdir)/$$DIR; \ diff --git a/stylesheets/docbook/images/blank.png b/stylesheets/docbook/images/blank.png Binary files differnew file mode 100644 index 00000000..764bf4f0 --- /dev/null +++ b/stylesheets/docbook/images/blank.png diff --git a/stylesheets/docbook/images/caution.png b/stylesheets/docbook/images/caution.png Binary files differnew file mode 100644 index 00000000..5b7809ca --- /dev/null +++ b/stylesheets/docbook/images/caution.png diff --git a/stylesheets/docbook/images/important.png b/stylesheets/docbook/images/important.png Binary files differnew file mode 100644 index 00000000..12c90f60 --- /dev/null +++ b/stylesheets/docbook/images/important.png diff --git a/stylesheets/docbook/images/note.png b/stylesheets/docbook/images/note.png Binary files differnew file mode 100644 index 00000000..d0c3c645 --- /dev/null +++ b/stylesheets/docbook/images/note.png diff --git a/stylesheets/docbook/images/tip.png b/stylesheets/docbook/images/tip.png Binary files differnew file mode 100644 index 00000000..5c4aab3b --- /dev/null +++ b/stylesheets/docbook/images/tip.png diff --git a/stylesheets/docbook/images/warning.png b/stylesheets/docbook/images/warning.png Binary files differnew file mode 100644 index 00000000..1c33db8f --- /dev/null +++ b/stylesheets/docbook/images/warning.png |