diff options
author | Shaun McCance <shaunm@src.gnome.org> | 2004-12-31 10:04:15 +0000 |
---|---|---|
committer | Shaun McCance <shaunm@src.gnome.org> | 2004-12-31 10:04:15 +0000 |
commit | 2402f576cb48ba1e0bac801c203f16beff2ee9aa (patch) | |
tree | f7349444196bfd57b547fb0280bed58f4b8a98f5 | |
parent | 9406f4b86c14030626187c1f3d5d3613643ec1e4 (diff) | |
download | yelp-2402f576cb48ba1e0bac801c203f16beff2ee9aa.tar.gz |
- Adding yelp-info-pager.[ch]
* src/Makefile.am:
* src/yelp-info-pager.c:
* src/yelp-info-pager.h:
* src/yelp-window.c:
- Adding yelp-info-pager.[ch]
* src/yelp-man-pager.c:
- Some cleanups
* stylesheets/Makefile.am:
* stylesheets/info2html.xsl:
- Adding info2html.xsl
* stylesheets/db2html.xsl.in:
* stylesheets/man2html.xsl:
- Minor stylistic stuff
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | src/Makefile.am | 7 | ||||
-rw-r--r-- | src/yelp-info-pager.c | 192 | ||||
-rw-r--r-- | src/yelp-info-pager.h | 55 | ||||
-rw-r--r-- | src/yelp-man-pager.c | 7 | ||||
-rw-r--r-- | src/yelp-window.c | 5 | ||||
-rw-r--r-- | stylesheets/Makefile.am | 2 | ||||
-rw-r--r-- | stylesheets/db2html.xsl.in | 16 | ||||
-rw-r--r-- | stylesheets/info2html.xsl | 82 | ||||
-rw-r--r-- | stylesheets/man2html.xsl | 44 |
10 files changed, 398 insertions, 31 deletions
@@ -1,5 +1,24 @@ 2004-12-31 Shaun McCance <shaunm@gnome.org> + * src/Makefile.am: + * src/yelp-info-pager.c: + * src/yelp-info-pager.h: + * src/yelp-window.c: + - Adding yelp-info-pager.[ch] + + * src/yelp-man-pager.c: + - Some cleanups + + * stylesheets/Makefile.am: + * stylesheets/info2html.xsl: + - Adding info2html.xsl + + * stylesheets/db2html.xsl.in: + * stylesheets/man2html.xsl: + - Minor stylistic stuff + +2004-12-31 Shaun McCance <shaunm@gnome.org> + * src/yelp-toc-pager.c: - Put in a NULL check to fix a crahser for Davyd diff --git a/src/Makefile.am b/src/Makefile.am index 0cbd70ee..67126fca 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,6 +7,12 @@ else man_sources = endif +if ENABLE_INFO +info_sources = yelp-info-pager.c yelp-info-pager.h +else +info_sources = +endif + INCLUDES = \ -I$(top_srcdir) \ $(YELP_CFLAGS) \ @@ -70,6 +76,7 @@ test_uri_LDADD = @YELP_LIBS@ yelp_SOURCES = \ $(gnome_yelp_idl_sources) \ + $(info_sources) \ $(man_sources) \ yelp-base.c yelp-base.h \ yelp-bookmarks.c yelp-bookmarks.h \ diff --git a/src/yelp-info-pager.c b/src/yelp-info-pager.c new file mode 100644 index 00000000..fcce2202 --- /dev/null +++ b/src/yelp-info-pager.c @@ -0,0 +1,192 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance <shaunm@gnome.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance <shaunm@gnome.org> + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <libgnome/gnome-i18n.h> +#include <libxml/parser.h> +#include <libxml/parserInternals.h> +#include <libxslt/xslt.h> +#include <libxslt/templates.h> +#include <libxslt/transform.h> +#include <libxslt/extensions.h> +#include <libxslt/xsltInternals.h> +#include <libxslt/xsltutils.h> + +#include "yelp-error.h" +#include "yelp-info-pager.h" +#include "yelp-settings.h" + +#define INFO_STYLESHEET_PATH DATADIR"/sgml/docbook/yelp/" +#define INFO_STYLESHEET INFO_STYLESHEET_PATH"info2html.xsl" + +struct _YelpInfoPagerPriv { + gpointer unused; +}; + +static void info_pager_class_init (YelpInfoPagerClass *klass); +static void info_pager_init (YelpInfoPager *pager); +static void info_pager_dispose (GObject *gobject); + +static xmlDocPtr info_pager_parse (YelpPager *pager); +static gchar ** info_pager_params (YelpPager *pager); + +static const gchar * info_pager_resolve_frag (YelpPager *pager, + const gchar *frag_id); +static GtkTreeModel * info_pager_get_sections (YelpPager *pager); + +static YelpPagerClass *parent_class; + +GType +yelp_info_pager_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (YelpInfoPagerClass), + NULL, + NULL, + (GClassInitFunc) info_pager_class_init, + NULL, + NULL, + sizeof (YelpInfoPager), + 0, + (GInstanceInitFunc) info_pager_init, + }; + type = g_type_register_static (YELP_TYPE_XSLT_PAGER, + "YelpInfoPager", + &info, 0); + } + return type; +} + +static void +info_pager_class_init (YelpInfoPagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + YelpPagerClass *pager_class = YELP_PAGER_CLASS (klass); + YelpXsltPagerClass *xslt_class = YELP_XSLT_PAGER_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->dispose = info_pager_dispose; + + pager_class->resolve_frag = info_pager_resolve_frag; + pager_class->get_sections = info_pager_get_sections; + + xslt_class->parse = info_pager_parse; + xslt_class->params = info_pager_params; + + xslt_class->stylesheet = INFO_STYLESHEET; +} + +static void +info_pager_init (YelpInfoPager *pager) +{ + YelpInfoPagerPriv *priv; + + priv = g_new0 (YelpInfoPagerPriv, 1); + pager->priv = priv; +} + +static void +info_pager_dispose (GObject *object) +{ + YelpInfoPager *pager = YELP_INFO_PAGER (object); + + g_free (pager->priv); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +/******************************************************************************/ + +YelpPager * +yelp_info_pager_new (YelpDocInfo *doc_info) +{ + YelpInfoPager *pager; + + g_return_val_if_fail (doc_info != NULL, NULL); + + pager = (YelpInfoPager *) g_object_new (YELP_TYPE_INFO_PAGER, + "document-info", doc_info, + NULL); + + return (YelpPager *) pager; +} + +static xmlDocPtr +info_pager_parse (YelpPager *pager) +{ + YelpDocInfo *doc_info; + gchar *filename; + xmlDocPtr doc; + GError *error; + + g_return_val_if_fail (YELP_IS_INFO_PAGER (pager), FALSE); + + doc_info = yelp_pager_get_doc_info (pager); + filename = yelp_doc_info_get_filename (doc_info); + + g_object_ref (pager); + + /* DO STUFF HERE */ + + g_object_unref (pager); + + return doc; +} + +static gchar ** +info_pager_params (YelpPager *pager) +{ + gchar **params; + gint params_i = 0; + gint params_max = 10; + + params = g_new0 (gchar *, params_max); + + params[params_i++] = "stylesheet_path"; + params[params_i++] = g_strdup_printf ("\"file://%s\"", INFO_STYLESHEET_PATH); + + params[params_i] = NULL; + + return params; +} + +static const gchar * +info_pager_resolve_frag (YelpPager *pager, const gchar *frag_id) +{ + /* DO SOMETHING ELSE HERE */ + return NULL; +} + +static GtkTreeModel * +info_pager_get_sections (YelpPager *pager) +{ + /* RETURN THE TREE STORE HERE */ + return NULL; +} diff --git a/src/yelp-info-pager.h b/src/yelp-info-pager.h new file mode 100644 index 00000000..227d1f92 --- /dev/null +++ b/src/yelp-info-pager.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2003 Shaun McCance <shaunm@gnome.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Shaun McCance <shaunm@gnome.org> + */ + +#ifndef __YELP_INFO_PAGER_H__ +#define __YELP_INFO_PAGER_H__ + +#include <glib-object.h> + +#include "yelp-pager.h" +#include "yelp-xslt-pager.h" + +#define YELP_TYPE_INFO_PAGER (yelp_info_pager_get_type ()) +#define YELP_INFO_PAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_INFO_PAGER, YelpInfoPager)) +#define YELP_INFO_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_INFO_PAGER, YelpInfoPagerClass)) +#define YELP_IS_INFO_PAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_INFO_PAGER)) +#define YELP_IS_INFO_PAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_INFO_PAGER)) +#define YELP_INFO_PAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_INFO_PAGER, YelpInfoPagerClass)) + +typedef struct _YelpInfoPager YelpInfoPager; +typedef struct _YelpInfoPagerClass YelpInfoPagerClass; +typedef struct _YelpInfoPagerPriv YelpInfoPagerPriv; + +struct _YelpInfoPager { + YelpXsltPager parent; + + YelpInfoPagerPriv *priv; +}; + +struct _YelpInfoPagerClass { + YelpXsltPagerClass parent_class; +}; + +GType yelp_info_pager_get_type (void); +YelpPager * yelp_info_pager_new (YelpDocInfo *doc_info); + +#endif /* __YELP_INFO_PAGER_H__ */ diff --git a/src/yelp-man-pager.c b/src/yelp-man-pager.c index 0563a2ce..21dfaff0 100644 --- a/src/yelp-man-pager.c +++ b/src/yelp-man-pager.c @@ -39,17 +39,10 @@ #include "yelp-man-pager.h" #include "yelp-man-parser.h" #include "yelp-settings.h" -#include "yelp-toc-pager.h" - -#define YELP_NAMESPACE "http://www.gnome.org/yelp/ns" #define MAN_STYLESHEET_PATH DATADIR"/sgml/docbook/yelp/" #define MAN_STYLESHEET MAN_STYLESHEET_PATH"man2html.xsl" -#define MAX_CHUNK_DEPTH 2 - -#define d(x) - struct _YelpManPagerPriv { gpointer unused; }; diff --git a/src/yelp-window.c b/src/yelp-window.c index 9cafe12c..4a0fdbb5 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -51,6 +51,9 @@ #ifdef ENABLE_MAN #include "yelp-man-pager.h" #endif +#ifdef ENABLE_INFO +#include "yelp-info-pager.h" +#endif #ifdef YELP_DEBUG #define d(x) x @@ -1061,7 +1064,7 @@ window_do_load_pager (YelpWindow *window, break; #ifdef ENABLE_INFO case YELP_DOC_TYPE_INFO: - // FIXME: yelp_info_pager_new (doc_info); + pager = yelp_info_pager_new (doc_info); break; #endif #ifdef ENABLE_MAN diff --git a/stylesheets/Makefile.am b/stylesheets/Makefile.am index 014bf126..45aed593 100644 --- a/stylesheets/Makefile.am +++ b/stylesheets/Makefile.am @@ -2,6 +2,6 @@ xsldir=$(datadir)/sgml/docbook/yelp -xsl_DATA = db2html.xsl man2html.xsl toc2html.xsl +xsl_DATA = db2html.xsl info2html.xsl man2html.xsl toc2html.xsl EXTRA_DIST=$(xsl_DATA) diff --git a/stylesheets/db2html.xsl.in b/stylesheets/db2html.xsl.in index d0c6cd7c..cbd46dc1 100644 --- a/stylesheets/db2html.xsl.in +++ b/stylesheets/db2html.xsl.in @@ -105,25 +105,15 @@ <xsl:template name="db2html.css.custom"> <xsl:text> h1 + div h2[class~="title"] { margin-top: 2em; } - h1 { color: </xsl:text> - <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } - h2 { color: </xsl:text> - <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } - h3 { color: </xsl:text> - <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } - h4 { color: </xsl:text> - <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } - h5 { color: </xsl:text> - <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } - h6 { color: </xsl:text> - <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } - h7 { color: </xsl:text> + h1, h2, h3, h4, h5, h6, h7 { color: </xsl:text> <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } + h3 span[class~="title"] { border-bottom: none; } h4 span[class~="title"] { border-bottom: none; } h5 span[class~="title"] { border-bottom: none; } h6 span[class~="title"] { border-bottom: none; } h7 span[class~="title"] { border-bottom: none; } + div[class~="admonition"] { color: </xsl:text> <xsl:value-of select="$yelp.color.base3"/><xsl:text>; } div[class~="programlisting"] { diff --git a/stylesheets/info2html.xsl b/stylesheets/info2html.xsl new file mode 100644 index 00000000..a0401d1f --- /dev/null +++ b/stylesheets/info2html.xsl @@ -0,0 +1,82 @@ +<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- --> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:yelp="http://www.gnome.org/yelp/ns" + xmlns="http://www.w3.org/1999/xhtml" + extension-element-prefixes="yelp" + version="1.0"> + +<xsl:param name="stylesheet_path" select="''"/> + +<xsl:param name="yelp.icon.blockquote"/> +<xsl:param name="yelp.icon.caution"/> +<xsl:param name="yelp.icon.important"/> +<xsl:param name="yelp.icon.note"/> +<xsl:param name="yelp.icon.programlisting"/> +<xsl:param name="yelp.icon.tip"/> +<xsl:param name="yelp.icon.warning"/> + +<xsl:param name="yelp.color.text"/> +<xsl:param name="yelp.color.anchor"/> +<xsl:param name="yelp.color.background"/> +<xsl:param name="yelp.color.rule"/> +<xsl:param name="yelp.color.base0"/> +<xsl:param name="yelp.color.base1"/> +<xsl:param name="yelp.color.base2"/> +<xsl:param name="yelp.color.base3"/> +<xsl:param name="yelp.color.selected0"/> +<xsl:param name="yelp.color.selected1"/> +<xsl:param name="yelp.color.selected2"/> +<xsl:param name="yelp.color.selected3"/> + +<xsl:template match="/"> + <yelp:document href="index"> + <html> + <head> + <title> + <xsl:text>FOO</xsl:text> + </title> + <style type="text/css"> + <xsl:call-template name="html.css"/> + </style> + </head> + <body> + <pre class="body"> + <xsl:value-of select="."/> + </pre> + </body> + </html> + </yelp:document> +</xsl:template> + +<xsl:template name="html.css"><xsl:text> +h1 { font-size: 1.6em; font-weight: bold; } +h2 { font-size: 1.4em; font-weight: bold; } +h3 { font-size: 1.2em; font-weight: bold; } + +h1, h2, h3, h4, h5, h6, h7 { color: </xsl:text> +<xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } + +body { margin: 0em; padding: 0em; } +pre[class~="body"] { +margin-left: 0.8em; +margin-right: 0.8em; +margin-bottom: 1.6em; +} + +p, div { margin: 0em; } +p + *, div + *, { margin-top: 1em; } + +dl { margin: 0em; } +dl dd + dt { margin-top: 1em; } +dl dd { + margin-top: 0.5em; + margin-left: 2em; + margin-right: 1em; +} +ol { margin-left: 2em; } +ul { margin-left: 2em; } +ul li { margin-right: 1em; } +</xsl:text></xsl:template> + +</xsl:stylesheet> diff --git a/stylesheets/man2html.xsl b/stylesheets/man2html.xsl index a089827f..3ab5cdc5 100644 --- a/stylesheets/man2html.xsl +++ b/stylesheets/man2html.xsl @@ -1,15 +1,33 @@ <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:exsl="http://exslt.org/common" xmlns:yelp="http://www.gnome.org/yelp/ns" xmlns="http://www.w3.org/1999/xhtml" - extension-element-prefixes="exsl yelp" + extension-element-prefixes="yelp" version="1.0"> <xsl:param name="stylesheet_path" select="''"/> -<xsl:param name="color_gray_background" select="'#E6E6E6'"/> -<xsl:param name="color_gray_border" select="'#A1A1A1'"/> + +<xsl:param name="yelp.icon.blockquote"/> +<xsl:param name="yelp.icon.caution"/> +<xsl:param name="yelp.icon.important"/> +<xsl:param name="yelp.icon.note"/> +<xsl:param name="yelp.icon.programlisting"/> +<xsl:param name="yelp.icon.tip"/> +<xsl:param name="yelp.icon.warning"/> + +<xsl:param name="yelp.color.text"/> +<xsl:param name="yelp.color.anchor"/> +<xsl:param name="yelp.color.background"/> +<xsl:param name="yelp.color.rule"/> +<xsl:param name="yelp.color.base0"/> +<xsl:param name="yelp.color.base1"/> +<xsl:param name="yelp.color.base2"/> +<xsl:param name="yelp.color.base3"/> +<xsl:param name="yelp.color.selected0"/> +<xsl:param name="yelp.color.selected1"/> +<xsl:param name="yelp.color.selected2"/> +<xsl:param name="yelp.color.selected3"/> <xsl:template match="Man"> <xsl:choose> @@ -48,6 +66,9 @@ h1 { font-size: 1.6em; font-weight: bold; } h2 { font-size: 1.4em; font-weight: bold; } h3 { font-size: 1.2em; font-weight: bold; } +h1, h2, h3, h4, h5, h6, h7 { color: </xsl:text> +<xsl:value-of select="$yelp.color.selected1"/><xsl:text>; } + div[class~="SH"] { margin-left: 1.2em; } div[class~="SS"] { margin-left: 1.6em; } @@ -61,13 +82,18 @@ margin-bottom: 1.6em; } p, div { margin: 0em; } -p + p, p + div, div + p, div + div { margin-top: 0.8em; } +p + *, div + * { margin-top: 1em; } dl { margin: 0em; } -ol { margin: 0em; } -ul { margin: 0em; } -ul li { padding-left: 0.4em; } -dd + dt { margin-top: 1.6em; } +dl dd + dt { margin-top: 1em; } +dl dd { + margin-top: 0.5em; + margin-left: 2em; + margin-right: 1em; +} +ol { margin-left: 2em; } +ul { margin-left: 2em; } +ul li { margin-right: 1em; } </xsl:text></xsl:template> <!-- ======================================================================= --> |