Get and set scroll position in WebGadget

Linux specific forum
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Get and set scroll position in WebGadget

Post by mdp »

mk-soft wrote: Mon Feb 07, 2022 7:30 pm Does not run under Ubuntu 20.04/21.04 because the libwebkitgtk-3.0-dev is no longer available.
They removed libwebkitgtk-3.0-dev from the packages two years ago!? Nothing can surprise me anymore. But: how does the WebGadget of PB 5.xx work on Ubuntu 18.04 LTS then?

Edit: I must suppose there is a compatibility trick that makes libwebkitgtk-3.0 and libwebkit2gtk-4.0-37 interchangeable inside PB.

Edit:
> Nothing can surprise me anymore
Probably little reason for surprise, since they will want to avoid shipping a web package which is seldom updated.
Last edited by mdp on Mon Feb 07, 2022 9:52 pm, edited 1 time in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Get and set scroll position in WebGadget

Post by mk-soft »

Very simple

Ubuntu 18.04 uses libwebkitgtk-3.0
PB v5.xx and PB v6.00 (18.04) also uses libwebkitgtk-3.0

Ununtu 20.xx/21.xx uses libwebkit2gtk-4.0
PB v6.00 (20.04) also uses libwebkit2gtk-4.0
(Not quite perfect yet, as not everything works as with webkit1. Therefore my Module WebGadget Extension)

Therefore work with compiler directives and compile your own app for Ubuntu 18.04 LTS until Long Time Service is finished.
Last edited by mk-soft on Mon Feb 07, 2022 9:12 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Get and set scroll position in WebGadget

Post by mdp »

mk-soft wrote: Mon Feb 07, 2022 9:04 pm Very simple

Ubuntu 18.04 uses libwebkitgtk-3.0
PB v5.xx and PB v6.00 (18.04) also uses libwebkitgtk-3.0

Ubuntu 20.xx/21.xx uses libwebkit2gtk-4.0
PB v6.00 (20.04) also uses libwebkit2gtk-4.0
(Not quite perfect yet, as not everything works as with webkit1. Therefore my Module WebGadget Extension)
The doubt was, how does the WebGadget on PB v5.xx work on Ubuntu 20.xx . If «PB v5.xx ... uses libwebkitgtk-3.0» and said package is not in Ubuntu 20+, then PB v5.xx must also be able to adapt to other libraries.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Get and set scroll position in WebGadget

Post by mk-soft »

The doubt was, how does the WebGadget on PB v5.xx work on Ubuntu 20.xx . If «PB v5.xx ... uses libwebkitgtk-3.0» and said package is not in Ubuntu 20+, then PB v5.xx must also be able to adapt to other libraries.
With linux, downward compatibility is a thing of the past.

Therefore there are two different PB v6.0 versions
One PB v6.00 (18.04) for Ubuntu 18.04 LTS
One PB v6.00 (20.04) for Ubuntu 20.04 LTS and higher

The LibWebkitGtk-3.0 and libWebKit2Gtk-4.0 work internally quite differently and are not compatible with each other.
GTK2 is no longer supported in libWebKit2Gtk-4.0.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Get and set scroll position in WebGadget

Post by mdp »

mk-soft wrote: Sun Feb 06, 2022 9:11 pm I have extended my modules for the WebGadget with RunJavaScript. It works
JavaScript 'window.scrollTo(0,500);'
By the way, Mk-Soft: I was just checking the documentation of webkit2gtk, since it's what we will have to deal in the future, and I noticed: the WebKitDOMDOMWindow is still present, as part of the WebKitDOMGTK+ . Since it is not deprecated, you should still be able to perform basic window content operations without javascript (as expected). See https://webkitgtk.org/reference/webkitd ... indow.html

With libWebKit2Gtk-4.0 you should still be able to get the WebKitDOMDocument with webkit_web_view_get_dom_document(GadgetID( webGadgetNum )) ,
the WebKitDOMDOMWindow with webkit_dom_document_get_default_view( *the_WebKitDOMDocument ) ,
then read the y-position with webkit_dom_dom_window_get_scroll_y( *the_WebKitDOMDOMWindow ) ,
and write the y-position with webkit_dom_dom_window_move_to( *the_WebKitDOMDOMWindow, 0.0, 1234.0 )

Basically the code of post https://www.purebasic.fr/english/viewto ... 24#p580424 ,
just changing the library name in the imports section. Does it work on your side? I am currently unable to try Ubuntu 20.xx (hardware issues and slow repairs...)
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Get and set scroll position in WebGadget

Post by mk-soft »

Edit:
dom_document is no longer used in new webkit_web_view (webkit2). Has been completely rewritten.

Its a own WebKitDOMObject g_object
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Get and set scroll position in WebGadget

Post by mdp »

Ok, bad news in general:
mk-soft wrote: Mon Feb 07, 2022 10:49 pm dom_document is no longer used in new webkit_web_view (webkit2). Has been completely rewritten.
Its a own WebKitDOMObject g_object
Right. I understood differently as the documentation for WebKitDOMDOMWindow suggests in the hompage that it is still current, but having gone through the documentation of WebKit2Gtk, there is no function that returns the window.

Even worse,
I did some checks with your code ("WebGadgetEx Example"), and I disabled the JavaScript: doing so, alert(), scrollTo() etc. do not work anymore. Which on the one hand ( "alert()" ) is expected, but on the other hand, if "scrollTo()" does not work (consistently), how is one supposed to operate on that window?! If you have JavaScript enabled you can perform normal operations, and if JavaScript is disabled (pretty normal demand) then functions like "programmatic scrolling" disappear?! The system would be broken by design. There must be a different way - there has to be.

Code: Select all

*settings = webkit_web_view_get_settings(*GadgetData\WebView)
webkit_settings_set_enable_javascript(*settings, #False)
webkit_web_view_set_settings(*GadgetData\WebView, *settings)
Incidentally, you mentioned different library versions and Gtk2: I think old WebKitGtk was compiled with Gtk2 when you find it as LibWebkitGtk-1.0, and with Gtk3 as LibWebkitGtk-3.0.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Get and set scroll position in WebGadget

Post by mk-soft »

Removed ...
Last edited by mk-soft on Tue Feb 08, 2022 9:04 pm, edited 2 times in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Get and set scroll position in WebGadget

Post by mk-soft »

Short Info
Description

WebKitWebView is the central class of the WebKit2GTK+ API. It is responsible for managing the drawing of the content and forwarding of events. You can load any URI into the WebKitWebView or a data string. With WebKitSettings you can control various aspects of the rendering and loading of the content.

Note that WebKitWebView is scrollable by itself, so you don't need to embed it in a GtkScrolledWindow.
When I built my own WebKitGadget, I also had a GtkWebKitWebView packed into a GtkScrolledWindow like in an example. Putting it in a GtkViewport did not work.
So the GtkScrolledWindow has no function because the GtkWebKitWebView has its own scrolling functions internally.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply