[yelp] Fixing some navigation wonkiness with error pages
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp] Fixing some navigation wonkiness with error pages
- Date: Thu, 6 Jan 2011 23:57:25 +0000 (UTC)
commit 9410bf06c2ca061bcfdb23fa53b1cfa53fb236b2
Author: Shaun McCance <shaunm gnome org>
Date: Thu Jan 6 13:39:54 2011 -0500
Fixing some navigation wonkiness with error pages
libyelp/yelp-location-entry.c | 38 +++++++++++----------
libyelp/yelp-view.c | 72 ++++++++++++++++++++++++++++++++++------
src/yelp-window.c | 6 +++-
3 files changed, 86 insertions(+), 30 deletions(-)
---
diff --git a/libyelp/yelp-location-entry.c b/libyelp/yelp-location-entry.c
index defe05b..a597066 100644
--- a/libyelp/yelp-location-entry.c
+++ b/libyelp/yelp-location-entry.c
@@ -1259,26 +1259,28 @@ view_loaded (YelpView *view,
entry_completion_sort,
NULL, NULL);
g_hash_table_insert (completions, g_strdup (doc_uri), completion);
- ids = yelp_document_list_page_ids (document);
- for (i = 0; ids[i]; i++) {
- GtkTreeIter iter;
- gchar *title, *desc, *icon;
- gtk_list_store_insert (GTK_LIST_STORE (base), &iter, 0);
- title = yelp_document_get_page_title (document, ids[i]);
- desc = yelp_document_get_page_desc (document, ids[i]);
- icon = yelp_document_get_page_icon (document, ids[i]);
- gtk_list_store_set (base, &iter,
- COMPLETION_COL_TITLE, title,
- COMPLETION_COL_DESC, desc,
- COMPLETION_COL_ICON, icon,
- COMPLETION_COL_PAGE, ids[i],
- -1);
- g_free (icon);
- g_free (desc);
- g_free (title);
+ if (document != NULL) {
+ ids = yelp_document_list_page_ids (document);
+ for (i = 0; ids[i]; i++) {
+ GtkTreeIter iter;
+ gchar *title, *desc, *icon;
+ gtk_list_store_insert (GTK_LIST_STORE (base), &iter, 0);
+ title = yelp_document_get_page_title (document, ids[i]);
+ desc = yelp_document_get_page_desc (document, ids[i]);
+ icon = yelp_document_get_page_icon (document, ids[i]);
+ gtk_list_store_set (base, &iter,
+ COMPLETION_COL_TITLE, title,
+ COMPLETION_COL_DESC, desc,
+ COMPLETION_COL_ICON, icon,
+ COMPLETION_COL_PAGE, ids[i],
+ -1);
+ g_free (icon);
+ g_free (desc);
+ g_free (title);
+ }
+ g_strfreev (ids);
}
g_object_unref (base);
- g_strfreev (ids);
}
g_free (priv->completion_uri);
priv->completion_uri = doc_uri;
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index 95c404e..4ae3361 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -258,6 +258,7 @@ enum {
static void
yelp_view_init (YelpView *view)
{
+ GtkAction *action;
YelpViewPrivate *priv = GET_PRIV (view);
g_object_set (view, "settings", websettings, NULL);
@@ -285,6 +286,10 @@ yelp_view_init (YelpView *view)
gtk_action_group_add_actions (priv->action_group,
entries, G_N_ELEMENTS (entries),
view);
+ action = gtk_action_group_get_action (priv->action_group, "YelpViewGoBack");
+ gtk_action_set_sensitive (action, FALSE);
+ action = gtk_action_group_get_action (priv->action_group, "YelpViewGoForward");
+ gtk_action_set_sensitive (action, FALSE);
}
static void
@@ -1636,6 +1641,7 @@ view_show_error_page (YelpView *view,
gchar *page, *title = NULL, *link = NULL, *title_m, *content_beg, *content_end;
gchar *textcolor, *bgcolor, *noteborder, *notebg, *titlecolor, *noteicon, *linkcolor;
gint iconsize;
+ GParamSpec *spec;
gboolean doc404 = FALSE;
const gchar *left = (gtk_widget_get_direction((GtkWidget *) view) == GTK_TEXT_DIR_RTL) ? "right" : "left";
@@ -1694,6 +1700,39 @@ view_show_error_page (YelpView *view,
left, iconsize, left, iconsize, left, iconsize,
titlecolor, linkcolor, title_m, content_beg,
(content_end != NULL) ? content_end : "");
+
+
+ if (doc404) {
+ g_free (priv->root_title);
+ priv->root_title = g_strdup (title);
+ spec = g_object_class_find_property ((GObjectClass *) YELP_VIEW_GET_CLASS (view),
+ "root-title");
+ g_signal_emit_by_name (view, "notify::root-title", spec);
+ g_free (priv->page_id);
+ priv->page_id = g_strdup ("//error");
+ spec = g_object_class_find_property ((GObjectClass *) YELP_VIEW_GET_CLASS (view),
+ "page-id");
+ g_signal_emit_by_name (view, "notify::page-id", spec);
+ }
+
+ g_free (priv->page_title);
+ priv->page_title = g_strdup (title);
+ spec = g_object_class_find_property ((GObjectClass *) YELP_VIEW_GET_CLASS (view),
+ "page-title");
+ g_signal_emit_by_name (view, "notify::page-title", spec);
+
+ g_free (priv->page_desc);
+ priv->page_desc = NULL;
+ spec = g_object_class_find_property ((GObjectClass *) YELP_VIEW_GET_CLASS (view),
+ "page-desc");
+ g_signal_emit_by_name (view, "notify::page-desc", spec);
+
+ g_free (priv->page_icon);
+ priv->page_icon = g_strdup ("dialog-warning");
+ spec = g_object_class_find_property ((GObjectClass *) YELP_VIEW_GET_CLASS (view),
+ "page-icon");
+ g_signal_emit_by_name (view, "notify::page-icon", spec);
+
g_object_set (view, "state", YELP_VIEW_STATE_ERROR, NULL);
g_signal_emit (view, signals[LOADED], 0);
g_signal_handler_block (view, priv->navigation_requested);
@@ -1765,7 +1804,7 @@ uri_resolved (YelpUri *uri,
YelpBackEntry *back;
GtkAction *action;
GSList *proxies, *cur;
- GError *error;
+ GError *error = NULL;
gchar *struri;
GParamSpec *spec;
@@ -1803,24 +1842,30 @@ uri_resolved (YelpUri *uri,
_("The URI does not point to a valid page."),
struri);
}
- view_show_error_page (view, error);
- return;
+ break;
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;
+ break;
default:
break;
}
- document = yelp_document_get_for_uri (uri);
- if (priv->document)
- g_object_unref (priv->document);
- priv->document = document;
+ if (error == NULL) {
+ document = yelp_document_get_for_uri (uri);
+ if (priv->document)
+ g_object_unref (priv->document);
+ priv->document = document;
+ }
+ else {
+ if (priv->document != NULL) {
+ g_object_unref (priv->document);
+ priv->document = NULL;
+ }
+ }
if (!priv->back_load) {
back = g_new0 (YelpBackEntry, 1);
@@ -1895,12 +1940,17 @@ uri_resolved (YelpUri *uri,
g_signal_emit_by_name (view, "notify::yelp-uri", spec);
g_free (priv->page_id);
- priv->page_id = yelp_uri_get_page_id (priv->uri);
+ priv->page_id = NULL;
+ if (priv->uri != NULL)
+ priv->page_id = yelp_uri_get_page_id (priv->uri);
spec = g_object_class_find_property ((GObjectClass *) YELP_VIEW_GET_CLASS (view),
"page-id");
g_signal_emit_by_name (view, "notify::page-id", spec);
- view_load_page (view);
+ if (error == NULL)
+ view_load_page (view);
+ else
+ view_show_error_page (view, error);
}
static void
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 04534c9..c15c252 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -1441,6 +1441,7 @@ view_loaded (YelpView *view,
YelpUri *uri;
gchar *doc_uri;
YelpViewState state;
+ GdkWindow *gdkwin;
YelpWindowPrivate *priv = GET_PRIV (window);
g_object_get (view,
@@ -1448,7 +1449,10 @@ view_loaded (YelpView *view,
"state", &state,
NULL);
doc_uri = yelp_uri_get_document_uri (uri);
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL);
+
+ gdkwin = gtk_widget_get_window (GTK_WIDGET (window));
+ if (gdkwin != NULL)
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL);
if (state != YELP_VIEW_STATE_ERROR) {
gchar *page_id, *icon, *title;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]