hybrid web application : HTML5 + PB

Share your advanced PureBasic knowledge/code with the community.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: hybrid web application : HTML5 + PB

Post by Kwai chang caine »

I have try this code in my home where they are no PROXY and this time that works
Again thanks to eddy 8)
ImageThe happiness is a road...
Not a destination
ricardo
Addict
Addict
Posts: 2402
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: hybrid web application : HTML5 + PB

Post by ricardo »

You can code a web interface and send a javascript message and make it trigger something in PB.
ARGENTINA WORLD CHAMPION
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: hybrid web application : HTML5 + PB

Post by Kukulkan »

Hi,

I'm just playing around with Sciter, Electron and nw.js to find if I can replace the boring PB GUI by that (at least for the GUI and encapsulating existing PureBasic stuff in DLL/SO/DYLIB). So I found your example. This is impressively easy and seems a good solution to keep an eye on. :)

But here on my Linux system, it does not trigger any event (but also no error messages). I only the the windows events (like #PB_Event_DeactivateWindow) but nothing from within the GUI. I'm using PB 5.46 LTS (x64) on KDE Neon (based on Ubuntu 16.04).

Also, I remember discussions that the needed WebKitGtk component is no longer available on some modern Linux distros (Fedora, Manjaro). So people will not be able to use that solution there, right? Seems the PureBasic WegGadget is not working there at all.
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: hybrid web application : HTML5 + PB

Post by Shardik »

Kukulkan wrote:But here on my Linux system, it does not trigger any event (but also no error messages).
eddy's example has to be modified to work with Linux because in PureBasic's WebGadget the execution of JavaScript is possibly disabled. You have to insert the following code between "If CatchXML(#xml,.." and "SmartWindowRefresh(#win, #True)" in order to check whether script execution is disabled and to enable it if yes:

Code: Select all

If CatchXML(#xml, @xml$, StringByteLength(xml$)) And XMLStatus(#xml)=#PB_XML_Success And CreateDialog(#dialog) And OpenXMLDialog(#dialog, #xml, "win")
   CompilerIf #PB_Compiler_OS = #PB_OS_Linux
      #G_TYPE_INT = 6 << 2
      ImportC ""
        g_object_get_property(*Object.GObject, PropertyName.P-UTF8, *PropertyValue)
      EndImport
      ImportC "-lwebkitgtk-3.0"
         webkit_web_view_get_settings(*WebView)
         webkit_web_view_set_settings(*WebView, *WebkitSettings)
      EndImport
      Define WebkitSettings.I = webkit_web_view_get_settings(GadgetID(#web))
      Define Value.GValue
      If WebkitSettings
         Value\g_type = #G_TYPE_INT
         g_object_get_property(WebkitSettings, "enable-scripts", @Value)
         If g_value_get_int_(@Value) = 0
            g_value_set_int_(@Value, 1)
            g_object_set_property_(WebkitSettings, "enable-scripts", @Value)
            webkit_web_view_set_settings(GadgetID(#web), WebkitSettings)
         EndIf
      EndIf
   CompilerEndIf
   SmartWindowRefresh(#win, #True)
After the insertion of this CompilerIf..CompilerEndIf block the WebGadget events are also triggered on Linux and eddy's example works like a charm (tested successfully with Linux Mint 18.3 x64 PB 5.46 x64 with GTK3 in ASCII and Unicode mode) if for your distribution webkitgtk-3.0 is still available.
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Re: hybrid web application : HTML5 + PB; web socket;

Post by HanPBF »

PWAs are on it's way to complete hopefully in 2019.
So all that very heavy electron/nw.js things get away.
node.js debugging is not so easy (WebStorm from Jetbrains does it).

Look how pgadmin is done -> web browser with client ("sitting" in systray).
It means: known, easy and powerful to use web ui and at the same time having access to local system.
pgadmin does it with AJAX-requests (slow, but hey, it's all local); I prefer web socket (more 'complex' but no/less latency).

Web socket server for PureBasic can be found here: viewtopic.php?f=12&t=61606.
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Vivaldi; hybrid web application : HTML5 + PB

Post by HanPBF »

https://vivaldi.com

This web browser can be extremly tailored until no browser ui remains.
Window then looks like a native application.
Post Reply