Scroll position problem (gtk2)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Scroll position problem (gtk2)

Matthew A. Postiff
I have a GtkWidget *A that contains another GtkWidget *B. The web
content of B changes from B_1 to B_2 when the user clicks a link inside
of it. When I click the "Back" button in B_2, I want it to return to B_1
at the last known scroll position. This is the code that I thought would
do it--by remembering the former vertical adjustment and then setting it
once the old content re-appears:

     webkit_web_view_load_string (WEBKIT_WEB_VIEW (B), htmlwriter.html.c_str(), NULL, NULL, NULL);
     // Scroll to the position that was stored while this url was last active.
     GtkAdjustment * adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (A));
     gtk_adjustment_set_value (adjustment, scrolling_position[active_url]);   <<=== This line doesn't do anything


scrolling_position[active_url] returns a value, say 1000, and the
gtk_adjustment_set doesn't seem to have any effect.
Any pointers on how to fix this?
Thank you,
Matt
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Scroll position problem (gtk2)

Franco Broi
"Other than the value field"

Signal Details
The “changed” signal
void
user_function (GtkAdjustment *adjustment,
               gpointer       user_data)
Emitted when one or more of the GtkAdjustment fields have been changed,
other than the value field.

You might want to try using

https://developer.gnome.org/gtk2/stable/GtkAdjustment.html#gtk-adjustment-clamp-page


On Sat, 2017-08-26 at 22:23 -0400, Matthew A. Postiff wrote:

> I have a GtkWidget *A that contains another GtkWidget *B. The web
> content of B changes from B_1 to B_2 when the user clicks a link inside
> of it. When I click the "Back" button in B_2, I want it to return to B_1
> at the last known scroll position. This is the code that I thought would
> do it--by remembering the former vertical adjustment and then setting it
> once the old content re-appears:
>
>      webkit_web_view_load_string (WEBKIT_WEB_VIEW (B), htmlwriter.html.c_str(), NULL, NULL, NULL);
>      // Scroll to the position that was stored while this url was last active.
>      GtkAdjustment * adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (A));
>      gtk_adjustment_set_value (adjustment, scrolling_position[active_url]);   <<=== This line doesn't do anything
>
>
> scrolling_position[active_url] returns a value, say 1000, and the
> gtk_adjustment_set doesn't seem to have any effect.
> Any pointers on how to fix this?
> Thank you,
> Matt
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list