summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-03-03 15:58:29 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-03-03 15:58:29 +0000
commit24adb4e3959db0814f3ab051971050ca5ae90464 (patch)
tree7e55794604f08d5337302c11290925914c79ff7a
parent180a51bcb17698bf33134adea35b6d7e8bcb8bb7 (diff)
downloadyelp-24adb4e3959db0814f3ab051971050ca5ae90464.tar.gz
- Fixes #72146 - Don't show "Other documents" if neither man or info are
2002-03-03 Mikael Hallendal <micke@codefactory.se> * src/yelp-view-toc.c (yelp_view_toc_start): - Fixes #72146 - Don't show "Other documents" if neither man or info are installed. - Don't show "Manual pages" link if no man pages are installed - Don't show "Info pages" link of no info pages are installed. * src/yelp-man.c (yelp_man_init): - return FALSE and don't create a topnode 'man' in the content tree if there weren't any man pages installed. * src/yelp-info.c (yelp_info_init): - return FALSE if no info pages was found. Also don't create the topnode 'info' in the content-tree if there weren't any pages. * src/yelp-html.c: removed commeted code. * src/yelp-base.c (yelp_base_new): don't care about the result for now.
-rw-r--r--ChangeLog20
-rw-r--r--src/yelp-base.c9
-rw-r--r--src/yelp-html.c20
-rw-r--r--src/yelp-info.c14
-rw-r--r--src/yelp-man.c38
-rw-r--r--src/yelp-view-toc.c33
6 files changed, 86 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index 4e3aca9c..0dcb0c52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
2002-03-03 Mikael Hallendal <micke@codefactory.se>
+ * src/yelp-view-toc.c (yelp_view_toc_start):
+ - Fixes #72146
+ - Don't show "Other documents" if neither man or info are
+ installed.
+ - Don't show "Manual pages" link if no man pages are installed
+ - Don't show "Info pages" link of no info pages are installed.
+
+ * src/yelp-man.c (yelp_man_init):
+ - return FALSE and don't create a topnode 'man' in the content
+ tree if there weren't any man pages installed.
+
+ * src/yelp-info.c (yelp_info_init):
+ - return FALSE if no info pages was found. Also don't create the
+ topnode 'info' in the content-tree if there weren't any pages.
+
+ * src/yelp-html.c: removed commeted code.
+
+ * src/yelp-base.c (yelp_base_new): don't care about the result for
+ now.
+
* src/yelp-info.c:
- Fixes #73270
(yelp_info_read_info_dir): renamed from
diff --git a/src/yelp-base.c b/src/yelp-base.c
index 61b6a67a..777ec001 100644
--- a/src/yelp-base.c
+++ b/src/yelp-base.c
@@ -166,16 +166,13 @@ yelp_base_new (void)
{
YelpBase *base;
YelpBasePriv *priv;
- gboolean result;
base = g_object_new (YELP_TYPE_BASE, NULL);
priv = base->priv;
- result = yelp_scrollkeeper_init (priv->toc_tree,
- (&priv->index));
-
- result = yelp_man_init (base->priv->toc_tree);
- result = yelp_info_init (base->priv->toc_tree);
+ yelp_scrollkeeper_init (priv->toc_tree, (&priv->index));
+ yelp_man_init (base->priv->toc_tree);
+ yelp_info_init (base->priv->toc_tree);
return base;
}
diff --git a/src/yelp-html.c b/src/yelp-html.c
index fbc97673..df6b9a91 100644
--- a/src/yelp-html.c
+++ b/src/yelp-html.c
@@ -249,6 +249,7 @@ yh_url_requested_cb (HtmlDocument *doc,
sdata = g_new0 (StreamData, 1);
sdata->view = view;
sdata->stream = stream;
+
priv->connections = g_slist_prepend (priv->connections, sdata);
@@ -266,25 +267,6 @@ yh_url_requested_cb (HtmlDocument *doc,
html_stream_set_cancel_func (stream, yh_stream_cancel, sdata);
}
-/* static void */
-/* kill_old_connections (HtmlDocument *doc) */
-/* { */
-/* GSList *connection_list, *tmp; */
-
-/* tmp = connection_list = g_object_get_data (G_OBJECT (doc), "connection_list"); */
-/* while(tmp) { */
-
-/* StreamData *sdata = (StreamData *)tmp->data; */
-/* gnome_vfs_async_cancel (sdata->handle); */
-/* free_stream_data (sdata, FALSE); */
-
-/* tmp = tmp->next; */
-/* } */
-
-/* g_object_set_data (G_OBJECT (doc), "connection_list", NULL); */
-/* g_slist_free (connection_list); */
-/* } */
-
static void
yh_stream_cancel (HtmlStream *stream,
gpointer user_data,
diff --git a/src/yelp-info.c b/src/yelp-info.c
index f1dcfbbd..4626c0d5 100644
--- a/src/yelp-info.c
+++ b/src/yelp-info.c
@@ -104,11 +104,6 @@ yelp_info_init (GNode *tree)
GSList *info_list = NULL;
GSList *node;
- root = g_node_append_data (tree,
- yelp_section_new (YELP_SECTION_CATEGORY,
- _("info"), NULL,
- NULL, NULL));
-
stat ("/usr/info", &stat_dir1);
stat ("/usr/share/info", &stat_dir2);
@@ -118,6 +113,15 @@ yelp_info_init (GNode *tree)
yelp_info_read_info_dir ("/usr/share/info", &info_list);
}
+ if (g_slist_length (info_list) <= 0) {
+ return FALSE;
+ }
+
+ root = g_node_append_data (tree,
+ yelp_section_new (YELP_SECTION_CATEGORY,
+ _("info"), NULL,
+ NULL, NULL));
+
info_list = g_slist_sort (info_list, yelp_section_compare);
for (node = info_list; node; node = node->next) {
diff --git a/src/yelp-man.c b/src/yelp-man.c
index a4d1dd13..1233ffea 100644
--- a/src/yelp-man.c
+++ b/src/yelp-man.c
@@ -42,7 +42,7 @@
#include "yelp-man.h"
struct TreeNode {
- char *name;
+ char *name;
GList *tree_nodes;
@@ -50,18 +50,20 @@ struct TreeNode {
};
struct TreeData {
- char *name;
+ char *name;
struct TreeData *children;
- char *section;
+ char *section;
};
+static gboolean any_man_pages = FALSE;
+
/* Caller must free this */
static char *
extract_secnum_from_filename (const char *filename)
{
char *end_string = NULL;
char *start;
- int len;
+ int len;
#ifdef HAVE_LIBBZ2
end_string = g_strrstr (filename, ".bz2");
@@ -119,9 +121,10 @@ yelp_man_populate_tree_for_subdir (GHashTable *section_hash,
char secnum)
{
DIR *dirh;
- struct dirent *dent;
- char uribuf[128], titlebuf[128];
+ struct dirent *dent;
+ char uribuf[128], titlebuf[128];
struct TreeNode *node;
+ YelpSection *yelp_section;
dirh = opendir (basedir);
if (!dirh) {
@@ -153,10 +156,13 @@ yelp_man_populate_tree_for_subdir (GHashTable *section_hash,
manname = man_name_without_suffix (dent->d_name);
filename = g_build_filename (basedir, dent->d_name, NULL);
- g_snprintf (titlebuf, sizeof (titlebuf), "%s (%s)", manname, section);
+ g_snprintf (titlebuf, sizeof (titlebuf), "%s (%s)",
+ manname, section);
+
g_snprintf (uribuf, sizeof (uribuf), "man:%s", filename);
node = g_hash_table_lookup (section_hash, section);
+
if (node == NULL) {
char buf[2];
buf[0] = secnum; buf[1] = 0;
@@ -166,10 +172,14 @@ yelp_man_populate_tree_for_subdir (GHashTable *section_hash,
g_assert (node != NULL);
- node->pages = g_list_prepend (node->pages,
- yelp_section_new (YELP_SECTION_DOCUMENT,
- titlebuf, uribuf,
- NULL, NULL));
+ any_man_pages = TRUE;
+
+ yelp_section = yelp_section_new (YELP_SECTION_DOCUMENT,
+ titlebuf, uribuf,
+ NULL, NULL);
+
+ node->pages = g_list_prepend (node->pages, yelp_section);
+
g_free (manname);
g_free (section);
g_free (filename);
@@ -502,7 +512,7 @@ yelp_man_cleanup_initial_tree (struct TreeNode *node)
}
- node->pages = g_list_sort (node->pages, (GCompareFunc)yelp_section_compare);
+ node->pages = g_list_sort (node->pages, yelp_section_compare);
}
static void
@@ -596,6 +606,10 @@ yelp_man_init (GNode *tree)
yelp_man_cleanup_initial_tree (root);
+ if (!any_man_pages) {
+ return FALSE;
+ }
+
yelp_man_push_initial_tree (root, tree);
yelp_man_free_initial_tree (root);
diff --git a/src/yelp-view-toc.c b/src/yelp-view-toc.c
index 2fca89ae..e1ad2a49 100644
--- a/src/yelp-view-toc.c
+++ b/src/yelp-view-toc.c
@@ -274,6 +274,8 @@ yelp_view_toc_start (YelpViewTOC *view)
gchar *installed_string = _("Installed documents");
YelpImportantDocsSection *important_section;
gboolean important_doc_installed = FALSE;
+ gboolean man_installed = FALSE;
+ gboolean info_installed = FALSE;
priv = view->priv;
@@ -362,13 +364,32 @@ yelp_view_toc_start (YelpViewTOC *view)
node = g_node_next_sibling (node);
}
+ if (yelp_util_find_toplevel (priv->doc_tree, "man")) {
+ man_installed = TRUE;
+ }
+
+ if (yelp_util_find_toplevel (priv->doc_tree, "info")) {
+ info_installed = TRUE;
+ }
+
+
+ if (man_installed || info_installed) {
+ yelp_view_toc_printf (view, "<h2>%s</h2>\n",
+ other_docs_string);
+
+ if (man_installed) {
+ yelp_view_toc_printf (view,
+ "<a href=\"toc:man\">%s</a><br>\n",
+ man_string);
+ }
+
+ if (info_installed) {
+ yelp_view_toc_printf (view,
+ "<a href=\"toc:info\">%s</a><br>\n",
+ info_string);
+ }
+ }
- yelp_view_toc_printf (view,
- "<h2>%s</h2>\n"
- "<a href=\"toc:man\">%s</a><br>\n"
- "<a href=\"toc:info\">%s</a><br>\n",
- other_docs_string, man_string, info_string);
-
yelp_view_toc_write (view,
"</td>\n", -1);