summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Larsson <alexl@redhat.com>2002-01-24 01:34:15 +0000
committerAlexander Larsson <alexl@src.gnome.org>2002-01-24 01:34:15 +0000
commit6669a81ebf6ec3026b5b378793983b778012d73e (patch)
tree8c810eb14b3491677b9a68a01c16680ccaa3c50b
parent1461846a580d29114833f3abc9c28355c7db4908 (diff)
downloadyelp-6669a81ebf6ec3026b5b378793983b778012d73e.tar.gz
Implement seriesid lookup.
2002-01-23 Alex Larsson <alexl@redhat.com> * src/yelp-scrollkeeper.[ch]: Implement seriesid lookup. * src/yelp-view-toc.c: Fix the startpage to contain the seriesid docs, and be more dynamic.
-rw-r--r--ChangeLog9
-rw-r--r--src/yelp-scrollkeeper.c24
-rw-r--r--src/yelp-scrollkeeper.h4
-rw-r--r--src/yelp-view-toc.c112
4 files changed, 108 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 272a023f..1d13be00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2002-01-23 Alex Larsson <alexl@redhat.com>
+ * src/yelp-scrollkeeper.[ch]:
+ Implement seriesid lookup.
+
+ * src/yelp-view-toc.c:
+ Fix the startpage to contain the seriesid docs, and
+ be more dynamic.
+
+2002-01-23 Alex Larsson <alexl@redhat.com>
+
* src/yelp-util.c:
Change path separator to '/'.
diff --git a/src/yelp-scrollkeeper.c b/src/yelp-scrollkeeper.c
index e65efae2..55fb329f 100644
--- a/src/yelp-scrollkeeper.c
+++ b/src/yelp-scrollkeeper.c
@@ -63,6 +63,8 @@ static gchar * ys_strip_scheme (gchar *original_uri,
static gint calls = 0;
+static GHashTable *seriesid_hash = NULL;
+
static gboolean
ys_trim_empty_branches (xmlNode *node)
{
@@ -207,8 +209,10 @@ ys_parse_doc (GNode *parent, xmlNode *xml_node)
gchar *link;
gchar *format;
gchar *docsource;
+ gchar *docseriesid;
GNode *node;
+ docseriesid = NULL;
for (cur = xml_node->xmlChildrenNode; cur; cur = cur->next) {
if (!g_strcasecmp (cur->name, "doctitle")) {
xml_str = xmlNodeGetContent (cur);
@@ -231,12 +235,21 @@ ys_parse_doc (GNode *parent, xmlNode *xml_node)
format = g_strdup (xml_str);
xmlFree (xml_str);
}
+ else if (!g_strcasecmp (cur->name, "docseriesid")) {
+ xml_str = xmlNodeGetContent (cur);
+ docseriesid = g_strdup (xml_str);
+ xmlFree (xml_str);
+ }
}
node = g_node_append_data (parent, yelp_section_new (YELP_SECTION_DOCUMENT,
title, link,
NULL, NULL));
+ if (docseriesid) {
+ g_hash_table_insert (seriesid_hash, docseriesid, node);
+ }
+
#if 0
ys_parse_toc (NULL, NULL, docsource);
#endif
@@ -450,6 +463,12 @@ yelp_scrollkeeper_init (GtkTreeStore *store)
}
#endif
+GNode *
+yelp_scrollkeeper_lookup_seriesid (const char *seriesid)
+{
+ return g_hash_table_lookup (seriesid_hash, seriesid);
+}
+
gboolean
yelp_scrollkeeper_init (GNode *tree)
{
@@ -459,8 +478,11 @@ yelp_scrollkeeper_init (GNode *tree)
g_return_val_if_fail (tree != NULL, FALSE);
+ seriesid_hash = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free, NULL);
+
doc = NULL;
-
for (node = gnome_i18n_get_language_list ("LC_MESSAGES"); node; node = node->next) {
docpath = ys_get_xml_docpath ("scrollkeeper-get-content-list",
node->data);
diff --git a/src/yelp-scrollkeeper.h b/src/yelp-scrollkeeper.h
index 5bf38782..a7ac9624 100644
--- a/src/yelp-scrollkeeper.h
+++ b/src/yelp-scrollkeeper.h
@@ -25,6 +25,6 @@
#include <glib.h>
-gboolean yelp_scrollkeeper_init (GNode *tree);
-
+gboolean yelp_scrollkeeper_init (GNode *tree);
+GNode * yelp_scrollkeeper_lookup_seriesid (const char *seriesid);
#endif /* __YELP_SCROLLKEEPER_H__ */
diff --git a/src/yelp-view-toc.c b/src/yelp-view-toc.c
index fa254bb7..52fa36ed 100644
--- a/src/yelp-view-toc.c
+++ b/src/yelp-view-toc.c
@@ -34,17 +34,20 @@
#include "yelp-view-toc.h"
#include "yelp-marshal.h"
#include "yelp-util.h"
+#include "yelp-scrollkeeper.h"
#define d(x) x
-static void yvh_init (YelpViewTOC *html);
-static void yvh_class_init (YelpViewTOCClass *klass);
-static void yvh_link_clicked_cb (HtmlDocument *doc,
- const gchar *url,
- YelpViewTOC *view);
-static void yelp_view_toc_man_1 (YelpViewTOC *view);
-static void yelp_view_toc_man_2 (YelpViewTOC *view,
- GNode *root);
+static void yvh_init (YelpViewTOC *html);
+static void yvh_class_init (YelpViewTOCClass *klass);
+static void yvh_link_clicked_cb (HtmlDocument *doc,
+ const gchar *url,
+ YelpViewTOC *view);
+static void yelp_view_toc_man_1 (YelpViewTOC *view);
+static void yelp_view_toc_man_2 (YelpViewTOC *view,
+ GNode *root);
+static GNode *yelp_view_toc_find_toplevel (YelpViewTOC *view,
+ gchar *name);
enum {
URL_SELECTED,
@@ -216,37 +219,28 @@ yelp_view_toc_write_footer (YelpViewTOC *view)
static void
yelp_view_toc_start (YelpViewTOC *view)
{
+ YelpViewTOCPriv *priv;
+ GNode *node;
+ YelpSection *section;
gchar *table_start = "
<center>
<table cellspacing=\"20\" width=\"100%\">
- <tr>
- <td valign=\"top\">
- <h2>GNOME</h2>
- <ul>
- <li><b>Introduction to GNOME</b>
- <li><b>GNOME User Guide</b>
- </ul>
- <ul>
-";
+ <tr>";
gchar *table_end = "
- </ul>
- </td>
- <td valign=\"top\">
- <h2>System</h2>
- <ul>
- <li><b>Man pages</b><br>
- Describe what <a href=\"toc:man\">man pages</a> are...
- <li><b>Info pages</b><br>
- Describe what <a href=\"toc:info\">info pages</a> are...
- </ul>
- </td>
</tr>
</table>
</center>
";
- YelpViewTOCPriv *priv;
- GNode *node;
- YelpSection *section;
+ /* FIXME: Hardcoded crap: */
+ char *seriesids[] = {
+ "01ddeea4-0a42-11d6-9cf9-ee43c422358d",
+ "01ddeea4-0a42-11d6-9cf9-ee43c422358e",
+ NULL
+ };
+ char *seriesid;
+ char **p;
+ GNode *root;
+ char *path;
priv = view->priv;
@@ -259,18 +253,60 @@ yelp_view_toc_start (YelpViewTOC *view)
yelp_view_toc_write_header (view, "Start page");
yelp_view_toc_write (view, table_start, -1);
+
+ yelp_view_toc_write (view,
+ "<td valign=\"top\">\n"
+ "<h2>Important documents</h2>\n"
+ "<ul>\n", -1);
+
+ p = &seriesids[0];
+ while (*p != NULL) {
+ seriesid = *p;
+ p++;
+
+ node = yelp_scrollkeeper_lookup_seriesid (seriesid);
+ if (node) {
+ section = node->data;
+ yelp_view_toc_printf (view,
+ "<li><a href=\"%s\">%s</a>\n",
+ section->uri, section->name);
+ }
+
+ }
- node = g_node_first_child (priv->doc_tree);
+
+ yelp_view_toc_write (view,
+ "</ul>\n"
+ "</td>\n", -1);
- do {
+
+
+ yelp_view_toc_write (view,
+ "<td valign=\"top\">\n"
+ "<h2>Installed documents</h2>\n", -1);
+
+ root = yelp_view_toc_find_toplevel (view, "scrollkeeper");
+ node = g_node_first_child (root);
+
+ while (node) {
section = (YelpSection *) node->data;
-
+ path = yelp_util_node_to_string_path (node);
yelp_view_toc_printf (view,
- "<li><a href=\"path:%s\">%s</a>\n",
- section->uri, section->name);
+ "<a href=\"toc:scrollkeeper/%s\">%s</a><br>\n",
+ path, section->name);
- } while ((node = g_node_next_sibling (node)));
+ node = g_node_next_sibling (node);
+ }
+
+ yelp_view_toc_write (view,
+ "<h2>Other document systems</h2>\n"
+ "<a href=\"toc:man\">Manual pages</a><br>\n"
+ "<a href=\"toc:info\">Info pages</a><br>\n", -1);
+
+ yelp_view_toc_write (view,
+ "</td>\n", -1);
+
yelp_view_toc_write (view, table_end, -1);
yelp_view_toc_write_footer (view);
@@ -470,7 +506,7 @@ static void
yelp_view_toc_info (YelpViewTOC *view)
{
YelpViewTOCPriv *priv;
- GNode *root, *node, *child;
+ GNode *root, *node;
YelpSection *section;
char *url;