[yelp] Present error message when page not found, instead of doing nothing



commit 75dea8184229f8b2436a5a74ffb3cbf66c5218f5
Author: Shaun McCance <shaunm gnome org>
Date:   Wed Aug 26 11:56:54 2009 -0500

    Present error message when page not found, instead of doing nothing

 src/yelp-document.c    |   29 +++++++++++++++++++++++++++++
 src/yelp-document.h    |    3 +++
 src/yelp-error.c       |    2 +-
 src/yelp-info-parser.c |    1 -
 src/yelp-mallard.c     |    6 +++++-
 5 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/yelp-document.c b/src/yelp-document.c
index bcef2f7..2d84dea 100644
--- a/src/yelp-document.c
+++ b/src/yelp-document.c
@@ -515,6 +515,35 @@ yelp_document_error_request (YelpDocument *document, gint req_id, YelpError *err
 }
 
 void
+yelp_document_error_page (YelpDocument *document, gchar *page_id, YelpError *error)
+{
+    GSList *requests;
+    Request *request = NULL;
+    YelpDocumentPriv *priv;
+
+    g_assert (document != NULL && YELP_IS_DOCUMENT (document));
+
+    debug_print (DB_FUNCTION, "entering\n");
+    priv = document->priv;
+    g_mutex_lock (priv->mutex);
+
+    requests = g_hash_table_lookup (priv->reqs_by_page_id, page_id);
+    while (requests) {
+	request = (Request *) requests->data;
+	if (request && request->error == NULL) {
+	    request->error = yelp_error_copy (error);
+	    request->idle_funcs++;
+	    g_idle_add ((GSourceFunc) request_idle_error, request);
+	}
+	requests = requests->next;
+    }
+
+    yelp_error_free (error);
+
+    g_mutex_unlock (priv->mutex);
+}
+
+void
 yelp_document_error_pending (YelpDocument *document, YelpError *error)
 {
     GSList *cur;
diff --git a/src/yelp-document.h b/src/yelp-document.h
index e82b6a0..7f558f9 100644
--- a/src/yelp-document.h
+++ b/src/yelp-document.h
@@ -124,6 +124,9 @@ gboolean          yelp_document_has_page       (YelpDocument       *document,
 void              yelp_document_error_request  (YelpDocument       *document,
 						gint                req_id,
 						YelpError          *error);
+void              yelp_document_error_page     (YelpDocument       *document,
+						gchar              *page_id,
+						YelpError          *error);
 void              yelp_document_error_pending  (YelpDocument       *document,
 						YelpError          *error);
 GtkTreeModel     *yelp_document_get_sections   (YelpDocument       *document);
diff --git a/src/yelp-error.c b/src/yelp-error.c
index fcb2142..63bd774 100644
--- a/src/yelp-error.c
+++ b/src/yelp-error.c
@@ -86,7 +86,7 @@ yelp_error_copy (YelpError *error)
     new->title = g_strdup (error->title);
     new->message = g_strdup (error->message);
 
-    return error;
+    return new;
 }
 
 const gchar *
diff --git a/src/yelp-info-parser.c b/src/yelp-info-parser.c
index a1b3e55..c849412 100644
--- a/src/yelp-info-parser.c
+++ b/src/yelp-info-parser.c
@@ -83,7 +83,6 @@ info_image_get_attributes (gchar const* string)
       if (!*value)
 	value = g_match_info_fetch (match_info, 3);
       g_hash_table_insert (h, key, value);
-      //fprintf (stderr, "Found: %s -> %s\n", key, value);
       g_match_info_next (match_info, NULL);
     }
   g_match_info_free (match_info);
diff --git a/src/yelp-mallard.c b/src/yelp-mallard.c
index 611a033..080ff37 100644
--- a/src/yelp-mallard.c
+++ b/src/yelp-mallard.c
@@ -373,10 +373,14 @@ mallard_try_run (YelpMallard *mallard,
 {
     /* We expect to be in a locked mutex when this function is called. */
     MallardPageData *page_data;
+    YelpError *error;
 
     page_data = g_hash_table_lookup (mallard->priv->pages_hash, page_id);
     if (page_data == NULL) {
-        printf ("FIXME: page not found: %s\n", page_id);
+	error = yelp_error_new (_("Page not found"),
+				_("The page %s was not found in the document %s."),
+				page_id, mallard->priv->directory);
+	yelp_document_error_page (YELP_DOCUMENT (mallard), page_id, error);
         return;
     }
 



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