Commit 5d401872 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

plug-ins/helpbrowser/dialog.c store the scroll offset in the history and

2005-05-26  Sven Neumann  <sven@gimp.org>

	* plug-ins/helpbrowser/dialog.c
	* plug-ins/helpbrowser/queue.[ch]: store the scroll offset in the
	history and set it when using the Back and Forward actions. Fixes
	bug #165022.
parent 85b201d6
2005-05-26 Sven Neumann <sven@gimp.org>
* plug-ins/helpbrowser/dialog.c
* plug-ins/helpbrowser/queue.[ch]: store the scroll offset in the
history and set it when using the Back and Forward actions. Fixes
bug #165022.
2005-05-26 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell.c (gimp_display_shell_set_highlight):
......
......@@ -340,6 +340,22 @@ idle_jump_to_anchor (const gchar *anchor)
return FALSE;
}
static gboolean
idle_scroll_to_pos (gpointer data)
{
gint offset = GPOINTER_TO_INT (data);
if (html)
{
GtkAdjustment *adj = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
gtk_adjustment_set_value (adj,
(gdouble) offset / (1 << 16) * adj->upper);
}
return FALSE;
}
void
browser_dialog_load (const gchar *uri,
gboolean add_to_queue)
......@@ -569,11 +585,16 @@ static void
back_callback (GtkAction *action,
gpointer data)
{
const gchar *uri = queue_prev (queue, GPOINTER_TO_INT (data));
gdouble pos;
const gchar *uri = queue_prev (queue, GPOINTER_TO_INT (data), &pos);
if (uri)
{
browser_dialog_load (uri, FALSE);
g_idle_add ((GSourceFunc) idle_scroll_to_pos,
GINT_TO_POINTER ((gint) (pos * (1 << 16))));
queue_move_prev (queue, GPOINTER_TO_INT (data));
}
......@@ -584,11 +605,16 @@ static void
forward_callback (GtkAction *action,
gpointer data)
{
const gchar *uri = queue_next (queue, GPOINTER_TO_INT (data));
gdouble pos;
const gchar *uri = queue_next (queue, GPOINTER_TO_INT (data), &pos);
if (uri)
{
browser_dialog_load (uri, FALSE);
g_idle_add ((GSourceFunc) idle_scroll_to_pos,
GINT_TO_POINTER ((gint) (pos * (1 << 16))));
queue_move_next (queue, GPOINTER_TO_INT (data));
}
......@@ -811,6 +837,11 @@ link_clicked (HtmlDocument *doc,
const gchar *uri,
gpointer data)
{
GtkAdjustment *adj = gtk_layout_get_vadjustment (GTK_LAYOUT (html));
if (adj->upper > 0.0)
queue_set_scroll_offset (queue, adj->value / adj->upper);
browser_dialog_load (uri, TRUE);
}
......
......@@ -39,6 +39,7 @@ typedef struct
{
gchar *uri;
gchar *title;
gdouble pos;
} Item;
......@@ -111,7 +112,8 @@ queue_move_next (Queue *h,
const gchar *
queue_prev (Queue *h,
gint skip)
gint skip,
gdouble *pos)
{
GList *p;
Item *item;
......@@ -129,12 +131,16 @@ queue_prev (Queue *h,
item = p->data;
if (pos)
*pos = item->pos;
return (const gchar *) item->uri;
}
const gchar *
queue_next (Queue *h,
gint skip)
gint skip,
gdouble *pos)
{
GList *p;
Item *item;
......@@ -152,6 +158,9 @@ queue_next (Queue *h,
item = p->data;
if (pos)
*pos = item->pos;
return (const gchar *) item->uri;
}
......@@ -200,6 +209,23 @@ queue_set_title (Queue *h,
item->title = g_strdup (title);
}
void
queue_set_scroll_offset (Queue *h,
gdouble pos)
{
Item *item;
g_return_if_fail (h != NULL);
if (! h->current || ! h->current->data)
return;
item = h->current->data;
item->pos = pos;
}
gboolean
queue_has_next (Queue *h)
{
......
......@@ -34,10 +34,15 @@ void queue_add (Queue *queue,
const gchar *uri);
void queue_set_title (Queue *queue,
const gchar *title);
void queue_set_scroll_offset (Queue *queue,
gdouble pos);
const gchar * queue_prev (Queue *queue,
gint skip);
gint skip,
gdouble *pos);
const gchar * queue_next (Queue *queue,
gint skip);
gint skip,
gdouble *pos);
void queue_move_prev (Queue *queue,
gint skip);
void queue_move_next (Queue *queue,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment