use an idle handler to jump to the anchor.

2004-11-10  Sven Neumann  <sven@gimp.org>

	* plug-ins/helpbrowser/dialog.c: use an idle handler to jump to the
	anchor.
This commit is contained in:
Sven Neumann 2004-11-10 00:27:43 +00:00 committed by Sven Neumann
parent 5ed7339aec
commit 390d49dfdf
2 changed files with 34 additions and 15 deletions

View File

@ -1,3 +1,8 @@
2004-11-10 Sven Neumann <sven@gimp.org>
* plug-ins/helpbrowser/dialog.c: use an idle handler to jump to the
anchor.
2004-11-09 Manish Singh <yosh@gimp.org> 2004-11-09 Manish Singh <yosh@gimp.org>
* plug-ins/common/bmpread.c: if the file has space in the colormap for * plug-ins/common/bmpread.c: if the file has space in the colormap for

View File

@ -282,15 +282,25 @@ browser_dialog_open (void)
gtk_widget_show (window); gtk_widget_show (window);
} }
static gboolean
idle_jump_to_anchor (const gchar *anchor)
{
if (html && anchor)
html_view_jump_to_anchor (HTML_VIEW (html), anchor);
return FALSE;
}
void void
browser_dialog_load (const gchar *ref, browser_dialog_load (const gchar *ref,
gboolean add_to_queue) gboolean add_to_queue)
{ {
HtmlDocument *doc = HTML_VIEW (html)->document; HtmlDocument *doc = HTML_VIEW (html)->document;
gchar *abs; GtkAdjustment *adj = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
gchar *new_ref; gchar *abs;
gchar *anchor; gchar *new_ref;
gchar *tmp; gchar *anchor;
gchar *tmp;
g_return_if_fail (ref != NULL); g_return_if_fail (ref != NULL);
@ -335,8 +345,12 @@ browser_dialog_load (const gchar *ref,
html_document_clear (doc); html_document_clear (doc);
html_document_open_stream (doc, "text/html"); html_document_open_stream (doc, "text/html");
gtk_adjustment_set_value (gtk_layout_get_vadjustment (GTK_LAYOUT (html)), gtk_adjustment_set_value (adj, 0.0);
0);
if (anchor)
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) idle_jump_to_anchor,
g_strdup (anchor), (GDestroyNotify) g_free);
if (! request_url (doc, abs, doc->current_stream, &error)) if (! request_url (doc, abs, doc->current_stream, &error))
{ {
@ -344,14 +358,16 @@ browser_dialog_load (const gchar *ref,
g_error_free (error); g_error_free (error);
} }
} }
else
{
if (anchor)
html_view_jump_to_anchor (HTML_VIEW (html), anchor);
else
gtk_adjustment_set_value (adj, 0.0);
}
g_free (tmp); g_free (tmp);
if (anchor)
html_view_jump_to_anchor (HTML_VIEW (html), anchor);
else
gtk_adjustment_set_value (gtk_layout_get_vadjustment (GTK_LAYOUT (html)), 0);
g_free (current_ref); g_free (current_ref);
current_ref = new_ref; current_ref = new_ref;
@ -565,12 +581,10 @@ io_handler (GIOChannel *io,
GIOCondition condition, GIOCondition condition,
gpointer data) gpointer data)
{ {
HtmlStream *stream; HtmlStream *stream = data;
gchar buffer[8192]; gchar buffer[8192];
gsize bytes; gsize bytes;
stream = (HtmlStream *) data;
if (condition & G_IO_IN) if (condition & G_IO_IN)
{ {
if (g_io_channel_read_chars (io, buffer, sizeof (buffer), if (g_io_channel_read_chars (io, buffer, sizeof (buffer),