summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2009-08-26 11:56:54 -0500
committerShaun McCance <shaunm@gnome.org>2009-08-26 16:57:06 -0500
commit75dea8184229f8b2436a5a74ffb3cbf66c5218f5 (patch)
treebbd33c28182e1fbfdb6c9d73a4de56a740054622
parent352270ce02f149181b07255a4700748bf87521ee (diff)
downloadyelp-75dea8184229f8b2436a5a74ffb3cbf66c5218f5.tar.gz
Present error message when page not found, instead of doing nothing
-rw-r--r--src/yelp-document.c29
-rw-r--r--src/yelp-document.h3
-rw-r--r--src/yelp-error.c2
-rw-r--r--src/yelp-info-parser.c1
-rw-r--r--src/yelp-mallard.c6
5 files changed, 38 insertions, 3 deletions
diff --git a/src/yelp-document.c b/src/yelp-document.c
index bcef2f70..2d84deaf 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 e82b6a0a..7f558f97 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 fcb21425..63bd7748 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 a1b3e55c..c8494127 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 611a0336..080ff37c 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;
}