[Done] PB V4.70B1 - No luck with the WebGadget()

Linux specific forum
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: [Done] PB V4.70B1 - No luck with the WebGadget()

Post by Shardik »

Guimauve wrote:With the new librairy, the WebGadget() finally work but I get a [WARNING] DEBUG: NP_Initialize succeeded
Fred wrote:It's a warning which comes from the lib, sounds more like a debug message than a warning anyway.
This WebKit warning is displayed if the embedding of scripting lanuages is enabled which is the WebKit default setting. By disabling the embedding of scripts the above warning will disappear:

Code: Select all

#G_TYPE_INT = 6 << 2

ImportC "-lwebkitgtk-1.0"
  webkit_web_settings_new()
  webkit_web_view_set_settings(*WebkitWebView, *WebkitSettings)
EndImport

Define Value.GValue

OpenWindow(0, 200, 100, 600, 300, "WebGadget")
WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")

; ----- Get current webkit settings
WebkitSettings = webkit_web_settings_new()

; ----- Disable embedding of scripting languages
Value\g_type = #G_TYPE_INT
g_value_set_int_(Value, 0)
g_object_set_property_(WebkitSettings, "enable-scripts", @Value)

; ----- Store changed settings
webkit_web_view_set_settings(GadgetID(0), WebkitSettings)

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: [Done] PB V4.70B1 - No luck with the WebGadget()

Post by Frarth »

Shardik wrote:
Guimauve wrote:With the new librairy, the WebGadget() finally work but I get a [WARNING] DEBUG: NP_Initialize succeeded
Fred wrote:It's a warning which comes from the lib, sounds more like a debug message than a warning anyway.
This WebKit warning is displayed if the embedding of scripting lanuages is enabled which is the WebKit default setting. By disabling the embedding of scripts the above warning will disappear:

Code: Select all

#G_TYPE_INT = 6 << 2

ImportC "-lwebkitgtk-1.0"
  webkit_web_settings_new()
  webkit_web_view_set_settings(*WebkitWebView, *WebkitSettings)
EndImport

Define Value.GValue

OpenWindow(0, 200, 100, 600, 300, "WebGadget")
WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")

; ----- Get current webkit settings
WebkitSettings = webkit_web_settings_new()

; ----- Disable embedding of scripting languages
Value\g_type = #G_TYPE_INT
g_value_set_int_(Value, 0)
g_object_set_property_(WebkitSettings, "enable-scripts", @Value)

; ----- Store changed settings
webkit_web_view_set_settings(GadgetID(0), WebkitSettings)

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow
How would that be for gtk3? when I use this code the debugger crashes with a message that mixing gtk2 and gtk3 symbols is not allowed.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: [Done] PB V4.70B1 - No luck with the WebGadget()

Post by Frarth »

OK found it, "-lwebkitgtk-3.0" should be used.

It may have been mentioned already, but to simply load a html string into the WebGadget on Linux a workaround is needed, like:

Code: Select all

ImportC "-lwebkitgtk-3.0" ; should be 3, not 1
  webkit_web_settings_new()
  webkit_web_view_load_string(*WebView, Content.P-UTF8, *MIMEType, *Encoding, *BaseURI)
  webkit_web_view_set_settings(*WebkitWebView, *WebkitSettings)
EndImport

Procedure WebGadgetText(gadget.l, html.s)
  ; replaces SetGadgetText for the WebGadget in Linux to set/change text
  webkit_web_view_load_string(GadgetID(gadget), html, 0, 0, 0)
  WebkitSettings = webkit_web_settings_new()
  webkit_web_view_set_settings(GadgetID(gadget), WebkitSettings)
EndProcedure
I pulled this from the net and adjusted it a little. Seems to work fine. But I suppress debug warnings. There's no harm, but they are annoying.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
Post Reply