summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <micke@codefactory.se>2002-05-17 23:53:25 +0000
committerMikael Hallendal <hallski@src.gnome.org>2002-05-17 23:53:25 +0000
commit5380a99302b519228bcaacae1ebba7f39904576e (patch)
tree794c51f7de87e4a703a433c747502d2ec27e656f
parent43a631a402525808e38800dd6ca19554ba87c7ea (diff)
downloadyelp-5380a99302b519228bcaacae1ebba7f39904576e.tar.gz
- commented out call to yelp_html_open_uri since it's been removed.
2002-05-18 Mikael Hallendal <micke@codefactory.se> * src/yelp-view-index.c (yelp_view_index_show_uri): - commented out call to yelp_html_open_uri since it's been removed. * src/yelp-view-content.c: - changed name on internal functions to conform with style. - moved functions from yelp-html.c - use the YelpReader to read the data instead of letting YelpHtml handle it. (yelp_view_content_stop): removed. * src/yelp-html.c: (html_reader_start_cb): moved to yelp-view-content.c (html_reader_data_cb): same (html_reader_finished_cb): same (html_reader_error_cb): same (yelp_html_clear): added/impl. (yelp_html_write): added/impl. (yelp_html_close): added/impl. (yelp_html_cancel_loading): removed (yelp_html_open_uri): removed (yelp_html_set_base_uri): added/impl.
-rw-r--r--ChangeLog23
-rw-r--r--src/yelp-html.c177
-rw-r--r--src/yelp-html.h15
-rw-r--r--src/yelp-view-content.c151
-rw-r--r--src/yelp-view-content.h1
-rw-r--r--src/yelp-view-index.c2
-rw-r--r--src/yelp-window.c2
7 files changed, 204 insertions, 167 deletions
diff --git a/ChangeLog b/ChangeLog
index 2feb7ceb..bc06bcdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2002-05-18 Mikael Hallendal <micke@codefactory.se>
+ * src/yelp-view-index.c (yelp_view_index_show_uri):
+ - commented out call to yelp_html_open_uri since it's been
+ removed.
+
+ * src/yelp-view-content.c:
+ - changed name on internal functions to conform with style.
+ - moved functions from yelp-html.c
+ - use the YelpReader to read the data instead of letting YelpHtml
+ handle it.
+ (yelp_view_content_stop): removed.
+
+ * src/yelp-html.c:
+ (html_reader_start_cb): moved to yelp-view-content.c
+ (html_reader_data_cb): same
+ (html_reader_finished_cb): same
+ (html_reader_error_cb): same
+ (yelp_html_clear): added/impl.
+ (yelp_html_write): added/impl.
+ (yelp_html_close): added/impl.
+ (yelp_html_cancel_loading): removed
+ (yelp_html_open_uri): removed
+ (yelp_html_set_base_uri): added/impl.
+
* src/yelp-reader.c:
(reader_man_info_start): emit "start"-signal.
(reader_io_watch_cb): do the right thing (hopefully) :)
diff --git a/src/yelp-html.c b/src/yelp-html.c
index 081f78eb..5304ebce 100644
--- a/src/yelp-html.c
+++ b/src/yelp-html.c
@@ -46,8 +46,6 @@ struct _YelpHtmlPriv {
HtmlView *view;
HtmlDocument *doc;
- HtmlDocument *load_doc;
- GSList *connections;
YelpURI *base_uri;
YelpReader *reader;
};
@@ -56,18 +54,6 @@ struct _YelpHtmlPriv {
static void html_init (YelpHtml *html);
static void html_class_init (YelpHtmlClass *klass);
-static void html_reader_start_cb (YelpReader *reader,
- YelpHtml *html);
-static void html_reader_data_cb (YelpReader *reader,
- gint len,
- const gchar *data,
- YelpHtml *html);
-static void html_reader_finished_cb (YelpReader *reader,
- YelpHtml *html);
-static void html_reader_error_cb (YelpReader *reader,
- GError *error,
- YelpHtml *html);
-
static void html_url_requested_cb (HtmlDocument *doc,
const gchar *uri,
HtmlStream *stream,
@@ -126,38 +112,7 @@ html_init (YelpHtml *html)
priv->view = HTML_VIEW (html_view_new ());
priv->doc = html_document_new ();
- priv->connections = NULL;
priv->base_uri = NULL;
- priv->load_doc = html_document_new ();
- priv->reader = yelp_reader_new (FALSE);
-
- g_signal_connect (G_OBJECT (priv->reader), "start",
- G_CALLBACK (html_reader_start_cb),
- html);
- g_signal_connect (G_OBJECT (priv->reader), "data",
- G_CALLBACK (html_reader_data_cb),
- html);
- g_signal_connect (G_OBJECT (priv->reader), "finished",
- G_CALLBACK (html_reader_finished_cb),
- html);
- g_signal_connect (G_OBJECT (priv->reader), "error",
- G_CALLBACK (html_reader_error_cb),
- html);
-
-
- html_document_open_stream (priv->load_doc, "text/html");
-
- {
- gint len;
- gchar *str = _("Loading...");
- gchar *text = g_strdup_printf ("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body bgcolor=\"white\"><center>%s</center></body></html>", str);
- len = strlen (text);
-
- html_document_write_stream (priv->load_doc, text, len);
- g_free (text);
- }
-
- html_document_close_stream (priv->load_doc);
html_view_set_document (HTML_VIEW (priv->view), priv->doc);
@@ -186,83 +141,6 @@ html_class_init (YelpHtmlClass *klass)
}
static void
-html_reader_start_cb (YelpReader *reader, YelpHtml *html)
-{
- YelpHtmlPriv *priv;
- GdkCursor *cursor;
-
- g_return_if_fail (YELP_IS_READER (reader));
- g_return_if_fail (YELP_IS_HTML (html));
-
- priv = html->priv;
-
- cursor = gdk_cursor_new (GDK_WATCH);
-
- gdk_window_set_cursor (GTK_WIDGET (priv->view)->window, cursor);
- gdk_cursor_unref (cursor);
-
- html_document_clear (priv->doc);
- html_document_open_stream (priv->doc, "text/html");
-
- html_stream_set_cancel_func (priv->doc->current_stream,
- html_cancel_stream,
- html);
-}
-
-static void
-html_reader_data_cb (YelpReader *reader,
- gint len,
- const gchar *data,
- YelpHtml *html)
-{
- YelpHtmlPriv *priv;
-
- g_return_if_fail (YELP_IS_READER (reader));
- g_return_if_fail (YELP_IS_HTML (html));
-
- priv = html->priv;
-
- if (len <= 0) {
- return;
- }
-
- html_document_write_stream (html->priv->doc, data, len);
-}
-
-static void
-html_reader_finished_cb (YelpReader *reader, YelpHtml *html)
-{
- YelpHtmlPriv *priv;
-
- g_return_if_fail (YELP_IS_READER (reader));
- g_return_if_fail (YELP_IS_HTML (html));
-
- priv = html->priv;
-
- html_document_close_stream (html->priv->doc);
-
- gtk_adjustment_set_value (gtk_layout_get_vadjustment (GTK_LAYOUT (priv->view)),
- 0);
-
- gdk_window_set_cursor (GTK_WIDGET (priv->view)->window, NULL);
-}
-
-static void
-html_reader_error_cb (YelpReader *reader, GError *error, YelpHtml *html)
-{
- YelpHtmlPriv *priv;
-
- g_return_if_fail (YELP_IS_READER (reader));
- g_return_if_fail (YELP_IS_HTML (html));
-
- priv = html->priv;
-
- /* Popup window */
-
- g_warning ("%s\n", error->message);
-}
-
-static void
html_url_requested_cb (HtmlDocument *doc,
const gchar *url,
HtmlStream *stream,
@@ -380,29 +258,66 @@ yelp_html_new (void)
}
void
-yelp_html_open_uri (YelpHtml *html, YelpURI *uri, GError **error)
+yelp_html_set_base_uri (YelpHtml *html, YelpURI *uri)
{
- YelpHtmlPriv *priv;
-
- d(g_print ("Open URI: %s\n", yelp_uri_to_string (uri)));
-
+ YelpHtmlPriv *priv;
+
g_return_if_fail (YELP_IS_HTML (html));
- g_return_if_fail (uri != NULL);
- priv = html->priv;
+ priv = html->priv;
if (priv->base_uri) {
yelp_uri_unref (priv->base_uri);
}
priv->base_uri = yelp_uri_ref (uri);
+}
+
+void
+yelp_html_clear (YelpHtml *html)
+{
+ YelpHtmlPriv *priv;
+
+ g_return_if_fail (YELP_IS_HTML (html));
+
+ priv = html->priv;
- yelp_reader_read (priv->reader, uri);
+ html_document_clear (priv->doc);
+ html_document_open_stream (priv->doc, "text/html");
+ html_stream_set_cancel_func (priv->doc->current_stream,
+ html_cancel_stream,
+ html);
}
void
-yelp_html_cancel_loading (YelpHtml *html)
+yelp_html_write (YelpHtml *html, gint len, const gchar *data)
{
+ YelpHtmlPriv *priv;
+
+ g_return_if_fail (YELP_IS_HTML (html));
+
+ priv = html->priv;
+
+ if (len <= 0) {
+ return;
+ }
+
+ html_document_write_stream (priv->doc, data, len);
+}
+
+void
+yelp_html_close (YelpHtml *html)
+{
+ YelpHtmlPriv *priv;
+
+ g_return_if_fail (YELP_IS_HTML (html));
+
+ priv = html->priv;
+
+ html_document_close_stream (html->priv->doc);
+
+ gtk_adjustment_set_value (gtk_layout_get_vadjustment (GTK_LAYOUT (priv->view)),
+ 0);
}
GtkWidget *
diff --git a/src/yelp-html.h b/src/yelp-html.h
index 8c010451..10731b17 100644
--- a/src/yelp-html.h
+++ b/src/yelp-html.h
@@ -55,13 +55,16 @@ struct _YelpHtmlClass {
GType yelp_html_get_type (void);
YelpHtml * yelp_html_new (void);
-
-void yelp_html_open_uri (YelpHtml *html,
- YelpURI *uri,
- GError **error);
-void yelp_html_cancel_loading (YelpHtml *html);
-GtkWidget * yelp_html_get_widget (YelpHtml *html);
+void yelp_html_set_base_uri (YelpHtml *html,
+ YelpURI *uri);
+void yelp_html_clear (YelpHtml *html);
+void yelp_html_write (YelpHtml *html,
+ gint len,
+ const gchar *data);
+void yelp_html_close (YelpHtml *html);
+
+GtkWidget * yelp_html_get_widget (YelpHtml *html);
#endif /* __YELP_HTML_H__ */
diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c
index 0ba46eb9..7af3a921 100644
--- a/src/yelp-view-content.c
+++ b/src/yelp-view-content.c
@@ -35,20 +35,33 @@
#include "yelp-html.h"
#include "yelp-marshal.h"
+#include "yelp-reader.h"
#include "yelp-scrollkeeper.h"
#include "yelp-util.h"
#include "yelp-view-content.h"
#define d(x)
-static void yvc_init (YelpViewContent *html);
-static void yvc_class_init (YelpViewContentClass *klass);
-static void yvc_tree_selection_changed_cb (GtkTreeSelection *selection,
- YelpViewContent *content);
-static void yvc_html_uri_selected_cb (YelpHtml *html,
- YelpURI *uri,
- gboolean handled,
- YelpViewContent *view);
+static void content_init (YelpViewContent *html);
+static void content_class_init (YelpViewContentClass *klass);
+static void content_tree_selection_changed_cb (GtkTreeSelection *selection,
+ YelpViewContent *content);
+static void content_html_uri_selected_cb (YelpHtml *html,
+ YelpURI *uri,
+ gboolean handled,
+ YelpViewContent *view);
+static void content_reader_start_cb (YelpReader *reader,
+ YelpViewContent *view);
+static void content_reader_data_cb (YelpReader *reader,
+ gint len,
+ const gchar *data,
+ YelpViewContent *view);
+static void content_reader_finished_cb (YelpReader *reader,
+ YelpViewContent *view);
+static void content_reader_error_cb (YelpReader *reader,
+ GError *error,
+ YelpViewContent *view);
+
enum {
@@ -65,8 +78,11 @@ struct _YelpViewContentPriv {
GtkTreeStore *tree_store;
GNode *doc_tree;
+ YelpReader *reader;
+
/* Html view */
YelpHtml *html_view;
+ GtkWidget *html_widget;
gchar *current_docpath;
};
@@ -83,12 +99,12 @@ yelp_view_content_get_type (void)
sizeof (YelpViewContentClass),
NULL,
NULL,
- (GClassInitFunc) yvc_class_init,
+ (GClassInitFunc) content_class_init,
NULL,
NULL,
sizeof (YelpViewContent),
0,
- (GInstanceInitFunc) yvc_init,
+ (GInstanceInitFunc) content_init,
};
view_type = g_type_register_static (GTK_TYPE_HPANED,
@@ -101,7 +117,7 @@ yelp_view_content_get_type (void)
static void
-yvc_init (YelpViewContent *view)
+content_init (YelpViewContent *view)
{
YelpViewContentPriv *priv;
@@ -117,15 +133,31 @@ yvc_init (YelpViewContent *view)
GTK_TREE_MODEL (priv->tree_store));
priv->html_view = yelp_html_new ();
+ priv->html_widget = yelp_html_get_widget (priv->html_view);
priv->current_docpath = g_strdup ("");
g_signal_connect (priv->html_view, "uri_selected",
- G_CALLBACK (yvc_html_uri_selected_cb),
+ G_CALLBACK (content_html_uri_selected_cb),
+ view);
+
+ priv->reader = yelp_reader_new (FALSE);
+
+ g_signal_connect (G_OBJECT (priv->reader), "start",
+ G_CALLBACK (content_reader_start_cb),
+ view);
+ g_signal_connect (G_OBJECT (priv->reader), "data",
+ G_CALLBACK (content_reader_data_cb),
+ view);
+ g_signal_connect (G_OBJECT (priv->reader), "finished",
+ G_CALLBACK (content_reader_finished_cb),
+ view);
+ g_signal_connect (G_OBJECT (priv->reader), "error",
+ G_CALLBACK (content_reader_error_cb),
view);
}
static void
-yvc_class_init (YelpViewContentClass *klass)
+content_class_init (YelpViewContentClass *klass)
{
signals[URI_SELECTED] =
g_signal_new ("uri_selected",
@@ -140,7 +172,7 @@ yvc_class_init (YelpViewContentClass *klass)
}
static void
-yvc_html_uri_selected_cb (YelpHtml *html,
+content_html_uri_selected_cb (YelpHtml *html,
YelpURI *uri,
gboolean handled,
YelpViewContent *view)
@@ -154,7 +186,7 @@ yvc_html_uri_selected_cb (YelpHtml *html,
}
static void
-yvc_tree_selection_changed_cb (GtkTreeSelection *selection,
+content_tree_selection_changed_cb (GtkTreeSelection *selection,
YelpViewContent *content)
{
YelpViewContentPriv *priv;
@@ -179,6 +211,77 @@ yvc_tree_selection_changed_cb (GtkTreeSelection *selection,
}
}
+static void
+content_reader_start_cb (YelpReader *reader, YelpViewContent *view)
+{
+ YelpViewContentPriv *priv;
+ GdkCursor *cursor;
+
+ g_return_if_fail (YELP_IS_READER (reader));
+ g_return_if_fail (YELP_IS_VIEW_CONTENT (view));
+
+ priv = view->priv;
+
+ cursor = gdk_cursor_new (GDK_WATCH);
+
+ gdk_window_set_cursor (priv->html_widget->window, cursor);
+ gdk_cursor_unref (cursor);
+
+ yelp_html_clear (priv->html_view);
+}
+
+static void
+content_reader_data_cb (YelpReader *reader,
+ gint len,
+ const gchar *data,
+ YelpViewContent *view)
+{
+ YelpViewContentPriv *priv;
+
+ g_return_if_fail (YELP_IS_READER (reader));
+ g_return_if_fail (YELP_IS_VIEW_CONTENT (view));
+
+ priv = view->priv;
+
+ if (len <= 0) {
+ return;
+ }
+
+ yelp_html_write (priv->html_view, len, data);
+}
+
+static void
+content_reader_finished_cb (YelpReader *reader, YelpViewContent *view)
+{
+ YelpViewContentPriv *priv;
+
+ g_return_if_fail (YELP_IS_READER (reader));
+ g_return_if_fail (YELP_IS_VIEW_CONTENT (view));
+
+ priv = view->priv;
+
+ yelp_html_close (priv->html_view);
+
+ gdk_window_set_cursor (priv->html_widget->window, NULL);
+}
+
+static void
+content_reader_error_cb (YelpReader *reader,
+ GError *error,
+ YelpViewContent *view)
+{
+ YelpViewContentPriv *priv;
+
+ g_return_if_fail (YELP_IS_READER (reader));
+ g_return_if_fail (YELP_IS_VIEW_CONTENT (view));
+
+ priv = view->priv;
+
+ /* Popup window */
+
+ g_warning ("%s\n", error->message);
+}
+
GtkWidget *
yelp_view_content_new (GNode *doc_tree)
{
@@ -209,7 +312,7 @@ yelp_view_content_new (GNode *doc_tree)
GTK_TREE_VIEW (priv->content_tree));
g_signal_connect (selection, "changed",
- G_CALLBACK (yvc_tree_selection_changed_cb),
+ G_CALLBACK (content_tree_selection_changed_cb),
view);
gtk_container_add (GTK_CONTAINER (priv->tree_sw), priv->content_tree);
@@ -223,8 +326,8 @@ yelp_view_content_new (GNode *doc_tree)
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (frame), html_sw);
- gtk_container_add (GTK_CONTAINER (html_sw),
- yelp_html_get_widget (priv->html_view));
+ gtk_container_add (GTK_CONTAINER (html_sw), priv->html_widget);
+
/* Add the tree and html view to the paned */
gtk_paned_add1 (GTK_PANED (view), priv->tree_sw);
@@ -320,13 +423,9 @@ yelp_view_content_show_uri (YelpViewContent *content,
gtk_widget_hide (priv->tree_sw);
}
- yelp_html_open_uri (priv->html_view, uri, error);
-}
-
-void
-yelp_view_content_stop (YelpViewContent *content)
-{
- g_return_if_fail (YELP_IS_VIEW_CONTENT (content));
+ yelp_html_set_base_uri (priv->html_view, uri);
- yelp_html_cancel_loading (content->priv->html_view);
+ yelp_reader_read (priv->reader, uri);
+
+/* yelp_html_open_uri (priv->html_view, uri, error); */
}
diff --git a/src/yelp-view-content.h b/src/yelp-view-content.h
index 4476b842..dd94fbf6 100644
--- a/src/yelp-view-content.h
+++ b/src/yelp-view-content.h
@@ -60,6 +60,5 @@ GtkWidget *yelp_view_content_new (GNode *doc_tree);
void yelp_view_content_show_uri (YelpViewContent *content,
YelpURI *uri,
GError **error);
-void yelp_view_content_stop (YelpViewContent *content);
#endif /* __YELP_VIEW_CONTENT__ */
diff --git a/src/yelp-view-index.c b/src/yelp-view-index.c
index 1fc18c23..baf3c6e0 100644
--- a/src/yelp-view-index.c
+++ b/src/yelp-view-index.c
@@ -424,7 +424,7 @@ yelp_view_index_show_uri (YelpViewIndex *view,
priv = view->priv;
/* FIXME: Handle the GError */
- yelp_html_open_uri (priv->html_view, uri, error);
+/* yelp_html_open_uri (priv->html_view, uri, error); */
}
/**
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 93356fb7..972f9d4d 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -325,8 +325,6 @@ yw_handle_uri (YelpWindow *window, YelpURI *uri)
d(g_print ("Handling URL: %s\n", yelp_uri_to_string (uri)));
-/* yelp_view_content_stop (YELP_VIEW_CONTENT (priv->content_view)); */
-
if (yelp_uri_get_type (uri) == YELP_URI_TYPE_TOC) {
d(g_print ("[TOC]\n"));