summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Scorgie <dscorgie@src.gnome.org>2007-06-13 18:02:14 +0000
committerDon Scorgie <dscorgie@src.gnome.org>2007-06-13 18:02:14 +0000
commitb372a2386104a7196fe8020c38a1670ddfbbae83 (patch)
treed791253a7ab052fa377d6a6f86c7ca1ee43daa74
parentad43a05d878f2964758a88d38c35efeb356fafa8 (diff)
downloadyelp-b372a2386104a7196fe8020c38a1670ddfbbae83.tar.gz
start loading yelp-toc at start of base to take advantage of threading and
* src/yelp-base.c: start loading yelp-toc at start of base to take advantage of threading and make the toc load even quicker (except man pages of course) * src/yelp-toc.c: Make icon work (when the rest of the customisations are plumbed in) * src/yelp-utils.c: Fix result for TOC pages * src/yelp-document.c: Fix crash when canceling page request * src/yelp-window.c: Implement canceling of requests Implement location dialog svn path=/branches/yelp-spoon/; revision=2824
-rw-r--r--ChangeLog22
-rw-r--r--src/yelp-base.c5
-rw-r--r--src/yelp-document.c2
-rw-r--r--src/yelp-toc.c2
-rw-r--r--src/yelp-utils.c6
-rw-r--r--src/yelp-window.c67
6 files changed, 73 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index fde06de6..586448d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2007-06-13 Don Scorgie <dscorgie@svn.gnome.org>
+
+ * src/yelp-base.c:
+ start loading yelp-toc at start of
+ base to take advantage of threading
+ and make the toc load even quicker
+ (except man pages of course)
+
+ * src/yelp-toc.c:
+ Make icon work (when the rest of the
+ customisations are plumbed in)
+
+ * src/yelp-utils.c:
+ Fix result for TOC pages
+
+ * src/yelp-document.c:
+ Fix crash when canceling page request
+
+ * src/yelp-window.c:
+ Implement canceling of requests
+ Implement location dialog
+
2007-06-12 Don Scorgie <dscorgie@svn.gnome.org>
* src/yelp-window.c:
diff --git a/src/yelp-base.c b/src/yelp-base.c
index a755eb81..d4744e9e 100644
--- a/src/yelp-base.c
+++ b/src/yelp-base.c
@@ -32,7 +32,7 @@
#include "yelp-window.h"
#include "yelp-settings.h"
-//#include "yelp-pager.h"
+#include "yelp-toc.h"
/*#include "yelp-toc-pager.h"*/
#include "yelp-base.h"
#include "yelp-bookmarks.h"
@@ -98,6 +98,9 @@ yelp_base_init (YelpBase *base)
priv->toc_tree = g_node_new (NULL);
priv->index = NULL;
priv->windows = NULL;
+ /* Init here to start processing before
+ * we even start the window */
+ yelp_toc_new();
yelp_bookmarks_init ();
yelp_settings_init ();
diff --git a/src/yelp-document.c b/src/yelp-document.c
index 21a6c041..619d854c 100644
--- a/src/yelp-document.c
+++ b/src/yelp-document.c
@@ -273,8 +273,6 @@ yelp_document_cancel_page (YelpDocument *document, gint req_id)
hash_slist_remove (priv->reqs_by_page_id,
request->page_id,
request);
- g_hash_table_remove (priv->reqs_by_req_id,
- GINT_TO_POINTER (req_id));
} else {
g_warning ("YelpDocument: Attempted to remove request %i,"
" but no such request exists.",
diff --git a/src/yelp-toc.c b/src/yelp-toc.c
index d437af5d..08f5e0e1 100644
--- a/src/yelp-toc.c
+++ b/src/yelp-toc.c
@@ -483,7 +483,7 @@ toc_process (YelpToc *toc)
/* FIXME: Once hooked up properly into yelp, uncomment
* to make the nice shiny icon appear
*/
- /*icon = xmlGetProp (node, BAD_CAST "icon");*/
+ icon = xmlGetProp (node, BAD_CAST "icon");
if (icon) {
GtkIconInfo *info;
GtkIconTheme *theme =
diff --git a/src/yelp-utils.c b/src/yelp-utils.c
index 7c1cd1cd..8e119890 100644
--- a/src/yelp-utils.c
+++ b/src/yelp-utils.c
@@ -1358,12 +1358,12 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section)
} else {
*section = g_strdup("index");
}
- *result = NULL;
+ *result = g_strdup ("x-yelp-toc:");
/* TOC page */
} else if (!strncmp (uri, "x-yelp-search:", 14)) {
/* Search pager request. *result contains the search terms */
- *result = g_strdup (uri+14);
- *section = NULL;
+ *result = g_strdup (uri);
+ *section = g_strdup (uri+14);
ret = YELP_SPOON_TYPE_SEARCH;
} else if (g_file_test (intern_uri, G_FILE_TEST_EXISTS)) {
/* Full path */
diff --git a/src/yelp-window.c b/src/yelp-window.c
index fc34b9a0..73638f05 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -268,10 +268,12 @@ struct _YelpWindowPriv {
GtkWidget *popup;
gint merge_id;
GtkWidget *maillink;
- gchar *uri;
/* Location Information */
- /*YelpDocInfo *current_doc;*/
+ gchar *uri;
+ gchar *req_uri;
+ gint current_request;
+ YelpDocument *current_document;
gchar *current_frag;
GSList *history_back;
GSList *history_forward;
@@ -911,8 +913,9 @@ document_func (YelpDocument *document,
YelpDocumentSignal signal,
gint req_id,
gpointer *func_data,
- YelpHtml *html)
+ YelpWindow *window)
{
+ YelpHtml *html = window->priv->html_view;
gchar contents[BUFFER_SIZE];
gsize read;
YelpPage *page;
@@ -927,9 +930,8 @@ document_func (YelpDocument *document,
yelp_html_write (html, contents, read);
} while (read == BUFFER_SIZE);
yelp_html_close (html);
- /* contents isn't \0-terminated */
- //printf (" DATA: %s\n", contents_);
- //g_free (contents_);
+
+ window->priv->current_request = -1;
yelp_page_free (page);
break;
case YELP_DOCUMENT_SIGNAL_TITLE:
@@ -950,7 +952,6 @@ void
yelp_window_load (YelpWindow *window, const gchar *uri)
{
YelpWindowPriv *priv;
- //YelpDocInfo *doc_info;
gchar *frag_id = NULL;
GtkAction *action;
gchar *real_uri = NULL;
@@ -960,17 +961,44 @@ yelp_window_load (YelpWindow *window, const gchar *uri)
g_return_if_fail (YELP_IS_WINDOW (window));
+ priv = window->priv;
+
+ if (priv->current_request != -1) {
+ yelp_document_cancel_page (priv->current_document, priv->current_request);
+ priv->current_request = -1;
+ }
+
type = yelp_uri_resolve (uri, &real_uri, &frag_id);
- switch (type) {
- case YELP_SPOON_TYPE_TOC:
- doc = yelp_toc_get ();
+ /* TODO: handle type errors here first */
+
+ if (priv->uri && g_str_equal (real_uri, priv->uri)) {
+ doc = priv->current_document;
+ } else {
+ switch (type) {
+ case YELP_SPOON_TYPE_TOC:
+ doc = yelp_toc_get ();
+ break;
+ case YELP_SPOON_TYPE_DOC:
+ break;
+ case YELP_SPOON_TYPE_HTML:
+ break;
+ default:
+ break;
+ }
}
if (doc) {
- yelp_document_get_page (doc, frag_id, document_func, (void *) window->priv->html_view);
+ priv->uri = real_uri;
+ priv->current_frag = frag_id;
+ priv->req_uri = g_strdup (uri);
+ priv->current_request = yelp_document_get_page (doc,
+ frag_id,
+ document_func,
+ (void *) window);
}
+ priv->current_document = doc;
/*
case YELP_DOC_TYPE_MAN:
@@ -1317,6 +1345,8 @@ window_populate (YelpWindow *window)
priv = window->priv;
+ priv->current_request = -1;
+
priv->main_box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), priv->main_box);
@@ -2675,24 +2705,12 @@ window_open_location_cb (GtkAction *action, YelpWindow *window)
GladeXML *glade;
GtkWidget *dialog;
GtkWidget *entry;
- gchar *uri;
+ gchar *uri = NULL;
g_return_if_fail (YELP_IS_WINDOW (window));
priv = window->priv;
- /*if (priv->current_doc) {
- uri = yelp_doc_info_get_uri (priv->current_doc,
- priv->current_frag,
- YELP_URI_TYPE_NO_FILE);
- if (!uri)
- uri = yelp_doc_info_get_uri (priv->current_doc,
- priv->current_frag,
- YELP_URI_TYPE_FILE);
- } else {
- uri = NULL;
- }*/
-
glade = glade_xml_new (DATADIR "/yelp/ui/yelp.glade",
"location_dialog",
NULL);
@@ -2708,6 +2726,7 @@ window_open_location_cb (GtkAction *action, YelpWindow *window)
priv->location_dialog = dialog;
priv->location_entry = entry;
+ uri = priv->req_uri;
if (uri) {
gtk_entry_set_text (GTK_ENTRY (entry), uri);
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);