If you want to use #PB_Web_Busy to detect when a download has ended by polling for #False, I don't advise this method because I have already made the experience that on some websites #PB_Web_Busy changes sometimes to #False and shortly afterwards back to #True because some components still need loading and therefore the download is still not completed. The best method on WebGadgets using WebKit should be to evaluate the signal "document-load-finished" (tested successfully on Linux Mint 19.3 x64 'Tricia' with Cinnamon using PB 5.73 x64):
Code: Select all
URL.S = "http://www.google.com"
ProcedureC DocumentLoadCompleted(WebView.I, WebFrame.I, UserData.I)
MessageRequester("Info", "Loading of web page has completed!")
EndProcedure
WindowID = OpenWindow(#PB_Any, 0, 0, 1000, 800,
"Detect completion of loading web page",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, WindowWidth(WindowID) - 10, WindowHeight(WindowID) - 10, URL)
g_signal_connect_(GadgetID(0), "document-load-finished",
@DocumentLoadCompleted(), 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
If you want to find out the current status when loading a website, you may try the following example:
Code: Select all
Enumeration WebKitLoadStatus
#WEBKIT_LOAD_PROVISIONAL
#WEBKIT_LOAD_COMMITTED
#WEBKIT_LOAD_FINISHED
#WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
#WEBKIT_LOAD_FAILED
EndEnumeration
ImportC "-lwebkitgtk-3.0"
webkit_web_view_get_load_status(*WebView)
EndImport
URL.S = "https://www.google.de"
WindowID = OpenWindow(#PB_Any, 100, 100, 1000, 800,
"Display status of loading web page",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, WindowWidth(WindowID) - 10, WindowHeight(WindowID) - 10, URL)
Repeat
WindowEvent = WaitWindowEvent()
If WebPageLoadCompleted = #False
Select webkit_web_view_get_load_status(GadgetID(0))
Case #WEBKIT_LOAD_PROVISIONAL
Debug "No data received yet, empty structures have been allocated"
Case #WEBKIT_LOAD_COMMITTED
Debug "First data chunk has arrived"
Case #WEBKIT_LOAD_FINISHED
WebPageLoadCompleted = #True
Debug "Loading of web page has completed"
Case #WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
Debug "First layout with visual content has started"
Case #WEBKIT_LOAD_FAILED
WebPageLoadCompleted = #True
Debug "Loading of web page has failed"
Break
EndSelect
EndIf
Until WindowEvent = #PB_Event_CloseWindow