Commit dd184d14 authored by Shaun McCance's avatar Shaun McCance

- Switched to the stylesheets from gnome-doc-utils

* configure.in:
* stylesheets/db2html.xsl:
* stylesheets/db2html.xsl.in:
- Switched to the stylesheets from gnome-doc-utils

* src/yelp-io-channel.c:
- Moved #include <stdio.h> above the other #includes

* src/test-pager.c:
* src/yelp-db-pager.c:
* src/yelp-man-pager.c:
* src/yelp-pager.c:
* src/yelp-pager.h:
* src/yelp-toc-pager.c:
* src/yelp-window.c:
- Made some changes to frag resolving that I've been wanting to do
parent 670422cb
2004-06-01 Shaun McCance <shaunm@gnome.org>
* configure.in:
* stylesheets/db2html.xsl:
* stylesheets/db2html.xsl.in:
- Switched to the stylesheets from gnome-doc-utils
* src/yelp-io-channel.c:
- Moved #include <stdio.h> above the other #includes
* src/test-pager.c:
* src/yelp-db-pager.c:
* src/yelp-man-pager.c:
* src/yelp-pager.c:
* src/yelp-pager.h:
* src/yelp-toc-pager.c:
* src/yelp-window.c:
- Made some changes to frag resolving that I've been wanting to do
2004-05-24 Pablo Saratxaga <pablo@mandrakesoft.com>
* configure.in: Added Tajik (tg) to ALL_LINGUAS.
......
......@@ -42,6 +42,7 @@ AC_DEFINE_UNQUOTED(GNOMELOCALEDIR, "$GNOMELOCALEDIR")
PKG_CHECK_MODULES(YELP,
[
gconf-2.0
gnome-doc-utils
gnome-vfs-2.0 >= 1.1
gtk+-2.0 >= 2.3.1
libbonobo-2.0 >= 1.108.0
......@@ -63,6 +64,9 @@ AC_PATH_PROGS(SED, gsed sed)
YELP_IDL_INCLUDES="`echo ${idl_dirs} | ${SED} -e 's/^/ /' -e 's/ *$//' -e 's/ */ -I /g' -e 's/^ *//'`"
AC_SUBST(YELP_IDL_INCLUDES)
DB2HTML="`$PKG_CONFIG --variable=db2html gnome-doc-utils`"
AC_SUBST(DB2HTML)
dnl Check for whereis
AC_CANONICAL_HOST
case $host in
......@@ -114,6 +118,7 @@ AC_OUTPUT([
Makefile
src/Makefile
stylesheets/Makefile
stylesheets/db2html.xsl
data/Makefile
data/icons/Makefile
data/ui/Makefile
......
......@@ -101,9 +101,9 @@ pager_page_cb (YelpPager *pager,
" id: %s\n"
" title: %s\n"
" strlen: %d\n",
page->id,
page->page_id,
page->title,
strlen (page->chunk));
strlen (page->contents));
}
static void
......
......@@ -82,8 +82,8 @@ void db_pager_cancel (YelpPager *pager);
void db_pager_finish (YelpPager *pager);
gboolean db_pager_process (YelpPager *pager);
gchar * db_pager_resolve_uri (YelpPager *pager,
YelpURI *uri);
const gchar * db_pager_resolve_frag (YelpPager *pager,
const gchar *frag_id);
const GtkTreeModel * db_pager_get_sections (YelpPager *pager);
static void walker_walk_xml (DBWalker *walker);
......@@ -143,7 +143,7 @@ db_pager_class_init (YelpDBPagerClass *klass)
pager_class->finish = db_pager_finish;
pager_class->process = db_pager_process;
pager_class->resolve_uri = db_pager_resolve_uri;
pager_class->resolve_frag = db_pager_resolve_frag;
pager_class->get_sections = db_pager_get_sections;
}
......@@ -210,13 +210,11 @@ db_pager_process (YelpPager *pager)
xsltStylesheetPtr stylesheet;
xsltTransformContextPtr tctxt;
gchar *p_doc_name, *p_doc_path;
gchar *db_chunk_basename, *db_chunk_basename_q;
const gchar *params[40];
YelpDBPagerPriv *priv = YELP_DB_PAGER (pager)->priv;
gchar *doc_name;
gchar *doc_path;
const gchar *params[40];
gint i = 0;
g_return_val_if_fail (pager != NULL, FALSE);
......@@ -282,23 +280,31 @@ db_pager_process (YelpPager *pager)
while (gtk_events_pending ())
gtk_main_iteration ();
doc_name = gnome_vfs_uri_extract_short_name (uri->uri);
db_chunk_basename = gnome_vfs_uri_extract_short_name (uri->uri);
db_chunk_basename_q = g_strconcat("\"", db_chunk_basename, "\"", NULL);
/*
doc_path = gnome_vfs_uri_extract_dirname (uri->uri);
p_doc_name = g_strconcat("\"", doc_name, "\"", NULL);
p_doc_path = g_strconcat("\"file://", doc_path, "/\"", NULL);
*/
params[i++] = "doc_name";
params[i++] = p_doc_name;
params[i++] = "db.chunk.basename";
params[i++] = db_chunk_basename_q;
/*
params[i++] = "doc_path";
params[i++] = p_doc_path;
*/
params[i++] = "stylesheet_path";
params[i++] = "\"file://" DB_STYLESHEET_PATH "/\"";
params[i++] = "html_extension";
params[i++] = "\"\"";
params[i++] = "resolve_xref_chunk";
params[i++] = "0";
/*
params[i++] = "mediaobject_path";
params[i++] = p_doc_path;
*/
params[i++] = "color_gray_background";
params[i++] = yelp_theme_get_gray_background ();
params[i++] = "color_gray_border";
......@@ -310,6 +316,7 @@ db_pager_process (YelpPager *pager)
stylesheet = xsltParseStylesheetFile (DB_STYLESHEET);
tctxt = xsltNewTransformContext (stylesheet,
doc);
tctxt->_private = pager;
xsltRegisterExtElement (tctxt,
"document",
......@@ -332,10 +339,9 @@ db_pager_process (YelpPager *pager)
g_free (path);
g_free (walker);
g_free (p_doc_name);
g_free (p_doc_path);
g_free (doc_name);
g_free (doc_path);
g_free (db_chunk_basename);
g_free (db_chunk_basename_q);
xmlFreeDoc (doc);
xsltFreeStylesheet (stylesheet);
......@@ -369,11 +375,10 @@ db_pager_finish (YelpPager *pager)
yelp_toc_pager_unpause (yelp_toc_pager_get ());
}
gchar *
db_pager_resolve_uri (YelpPager *pager, YelpURI *uri)
const gchar *
db_pager_resolve_frag (YelpPager *pager, const gchar *frag_id)
{
YelpDBPager *db_pager;
const gchar *frag_id;
gchar *page_id = NULL;
g_return_val_if_fail (pager != NULL, NULL);
......@@ -381,17 +386,13 @@ db_pager_resolve_uri (YelpPager *pager, YelpURI *uri)
db_pager = YELP_DB_PAGER (pager);
frag_id = gnome_vfs_uri_get_fragment_identifier (uri->uri);
if (frag_id)
page_id = g_hash_table_lookup (db_pager->priv->frags_hash,
frag_id);
else if (db_pager->priv->root_id)
page_id = db_pager->priv->root_id;
else
page_id = "index";
page_id = db_pager->priv->root_id;
return g_strdup (page_id);
return (const gchar *) page_id;
}
const GtkTreeModel *
......@@ -482,9 +483,9 @@ xslt_yelp_document (xsltTransformContextPtr ctxt,
page = g_new0 (YelpPage, 1);
page->id = page_id;
page->title = page_title;
page->chunk = page_buf;
page->page_id = page_id;
page->title = page_title;
page->contents = page_buf;
cur = xmlDocGetRootElement (new_doc);
for (cur = cur->children; cur; cur = cur->next) {
......@@ -494,11 +495,11 @@ xslt_yelp_document (xsltTransformContextPtr ctxt,
xmlChar *rel = xmlGetProp (cur, "rel");
if (!xmlStrcmp (rel, (xmlChar *) "Previous"))
page->prev = xmlGetProp (cur, "href");
page->prev_id = xmlGetProp (cur, "href");
else if (!xmlStrcmp (rel, (xmlChar *) "Next"))
page->next = xmlGetProp (cur, "href");
page->next_id = xmlGetProp (cur, "href");
else if (!xmlStrcmp (rel, (xmlChar *) "Top"))
page->toc = xmlGetProp (cur, "href");
page->toc_id = xmlGetProp (cur, "href");
xmlFree (rel);
}
......@@ -556,7 +557,7 @@ walker_walk_xml (DBWalker *walker)
id = xmlGetProp (walker->cur, "id");
if (!id && walker->cur->parent->type == XML_DOCUMENT_NODE) {
id = xmlStrdup ("index");
id = xmlStrdup ("__yelp_toc");
}
if (walker_is_chunk (walker)) {
......
......@@ -24,13 +24,13 @@
#include <config.h>
#endif
#include <stdio.h>
#include <glib.h>
#include <zlib.h>
#ifdef HAVE_LIBBZ2
#include <bzlib.h>
#endif
#include <string.h>
#include <stdio.h>
#include "yelp-error.h"
#include "yelp-io-channel.h"
......
......@@ -62,8 +62,8 @@ void man_pager_cancel (YelpPager *pager);
void man_pager_finish (YelpPager *pager);
gboolean man_pager_process (YelpPager *pager);
gchar * man_pager_resolve_uri (YelpPager *pager,
YelpURI *uri);
const gchar * man_pager_resolve_frag (YelpPager *pager,
const gchar *frag_id);
const GtkTreeModel * man_pager_get_sections (YelpPager *pager);
static void xslt_yelp_document (xsltTransformContextPtr ctxt,
......@@ -114,7 +114,7 @@ man_pager_class_init (YelpManPagerClass *klass)
pager_class->finish = man_pager_finish;
pager_class->process = man_pager_process;
pager_class->resolve_uri = man_pager_resolve_uri;
pager_class->resolve_frag = man_pager_resolve_frag;
pager_class->get_sections = man_pager_get_sections;
}
......@@ -255,10 +255,10 @@ man_pager_finish (YelpPager *pager)
yelp_toc_pager_unpause (yelp_toc_pager_get ());
}
gchar *
man_pager_resolve_uri (YelpPager *pager, YelpURI *uri)
const gchar *
man_pager_resolve_frag (YelpPager *pager, const gchar *frag_id)
{
return g_strdup ("index");
return "index";
}
const GtkTreeModel *
......@@ -342,13 +342,13 @@ xslt_yelp_document (xsltTransformContextPtr ctxt,
page = g_new0 (YelpPage, 1);
page->id = page_id;
page->title = page_title;
page->chunk = page_buf;
page->page_id = page_id;
page->title = page_title;
page->contents = page_buf;
page->prev = NULL;
page->next = NULL;
page->toc = NULL;
page->prev_id = NULL;
page->next_id = NULL;
page->toc_id = NULL;
yelp_pager_add_page (pager, page);
g_signal_emit_by_name (pager, "page", page_id);
......
......@@ -364,71 +364,31 @@ yelp_pager_get_sections (YelpPager *pager)
return YELP_PAGER_GET_CLASS (pager)->get_sections (pager);
}
gchar *
yelp_pager_resolve_uri (YelpPager *pager, YelpURI *uri)
const gchar *
yelp_pager_resolve_frag (YelpPager *pager, const gchar *frag_id)
{
gchar *frag_id = NULL;
frag_id = (gchar *) (YELP_PAGER_GET_CLASS (pager)->resolve_uri (pager, uri));
return frag_id;
return YELP_PAGER_GET_CLASS (pager)->resolve_frag (pager, frag_id);
}
gboolean
yelp_pager_uri_is_page (YelpPager *pager, gchar *page_id, YelpURI *uri)
yelp_pager_page_contains_frag (YelpPager *pager,
const gchar *page_id,
const gchar *frag_id)
{
gchar *frag_id = NULL;
gboolean equal;
frag_id = (gchar *) (YELP_PAGER_GET_CLASS (pager)->resolve_uri (pager, uri));
if (!frag_id || !strcmp (frag_id, ""))
equal = FALSE;
else if (!page_id || !strcmp (page_id, "") || !strcmp (page_id, "index")) {
if (!strcmp (frag_id, "index"))
equal = TRUE;
else
equal = FALSE;
}
else if (!strcmp (page_id, frag_id))
equal = TRUE;
else
equal = FALSE;
const gchar *frag_page_id =
YELP_PAGER_GET_CLASS (pager)->resolve_frag (pager, frag_id);
g_free (frag_id);
return equal;
return !strcmp (frag_page_id, page_id);
}
const YelpPage *
yelp_pager_lookup_page (YelpPager *pager, YelpURI *uri)
yelp_pager_get_page (YelpPager *pager, const gchar *frag_id)
{
gchar *page_id = NULL;
YelpPage *page;
YelpPage *page;
const gchar *page_id =
YELP_PAGER_GET_CLASS (pager)->resolve_frag (pager, frag_id);
g_return_val_if_fail (pager != NULL, NULL);
g_return_val_if_fail (YELP_IS_PAGER (pager), NULL);
page_id = (gchar *) (YELP_PAGER_GET_CLASS (pager)->resolve_uri (pager, uri));
if (!page_id)
page_id = g_strdup (gnome_vfs_uri_get_fragment_identifier (uri->uri));
page = (YelpPage *) yelp_pager_get_page (pager, page_id);
g_free (page_id);
return (const YelpPage *) page;
}
const YelpPage *
yelp_pager_get_page (YelpPager *pager, gchar *id)
{
YelpPage *page;
g_return_val_if_fail (pager != NULL, NULL);
g_return_val_if_fail (YELP_IS_PAGER (pager), NULL);
page = (YelpPage *) g_hash_table_lookup (pager->priv->page_hash, id);
page = (YelpPage *) g_hash_table_lookup (pager->priv->page_hash, page_id);
return (const YelpPage *) page;
}
......@@ -440,21 +400,23 @@ yelp_pager_add_page (YelpPager *pager,
g_return_if_fail (pager != NULL);
g_return_if_fail (YELP_IS_PAGER (pager));
g_return_if_fail (page->id != NULL);
g_return_if_fail (page->page_id != NULL);
g_hash_table_insert (pager->priv->page_hash, page->id, page);
g_hash_table_insert (pager->priv->page_hash, page->page_id, page);
}
void
yelp_page_free (YelpPage *page)
{
g_free (page->id);
g_return_if_fail (page != NULL);
g_free (page->page_id);
g_free (page->title);
g_free (page->chunk);
g_free (page->contents);
g_free (page->prev);
g_free (page->next);
g_free (page->toc);
g_free (page->prev_id);
g_free (page->next_id);
g_free (page->toc_id);
g_free (page);
}
......@@ -65,19 +65,19 @@ struct _YelpPagerClass {
/* Virtual Functions */
gboolean (*process) (YelpPager *pager);
gchar * (*resolve_uri) (YelpPager *pager,
YelpURI *uri);
const gchar * (*resolve_frag) (YelpPager *pager,
const gchar *frag_id);
const GtkTreeModel * (*get_sections) (YelpPager *pager);
};
struct _YelpPage {
gchar *id;
gchar *page_id;
gchar *title;
gchar *chunk;
gchar *contents;
gchar *prev;
gchar *next;
gchar *toc;
gchar *prev_id;
gchar *next_id;
gchar *toc_id;
};
GType yelp_pager_get_type (void);
......@@ -96,20 +96,17 @@ GError * yelp_pager_get_error (YelpPager *pager);
void yelp_pager_error (YelpPager *pager,
GError *error);
const GtkTreeModel * yelp_pager_get_sections (YelpPager *pager);
gchar * yelp_pager_resolve_uri (YelpPager *pager,
YelpURI *uri);
gboolean yelp_pager_uri_is_page (YelpPager *pager,
gchar *page_id,
YelpURI *uri);
const YelpPage * yelp_pager_lookup_page (YelpPager *pager,
YelpURI *uri);
const YelpPage * yelp_pager_get_page (YelpPager *pager,
gchar *id);
void yelp_pager_add_page (YelpPager *pager,
YelpPage *page);
void yelp_page_free (YelpPage *page);
const GtkTreeModel * yelp_pager_get_sections (YelpPager *pager);
const gchar * yelp_pager_resolve_frag (YelpPager *pager,
const gchar *frag_id);
gboolean yelp_pager_page_contains_frag (YelpPager *pager,
const gchar *page_id,
const gchar *frag_id);
const YelpPage * yelp_pager_get_page (YelpPager *pager,
const gchar *frag_id);
void yelp_pager_add_page (YelpPager *pager,
YelpPage *page);
void yelp_page_free (YelpPage *page);
#endif /* __YELP_PAGER_H__ */
......@@ -123,8 +123,8 @@ static void toc_pager_dispose (GObject *gobject);
gboolean toc_pager_process (YelpPager *pager);
void toc_pager_cancel (YelpPager *pager);
gchar * toc_pager_resolve_uri (YelpPager *pager,
YelpURI *uri);
const gchar * toc_pager_resolve_frag (YelpPager *pager,
const gchar *frag_id);
const GtkTreeModel * toc_pager_get_sections (YelpPager *pager);
static gboolean toc_process_pending (YelpTocPager *pager);
......@@ -196,7 +196,7 @@ toc_pager_class_init (YelpTocPagerClass *klass)
pager_class->process = toc_pager_process;
pager_class->cancel = toc_pager_cancel;
pager_class->resolve_uri = toc_pager_resolve_uri;
pager_class->resolve_frag = toc_pager_resolve_frag;
pager_class->get_sections = toc_pager_get_sections;
}
......@@ -325,15 +325,13 @@ toc_pager_cancel (YelpPager *pager)
priv->cancel = TRUE;
}
gchar *
toc_pager_resolve_uri (YelpPager *pager, YelpURI *uri)
const gchar *
toc_pager_resolve_frag (YelpPager *pager, const gchar *frag_id)
{
const gchar *frag = gnome_vfs_uri_get_fragment_identifier (uri->uri);
if (!frag)
return g_strdup ("index");
if (!frag_id)
return "index";
else
return g_strdup (frag);
return frag_id;
}
const GtkTreeModel *
......@@ -772,9 +770,9 @@ process_menu_pending (YelpTocPager *pager)
if (menu->has_submenus || menu->metafiles) {
YelpPage *page = g_new0 (YelpPage, 1);
page->chunk = menu_write_page (menu);
page->id = menu->id;
page->title = menu->title;
page->page_id = menu->id;
page->title = menu->title;
page->contents = menu_write_page (menu);
yelp_pager_add_page (YELP_PAGER (pager), page);
g_signal_emit_by_name (pager, "page", menu->id);
......
......@@ -224,9 +224,9 @@ struct _YelpWindowPriv {
GtkWidget *back_button;
/* Don't free these */
gchar *prev;
gchar *next;
gchar *toc;
gchar *prev_id;
gchar *next_id;
gchar *toc_id;
};
typedef struct _IdleWriterContext IdleWriterContext;
......@@ -744,6 +744,8 @@ window_handle_pager_uri (YelpWindow *window,
YelpPage *page = NULL;
YelpPager *pager;
YelpPagerState state;
const gchar *frag_id =
gnome_vfs_uri_get_fragment_identifier (uri->uri);
priv = window->priv;
......@@ -803,21 +805,17 @@ window_handle_pager_uri (YelpWindow *window,
if (state & YELP_PAGER_STATE_STARTED) {
if (state & YELP_PAGER_STATE_CONTENTS) {
const gchar *frag_id =
gnome_vfs_uri_get_fragment_identifier (uri->uri);
gchar *page_id = yelp_pager_resolve_uri (pager, uri);
const gchar *page_id =
yelp_pager_resolve_frag (pager, frag_id);
if (!page_id && (frag_id && strcmp (frag_id, ""))) {
yelp_set_error (&error, YELP_ERROR_NO_PAGE);
window_error (window, error);
g_free (page_id);
g_error_free (error);
return FALSE;
}
g_free (page_id);
} else {
priv->contents_handler =
g_signal_connect (pager,
......@@ -826,7 +824,7 @@ window_handle_pager_uri (YelpWindow *window,
window);
}
page = (YelpPage *) yelp_pager_lookup_page (pager, uri);
page = (YelpPage *) yelp_pager_get_page (pager, frag_id);
loadnow = (page ? TRUE : FALSE);
startnow = FALSE;
......@@ -997,6 +995,7 @@ window_handle_page (YelpWindow *window,
YelpWindowPriv *priv;
gchar *id;
gboolean valid;
const gchar *frag_id;
IdleWriterContext *context;
g_return_if_fail (YELP_IS_WINDOW (window));
......@@ -1007,13 +1006,15 @@ window_handle_page (YelpWindow *window,
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->side_sects));
frag_id = gnome_vfs_uri_get_fragment_identifier (uri->uri);
if (model) {
valid = gtk_tree_model_get_iter_first (model, &iter);
while (valid) {
gtk_tree_model_get (model, &iter,
0, &id,
-1);
if (yelp_pager_uri_is_page (priv->pager, id, uri)) {
if (yelp_pager_page_contains_frag (priv->pager, id, frag_id)) {
GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
GtkTreeSelection *selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->side_sects));
......@@ -1041,29 +1042,29 @@ window_handle_page (YelpWindow *window,
}
}
priv->prev = page->prev;
priv->prev_id = page->prev_id;
menu_item =
gtk_item_factory_get_item_by_action (priv->item_factory,
YELP_WINDOW_GO_PREVIOUS);
if (menu_item)
gtk_widget_set_sensitive (menu_item,
priv->prev ? TRUE : FALSE);
priv->prev_id ? TRUE : FALSE);
priv->next = page->next;
priv->next_id = page->next_id;
menu_item =
gtk_item_factory_get_item_by_action (priv->item_factory,
YELP_WINDOW_GO_NEXT);
if (menu_item)
gtk_widget_set_sensitive (menu_item,
priv->next ? TRUE : FALSE);
priv->next_id ? TRUE : FALSE);
priv->toc = page->toc;
priv->toc_id = page->toc_id;
menu_item =