diff options
author | Mikael Hallendal <micke@codefactory.se> | 2002-06-02 23:21:33 +0000 |
---|---|---|
committer | Mikael Hallendal <hallski@src.gnome.org> | 2002-06-02 23:21:33 +0000 |
commit | 063711af525d5bb6fe83047585079720d0928590 (patch) | |
tree | b3e16e5000307d7855dbb9053e639a62d41b397a | |
parent | e954a3edabfcdb9b596c73e3d4326967e771d900 (diff) | |
download | yelp-063711af525d5bb6fe83047585079720d0928590.tar.gz |
added, used to find the path to a certain URI.
2002-06-03 Mikael Hallendal <micke@codefactory.se>
* src/yelp-view-content.c:
(content_find_path_from_uri): added, used to find the path to a
certain URI.
(content_tree_model_foreach): added, used by above function.
(content_reader_finished_cb): expand tree and select the correct
node. Fixes #80518
* src/yelp-reader.h: finish signal includes the URI which finished
loading.
* src/yelp-db2html.c: send path to the docbook stylesheets as a
parameter. Still doesn't seem to fix the path problem with the
images.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | src/yelp-db2html.c | 6 | ||||
-rw-r--r-- | src/yelp-reader.c | 9 | ||||
-rw-r--r-- | src/yelp-reader.h | 3 | ||||
-rw-r--r-- | src/yelp-view-content.c | 105 | ||||
-rw-r--r-- | src/yelp-view-toc.c | 2 |
6 files changed, 125 insertions, 16 deletions
@@ -1,3 +1,19 @@ +2002-06-03 Mikael Hallendal <micke@codefactory.se> + + * src/yelp-view-content.c: + (content_find_path_from_uri): added, used to find the path to a + certain URI. + (content_tree_model_foreach): added, used by above function. + (content_reader_finished_cb): expand tree and select the correct + node. Fixes #80518 + + * src/yelp-reader.h: finish signal includes the URI which finished + loading. + + * src/yelp-db2html.c: send path to the docbook stylesheets as a + parameter. Still doesn't seem to fix the path problem with the + images. + 2002-06-02 Mikael Hallendal <micke@codefactory.se> * Fixes #69047 diff --git a/src/yelp-db2html.c b/src/yelp-db2html.c index 0712cdb4..111f52c3 100644 --- a/src/yelp-db2html.c +++ b/src/yelp-db2html.c @@ -48,8 +48,8 @@ /* stylesheet location based on Linux Standard Base * * http://www.linuxbase.org/spec/gLSB/gLSB/sgmlr002.html */ -#define STYLESHEET_PATH DATADIR"/sgml/docbook/yelp" -#define STYLESHEET STYLESHEET_PATH"/yelp-customization.xsl" +#define DB_STYLESHEET_PATH DATADIR"/sgml/docbook/yelp/docbook" +#define STYLESHEET DATADIR"/sgml/docbook/yelp/yelp-customization.xsl" /* xmlParserInput * */ /* external_entity_loader (const char *URL, */ @@ -114,7 +114,7 @@ main (gint argc, gchar **argv) params[2] = "gdb_pathname"; params[3] = g_strconcat("\"", pathname, "\"", NULL) ; params[4] = "gdb_stylesheet_path"; - params[5] = STYLESHEET_PATH; + params[5] = DB_STYLESHEET_PATH; params[6] = "gdb_multichunk"; params[7] = "1"; params[8] = NULL; diff --git a/src/yelp-reader.c b/src/yelp-reader.c index 83844538..95e958c5 100644 --- a/src/yelp-reader.c +++ b/src/yelp-reader.c @@ -166,9 +166,9 @@ reader_class_init (YelpReaderClass *klass) G_STRUCT_OFFSET (YelpReaderClass, finished), NULL, NULL, - yelp_marshal_VOID__VOID, + yelp_marshal_VOID__POINTER, G_TYPE_NONE, - 0); + 1, G_TYPE_POINTER); signals[CANCELLED] = g_signal_new ("cancelled", G_TYPE_FROM_CLASS (klass), @@ -402,7 +402,7 @@ reader_file_start (ReaderThreadData *th_data) } q_data = reader_q_data_new (reader, stamp, READER_QUEUE_TYPE_FINISHED); - + g_async_queue_push (priv->thread_queue, q_data); } @@ -582,7 +582,8 @@ reader_idle_check_queue (ReaderThreadData *th_data) priv->stamp = 1; } - g_signal_emit (reader, signals[FINISHED], 0); + g_signal_emit (reader, signals[FINISHED], 0, + th_data->uri); ret_val = FALSE; break; diff --git a/src/yelp-reader.h b/src/yelp-reader.h index 3f881356..d545c87a 100644 --- a/src/yelp-reader.h +++ b/src/yelp-reader.h @@ -52,7 +52,8 @@ struct _YelpReaderClass { void (*data) (YelpReader *reader, const gchar *buffer, gint len); - void (*finished) (YelpReader *reader); + void (*finished) (YelpReader *reader, + YelpURI *read_uri); void (*cancelled) (YelpReader *reader); void (*error) (YelpReader *reader, GError *error); diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c index 0db26c18..718302fa 100644 --- a/src/yelp-view-content.c +++ b/src/yelp-view-content.c @@ -38,6 +38,7 @@ #include "yelp-reader.h" #include "yelp-scrollkeeper.h" #include "yelp-util.h" +#include "yelp-uri.h" #include "yelp-view-content.h" #define d(x) @@ -62,12 +63,14 @@ static void content_reader_data_cb (YelpReader *reader, gint len, YelpViewContent *view); static void content_reader_finished_cb (YelpReader *reader, + YelpURI *uri, YelpViewContent *view); static void content_reader_error_cb (YelpReader *reader, GError *error, YelpViewContent *view); - - +static GtkTreePath * +content_find_path_from_uri (GtkTreeModel *model, + YelpURI *uri); enum { URI_SELECTED, @@ -216,14 +219,12 @@ content_html_title_changed_cb (YelpHtml *html, const gchar *title, YelpViewContent *view) { - g_print ("Title changed to: %s\n", title); - g_signal_emit (view, signals[TITLE_CHANGED], 0, title); } static void content_tree_selection_changed_cb (GtkTreeSelection *selection, - YelpViewContent *content) + YelpViewContent *content) { YelpViewContentPriv *priv; GtkTreeIter iter; @@ -309,9 +310,12 @@ content_reader_data_cb (YelpReader *reader, } static void -content_reader_finished_cb (YelpReader *reader, YelpViewContent *view) +content_reader_finished_cb (YelpReader *reader, + YelpURI *uri, + YelpViewContent *view) { YelpViewContentPriv *priv; + GtkTreePath *path = NULL; g_return_if_fail (YELP_IS_READER (reader)); g_return_if_fail (YELP_IS_VIEW_CONTENT (view)); @@ -320,6 +324,54 @@ content_reader_finished_cb (YelpReader *reader, YelpViewContent *view) yelp_html_close (priv->html_view); + path = content_find_path_from_uri (GTK_TREE_MODEL (priv->tree_store), + uri); + + if (path) { + GtkTreeSelection *selection; + GtkTreePath *parent; + + /* Open the correct node in the tree */ + + d(g_print ("Found path\n")); + + selection = gtk_tree_view_get_selection ( + GTK_TREE_VIEW (priv->content_tree)); + + parent = gtk_tree_path_copy (path); + + gtk_tree_path_up (parent); + + gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->content_tree), + parent, FALSE); + + gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->content_tree), + path, TRUE); + + parent = gtk_tree_path_copy (path); + + g_signal_handlers_block_by_func ( + selection, + content_tree_selection_changed_cb, + view); + + gtk_tree_selection_select_path (selection, path); + + g_signal_handlers_unblock_by_func ( + selection, + content_tree_selection_changed_cb, + view); + + while (gtk_tree_path_up (path)) { + gtk_tree_view_expand_row ( + GTK_TREE_VIEW (priv->content_tree), + path, FALSE); + } + + gtk_tree_path_free (path); + gtk_tree_path_free (parent); + } + gdk_window_set_cursor (priv->html_widget->window, NULL); gtk_widget_grab_focus (priv->html_widget); } @@ -341,6 +393,47 @@ content_reader_error_cb (YelpReader *reader, g_warning ("%s\n", error->message); } +static GtkTreePath *found_path; + +static gboolean +content_tree_model_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + YelpURI *uri) +{ + YelpSection *section = NULL; + + g_return_val_if_fail (GTK_IS_TREE_MODEL (model), TRUE); + g_return_val_if_fail (uri != NULL, TRUE); + + gtk_tree_model_get (model, iter, + 1, §ion, + -1); + + if (!section) { + return FALSE; + } + + if (yelp_uri_equal (uri, section->uri)) { + found_path = gtk_tree_path_copy (path); + return TRUE; + } + + return FALSE; +} + +static GtkTreePath * +content_find_path_from_uri (GtkTreeModel *model, YelpURI *uri) +{ + found_path = NULL; + + gtk_tree_model_foreach (model, + (GtkTreeModelForeachFunc) content_tree_model_foreach, + uri); + + return found_path; +} + GtkWidget * yelp_view_content_new (GNode *doc_tree) { diff --git a/src/yelp-view-toc.c b/src/yelp-view-toc.c index 9c5b6549..d8c59e76 100644 --- a/src/yelp-view-toc.c +++ b/src/yelp-view-toc.c @@ -685,8 +685,6 @@ toc_html_title_changed_cb (YelpHtml *html, const gchar *title, YelpViewTOC *view) { - g_print ("Title changed to: %s\n", title); - g_signal_emit (view, signals[TITLE_CHANGED], 0, title); } |