diff options
author | Brent Smith <bmsmith@src.gnome.org> | 2006-07-10 23:50:03 +0000 |
---|---|---|
committer | Brent Smith <bmsmith@src.gnome.org> | 2006-07-10 23:50:03 +0000 |
commit | 21481ce3def7d1dad6a0b7510c20d254b98b4afe (patch) | |
tree | 5e5052b885af2f7cb78961285abc31bfa6530aa5 | |
parent | 4fee9ec9162293fbc1ccb56b6672a91a4a91a17e (diff) | |
download | yelp-21481ce3def7d1dad6a0b7510c20d254b98b4afe.tar.gz |
- Restructure the table of contents to make most documentation accessible
* data/info.xml.in:
* data/man.xml.in:
* data/scrollkeeper.xml:
* data/toc.xml.in:
- Restructure the table of contents to make most documentation
accessible via a single click (except for man pages and info pages)
- Put descriptions for each section at the top in the right side
above the document listing
- Rename the top level category to 'Desktop' and include the
User guide, System Administration Guide, and Accessibility Guide
in this section
* src/yelp-pager.c: (yelp_pager_get_page_from_id):
* src/yelp-pager.h:
* src/yelp-toc-pager.c: (toc_pager_resolve_frag),
(toc_process_pending), (process_mandir_pending),
(process_info_pending), (process_read_menu), (process_cleanup):
* src/yelp-window.c: (window_do_load_pager), (pager_finish_cb):
Load each table of contents page on demand instead of
creating all pages at once.
* stylesheets/toc2html.xsl:
Maintain a list of categories on the left hand side in the
table of contents, that expands subcategories for the currently
selected category
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | data/info.xml.in | 1 | ||||
-rw-r--r-- | data/man.xml.in | 88 | ||||
-rw-r--r-- | data/scrollkeeper.xml | 28 | ||||
-rw-r--r-- | data/toc.xml.in | 120 | ||||
-rw-r--r-- | src/yelp-pager.c | 9 | ||||
-rw-r--r-- | src/yelp-pager.h | 2 | ||||
-rw-r--r-- | src/yelp-toc-pager.c | 158 | ||||
-rw-r--r-- | src/yelp-window.c | 25 | ||||
-rw-r--r-- | stylesheets/toc2html.xsl | 198 |
10 files changed, 488 insertions, 167 deletions
@@ -1,3 +1,29 @@ +2006-07-10 Brent Smith <gnome@nextreality.net> + + * data/info.xml.in: + * data/man.xml.in: + * data/scrollkeeper.xml: + * data/toc.xml.in: + - Restructure the table of contents to make most documentation + accessible via a single click (except for man pages and info pages) + - Put descriptions for each section at the top in the right side + above the document listing + - Rename the top level category to 'Desktop' and include the + User guide, System Administration Guide, and Accessibility Guide + in this section + * src/yelp-pager.c: (yelp_pager_get_page_from_id): + * src/yelp-pager.h: + * src/yelp-toc-pager.c: (toc_pager_resolve_frag), + (toc_process_pending), (process_mandir_pending), + (process_info_pending), (process_read_menu), (process_cleanup): + * src/yelp-window.c: (window_do_load_pager), (pager_finish_cb): + Load each table of contents page on demand instead of + creating all pages at once. + * stylesheets/toc2html.xsl: + Maintain a list of categories on the left hand side in the + table of contents, that expands subcategories for the currently + selected category + 2006-07-07 Wouter Bolsterlee <uws+gnome@xs4all.nl> * src/yelp-window.c: (tree_row_expand_cb): diff --git a/data/info.xml.in b/data/info.xml.in index de38a468..f22ccd1a 100644 --- a/data/info.xml.in +++ b/data/info.xml.in @@ -2,5 +2,6 @@ <?xml-stylesheet href="toc.xml.in.content/toc.css" type="text/css"?> <toc id="Info"> <_title>GNU Info Pages</_title> + <_description>Traditional command line help (info)</_description> </toc> diff --git a/data/man.xml.in b/data/man.xml.in index 15b0c38f..be883b80 100644 --- a/data/man.xml.in +++ b/data/man.xml.in @@ -2,87 +2,137 @@ <?xml-stylesheet href="toc.xml.in.content/toc.css" type="text/css"?> <toc id="Man"> <_title>Manual Pages</_title> + <_description>Traditional command line help (man)</_description> <toc id="Man-man1" sect="1 1p 1g 1t"> <_title>Applications</_title> + <_description>Sections 1, 1p, 1g and 1t</_description> <toc id="Man-man1x" sect="1x"> <_title>X11 Applications</_title> + <_description>Section 1x</_description> </toc> <toc id="Man-man1ssl" sect="1ssl"> <_title>OpenSSL Applications</_title> + <_description>Section 1ssl</_description> </toc> <toc id="Man-man1m" sect="1m"> <_title>Termcap Applications</_title> + <_description>Section 1m</_description> </toc> </toc> - <toc id="Man-development"> + <toc id="Man-man3" sect="3 3o 3t"> <_title>Development</_title> + <_description>Sections 3, 3o, and 3t</_description> + <toc id="Man-man3p" sect="3p"> + <_title>POSIX Functions</_title> + <_description>Section 3p</_description> + </toc> <toc id="Man-man0p" sect="0p"> <_title>POSIX Headers</_title> + <_description>Section 0p</_description> + </toc> + <toc id="Man-3blt" sect="3blt"> + <_title>BLT Functions</_title> + <_description>Section 3blt</_description> + </toc> + <toc id="Man-3nas" sect="3nas"> + <_title>Network Audio Sound Functions</_title> + <_description>Section 3nas</_description> + </toc> + <toc id="Man-3form" sect="3form 3menu"> + <_title>System V Form/Menu Functions</_title> + <_description>Sections 3form and 3menu</_description> + </toc> + <toc id="Man-3tiff" sect="3tiff"> + <_title>TIFF Functions</_title> + <_description>Section 3tiff</_description> + </toc> + <toc id="Man-3ssl" sect="3ssl"> + <_title>OpenSSL Functions</_title> + <_description>Section 3ssl</_description> + </toc> + <toc id="Man-3readline" sect="3readline"> + <_title>Readline Functions</_title> + <_description>Section 3readline</_description> + </toc> + <toc id="Man-3curses" sect="3ncurses 3curses"> + <_title>Curses Functions</_title> + <_description>Sections 3ncurses and 3curses</_description> + </toc> + <toc id="Man-man3f" sect="3f"> + <_title>FORTRAN Functions</_title> + <_description>Section 3f</_description> + </toc> + <toc id="Man-man3pm" sect="3pm 3perl"> + <_title>Perl Functions</_title> + <_description>Sections 3pm and 3perl</_description> + </toc> + <toc id="Man-man3qt" sect="3qt"> + <_title>Qt Functions</_title> + <_description>Section 3qt</_description> + </toc> + <toc id="Man-man3x" sect="3x 3X11"> + <_title>X11 Functions</_title> + <_description>Sections 3x and 3X11</_description> </toc> <toc id="Man-man2" sect="2"> <_title>System Calls</_title> - </toc> - <toc id="Man-man3" sect="3 3o 3t 3readline 3blt 3form 3ncurses 3menu 3curses 3ssl 3nas 3tiff"> - <_title>Library Functions</_title> - <toc id="Man-man3p" sect="3p"> - <_title>POSIX Functions</_title> - </toc> - <toc id="Man-man3f" sect="3f"> - <_title>FORTRAN Functions</_title> - </toc> - <toc id="Man-man3pm" sect="3pm 3perl"> - <_title>Perl Functions</_title> - </toc> - <toc id="Man-man3qt" sect="3qt"> - <_title>Qt Functions</_title> - </toc> - <toc id="Man-man3x" sect="3x 3X11"> - <_title>X11 Functions</_title> - </toc> + <_description>Section 2</_description> </toc> <toc id="Man-man9" sect="9"> <_title>Kernel Routines</_title> + <_description>Section 9</_description> </toc> </toc> <toc id="Man-man4" sect="4"> <_title>Hardware Devices</_title> + <_description>Section 4</_description> <toc id="Man-man4x" sect="4x"> <_title>X11 Devices</_title> + <_description>Section 4x</_description> </toc> </toc> <toc id="Man-man5" sect="5 5snmp"> <_title>Configuration Files</_title> + <_description>Section 5</_description> <toc id="Man-man5x" sect="5x"> <_title>X11 Configuration</_title> + <_description>Section 5x</_description> </toc> <toc id="Man-man5ssl" sect="5ssl"> <_title>OpenSSL Configuration</_title> + <_description>Section 5ssl</_description> </toc> </toc> <toc id="Man-man6" sect="6"> <_title>Games</_title> + <_description>Section 6</_description> <toc id="Man-man6x" sect="6x"> <_title>X11 Games</_title> + <_description>Section 6x</_description> </toc> </toc> <toc id="Man-man7" sect="7 7gcc"> <_title>Overviews</_title> + <_description>Sections 7 and 7gcc</_description> <toc id="Man-man7x" sect="7x"> <_title>X11 Overviews</_title> + <_description>Section 7x</_description> </toc> <toc id="Man-man7ssl" sect="7ssl"> <_title>OpenSSL Overviews</_title> + <_description>Section 7ssl</_description> </toc> </toc> <toc id="Man-man8" sect="8 8l"> <_title>System Administration</_title> + <_description>Sections 8 and 8l</_description> </toc> </toc> diff --git a/data/scrollkeeper.xml b/data/scrollkeeper.xml index 303a0fe4..51626517 100644 --- a/data/scrollkeeper.xml +++ b/data/scrollkeeper.xml @@ -1,11 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?><!-- -*- indent-tabs-mode: nil -*- --> <toc> - <toc id="Desktop"> + <toc id="index"> <subject category="GNOME"/> <subject category="GNOME|Core Desktop"/> <subject category="GNOME|Desktop"/> <subject category="GNOME|Desktop|User Guides"/> <subject category="GNOME|Other"/> + <subject category="GNOME|Settings"/> + <subject category="GNOME|Applications|Desktop Preferences"/> + <subject category="GNOME|Preferences"/> </toc> <toc id="DesktopApplets"> <subject category="GNOME|Applets"/> @@ -18,22 +21,12 @@ <subject category="GNOME|Applets|Network"/> <subject category="GNOME|Applets|Utility"/> </toc> - <toc id="DesktopAdministration"> - <subject category="GNOME|Settings"/> - </toc> - <toc id="DesktopPreferences"> - <subject category="GNOME|Applications|Desktop Preferences"/> - <subject category="GNOME|Preferences"/> - </toc> <toc id="KDE"> <subject category="KDE"/> <subject category="KDE|Settings"/> - </toc> - <toc id="Applications"> - <subject category="Applications"/> - <subject category="GNOME|Applications"/> <subject category="KDE|Applications"/> <subject category="KDE|Programs"/> + <subject category="KDE|Other"/> </toc> <toc id="ApplicationsAccessibility"> <subject category="GNOME|Accessibility"/> @@ -153,12 +146,6 @@ <subject category="Applications|Office|Other"/> <subject category="GNOME|Applications|Office"/> </toc> - <toc id="ApplicationsOther"> - <subject category="Applications|Security"/> - <subject category="Applications|Security|Cryptography"/> - <subject category="Applications|Security|Other"/> - <subject category="KDE|Other"/> - </toc> <toc id="ApplicationsProgramming"> <subject category="Applications|Text Editors"/> <subject category="Applications|Text Editors|CLI"/> @@ -224,6 +211,9 @@ <toc id="ApplicationsSystem"> <subject category="Applications|Utilities|Monitors"/> <subject category="Applications|Utilities|Terminals"/> + <subject category="Applications|Security"/> + <subject category="Applications|Security|Cryptography"/> + <subject category="Applications|Security|Other"/> <subject category="GNOME|Applications|System Tools"/> <subject category="GNOME|System"/> <subject category="GNOME|System Administration"/> @@ -240,6 +230,8 @@ <subject category="CDE"/> </toc> <toc id="Other"> + <subject category="Applications"/> + <subject category="GNOME|Applications"/> <subject category="General"/> <subject category="General|Licenses"/> <subject category="General|Linux"/> diff --git a/data/toc.xml.in b/data/toc.xml.in index fde203b9..04c8ea5d 100644 --- a/data/toc.xml.in +++ b/data/toc.xml.in @@ -1,69 +1,71 @@ <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="toc.xml.in.content/toc.css" type="text/css"?> <toc id="index"> - <_title>Help Topics</_title> + <_title>Desktop</_title> + <_description>Welcome to the GNOME Help Browser</_description> - <toc id="Desktop"> - <_title>Desktop</_title> - <toc id="DesktopApplets"> - <_title>Panel Applets</_title> - </toc> - <toc id="DesktopAdministration"> - <_title>Administration</_title> - </toc> - <toc id="DesktopPreferences"> - <_title>Preferences</_title> - </toc> - <toc id="KDE"> - <_title>KDE</_title> - </toc> + <toc id="ApplicationsAccessibility" icon="accessibility-directory"> + <_title>Accessibility</_title> + <_description>Applications that support assistive technologies</_description> </toc> - - <toc id="Applications"> - <_title>Applications</_title> - - <toc id="ApplicationsAccessibility" icon="accessibility-directory"> - <_title>Accessibility</_title> - </toc> - <toc id="ApplicationsAccessories" icon="gnome-util"> - <_title>Accessories</_title> - </toc> - <toc id="ApplicationsEducation"> - <_title>Education Applications</_title> - </toc> - <toc id="ApplicationsGames" icon="gnome-joystick"> - <_title>Games</_title> - </toc> - <toc id="ApplicationsGraphics" icon="gnome-graphics"> - <_title>Graphics</_title> - </toc> - <toc id="ApplicationsInternet" icon="gnome-globe"> - <_title>Internet</_title> - </toc> - <toc id="ApplicationsMultimedia" icon="gnome-multimedia"> - <_title>Sound & Vision</_title> - </toc> - <toc id="ApplicationsOffice" icon="gnome-applications"> - <_title>Office</_title> - </toc> - <toc id="ApplicationsOther" icon="gnome-other"> - <_title>Other</_title> - </toc> - <toc id="ApplicationsProgramming" icon="gnome-devel"> - <_title>Programming</_title> - </toc> - <toc id="ApplicationsScientific"> - <_title>Scientific</_title> - </toc> - <toc id="ApplicationsSystem" icon="gnome-system"> - <_title>System Tools</_title> - </toc> - <toc id="ApplicationsX"> - <_title>X Applications</_title> - </toc> + <toc id="ApplicationsAccessories" icon="gnome-util"> + <_title>Accessories</_title> + <_description>Utility applications</_description> + </toc> + <toc id="ApplicationsEducation"> + <_title>Education</_title> + <_description>Learning applications</_description> + </toc> + <toc id="ApplicationsGames" icon="gnome-joystick"> + <_title>Games</_title> + <_description>Applications for fun</_description> + </toc> + <toc id="ApplicationsGraphics" icon="gnome-graphics"> + <_title>Graphics</_title> + <_description>Applications for manipulating or viewing graphics</_description> + </toc> + <toc id="ApplicationsInternet" icon="gnome-globe"> + <_title>Internet</_title> + <_description>Applications related to the internet</_description> + </toc> + <toc id="KDE"> + <_title>KDE</_title> + <_description>Documents specific to the KDE Desktop Environment</_description> + </toc> + <toc id="ApplicationsOffice" icon="gnome-applications"> + <_title>Office</_title> + <_description>Applications for word processing and other office tasks</_description> + </toc> + <toc id="ApplicationsOther" icon="gnome-other"> + <_title>Other Applications</_title> + <_description>Variety of other applications</_description> + </toc> + <toc id="DesktopApplets"> + <_title>Panel Applets</_title> + <_description>Applications specific to the panel</_description> + </toc> + <toc id="ApplicationsProgramming" icon="gnome-devel"> + <_title>Programming</_title> + <_description>Applications related to software development</_description> + </toc> + <toc id="ApplicationsScientific"> + <_title>Scientific</_title> + <_description>Scientific Applications.</_description> + </toc> + <toc id="ApplicationsMultimedia" icon="gnome-multimedia"> + <_title>Sound & Vision</_title> + <_description>Applications related to multimedia</_description> + </toc> + <toc id="ApplicationsSystem" icon="gnome-system"> + <_title>System Tools</_title> + <_description>Utilities to manage your computer</_description> + </toc> + <toc id="ApplicationsX"> + <_title>X Applications</_title> + <_description>Applications related to X Windows</_description> </toc> - <toc id="Other"> <_title>Other Documentation</_title> + <_description>Miscellaneous documents</_description> </toc> </toc> diff --git a/src/yelp-pager.c b/src/yelp-pager.c index 62d78ebc..4b978fc7 100644 --- a/src/yelp-pager.c +++ b/src/yelp-pager.c @@ -355,6 +355,15 @@ yelp_pager_page_contains_frag (YelpPager *pager, } const YelpPage * +yelp_pager_get_page_from_id (YelpPager *pager, const gchar *page_id) +{ + if (page_id == NULL) + return NULL; + + return (const YelpPage *) g_hash_table_lookup (pager->priv->page_hash, page_id); +} + +const YelpPage * yelp_pager_get_page (YelpPager *pager, const gchar *frag_id) { YelpPage *page; diff --git a/src/yelp-pager.h b/src/yelp-pager.h index 4c8a42e6..088270a2 100644 --- a/src/yelp-pager.h +++ b/src/yelp-pager.h @@ -110,6 +110,8 @@ const gchar * yelp_pager_resolve_frag (YelpPager *pager, gboolean yelp_pager_page_contains_frag (YelpPager *pager, const gchar *page_id, const gchar *frag_id); +const YelpPage * yelp_pager_get_page_from_id (YelpPager *pager, + const gchar *page_id); const YelpPage * yelp_pager_get_page (YelpPager *pager, const gchar *frag_id); void yelp_pager_add_page (YelpPager *pager, diff --git a/src/yelp-toc-pager.c b/src/yelp-toc-pager.c index 5980e0dc..45a91c4d 100644 --- a/src/yelp-toc-pager.c +++ b/src/yelp-toc-pager.c @@ -86,6 +86,8 @@ struct _YelpTocPagerPriv { #endif xmlDocPtr toc_doc; + xmlDocPtr man_doc; + xmlDocPtr info_doc; GHashTable *unique_hash; GHashTable *category_hash; @@ -321,13 +323,118 @@ toc_pager_process (YelpPager *pager) return FALSE; } +/* we take advantage of the resolve_frag function to do lazy + * loading of each page the TOC. frag_id is the id attribute + * of the toc element that we want. + * + * yes, this kind of a hack */ static const gchar * toc_pager_resolve_frag (YelpPager *pager, const gchar *frag_id) { - if (!frag_id) - return "index"; - else + YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; + YelpPage *page = NULL; + GError *error = NULL; + xmlDocPtr outdoc = NULL; + gchar **params = NULL; + gint params_i = 0; + gint params_max = 10; + GtkIconInfo *info; + GtkIconTheme *theme = (GtkIconTheme *) yelp_settings_get_icon_theme (); + + if (priv->toc_doc == NULL) + return NULL; + + debug_print (DB_FUNCTION, "entering\n"); + debug_print (DB_ARG, "frag_id = %s\n", frag_id); + + /* if frag_id is NULL, we assume we are loading the top level TOC page */ + if (frag_id == NULL) + frag_id = "index"; + + /* we use the "frag_id" as the page_id here */ + page = yelp_pager_get_page_from_id (pager, frag_id); + + /* if we found the page just return */ + if (page != NULL) { + debug_print (DB_DEBUG, "found the frag_id=%s\n", frag_id); return frag_id; + } + + /* only create and parse the stylesheet on the first call to this function */ + if (!priv->stylesheet) { + priv->stylesheet = xsltParseStylesheetFile (BAD_CAST TOC_STYLESHEET); + } + + if (!priv->stylesheet) { + g_set_error (&error, YELP_ERROR, YELP_ERROR_PROC, + _("The table of contents could not be processed. The " + "file ‘%s’ is either missing or is not a valid XSLT " + "stylesheet."), + TOC_STYLESHEET); + yelp_pager_error (YELP_PAGER (pager), error); + goto done; + } + + priv->transformContext = xsltNewTransformContext (priv->stylesheet, + priv->toc_doc); + priv->transformContext->_private = pager; + xsltRegisterExtElement (priv->transformContext, + BAD_CAST "document", + BAD_CAST YELP_NAMESPACE, + (xsltTransformFunction) xslt_yelp_document); + + params = g_new0 (gchar *, params_max); + yelp_settings_params (¶ms, ¶ms_i, ¶ms_max); + + if ((params_i + 10) >= params_max - 1) { + params_max += 10; + params = g_renew (gchar *, params, params_max); + } + + info = gtk_icon_theme_lookup_icon (theme, "yelp-icon-big", 192, 0); + if (info) { + params[params_i++] = "help_icon"; + params[params_i++] = g_strdup_printf ("\"%s\"", + gtk_icon_info_get_filename (info)); + params[params_i++] = "help_icon_size"; + params[params_i++] = g_strdup_printf ("%i", + gtk_icon_info_get_base_size (info)); + gtk_icon_info_free (info); + } + + /* we specify the id attribute of the toc element that we want to process to + * the stylesheet */ + params[params_i++] = "yelp.toc.id"; + params[params_i++] = g_strdup_printf ("\'%s\'", frag_id); + + params[params_i++] = NULL; + + outdoc = xsltApplyStylesheetUser (priv->stylesheet, + priv->toc_doc, + (const gchar **)params, NULL, NULL, + priv->transformContext); + /* Don't do this */ + g_signal_emit_by_name (pager, "finish"); + + done: + if (params) { + for (params_i = 0; params[params_i] != NULL; params_i++) + if (params_i % 2 == 1) + g_free ((gchar *) params[params_i]); + } + if (outdoc) + xmlFreeDoc (outdoc); + /* with this hack (this function) we can't free the toc_doc */ + /*if (priv->toc_doc) { + xmlFreeDoc (priv->toc_doc); + priv->toc_doc = NULL; + }*/ + if (priv->transformContext) { + xsltFreeTransformContext (priv->transformContext); + priv->transformContext = NULL; + } + + return frag_id; } static GtkTreeModel * @@ -346,15 +453,13 @@ toc_process_pending (YelpTocPager *pager) static ProcessFunction process_funcs[] = { process_read_menu, process_omf_pending, - process_xslt, #ifdef ENABLE_MAN process_mandir_pending, - process_xslt, #endif #ifdef ENABLE_INFO process_info_pending, - process_xslt, #endif + /* process_xslt, */ process_cleanup, NULL }; @@ -1221,18 +1326,18 @@ process_mandir_pending (YelpTocPager *pager) YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; - if (!priv->toc_doc) { + if (!priv->man_doc) { xmlXPathContextPtr xpath; xmlXPathObjectPtr obj; /* NOTE: this document is free()'d at the end of the process_xslt function */ - priv->toc_doc = xmlCtxtReadFile (priv->parser, DATADIR "/yelp/man.xml", NULL, + priv->man_doc = xmlCtxtReadFile (priv->parser, DATADIR "/yelp/man.xml", NULL, XML_PARSE_NOBLANKS | XML_PARSE_NOCDATA | XML_PARSE_NOENT | XML_PARSE_NOERROR | XML_PARSE_NONET ); priv->man_secthash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - xpath = xmlXPathNewContext (priv->toc_doc); + xpath = xmlXPathNewContext (priv->man_doc); obj = xmlXPathEvalExpression (BAD_CAST "//toc", xpath); for (i = 0; i < obj->nodesetval->nodeNr; i++) { @@ -1277,6 +1382,12 @@ process_mandir_pending (YelpTocPager *pager) * searching the hard disk for them - should make startup much faster */ if (g_file_test (index_file, G_FILE_TEST_IS_REGULAR) && create_toc_from_index (pager, index_file)) { + xmlNodePtr mynode; + + mynode = xmlCopyNode (xmlDocGetRootElement (priv->man_doc), 1); + xmlAddChild (xmlDocGetRootElement(priv->toc_doc), mynode); + + xmlFreeDoc (priv->man_doc); /* we are done processing, return FALSE so we don't call this * function again. */ @@ -1452,6 +1563,7 @@ process_mandir_pending (YelpTocPager *pager) } } else { /* no more entries to prcoess, write file & cleanup */ GSList *listptr = priv->mandir_list; + xmlNodePtr copynode; while (listptr && listptr->data) { GSList *langptr = listptr->data; @@ -1472,6 +1584,11 @@ process_mandir_pending (YelpTocPager *pager) xmlFree (priv->manindex_xml); + copynode = xmlCopyNode (xmlDocGetRootElement (priv->man_doc), 1); + xmlAddChild (xmlDocGetRootElement(priv->toc_doc), copynode); + + xmlFreeDoc (priv->man_doc); + /* done processing */ return FALSE; } @@ -1488,6 +1605,7 @@ process_info_pending (YelpTocPager *pager) gchar ** info_paths = yelp_get_info_paths (); int i = 0; gchar *filename = NULL; + xmlNodePtr mynode = NULL; GHashTable *info_parsed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -1496,7 +1614,6 @@ process_info_pending (YelpTocPager *pager) YelpTocPagerPriv *priv = YELP_TOC_PAGER (pager)->priv; xmlNodePtr node = NULL; - for (i=0; info_paths[i]; i++) { filename = g_strconcat (info_paths[i], "/dir", NULL); @@ -1516,17 +1633,21 @@ process_info_pending (YelpTocPager *pager) gboolean menufound = FALSE; gchar ** amp; - if (!priv->toc_doc) { + if (!priv->info_doc) { xmlXPathContextPtr xpath; xmlXPathObjectPtr obj; - priv->toc_doc = xmlCtxtReadFile (priv->parser, DATADIR "/yelp/info.xml", NULL, + priv->info_doc = xmlCtxtReadFile (priv->parser, DATADIR "/yelp/info.xml", NULL, XML_PARSE_NOBLANKS | XML_PARSE_NOCDATA | XML_PARSE_NOENT | XML_PARSE_NOERROR | XML_PARSE_NONET ); - xpath = xmlXPathNewContext (priv->toc_doc); + xpath = xmlXPathNewContext (priv->info_doc); obj = xmlXPathEvalExpression (BAD_CAST "//toc", xpath); node = obj->nodesetval->nodeTab[0]; + for (i=0; i < obj->nodesetval->nodeNr; i++) { + xmlNodePtr tmpnode = obj->nodesetval->nodeTab[i]; + xml_trim_titles (tmpnode); + } xmlXPathFreeObject (obj); xmlXPathFreeContext (xpath); } @@ -1652,6 +1773,12 @@ process_info_pending (YelpTocPager *pager) } g_hash_table_destroy (info_parsed); g_hash_table_destroy (categories); + + mynode = xmlCopyNode (xmlDocGetRootElement (priv->info_doc), 1); + xmlAddChild (xmlDocGetRootElement (priv->toc_doc), mynode); + + xmlFreeDoc (priv->info_doc); + return FALSE; } #endif /* ENABLE_INFO */ @@ -1686,7 +1813,7 @@ process_read_menu (YelpTocPager *pager) for (i = 0; i < obj->nodesetval->nodeNr; i++) { xmlNodePtr node = obj->nodesetval->nodeTab[i]; xmlChar *icon = NULL; -#ifdef ENABLE_MAN_OR_INFO +#if 0 xmlChar *id = NULL; xmlNodePtr cmdhelp; xmlNodePtr newnode; @@ -1882,6 +2009,9 @@ process_cleanup (YelpTocPager *pager) { YelpTocPagerPriv *priv = pager->priv; + /* dump the toc_doc if we are debugging */ + /*d (xmlDocDump (stdout, priv->toc_doc)); */ + #ifdef ENABLE_MAN /* clean up the man directory language hash table */ if (priv->man_dirlang) { diff --git a/src/yelp-window.c b/src/yelp-window.c index 5261e73f..d595db4f 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -1538,6 +1538,7 @@ window_do_load_pager (YelpWindow *window, startnow = FALSE; state = yelp_pager_get_state (pager); + debug_print (DB_DEBUG, "pager state=%d\n", state); switch (state) { case YELP_PAGER_STATE_ERROR: error = yelp_pager_get_error (pager); @@ -2042,18 +2043,26 @@ pager_finish_cb (YelpPager *pager, { GError *error = NULL; YelpWindow *window = YELP_WINDOW (user_data); + const gchar *page_id; + + page_id = yelp_pager_resolve_frag (pager, + window->priv->current_frag); debug_print (DB_FUNCTION, "entering\n"); + + if (!page_id && window->priv->current_frag && + strcmp (window->priv->current_frag, "")) { - window_disconnect (window); + window_disconnect (window); - g_set_error (&error, YELP_ERROR, YELP_ERROR_NO_PAGE, - _("The section ‘%s’ does not exist in this document. " - "If you were directed to this section from a Help " - "button in an application, please report this to " - "the maintainers of that application."), - window->priv->current_frag); - window_error (window, error, TRUE); + g_set_error (&error, YELP_ERROR, YELP_ERROR_NO_PAGE, + _("The section ‘%s’ does not exist in this document. " + "If you were directed to this section from a Help " + "button in an application, please report this to " + "the maintainers of that application."), + window->priv->current_frag); + window_error (window, error, TRUE); + } /* FIXME: Remove the URI from the history and go back */ } diff --git a/stylesheets/toc2html.xsl b/stylesheets/toc2html.xsl index 184c4833..5be5b544 100644 --- a/stylesheets/toc2html.xsl +++ b/stylesheets/toc2html.xsl @@ -28,6 +28,8 @@ <xsl:param name="yelp.color.admon.bg.dark2"/> <xsl:param name="yelp.color.admon.bg.dark3"/> +<xsl:param name="yelp.toc.id" select="'Man-man6'"/> + <xsl:template match="toc"> <yelp:document href="{@id}"> <html> @@ -62,6 +64,9 @@ top: 6px; right: 18px; } + h2 h3 { + color: </xsl:text><xsl:value-of select="$yelp.color.fg"/><xsl:text>; + } div[class~="body"] { } div[class~="leftbar"] { position: absolute; @@ -69,37 +74,69 @@ left: 12px; width: 192px; min-height: 192px; - text-align: center; - padding-top: </xsl:text> + text-align: left; + /* padding-top: </xsl:text> <xsl:value-of select="$help_icon_size"/><xsl:text>px; background-image: url("</xsl:text> <xsl:value-of select="$help_icon"/><xsl:text>"); background-position: </xsl:text> <xsl:value-of select="(192 - $help_icon_size) div 2"/><xsl:text>px 0px; background-repeat: no-repeat; - opacity: .3; + opacity: .3; */ + } + div[class~="leftbackground"] { + position: absolute; + top: 4em; + left: 1px; + width: 210px; + min-height: 192px; + text-align: center; + padding-top: 0px; + background-image:url("</xsl:text> + <xsl:value-of select="$help_icon"/><xsl:text>"); + background-position: </xsl:text> + <xsl:value-of select="(192 - $help_icon_size) div 2"/><xsl:text>px 0px; + + background-repeat: no-repeat; + opacity: .1; } div[class~="rightbar"] { margin-left: 216px; padding-bottom: 1em; + padding-top: 1em; + padding-left: 1em; + padding-right: 1em; margin-right: 12px; - } - div[class~="tocs"] + div[class~="docs"] { - border-top: solid 1px </xsl:text> - <xsl:value-of select="$yelp.color.selected.bg"/><xsl:text>; + background-color: </xsl:text><xsl:value-of select="$yelp.color.bg"/><xsl:text>; + color: </xsl:text><xsl:value-of select="$yelp.color.fg"/><xsl:text>; + -moz-border-radius: 8px; } ul { margin-left: 0em; padding-left: 0em; } - li { - margin-top: 0.5em; + li[class~="toclist"] { + margin-top: 0.3em; margin-left: 0em; padding-left: 0em; font-size: 1.2em; list-style-type: none; } + li li[class~="toclist"] { + padding-left: 0.8em; + font-size: 0.8em; + } + li li li[class~="toclist"] { + padding-left: 0.8em; + font-size: 0.6em; + } + li[class~="toc"] { + margin-left: 0em; + font-size: 1.2em; + padding-top: 0.5em; + list-style-type: none; + } dl { margin-left: 0em; padding-left: 0em; } dt { font-size: 1.2em; margin-top: 1em; } dd { margin-left: 1em; margin-top: 0.5em; } - a { text-decoration: none; } + a { text-decoration: none; color: </xsl:text><xsl:value-of select="$yelp.color.anchor"/><xsl:text>; } a:hover { text-decoration: underline; } </xsl:text></style> </head> @@ -108,59 +145,122 @@ </body> </html> </yelp:document> - <xsl:apply-templates select="toc[(.//doc[1]) or (@id = 'ManInfoHolder')]"/> +</xsl:template> + +<xsl:template name="print.documents"> + <div class="docs"> + <dl> + <xsl:for-each select="doc"> + <xsl:sort select="normalize-space(title)"/> + <dt class="doc"> + <a href="{@href}" title="{@href}"> + <xsl:if test="tooltip"> + <xsl:attribute name="title"> + <xsl:value-of select="tooltip"/> + </xsl:attribute> + </xsl:if> + <xsl:value-of select="title"/> + </a> + </dt> + <dd> + <xsl:value-of select="description"/> + </dd> + </xsl:for-each> + </dl> + </div> +</xsl:template> + +<xsl:template name="print.subsections"> + <div class="tocs"> + <ul> + <xsl:for-each select="toc[../@id = 'index' or .//doc]"> + <xsl:sort select="number(../@id = 'index') * position()"/> + <xsl:sort select="normalize-space(title)"/> + <li class="toc"> + <a href="x-yelp-toc:{@id}"> + <xsl:apply-templates select="title[1]/node()"/> + </a> + </li> + </xsl:for-each> + </ul> + </div> </xsl:template> <xsl:template mode="body.mode" match="toc"> + <div class="leftbackground"> + </div> <div class="body"> <h1> <xsl:if test="icon"> <img src="{icon/@file}"/> </xsl:if> - <xsl:apply-templates select="title[1]/node()"/> + <xsl:apply-templates select="title"/> </h1> <div class="leftbar"> + <xsl:choose> + <xsl:when test="@id= 'index'"> + <h2><xsl:value-of select="/toc/title"/></h2> + </xsl:when> + <xsl:otherwise> + <a href="x-yelp-toc:index"><h2><xsl:value-of select="/toc/title"/> + </h2></a> + </xsl:otherwise> + </xsl:choose> + <xsl:apply-templates mode="leftbar.mode" select="/toc"> + <xsl:with-param name="curid" select="@id"/> + </xsl:apply-templates> </div> <div class="rightbar"> - <xsl:if test="toc[.//doc[1]] or @id = 'ManInfoHolder'"> - <div class="tocs"> - <ul> - <xsl:for-each select="toc[../@id = 'index' or ../@id = 'ManInfoHolder' or .//doc]"> - <xsl:sort select="number(../@id = 'index') * position()"/> - <xsl:sort select="normalize-space(title)"/> - <li class="toc"> - <a href="x-yelp-toc:{@id}"> - <xsl:apply-templates select="title[1]/node()"/> - </a> - </li> - </xsl:for-each> - </ul> - </div> - </xsl:if> - <xsl:if test="doc[1]"> - <div class="docs"> - <dl> - <xsl:for-each select="doc"> - <xsl:sort select="normalize-space(title)"/> - <dt class="doc"> - <a href="{@href}" title="{@href}"> - <xsl:if test="tooltip"> - <xsl:attribute name="title"> - <xsl:value-of select="tooltip"/> - </xsl:attribute> - </xsl:if> - <xsl:value-of select="title"/> - </a> - </dt> - <dd> - <xsl:value-of select="description"/> - </dd> - </xsl:for-each> - </dl> - </div> - </xsl:if> + <h3><xsl:apply-templates select="description/node()"/></h3> + <xsl:choose> + <!-- if there are documents and subsections, only print documents --> + <xsl:when test="doc[1] and toc[.//doc[1]]"> + <xsl:call-template name="print.documents"/> + </xsl:when> + <!-- if there are documents, print them --> + <xsl:when test="doc[1]"> + <xsl:call-template name="print.documents"/> + </xsl:when> + <!-- if there are subsections, print them --> + <xsl:when test="toc[.//doc[1]]"> + <xsl:call-template name="print.subsections"/> + </xsl:when> + <xsl:otherwise> + <h3>No documents or subcategories found.</h3> + </xsl:otherwise> + </xsl:choose> </div> </div> </xsl:template> +<!-- tricky recursive xslt --> +<xsl:template mode="leftbar.mode" match="toc"> + <xsl:param name="curid" select="0"/> + <ul> + <xsl:for-each select="toc[.//doc[1]]"> + <li class="toclist"> + <xsl:choose> + <xsl:when test="@id != $curid"> + <a href="x-yelp-toc:{@id}"> + <xsl:value-of select="title[1]/node()"/> + </a> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="title[1]/node()"/> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="@id = $curid or .//toc[@id = $curid]"> + <xsl:apply-templates mode="leftbar.mode" select="."> + <xsl:with-param name="curid" select="$curid"/> + </xsl:apply-templates> + </xsl:if> + </li> + </xsl:for-each> + </ul> +</xsl:template> + +<xsl:template match="/"> + <xsl:apply-templates select="//toc[@id = $yelp.toc.id]" /> +</xsl:template> + </xsl:stylesheet> |