summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-02-18 14:13:45 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-02-18 14:13:45 +0000
commite022ece45c0ba86d122a9be2e0c300610252940c (patch)
treeb222246ba509efad736b0cc11aef0df7fc75214b /src
parent5e4cd1e2c440b159d395dd87ae2c4fbe2c30e56b (diff)
downloadyelp-e022ece45c0ba86d122a9be2e0c300610252940c.tar.gz
don't add entry to history list if it's the same as the current.
2002-02-18 Mikael Hallendal <micke@codefactory.se> * src/yelp-history.c (yelp_history_goto): don't add entry to history list if it's the same as the current. * src/yelp-window.c (yw_home_button_clicked): Notify the history list that we have moved. * src/yelp-view-index.c (yvi_tree_selection_changed_cb): call yelp_html_open_uri instead of yelp_html_open_section. * src/yelp-html.[ch] (yelp_html_open_uri): renamed from yelp_html_open_sectoin. It now takes an uri and a reference instead of a YelpSection. * src/yelp-view-content.c (yelp_view_content_show_uri): call yelp_html_open_uri instead of creating a temporary YelpSection. * src/yelp-view-toc.c (yelp_view_toc_man_2): don't send html for translations, reported by Christian Rose * src/yelp-window.c (yw_init): make the default size smaller. * src/yelp-view-toc.c: typedef the YelpImportantDocsSection struct (yelp_view_toc_start): only write section topic for important documents if there is any documents installed in that section. * src/yelp-util.c: (yelp_util_extract_docpath_from_uri): - Also work for sgml documents.
Diffstat (limited to 'src')
-rw-r--r--src/yelp-history.c5
-rw-r--r--src/yelp-html.c28
-rw-r--r--src/yelp-html.h5
-rw-r--r--src/yelp-scrollkeeper.c2
-rw-r--r--src/yelp-util.c6
-rw-r--r--src/yelp-view-content.c12
-rw-r--r--src/yelp-view-index.c3
-rw-r--r--src/yelp-view-toc.c46
-rw-r--r--src/yelp-window.c8
9 files changed, 73 insertions, 42 deletions
diff --git a/src/yelp-history.c b/src/yelp-history.c
index 22318df8..03e32b5c 100644
--- a/src/yelp-history.c
+++ b/src/yelp-history.c
@@ -194,6 +194,11 @@ yelp_history_goto (YelpHistory *history, const gchar *location)
g_return_if_fail (YELP_IS_HISTORY (history));
priv = history->priv;
+
+ if (priv->current && priv->current->data &&
+ !strcmp ((gchar *)priv->current->data, location)) {
+ return;
+ }
if (yelp_history_exist_forward (history)) {
forward_list = priv->current->next;
diff --git a/src/yelp-html.c b/src/yelp-html.c
index 9244a842..19585c56 100644
--- a/src/yelp-html.c
+++ b/src/yelp-html.c
@@ -124,7 +124,7 @@ yh_init (YelpHtml *view)
priv->doc = html_document_new ();
priv->connections = NULL;
- priv->base_uri = NULL;
+ priv->base_uri = g_strdup ("");
html_view_set_document (HTML_VIEW (view), priv->doc);
@@ -370,8 +370,11 @@ yelp_html_new (void)
return GTK_WIDGET (view);
}
+
void
-yelp_html_open_section (YelpHtml *view, const YelpSection *section)
+yelp_html_open_uri (YelpHtml *view,
+ const gchar *str_uri,
+ const gchar *reference)
{
YelpHtmlPriv *priv;
StreamData *sdata;
@@ -381,11 +384,11 @@ yelp_html_open_section (YelpHtml *view, const YelpSection *section)
d(puts(G_GNUC_FUNCTION));
g_return_if_fail (YELP_IS_HTML (view));
- g_return_if_fail (section != NULL);
+ g_return_if_fail (str_uri != NULL);
priv = view->priv;
- d(g_print ("Trying to open: %s\n", section->uri));
+ d(g_print ("Trying to open: %s\n", str_uri));
html_document_clear (priv->doc);
html_document_open_stream (priv->doc, "text/html");
@@ -393,11 +396,10 @@ yelp_html_open_section (YelpHtml *view, const YelpSection *section)
gtk_adjustment_set_value (
gtk_layout_get_vadjustment (GTK_LAYOUT (view)), 0);
- if (priv->base_uri) {
+ if (strcmp (priv->base_uri, str_uri)) {
g_free (priv->base_uri);
+ priv->base_uri = g_strdup (str_uri);
}
-
- priv->base_uri = g_strdup (section->uri);
sdata = g_new0 (StreamData, 1);
sdata->view = view;
@@ -406,18 +408,16 @@ yelp_html_open_section (YelpHtml *view, const YelpSection *section)
priv->connections = g_slist_prepend (priv->connections, sdata);
- if (section->reference) {
- gchar *tmp_uri = g_strconcat (section->uri,
- section->reference,
- NULL);
+ if (reference) {
+ gchar *tmp_uri = g_strconcat (str_uri, reference, NULL);
uri = gnome_vfs_uri_new (tmp_uri);
g_free (tmp_uri);
} else {
- uri = gnome_vfs_uri_new (section->uri);
+ uri = gnome_vfs_uri_new (str_uri);
}
- if (section->reference) {
- sdata->anchor = g_strdup (section->reference);
+ if (reference) {
+ sdata->anchor = g_strdup (reference);
} else if (uri) {
fragment = gnome_vfs_uri_get_fragment_identifier (uri);
if (fragment) {
diff --git a/src/yelp-html.h b/src/yelp-html.h
index 34b2eb00..a68a6e10 100644
--- a/src/yelp-html.h
+++ b/src/yelp-html.h
@@ -58,8 +58,9 @@ struct _YelpHtmlClass {
GType yelp_html_get_type (void);
GtkWidget *yelp_html_new (void);
-void yelp_html_open_section (YelpHtml *view,
- const YelpSection *section);
+void yelp_html_open_uri (YelpHtml *view,
+ const gchar *uri,
+ const gchar *reference);
#endif /* __YELP_HTML_H__ */
diff --git a/src/yelp-scrollkeeper.c b/src/yelp-scrollkeeper.c
index fe6abcf8..229518e2 100644
--- a/src/yelp-scrollkeeper.c
+++ b/src/yelp-scrollkeeper.c
@@ -426,6 +426,8 @@ yelp_scrollkeeper_get_toc_tree (const gchar *docpath)
tree = g_node_new (NULL);
+ g_print ("Trying to find doc tree for: %s\n", docpath);
+
toc_file = ys_get_xml_docpath ("scrollkeeper-get-toc-from-docpath",
docpath);
diff --git a/src/yelp-util.c b/src/yelp-util.c
index dd112a48..42893a46 100644
--- a/src/yelp-util.c
+++ b/src/yelp-util.c
@@ -485,12 +485,16 @@ yelp_util_extract_docpath_from_uri (const gchar *str_uri)
return NULL;
}
-
if ((extension = strstr (str_uri, ".xml"))) {
const gchar *str;
str = str_uri + 6;
/* This means we have a ghelp-uri with full path */
docpath = g_strndup (str, extension + 4 - str);
+ }
+ else if ((extension = strstr (str_uri, ".sgml"))) {
+ const gchar *str;
+ str = str_uri + 6;
+ docpath = g_strndup (str, extension + 5 - str);
} else {
/* URI not a fullpath URI, let the GnomeVFS help module
calculate the full URI */
diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c
index 30b8bf3e..1b99a4d3 100644
--- a/src/yelp-view-content.c
+++ b/src/yelp-view-content.c
@@ -290,7 +290,6 @@ yelp_view_content_show_uri (YelpViewContent *content,
const gchar *url)
{
YelpViewContentPriv *priv;
- YelpSection *section;
gchar *content_url;
GNode *node;
@@ -323,7 +322,7 @@ yelp_view_content_show_uri (YelpViewContent *content,
/* Try to find it in the scrollkeeper database,
doesn't have to exist here */
node = yelp_scrollkeeper_get_toc_tree (docpath);
-
+
if (node) {
yelp_view_content_set_tree (content, node);
@@ -351,15 +350,10 @@ yelp_view_content_show_uri (YelpViewContent *content,
content_url = (char *) url;
}
- /* FIXME: This is a quite dubious way to load the url... */
- section = yelp_section_new (YELP_SECTION_DOCUMENT,
- NULL, content_url, NULL, NULL);
-
- yelp_html_open_section (YELP_HTML (content->priv->html_view), section);
- yelp_section_free (section);
+ yelp_html_open_uri (YELP_HTML (content->priv->html_view),
+ content_url, NULL);
if (content_url != url) {
g_free (content_url);
}
}
-
diff --git a/src/yelp-view-index.c b/src/yelp-view-index.c
index 78c23292..d6aba069 100644
--- a/src/yelp-view-index.c
+++ b/src/yelp-view-index.c
@@ -116,7 +116,8 @@ yvi_tree_selection_changed_cb (GtkTreeSelection *selection,
1, &section,
-1);
- yelp_html_open_section (YELP_HTML (priv->html_view), section);
+ yelp_html_open_uri (YELP_HTML (priv->html_view),
+ section->uri, section->reference);
}
/* FIXME: Emit section_selected?? */
diff --git a/src/yelp-view-toc.c b/src/yelp-view-toc.c
index 1f033e84..c9e050c6 100644
--- a/src/yelp-view-toc.c
+++ b/src/yelp-view-toc.c
@@ -57,10 +57,10 @@ enum {
static gint signals[LAST_SIGNAL] = { 0 };
-struct YelpImportantDocsSection {
+typedef struct {
char *title;
GList *seriesids;
-};
+} YelpImportantDocsSection;
#define BUFFER_SIZE 4096
@@ -272,8 +272,9 @@ yelp_view_toc_start (YelpViewTOC *view)
gchar *man_string = _("Manual pages");
gchar *info_string = _("Info pages");
gchar *installed_string = _("Installed documents");
- struct YelpImportantDocsSection *important_section;
-
+ YelpImportantDocsSection *important_section;
+ gboolean important_doc_installed = FALSE;
+
priv = view->priv;
if (!g_node_first_child (priv->doc_tree)) {
@@ -292,16 +293,36 @@ yelp_view_toc_start (YelpViewTOC *view)
sections = priv->important_sections;
while (sections != NULL) {
important_section = sections->data;
-
- yelp_view_toc_printf (view,
- "<h2>%s</h2>\n"
- "<ul>\n", important_section->title);
seriesids = important_section->seriesids;
+
+ /* Check if any of the important documents are installed *
+ * before trying to write the section topic */
+
+ for (seriesids = important_section->seriesids;
+ seriesids;
+ seriesids = seriesids->next) {
+ seriesid = seriesids->data;
+
+ if (yelp_scrollkeeper_lookup_seriesid (seriesid)){
+ important_doc_installed = TRUE;
+ }
+ }
+
+ if (important_doc_installed) {
+ yelp_view_toc_printf (view,
+ "<h2>%s</h2>\n"
+ "<ul>\n",
+ important_section->title);
+ }
+
+ seriesids = important_section->seriesids;
+
while (seriesids != NULL) {
seriesid = seriesids->data;
node = yelp_scrollkeeper_lookup_seriesid (seriesid);
+
if (node) {
section = node->data;
yelp_view_toc_printf (view,
@@ -457,7 +478,7 @@ yelp_view_toc_man_2 (YelpViewTOC *view,
{
GNode *first;
gchar *name;
- gchar *string = _("<a href=\"toc:man\">Manual pages</a>: ");
+ gchar *string = _("Manual pages");
if (root->children == NULL) {
return;
@@ -471,7 +492,7 @@ yelp_view_toc_man_2 (YelpViewTOC *view,
name = yelp_view_toc_full_path_name (view, root);
- yelp_view_toc_printf (view, "<h1>%s '%s'</h1>\n", string, name);
+ yelp_view_toc_printf (view, "<h1><a href=\"toc:man\">%s</a>: '%s'</h1>\n", string, name);
g_free (name);
yelp_view_toc_man_emit (view, first);
@@ -579,7 +600,7 @@ yelp_view_read_important_docs (YelpViewTOC *view)
xmlNodePtr section;
xmlNodePtr title;
xmlChar *prop;
- struct YelpImportantDocsSection *important_section;
+ YelpImportantDocsSection *important_section;
doc = xmlParseFile (DATADIR "/yelp/important_docs.xml");
if (doc == NULL)
@@ -599,8 +620,7 @@ yelp_view_read_important_docs (YelpViewTOC *view)
section = node->children;
while (section) {
if (strcmp (section->name, "section") == 0) {
- important_section = g_new0 (struct YelpImportantDocsSection, 1);
-
+ important_section = g_new0 (YelpImportantDocsSection, 1);
child = section->children;
while (child) {
if (strcmp (child->name, "title") == 0) {
diff --git a/src/yelp-window.c b/src/yelp-window.c
index ee99042b..4b901b8d 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -30,6 +30,7 @@
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomeui/gnome-about.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-url.h>
#include <string.h>
#include "yelp-html.h"
#include "yelp-util.h"
@@ -159,7 +160,7 @@ yw_init (YelpWindow *window)
priv->history = yelp_history_new ();
yelp_history_goto (priv->history, "toc:");
- gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
+ gtk_window_set_default_size (GTK_WINDOW (window), 600, 420);
gtk_window_set_title (GTK_WINDOW (window), _("Help Browser"));
}
@@ -269,7 +270,7 @@ yw_handle_url (YelpWindow *window, const gchar *url)
return TRUE;
} else {
/* FIXME: Show dialog on failure? */
- gnome_url_show (url);
+ gnome_url_show (url, NULL);
}
return FALSE;
@@ -356,8 +357,11 @@ yw_home_button_clicked (GtkWidget *button, YelpWindow *window)
g_return_if_fail (GTK_IS_BUTTON (button));
g_return_if_fail (YELP_IS_WINDOW (window));
+ yelp_history_goto (window->priv->history, "toc:");
+
yelp_view_toc_open_url (YELP_VIEW_TOC (window->priv->toc_view),
"toc:");
+
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
PAGE_TOC_VIEW);
}