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.
This commit is contained in:
Sven Neumann 2005-05-26 17:13:59 +00:00 committed by Sven Neumann
parent 85b201d6e8
commit 5d40187247
4 changed files with 95 additions and 26 deletions

View File

@ -1,3 +1,10 @@
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):

View File

@ -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);
}

View File

@ -37,8 +37,9 @@ struct _Queue
typedef struct
{
gchar *uri;
gchar *title;
gchar *uri;
gchar *title;
gdouble pos;
} Item;
@ -110,8 +111,9 @@ queue_move_next (Queue *h,
}
const gchar *
queue_prev (Queue *h,
gint skip)
queue_prev (Queue *h,
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)
queue_next (Queue *h,
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)
{

View File

@ -28,24 +28,29 @@
typedef struct _Queue Queue;
Queue * queue_new (void);
void queue_free (Queue *queue);
void queue_add (Queue *queue,
const gchar *uri);
void queue_set_title (Queue *queue,
const gchar *title);
const gchar * queue_prev (Queue *queue,
gint skip);
const gchar * queue_next (Queue *queue,
gint skip);
void queue_move_prev (Queue *queue,
gint skip);
void queue_move_next (Queue *queue,
gint skip);
gboolean queue_has_next (Queue *queue);
gboolean queue_has_prev (Queue *queue);
GList * queue_list_prev (Queue *queue);
GList * queue_list_next (Queue *queue);
Queue * queue_new (void);
void queue_free (Queue *queue);
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,
gdouble *pos);
const gchar * queue_next (Queue *queue,
gint skip,
gdouble *pos);
void queue_move_prev (Queue *queue,
gint skip);
void queue_move_next (Queue *queue,
gint skip);
gboolean queue_has_next (Queue *queue);
gboolean queue_has_prev (Queue *queue);
GList * queue_list_prev (Queue *queue);
GList * queue_list_next (Queue *queue);
#endif /* _GIMP_HELP_QUEUE_H_ */