[yelp/yelp-3-0] [libyelp/yelp-view] Emit signal on external URIs, handle errors better



commit 287e124934f503c7bdc7498002288f79379f1ef6
Author: Shaun McCance <shaunm gnome org>
Date:   Wed Mar 17 15:23:23 2010 -0500

    [libyelp/yelp-view] Emit signal on external URIs, handle errors better

 libyelp/yelp-uri.c  |    2 +-
 libyelp/yelp-view.c |   37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c
index 6c3af0a..a06af45 100644
--- a/libyelp/yelp-uri.c
+++ b/libyelp/yelp-uri.c
@@ -306,7 +306,7 @@ resolve_async (YelpUri *uri)
     }
     else if (strchr (priv->res_arg, ':')) {
         priv->tmptype = YELP_URI_DOCUMENT_TYPE_EXTERNAL;
-        /* FIXME: resolve as external URI */
+        priv->fulluri = g_strdup (priv->res_arg);
     }
     else {
         resolve_file_path (uri);
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index d0b042c..a497ef0 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -89,6 +89,7 @@ enum {
 
 enum {
     NEW_VIEW_REQUESTED,
+    EXTERNAL_URI,
     LAST_SIGNAL
 };
 static gint signals[LAST_SIGNAL] = { 0 };
@@ -193,13 +194,21 @@ yelp_view_class_init (YelpViewClass *klass)
     object_class->set_property = yelp_view_set_property;
 
     signals[NEW_VIEW_REQUESTED] =
-	g_signal_new ("new_view_requested",
+	g_signal_new ("new-view-requested",
 		      G_TYPE_FROM_CLASS (klass),
 		      G_SIGNAL_RUN_LAST,
                       0, NULL, NULL,
 		      g_cclosure_marshal_VOID__STRING,
 		      G_TYPE_NONE, 1, G_TYPE_STRING);
 
+    signals[EXTERNAL_URI] =
+	g_signal_new ("external-uri",
+		      G_TYPE_FROM_CLASS (klass),
+		      G_SIGNAL_RUN_LAST,
+                      0, NULL, NULL,
+		      g_cclosure_marshal_VOID__OBJECT,
+		      G_TYPE_NONE, 1, YELP_TYPE_URI);
+
     g_type_class_add_private (klass, sizeof (YelpViewPrivate));
 
     g_object_class_install_property (object_class,
@@ -573,9 +582,35 @@ uri_resolved (YelpUri  *uri,
 {
     YelpViewPrivate *priv = GET_PRIV (view);
     YelpDocument *document;
+    GError *error;
+    gchar *struri;
 
     debug_print (DB_FUNCTION, "entering\n");
 
+    switch (yelp_uri_get_document_type (uri)) {
+    case YELP_URI_DOCUMENT_TYPE_EXTERNAL:
+        g_signal_emit (view, signals[EXTERNAL_URI], 0, uri, 0);
+        return;
+    case YELP_URI_DOCUMENT_TYPE_NOT_FOUND:
+        struri = yelp_uri_get_canonical_uri (uri);
+        error = g_error_new (YELP_ERROR, YELP_ERROR_NOT_FOUND,
+                             _("The URI â??%sâ?? does point to a valid page."),
+                             struri);
+        g_free (struri);
+        view_show_error_page (view, error);
+        return;
+    case YELP_URI_DOCUMENT_TYPE_ERROR:
+        struri = yelp_uri_get_canonical_uri (uri);
+        error = g_error_new (YELP_ERROR, YELP_ERROR_PROCESSING,
+                             _("The URI â??%sâ?? could not be parsed."),
+                             struri);
+        g_free (struri);
+        view_show_error_page (view, error);
+        return;
+    default:
+        break;
+    }
+
     document  = yelp_document_get_for_uri (uri);
     if (priv->document)
         g_object_unref (priv->document);



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