diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | src/Makefile.am | 53 | ||||
-rw-r--r-- | src/yelp-base.c | 8 | ||||
-rw-r--r-- | src/yelp-toc.c | 21 | ||||
-rw-r--r-- | src/yelp-toc.h | 1 | ||||
-rw-r--r-- | src/yelp-utils.c | 73 | ||||
-rw-r--r-- | src/yelp-utils.h | 18 | ||||
-rw-r--r-- | src/yelp-window.c | 289 | ||||
-rw-r--r-- | src/yelp-window.h | 3 | ||||
-rw-r--r-- | stylesheets/toc2html.xsl | 2 |
10 files changed, 351 insertions, 138 deletions
@@ -1,5 +1,26 @@ 2007-06-12 Don Scorgie <dscorgie@svn.gnome.org> + * src/yelp-window.c: + * src/yelp-base.c: + * src/yelp-window.h: + * src/yelp-utils.c: + * src/yelp-utils.h: + * src/Makefile.am: + * stylesheets/toc2html.xsl: + First pass at making yelp work again + Very, very broken, but TOC shows up (and is navigatable) + Thought, nothing else works and is + liable to crash if used + rename YELP_TYPE_* to YELP_SPOON_TYPE_* + to stop conflict when compiling + Oh, and introduce hundreds of compiler warnings + + * src/yelp-toc.c: + * src/yelp-toc.h: + Make TOC doc singleton + +2007-06-12 Don Scorgie <dscorgie@svn.gnome.org> + * src/yelp-utils.c: Add ghelp resolve support Many minor fixes to pass default test suite diff --git a/src/Makefile.am b/src/Makefile.am index 549eb5c1..c773cca7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,41 +4,40 @@ yelp_SOURCES = \ Yelper.cpp Yelper.h \ yelp-base.c yelp-base.h \ yelp-bookmarks.c yelp-bookmarks.h \ - yelp-db-pager.c yelp-db-pager.h \ - yelp-db-print-pager.c yelp-db-print-pager.h \ yelp-debug.c yelp-debug.h \ yelp-error.c yelp-error.h \ yelp-gecko-utils.cpp yelp-gecko-utils.h \ yelp-html.cpp yelp-html.h \ yelp-io-channel.c yelp-io-channel.h \ - yelp-pager.c yelp-pager.h \ yelp-settings.c yelp-settings.h \ - yelp-toc-pager.c yelp-toc-pager.h \ yelp-utils.c yelp-utils.h \ yelp-window.c yelp-window.h \ - yelp-xslt-pager.c yelp-xslt-pager.h \ yelp-marshal.c yelp-marshal.h \ yelp-main.c \ yelp-print.c yelp-print.h \ - yelp-gecko-services.h yelp-gecko-services.cpp - -if ENABLE_MAN -yelp_SOURCES += \ - yelp-man-parser.c yelp-man-parser.h \ - yelp-man-pager.c yelp-man-pager.h -endif - -if ENABLE_INFO -yelp_SOURCES += \ - yelp-info-pager.c yelp-info-pager.h \ - yelp-info-parser.c yelp-info-parser.h -endif - -if ENABLE_SEARCH -yelp_SOURCES += \ - gtkentryaction.c gtkentryaction.h \ - yelp-search-pager.c yelp-search-pager.h -endif + yelp-page.c yelp-page.h \ + yelp-transform.c yelp-transform.h \ + yelp-gecko-services.h yelp-gecko-services.cpp \ + yelp-document.h yelp-document.c \ + yelp-toc.h yelp-toc.c + +#if ENABLE_MAN +#yelp_SOURCES += \ +# yelp-man-parser.c yelp-man-parser.h \ +# yelp-man-pager.c yelp-man-pager.h +#endif + +#if ENABLE_INFO +#yelp_SOURCES += \ +# yelp-info-pager.c yelp-info-pager.h \ +# yelp-info-parser.c yelp-info-parser.h +#endif + +#if ENABLE_SEARCH +#yelp_SOURCES += \ +# gtkentryaction.c gtkentryaction.h \ +# yelp-search-pager.c yelp-search-pager.h +#endif YELP_DEFINES = \ -DG_LOG_DOMAIN=\"Yelp\" \ @@ -81,13 +80,15 @@ yelp_CPPFLAGS = \ yelp_CFLAGS = \ $(YELP_CFLAGS) \ $(YELP_SEARCH_CFLAGS) \ - $(AM_CFLAGS) + $(AM_CFLAGS) \ + -DDON_UTIL yelp_CXXFLAGS = \ $(YELP_CFLAGS) \ $(YELP_SEARCH_CFLAGS) \ $(MOZILLA_COMPONENT_CFLAGS) \ - $(AM_CXXFLAGS) + $(AM_CXXFLAGS) \ + -DDON_UTIL yelp_LDADD = \ $(YELP_LIBS) \ diff --git a/src/yelp-base.c b/src/yelp-base.c index 6761e969..a755eb81 100644 --- a/src/yelp-base.c +++ b/src/yelp-base.c @@ -32,8 +32,8 @@ #include "yelp-window.h" #include "yelp-settings.h" -#include "yelp-pager.h" -#include "yelp-toc-pager.h" +//#include "yelp-pager.h" +/*#include "yelp-toc-pager.h"*/ #include "yelp-base.h" #include "yelp-bookmarks.h" #include "server-bindings.h" @@ -127,6 +127,7 @@ server_new_window (YelpBase *base, gchar *url, gchar *timestamp, gboolean server_get_url_list (YelpBase *server, gchar **urls, GError **error) { +#if 0 gint len, i; GSList *node; YelpDocInfo *doc_info; @@ -158,6 +159,7 @@ server_get_url_list (YelpBase *server, gchar **urls, GError **error) g_free (uri); } return TRUE; +#endif } static void @@ -200,7 +202,7 @@ yelp_base_new (gboolean priv) if (!priv) yelp_base_register_dbus (base); base->priv->private_session = priv; - yelp_toc_pager_init (); + //yelp_toc_pager_init (); return base; } diff --git a/src/yelp-toc.c b/src/yelp-toc.c index 8441502b..d437af5d 100644 --- a/src/yelp-toc.c +++ b/src/yelp-toc.c @@ -83,6 +83,8 @@ struct _YelpTocPriv { }; +static YelpDocument *toc_doc = NULL; + static void toc_class_init (YelpTocClass *klass); static void toc_init (YelpToc *toc); static void toc_try_dispose (GObject *object); @@ -212,12 +214,25 @@ toc_dispose (GObject *object) YelpDocument * yelp_toc_new (void) { - YelpToc *toc; debug_print (DB_FUNCTION, "entering\n"); - toc = (YelpToc *) g_object_new (YELP_TYPE_TOC, NULL); + if (toc_doc == NULL) { + toc_doc = (YelpToc *) g_object_new (YELP_TYPE_TOC, NULL); + } + + return (YelpDocument *) toc_doc; +} + +YelpDocument * +yelp_toc_get (void) +{ + debug_print (DB_FUNCTION, "entering\n"); + + if (toc_doc == NULL) { + toc_doc = (YelpToc *) g_object_new (YELP_TYPE_TOC, NULL); + } - return (YelpDocument *) toc; + return (YelpDocument *) toc_doc; } diff --git a/src/yelp-toc.h b/src/yelp-toc.h index 5dc457cb..83b6e919 100644 --- a/src/yelp-toc.h +++ b/src/yelp-toc.h @@ -49,5 +49,6 @@ struct _YelpTocClass { GType yelp_toc_get_type (void); YelpDocument * yelp_toc_new (void); +YelpDocument * yelp_toc_get (void); #endif /* __YELP_TOC_H__ */ diff --git a/src/yelp-utils.c b/src/yelp-utils.c index 230607f8..7c1cd1cd 100644 --- a/src/yelp-utils.c +++ b/src/yelp-utils.c @@ -1056,7 +1056,7 @@ YelpSpoonType resolve_process_ghelp (char *uri, gchar **result) { SpoonReg *reg = spoon_find_from_ghelp (&uri[6]); - YelpSpoonType type = YELP_TYPE_ERROR; + YelpSpoonType type = YELP_SPOON_TYPE_ERROR; if (reg) { gchar *mime = NULL; @@ -1074,10 +1074,10 @@ resolve_process_ghelp (char *uri, gchar **result) if (g_str_equal (mime, "text/xml") || g_str_equal (mime, "application/docbook+xml") || g_str_equal (mime, "application/xml")) - type = YELP_TYPE_DOC; + type = YELP_SPOON_TYPE_DOC; else if (g_str_equal (mime, "text/html") || g_str_equal (mime, "application/xhtml+xml")) - type = YELP_TYPE_HTML; + type = YELP_SPOON_TYPE_HTML; } @@ -1137,43 +1137,43 @@ YelpSpoonType resolve_full_file (const gchar *path) { gchar *mime_type; - YelpSpoonType type = YELP_TYPE_ERROR; + YelpSpoonType type = YELP_SPOON_TYPE_ERROR; if (!g_file_test (path, G_FILE_TEST_EXISTS)) { - return YELP_TYPE_ERROR; + return YELP_SPOON_TYPE_ERROR; } mime_type = gnome_vfs_get_mime_type (path); if (mime_type == NULL) - return YELP_TYPE_ERROR; + return YELP_SPOON_TYPE_ERROR; if (g_str_equal (mime_type, "text/xml") || g_str_equal (mime_type, "application/docbook+xml") || g_str_equal (mime_type, "application/xml")) - type = YELP_TYPE_DOC; + type = YELP_SPOON_TYPE_DOC; else if (g_str_equal (mime_type, "text/html") || g_str_equal (mime_type, "application/xhtml+xml")) - type = YELP_TYPE_HTML; + type = YELP_SPOON_TYPE_HTML; /* No distinction between HTML and XHTML now. They're handled the same way */ else if (g_str_equal (mime_type, "application/x-gzip")) { if (g_str_has_suffix (path, ".info.gz")) { - type = YELP_TYPE_INFO; + type = YELP_SPOON_TYPE_INFO; } else if (resolve_is_man_path (path, "gz")) { - type = YELP_TYPE_MAN; + type = YELP_SPOON_TYPE_MAN; } } else if (g_str_equal (mime_type, "application/x-bzip")) { if (g_str_has_suffix (path, ".info.bz2")) { - type = YELP_TYPE_INFO; + type = YELP_SPOON_TYPE_INFO; } else if (resolve_is_man_path (path, "bz2")) { - type = YELP_TYPE_MAN; + type = YELP_SPOON_TYPE_MAN; } } else if (g_str_equal (mime_type, "text/plain")) { if (g_str_has_suffix (path, ".info")) { - type = YELP_TYPE_INFO; + type = YELP_SPOON_TYPE_INFO; } else if (resolve_is_man_path (path, NULL)) { - type = YELP_TYPE_MAN; + type = YELP_SPOON_TYPE_MAN; } } else { - type = YELP_TYPE_EXTERNAL; + type = YELP_SPOON_TYPE_EXTERNAL; } g_free (mime_type); @@ -1229,16 +1229,16 @@ resolve_man_page (const gchar *name, gchar **result, gchar **section) if (entry) { *result = strdup (entry->path); *section = strdup (entry->section); - return YELP_TYPE_MAN; + return YELP_SPOON_TYPE_MAN; } else if (repeat) { entry = spoon_man_find_from_name (name, NULL); if (entry) { *result = strdup (entry->path); *section = strdup (entry->section); - return YELP_TYPE_MAN; + return YELP_SPOON_TYPE_MAN; } } - return YELP_TYPE_ERROR; + return YELP_SPOON_TYPE_ERROR; } @@ -1254,7 +1254,7 @@ resolve_remove_section (const gchar *uri, const gchar *sect) YelpSpoonType yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) { - YelpSpoonType ret = YELP_TYPE_ERROR; + YelpSpoonType ret = YELP_SPOON_TYPE_ERROR; gchar *intern_section = NULL; gchar *intern_uri = NULL; g_assert (result != NULL); @@ -1281,7 +1281,7 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) } } else if (!strncmp (uri, "man:", 4)) { ret = resolve_man_page (&uri[4], result, section); - if (ret == YELP_TYPE_ERROR) { + if (ret == YELP_SPOON_TYPE_ERROR) { *result = NULL; *section = NULL; } @@ -1293,6 +1293,13 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) gchar *info_sect = intern_section; gboolean free_stuff = FALSE; SpoonInfoEntry *entry = NULL; + + if (g_str_equal (&uri[5], "dir")) { + *section = g_strdup ("info"); + *result = NULL; + ret = YELP_SPOON_TYPE_TOC; + return ret; + } if (!intern_section) { gchar *lbrace = NULL; @@ -1312,7 +1319,7 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) entry = spoon_info_find_from_uri (info_name, info_sect); if (entry) { - ret = YELP_TYPE_INFO; + ret = YELP_SPOON_TYPE_INFO; if (entry->section) *section = g_strdup (entry->section); else @@ -1321,7 +1328,7 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) } else { ret = resolve_man_page (&uri[5], result, section); if (!ret) { - ret = YELP_TYPE_ERROR; + ret = YELP_SPOON_TYPE_ERROR; *section = NULL; *result = NULL; } @@ -1332,11 +1339,11 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) } } else if (!strncmp (uri, "file:", 5)) { ret = resolve_full_file (&intern_uri[5]); - if (ret == YELP_TYPE_EXTERNAL) { + if (ret == YELP_SPOON_TYPE_EXTERNAL) { *section = NULL; *result = g_strdup (uri); } - else if (ret == YELP_TYPE_ERROR) { + else if (ret == YELP_SPOON_TYPE_ERROR) { *section = NULL; *result = NULL; } else { @@ -1345,23 +1352,27 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) } /* full file path. Ensure file exists and determine type */ } else if (!strncmp (uri, "x-yelp-toc:", 11)) { - ret = YELP_TYPE_TOC; - *section = intern_section; + ret = YELP_SPOON_TYPE_TOC; + if (strlen (uri) > 11) { + *section = g_strdup (&uri[11]); + } else { + *section = g_strdup("index"); + } *result = NULL; /* 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; - ret = YELP_TYPE_SEARCH; + ret = YELP_SPOON_TYPE_SEARCH; } else if (g_file_test (intern_uri, G_FILE_TEST_EXISTS)) { /* Full path */ ret = resolve_full_file (intern_uri); - if (ret == YELP_TYPE_EXTERNAL) { + if (ret == YELP_SPOON_TYPE_EXTERNAL) { *section = NULL; *result = g_strdup (uri); } - else if (ret == YELP_TYPE_ERROR) { + else if (ret == YELP_SPOON_TYPE_ERROR) { *section = NULL; *result = NULL; } else { @@ -1372,14 +1383,14 @@ yelp_uri_resolve (gchar *uri, gchar **result, gchar **section) /* Quite probable it was supposed to be ours, but * the file doesn't exist. Hence, we should bin it */ - ret = YELP_TYPE_ERROR; + ret = YELP_SPOON_TYPE_ERROR; *result = NULL; *section = NULL; } else { /* We really don't care what it is. It's not ours. Let * someone else handle it */ - ret = YELP_TYPE_EXTERNAL; + ret = YELP_SPOON_TYPE_EXTERNAL; *result = g_strdup (uri); *section = NULL; } diff --git a/src/yelp-utils.h b/src/yelp-utils.h index 3290ea4c..88c05333 100644 --- a/src/yelp-utils.h +++ b/src/yelp-utils.h @@ -115,15 +115,15 @@ gchar ** yelp_get_man_paths (void); #else typedef enum { - YELP_TYPE_DOC = 0, - YELP_TYPE_MAN, - YELP_TYPE_INFO, - YELP_TYPE_HTML, - YELP_TYPE_TOC, - YELP_TYPE_SEARCH, - YELP_TYPE_NOT_FOUND, - YELP_TYPE_EXTERNAL, - YELP_TYPE_ERROR + YELP_SPOON_TYPE_DOC = 0, + YELP_SPOON_TYPE_MAN, + YELP_SPOON_TYPE_INFO, + YELP_SPOON_TYPE_HTML, + YELP_SPOON_TYPE_TOC, + YELP_SPOON_TYPE_SEARCH, + YELP_SPOON_TYPE_NOT_FOUND, + YELP_SPOON_TYPE_EXTERNAL, + YELP_SPOON_TYPE_ERROR } YelpSpoonType; diff --git a/src/yelp-window.c b/src/yelp-window.c index de10350d..fc34b9a0 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -37,18 +37,23 @@ #include <libgnome/gnome-url.h> #include "yelp-bookmarks.h" -#include "yelp-db-pager.h" +#include "yelp-utils.h" +/*#include "yelp-db-pager.h" #include "yelp-db-print-pager.h" #include "yelp-error.h" +*/ #include "yelp-html.h" -#include "yelp-pager.h" +/* +#include "yelp-pager.h"*/ #include "yelp-settings.h" -#include "yelp-toc-pager.h" +//#include "yelp-toc-pager.h" +#include "yelp-toc.h" #include "yelp-window.h" #include "yelp-print.h" #include "yelp-debug.h" -#ifdef ENABLE_MAN + +/*#ifdef ENABLE_MAN #include "yelp-man-pager.h" #endif #ifdef ENABLE_INFO @@ -57,7 +62,7 @@ #ifdef ENABLE_SEARCH #include "yelp-search-pager.h" #include "gtkentryaction.h" -#endif +#endif*/ #define YELP_CONFIG_WIDTH "/yelp/Geometry/width" #define YELP_CONFIG_HEIGHT "/yelp/Geometry/height" @@ -72,7 +77,7 @@ typedef struct { } YelpLoadData; typedef struct { - YelpDocInfo *doc_info; + YelpDocument *doc; gchar *frag_id; GtkWidget *menu_entry; @@ -94,15 +99,15 @@ static void window_populate_find (YelpWindow *window, GtkWidget *find_bar); static void window_set_sections (YelpWindow *window, GtkTreeModel *sections); -static void window_do_load (YelpWindow *window, +/*static void window_do_load (YelpWindow *window, YelpDocInfo *doc_info, - gchar *frag_id); -static gboolean window_do_load_pager (YelpWindow *window, + gchar *frag_id);*/ +/*static gboolean window_do_load_pager (YelpWindow *window, YelpDocInfo *doc_info, gchar *frag_id); static gboolean window_do_load_html (YelpWindow *window, YelpDocInfo *doc_info, - gchar *frag_id); + gchar *frag_id);*/ static void window_set_loading (YelpWindow *window); static void window_handle_page (YelpWindow *window, YelpPage *page); @@ -114,7 +119,7 @@ static gboolean window_configure_cb (GtkWidget *widget, gpointer data); /** Pager Callbacks **/ -static void pager_start_cb (YelpPager *pager, +/*static void pager_start_cb (YelpPager *pager, gpointer user_data); static void pager_page_cb (YelpPager *pager, gchar *page_id, @@ -124,7 +129,7 @@ static void pager_error_cb (YelpPager *pager, static void pager_cancel_cb (YelpPager *pager, gpointer user_data); static void pager_finish_cb (YelpPager *pager, - gpointer user_data); +gpointer user_data);*/ /** Gecko Callbacks **/ static void html_uri_selected_cb (YelpHtml *html, @@ -162,8 +167,8 @@ static void window_add_widget (GtkUIManager *ui_manager, GtkWidget *vbox); static void window_new_window_cb (GtkAction *action, YelpWindow *window); static void window_about_document_cb (GtkAction *action, YelpWindow *window); -static void window_print_document_cb (GtkAction *action, YelpWindow *window); -static void window_print_page_cb (GtkAction *action, YelpWindow *window); +/*static void window_print_document_cb (GtkAction *action, YelpWindow *window); + static void window_print_page_cb (GtkAction *action, YelpWindow *window);*/ static void window_open_location_cb (GtkAction *action, YelpWindow *window); static void window_close_window_cb (GtkAction *action, YelpWindow *window); static void window_copy_cb (GtkAction *action, YelpWindow *window); @@ -266,7 +271,7 @@ struct _YelpWindowPriv { gchar *uri; /* Location Information */ - YelpDocInfo *current_doc; + /*YelpDocInfo *current_doc;*/ gchar *current_frag; GSList *history_back; GSList *history_forward; @@ -325,7 +330,7 @@ static const GtkActionEntry entries[] = { "<Control>N", NULL, G_CALLBACK (window_new_window_cb) }, - { "PrintDocument", NULL, + /*{ "PrintDocument", NULL, N_("Print This Document"), NULL, NULL, @@ -334,7 +339,7 @@ static const GtkActionEntry entries[] = { N_("Print This Page"), NULL, NULL, - G_CALLBACK (window_print_page_cb) }, + G_CALLBACK (window_print_page_cb) },*/ { "AboutDocument", NULL, N_("About This Document"), NULL, @@ -537,8 +542,8 @@ window_finalize (GObject *object) g_free (priv->find_string); - if (priv->current_doc) - yelp_doc_info_unref (priv->current_doc); + /*if (priv->current_doc) + yelp_doc_info_unref (priv->current_doc);*/ g_free (priv->current_frag); /* FIXME there are many more things to free */ @@ -580,12 +585,12 @@ history_push_back (YelpWindow *window) gchar *title; g_return_if_fail (YELP_IS_WINDOW (window)); - g_return_if_fail (window->priv->current_doc != NULL); + /*g_return_if_fail (window->priv->current_doc != NULL);*/ priv = window->priv; entry = g_new0 (YelpHistoryEntry, 1); - entry->doc_info = yelp_doc_info_ref (priv->current_doc); + /*entry->doc_info = yelp_doc_info_ref (priv->current_doc);*/ entry->frag_id = g_strdup (priv->current_frag); /* page_title, frag_title */ @@ -626,12 +631,12 @@ history_push_forward (YelpWindow *window) gchar *title; g_return_if_fail (YELP_IS_WINDOW (window)); - g_return_if_fail (window->priv->current_doc != NULL); + /*g_return_if_fail (window->priv->current_doc != NULL);*/ priv = window->priv; entry = g_new0 (YelpHistoryEntry, 1); - entry->doc_info = yelp_doc_info_ref (priv->current_doc); + /*entry->doc_info = yelp_doc_info_ref (priv->current_doc);*/ entry->frag_id = g_strdup (priv->current_frag); /* page_title, frag_title */ @@ -698,17 +703,17 @@ history_step_back (YelpWindow *window) priv = window->priv; entry = history_pop_back (window); - if (priv->current_doc) { + /*if (priv->current_doc) { yelp_doc_info_unref (priv->current_doc); priv->current_doc = NULL; - } + }*/ if (priv->current_frag) { g_free (priv->current_frag); priv->current_frag = NULL; } if (entry) { - priv->current_doc = yelp_doc_info_ref (entry->doc_info); + /*priv->current_doc = yelp_doc_info_ref (entry->doc_info);*/ priv->current_frag = g_strdup (entry->frag_id); history_entry_free (entry); } else { @@ -771,7 +776,7 @@ history_entry_free (YelpHistoryEntry *entry) { g_return_if_fail (entry != NULL); - yelp_doc_info_unref (entry->doc_info); + /*yelp_doc_info_unref (entry->doc_info);*/ g_free (entry->frag_id); g_free (entry->page_title); g_free (entry->frag_title); @@ -821,15 +826,15 @@ history_back_to (GtkMenuItem *menuitem, YelpHistoryEntry *entry) latest->menu_entry = NULL; } - if (priv->current_doc) - yelp_doc_info_unref (priv->current_doc); + /*if (priv->current_doc) + yelp_doc_info_unref (priv->current_doc);*/ if (priv->current_frag) g_free (priv->current_frag); - priv->current_doc = yelp_doc_info_ref (entry->doc_info); + /*priv->current_doc = yelp_doc_info_ref (entry->doc_info);*/ priv->current_frag = g_strdup (entry->frag_id); - window_do_load (window, entry->doc_info, entry->frag_id); + /*window_do_load (window, entry->doc_info, entry->frag_id);*/ } @@ -870,15 +875,15 @@ history_forward_to (GtkMenuItem *menuitem, YelpHistoryEntry *entry) latest->menu_entry = NULL; } - if (priv->current_doc) - yelp_doc_info_unref (priv->current_doc); + /*if (priv->current_doc) + yelp_doc_info_unref (priv->current_doc);*/ if (priv->current_frag) g_free (priv->current_frag); - priv->current_doc = yelp_doc_info_ref (entry->doc_info); + /*priv->current_doc = yelp_doc_info_ref (entry->doc_info);*/ priv->current_frag = g_strdup (entry->frag_id); - window_do_load (window, entry->doc_info, entry->frag_id); + /*window_do_load (window, entry->doc_info, entry->frag_id);*/ } @@ -901,17 +906,144 @@ yelp_window_new (GNode *doc_tree, GList *index) return GTK_WIDGET (g_object_new (YELP_TYPE_WINDOW, NULL)); } +static void +document_func (YelpDocument *document, + YelpDocumentSignal signal, + gint req_id, + gpointer *func_data, + YelpHtml *html) +{ + gchar contents[BUFFER_SIZE]; + gsize read; + YelpPage *page; + YelpError *error; + switch (signal) { + case YELP_DOCUMENT_SIGNAL_PAGE: + yelp_html_set_base_uri (html, "file:///tmp/blah.html"); + yelp_html_open_stream (html, "application/xhtml+xml"); + page = (YelpPage *) func_data; + do { + yelp_page_read (page, contents, BUFFER_SIZE, &read, NULL); + 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_); + yelp_page_free (page); + break; + case YELP_DOCUMENT_SIGNAL_TITLE: + printf ("TITLE: %s (%i)\n", (gchar *) func_data, req_id); + g_free (func_data); + break; + case YELP_DOCUMENT_SIGNAL_ERROR: + error = (YelpError *) func_data; + printf ("ERROR: %s\n", yelp_error_get_title (error)); + printf (" %s\n", yelp_error_get_message (error)); + yelp_error_free (error); + break; + } +} + + void yelp_window_load (YelpWindow *window, const gchar *uri) { YelpWindowPriv *priv; - YelpDocInfo *doc_info; - gchar *frag_id; + //YelpDocInfo *doc_info; + gchar *frag_id = NULL; GtkAction *action; - gchar *real_uri; + gchar *real_uri = NULL; + YelpSpoonType type = YELP_SPOON_TYPE_ERROR; + YelpDocument *doc = NULL; + + g_return_if_fail (YELP_IS_WINDOW (window)); - if (g_str_has_prefix (uri, "info:") && g_str_has_suffix (uri, "dir")) { + + type = yelp_uri_resolve (uri, &real_uri, &frag_id); + + switch (type) { + case YELP_SPOON_TYPE_TOC: + doc = yelp_toc_get (); + } + + if (doc) { + yelp_document_get_page (doc, frag_id, document_func, (void *) window->priv->html_view); + } + + /* + case YELP_DOC_TYPE_MAN: +#ifdef ENABLE_MAN + window_do_load_pager (window, doc_info, frag_id); + break; +#else + g_set_error (&error, YELP_ERROR, YELP_ERROR_FORMAT, + _("Man pages are not supported in this version.")); + break; +#endif + + case YELP_DOC_TYPE_INFO: +#ifdef ENABLE_INFO + window_do_load_pager (window, doc_info, frag_id); + break; +#else + g_set_error (&error, YELP_ERROR, YELP_ERROR_FORMAT, + _("GNU info pages are not supported in this version")); + break; +#endif + + case YELP_DOC_TYPE_DOCBOOK_XML: + g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL); + g_object_set (G_OBJECT (about), "sensitive", TRUE, NULL); + case YELP_DOC_TYPE_TOC: + window_do_load_pager (window, doc_info, frag_id); + break; + case YELP_DOC_TYPE_SEARCH: +#ifdef ENABLE_SEARCH + window_do_load_pager (window, doc_info, frag_id); + break; +#else + g_set_error (&error, YELP_ERROR, YELP_ERROR_FORMAT, + _("Search is not supported in this version.")); + break; +#endif + case YELP_DOC_TYPE_DOCBOOK_SGML: + g_set_error (&error, YELP_ERROR, YELP_ERROR_FORMAT, + _("SGML documents are no longer supported. Please ask " + "the author of the document to convert to XML.")); + break; + case YELP_DOC_TYPE_HTML: + case YELP_DOC_TYPE_XHTML: + window_do_load_html (window, doc_info, frag_id); + break; + case YELP_DOC_TYPE_EXTERNAL: + history_step_back (window); + uri = yelp_doc_info_get_uri (doc_info, NULL, YELP_URI_TYPE_ANY); + gnome_url_show (uri, &error); + g_free (uri); + break; + case YELP_DOC_TYPE_ERROR: + default: + uri = yelp_doc_info_get_uri (doc_info, NULL, YELP_URI_TYPE_NO_FILE); + if (!uri) + uri = yelp_doc_info_get_uri (doc_info, NULL, YELP_URI_TYPE_FILE); + if (uri) + g_set_error (&error, YELP_ERROR, YELP_ERROR_NO_DOC, + _("The Uniform Resource Identifier ā%sā is invalid " + "or does not point to an actual file."), + uri); + else + g_set_error (&error, YELP_ERROR, YELP_ERROR_NO_DOC, + _("The Uniform Resource Identifier for the file is " + "invalid.")); + g_free (uri); + break; + */ + + + + /*if (g_str_has_prefix (uri, "info:") && g_str_has_suffix (uri, "dir")) { real_uri = g_strdup ("x-yelp-toc:#Info"); } else { real_uri = g_strdup (uri); @@ -973,16 +1105,16 @@ yelp_window_load (YelpWindow *window, const gchar *uri) if (priv->current_frag != frag_id) g_free (frag_id); - g_free (real_uri); + g_free (real_uri);*/ } -YelpDocInfo * +/*YelpDocInfo * yelp_window_get_doc_info (YelpWindow *window) { g_return_val_if_fail (YELP_IS_WINDOW (window), NULL); return window->priv->current_doc; -} +}*/ GtkUIManager * yelp_window_get_ui_manager (YelpWindow *window) @@ -992,7 +1124,7 @@ yelp_window_get_ui_manager (YelpWindow *window) return window->priv->ui_manager; } -static void +/*static void window_do_load (YelpWindow *window, YelpDocInfo *doc_info, gchar *frag_id) @@ -1090,7 +1222,7 @@ window_do_load (YelpWindow *window, window_find_buttons_set_sensitive (window, TRUE, TRUE); } - +*/ /******************************************************************************/ static void @@ -1115,7 +1247,7 @@ window_error (YelpWindow *window, GError *error, gboolean pop) if (action) g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL); - dialog = gtk_message_dialog_new + /*dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, @@ -1124,7 +1256,7 @@ window_error (YelpWindow *window, GError *error, gboolean pop) gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", yelp_error_get_secondary (error)); - gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_dialog_run (GTK_DIALOG (dialog));*/ g_error_free (error); gtk_widget_destroy (dialog); @@ -1217,7 +1349,7 @@ window_populate (YelpWindow *window) gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (f_proxy), priv->forward_menu); -#ifdef ENABLE_SEARCH +#if 0//def ENABLE_SEARCH action = gtk_entry_action_new ("Search", _("_Search:"), _("Search for other documentation"), @@ -1243,7 +1375,7 @@ window_populate (YelpWindow *window) window_error (window, error, FALSE); } -#ifdef ENABLE_SEARCH +#if 0//def ENABLE_SEARCH if (!gtk_ui_manager_add_ui_from_file (priv->ui_manager, DATADIR "/yelp/ui/yelp-search-ui.xml", &error)) { @@ -1296,11 +1428,11 @@ window_populate (YelpWindow *window) g_object_set (priv->side_sects, "headers-visible", FALSE, NULL); - gtk_tree_view_insert_column_with_attributes + /*gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->side_sects), -1, NULL, gtk_cell_renderer_text_new (), "text", YELP_PAGER_COLUMN_TITLE, - NULL); + NULL);*/ /* DISABLE FOR NOW gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (priv->side_sects), @@ -1455,6 +1587,7 @@ window_set_sections (YelpWindow *window, gtk_widget_hide (priv->side_sw); } +#if 0 static gboolean window_do_load_pager (YelpWindow *window, YelpDocInfo *doc_info, @@ -1510,7 +1643,7 @@ window_do_load_pager (YelpWindow *window, pager = YELP_PAGER (yelp_toc_pager_get ()); break; case YELP_DOC_TYPE_SEARCH: -#ifdef ENABLE_SEARCH +#if 0//def ENABLE_SEARCH pager = YELP_PAGER (yelp_search_pager_get (doc_info)); break; #else @@ -1717,6 +1850,7 @@ window_do_load_html (YelpWindow *window, return handled; } +#endif static void window_set_loading (YelpWindow *window) @@ -1766,6 +1900,7 @@ static void window_handle_page (YelpWindow *window, YelpPage *page) { +#if 0 YelpWindowPriv *priv; YelpPager *pager; GtkAction *action; @@ -1879,11 +2014,13 @@ window_handle_page (YelpWindow *window, */ g_free (uri); +#endif } static void window_disconnect (YelpWindow *window) { +#if 0 YelpWindowPriv *priv; YelpPager *pager = NULL; @@ -1934,6 +2071,7 @@ window_disconnect (YelpWindow *window) g_source_remove (priv->idle_write); priv->idle_write = 0; } +#endif } /** Window Callbacks **********************************************************/ @@ -1953,7 +2091,7 @@ window_configure_cb (GtkWidget *widget, } /** Pager Callbacks ***********************************************************/ - +#if 0 static void pager_start_cb (YelpPager *pager, gpointer user_data) @@ -2070,7 +2208,7 @@ pager_finish_cb (YelpPager *pager, /* FIXME: Remove the URI from the history and go back */ } - +#endif /** Gecko Callbacks ***********************************************************/ static void @@ -2093,6 +2231,7 @@ static gboolean html_frame_selected_cb (YelpHtml *html, gchar *uri, gboolean handled, gpointer user_data) { +#if 0 YelpWindow *window = YELP_WINDOW (user_data); gboolean handle; YelpDocInfo *info = yelp_doc_info_get (uri, FALSE); @@ -2111,6 +2250,7 @@ html_frame_selected_cb (YelpHtml *html, gchar *uri, gboolean handled, yelp_window_load (window, uri); } return TRUE; +#endif } static void @@ -2153,6 +2293,7 @@ static void tree_selection_changed_cb (GtkTreeSelection *selection, YelpWindow *window) { +#if 0 YelpWindowPriv *priv; GtkTreeModel *model; GtkTreeIter iter; @@ -2171,6 +2312,7 @@ tree_selection_changed_cb (GtkTreeSelection *selection, yelp_window_load (window, uri); g_free (uri); } +#endif } static void @@ -2181,6 +2323,7 @@ tree_drag_data_get_cb (GtkWidget *widget, guint32 time, YelpWindow *window) { +#if 0 YelpWindowPriv *priv; GtkTreeSelection *tree_selection; GtkTreeModel *model; @@ -2219,6 +2362,7 @@ tree_drag_data_get_cb (GtkWidget *widget, } g_free (uri); +#endif } void @@ -2252,18 +2396,20 @@ window_new_window_cb (GtkAction *action, YelpWindow *window) g_signal_emit (window, signals[NEW_WINDOW_REQUESTED], 0, NULL); } + typedef struct { gulong page_handler; gulong error_handler; gulong cancel_handler; gulong finish_handler; - YelpPager *pager; + /*YelpPager *pager;*/ YelpWindow *window; } PrintStruct; static void print_disconnect (PrintStruct *data) { +#if 0 debug_print (DB_FUNCTION, "entering\n"); if (data->page_handler) { g_signal_handler_disconnect (data->pager, @@ -2286,8 +2432,10 @@ print_disconnect (PrintStruct *data) data->finish_handler = 0; } g_free (data); +#endif } +#if 0 static void print_pager_page_cb (YelpPager *pager, gchar *page_id, @@ -2499,10 +2647,12 @@ window_print_page_cb (GtkAction *action, YelpWindow *window) g_free (uri); yelp_print_run (window, html, gtk_win, vbox); } +#endif static void window_about_document_cb (GtkAction *action, YelpWindow *window) { +#if 0 YelpWindowPriv *priv; gchar *uri; @@ -2515,6 +2665,7 @@ window_about_document_cb (GtkAction *action, YelpWindow *window) YELP_URI_TYPE_ANY); yelp_window_load (window, uri); g_free (uri); +#endif } static void @@ -2530,7 +2681,7 @@ window_open_location_cb (GtkAction *action, YelpWindow *window) priv = window->priv; - if (priv->current_doc) { + /*if (priv->current_doc) { uri = yelp_doc_info_get_uri (priv->current_doc, priv->current_frag, YELP_URI_TYPE_NO_FILE); @@ -2540,7 +2691,7 @@ window_open_location_cb (GtkAction *action, YelpWindow *window) YELP_URI_TYPE_FILE); } else { uri = NULL; - } + }*/ glade = glade_xml_new (DATADIR "/yelp/ui/yelp.glade", "location_dialog", @@ -2638,6 +2789,7 @@ window_preferences_cb (GtkAction *action, YelpWindow *window) static void window_reload_cb (GtkAction *action, YelpWindow *window) { +#if 0 YelpPager *pager; g_return_if_fail (YELP_IS_WINDOW (window)); @@ -2662,6 +2814,7 @@ window_reload_cb (GtkAction *action, YelpWindow *window) data->uri = uri; g_idle_add ((GSourceFunc) window_load_async, data); } +#endif } static void @@ -2695,15 +2848,15 @@ window_go_back_cb (GtkAction *action, YelpWindow *window) entry = history_pop_back (window); - if (priv->current_doc) - yelp_doc_info_unref (priv->current_doc); + /*if (priv->current_doc) + yelp_doc_info_unref (priv->current_doc);*/ if (priv->current_frag) g_free (priv->current_frag); - priv->current_doc = yelp_doc_info_ref (entry->doc_info); + /*priv->current_doc = yelp_doc_info_ref (entry->doc_info);*/ priv->current_frag = g_strdup (entry->frag_id); - window_do_load (window, entry->doc_info, entry->frag_id); + /*window_do_load (window, entry->doc_info, entry->frag_id);*/ history_entry_free (entry); } @@ -2723,15 +2876,15 @@ window_go_forward_cb (GtkAction *action, YelpWindow *window) entry = history_pop_forward (window); - if (priv->current_doc) - yelp_doc_info_unref (priv->current_doc); + /*if (priv->current_doc) + yelp_doc_info_unref (priv->current_doc);*/ if (priv->current_frag) g_free (priv->current_frag); - priv->current_doc = yelp_doc_info_ref (entry->doc_info); + /*priv->current_doc = yelp_doc_info_ref (entry->doc_info);*/ priv->current_frag = g_strdup (entry->frag_id); - window_do_load (window, entry->doc_info, entry->frag_id); + /*window_do_load (window, entry->doc_info, entry->frag_id);*/ history_entry_free (entry); } @@ -2747,6 +2900,7 @@ window_go_home_cb (GtkAction *action, YelpWindow *window) static void window_go_previous_cb (GtkAction *action, YelpWindow *window) { +#if 0 YelpWindowPriv *priv; gchar *base, *uri; @@ -2762,11 +2916,13 @@ window_go_previous_cb (GtkAction *action, YelpWindow *window) g_free (uri); g_free (base); +#endif } static void window_go_next_cb (GtkAction *action, YelpWindow *window) { +#if 0 YelpWindowPriv *priv; gchar *base, *uri; @@ -2782,11 +2938,13 @@ window_go_next_cb (GtkAction *action, YelpWindow *window) g_free (uri); g_free (base); +#endif } static void window_go_toc_cb (GtkAction *action, YelpWindow *window) { +#if 0 YelpWindowPriv *priv; gchar *base, *uri; @@ -2802,11 +2960,13 @@ window_go_toc_cb (GtkAction *action, YelpWindow *window) g_free (uri); g_free (base); +#endif } static void window_add_bookmark_cb (GtkAction *action, YelpWindow *window) { +#if 0 gchar *uri; YelpWindowPriv *priv = window->priv; @@ -2824,6 +2984,7 @@ window_add_bookmark_cb (GtkAction *action, YelpWindow *window) yelp_bookmarks_add (uri, window); g_free (uri); +#endif } static void window_copy_link_cb (GtkAction *action, YelpWindow *window) diff --git a/src/yelp-window.h b/src/yelp-window.h index 0f45fa3e..9fc7047f 100644 --- a/src/yelp-window.h +++ b/src/yelp-window.h @@ -25,6 +25,7 @@ #include <gtk/gtktreemodel.h> #include <gtk/gtkwindow.h> +#include <gtk/gtk.h> #include "yelp-base.h" #include "yelp-utils.h" @@ -61,7 +62,7 @@ GtkWidget * yelp_window_new (GNode *doc_tree, GList *index); void yelp_window_load (YelpWindow *window, const gchar *uri); -YelpDocInfo * yelp_window_get_doc_info (YelpWindow *window); +/*YelpDocInfo * yelp_window_get_doc_info (YelpWindow *window);*/ GtkUIManager * yelp_window_get_ui_manager (YelpWindow *window); #endif /* __YELP_WINDOW_H__ */ diff --git a/stylesheets/toc2html.xsl b/stylesheets/toc2html.xsl index 4aa7711a..26cb7727 100644 --- a/stylesheets/toc2html.xsl +++ b/stylesheets/toc2html.xsl @@ -237,7 +237,7 @@ <xsl:template mode="leftbar.mode" match="toc"> <xsl:param name="curid" select="0"/> <ul> - <xsl:for-each select="toc[.//doc[1]]"> + <xsl:for-each select="toc[.//doc[1] or @protected]"> <li class="toclist"> <xsl:choose> <xsl:when test="@id != $curid"> |