Web app without gtk builder.ui

I have written some software which I hope to be able to use both off-www and on www. I have written it “programmatically”, that is, the gui is all hand-written without use of a builder.ui file or similar. Can I implement such software on the web?

I don’t understand what you want to achieve.

You have written some software how? What does “on www” mean?

You may be looking for the GTK broadway backend? This allows interaction with GTK apps through a web browser.

Hi to Jason F and Emmanuel B,
I may be looking for GTK broadway backend, but I’m not sure, what I need to know is how to set up a website from scratch, a bit of a tall order I guess. What I have is a program that I have written without the use of Glade or builder.ui files, it is written entirely “programmatically”. Basically, it is a CNC machining program that, in its current state, produces G-code output files that can be put into a CNC milling machine running Linux/UNIX or Windows. I would like to get this set up on a website and need a few pointers on how to do this, particularly concerning 1) whether I need to use Glade or builder.ui files to generate html code, and 2) what operating system(s) the web-server(s) are likely to be using? Any constructive criticism or help is welcome, thanks,

Glade does not generate HTML code. The builder ui files are in an XML format that is used only to create GTK widgets. It may look similar to HTML but it is not the same. If your app already works without .ui files, you don’t need to change it – it will work the same to the user regardless of whether you use a builder XML or you construct the widgets manually in the code.

Is your app already using GTK 3 or 4 for a GUI? If so, using the broadway backend will make it so the app runs in the broadway server, which is a web server that is capable of displaying GTK apps in a web browser. You can test this out with any pre-existing GTK3 or GTK4 apps to see if it works the way you want. Please see the docs I posted above for the instructions. The server should run on any operating system provided that you have the broadway backend enabled at compile time of GTK. There are also a few other ways to put apps like this in a browser such as deploying a web-based VNC/RDP client.

If you aren’t using GTK already, then another approach would be to add a web backend to the app, and then write a native web GUI in a javascript framework such as React, Angular, Vue, etc.

I’m writing in C with GTK3 on Ubuntu, but to access internet I’m using a radio-dongle on a Windows laptop. I’m living in a remote location in Australia and the only available network is through a Telstra tower and the radio-dongle is how I connect. I cannot connect via cable but may be able to with satellite-dish, but haven’t got one, and I can’t get a dongle that I can use with any Linux/UNIX. I am currently also trying to get my program working on Windows, when I do I should then be able to test it with Broadway. With regard to your instructions I don’t understand where I am to place the first command or ‘select’: GDK_BACKEND=broadway. What are web sockets? Does this mean that the web-site is hosted by Broadway server(s). If so where is this server physically and what protection of my program do I have? How do I get it to show up on other people’s web-browsers? Please excuse my ignorance in these matters, the only way to learn is by asking stupid questions.

You will have to run that from the shell to set an environment variable, it may or may not work depending on where you got your GTK build from. I don’t remember how exactly to do it in the windows command prompt, every time I used windows I used git bash or an equivalent. I think there is even some kind of Bash that enables by default now if you have WSL on Win10.

Very loosely: a web socket is a way to get closer to the full functionality and performance of a TCP socket, inside a web browser.

No, you run the broadway server on your machine, which contains a small web server. You have to make your GTK applications connect to it by changing the backend. Then when you open the broadway in your browser, you should see the GTK app displaying there. You may want to check the GTK3 instructions because I think they’re slightly different.

Since the server is run on your machine, you will have to make sure it’s protected with a firewall or reverse proxy or something similar. You could probably deploy it on a cloud somewhere if that was easier. If you can’t get broadway to work on your machine, the same thing would apply with e.g. trying to allow other people to connect to your machine with a web-based RDP client.

I should mention that these methods are not suitable as a public website that other people can access freely, they’re only really usable by one person at a time because that’s what GTK is designed to do.

Hi @roger.matthews!

by your description I suspect you are trying to achieve something similar to what I was trying to do with pizarra which not only works as a desktop application but also as a website using webassembly.

To achieve that I had to write the code of my application completely agnostic of the graphic environment (which I think is what you referred to as programatically), and then implemented two frontends, one using gtk3 and one in webassembly+javascript.

This might be an option for you. If you are using C that’s a language that also compiles to webassembly, so you could implement a frontend using webassembly and deploy it to the www using a simple web server (like nginx or apache).

1 Like

Hi roger.matthews , nice to hear about your program, i am also planning to do some CNC stuff here on our company and would be very happy to set up some stuff with gnome. I am also ready to contribute if needed. Is your program open sourced or is just something you want to keep for yourself ?

Hi Sasa,
my program is written with open source software but I would like to keep it to myself, and perhaps to someone else in partnership who would help to set up a website. You have offered to help, what are you willing to do or how would you like to become involved? I don’t plan on giving away the many years of work I’ve put into this, however, if a suitable agreement could be made I would be willing to proceed to commercial arrangements.

Hi Jason,
I have now realised that the dongle allows me to access the internet with Ubuntu, I have successfully run GDK_BACKEND=broadway at the Ubuntu command-prompt (no error messages anyway) and am now trying to come to terms with sockets. Ubuntu has Mozilla Firefox as it’s default web-browser but I can’t find any reference to sockets there, but I have found ‘web development’ there. It would seem to be there that I could write a javascript website. If so, would this be a ‘front-end’ coding, and how to get started with writing it?

Hi Abraham,
yes, I have it as a Desktop Application, written in C, and would like to have it on a website. I don’t understand the difference between a ‘frontend’ and ‘backend’, as stupid as that sounds. I don’t understand why you have two fontends, 1) GTK, 2) webassembly+javascript. I also don’t know where and how to access ‘simple’ webservers like nginx or apache, are these host-servers?

Hi Roger, with the broadway backend you don’t have to worry about the websocket, it implements it for you. Once the broadway server is running locally, you can visit and that will handle the web socket communication for you automatically.

A web frontend is a piece of code that runs inside the user’s web browser – this is in contrast to the backend which is the piece of code that runs on a server. Usually a web app is split into those two parts. @categulario gives a good suggestion too, which is to use web assembly to write the frontend. Then you can write it in your language of choice, and you don’t have to use javascript. The reason two frontends are needed is because GTK does not support compiling to web assembly at this time.

just as @jfrancis points out, the front-end is usually understood as the user-facing part of some application. In my case I wrote the code of pizarra in such a way that there’s a rust package (crate as we call them) which defines all the objects and functions needed to operate it, but has no knowledge of how to display itself to the user. That is what I call the backend.

At first I had only one frontend, the gtk one, which imported the objects and functions from my pizarra crate and added some GUI logic to create the window and render everything. It also took care of passing mouse events and other actions to the backend.

When I wanted pizarra to be available in a website I implemented a second frontend, built with webassembly, in which I had to reimplement some rendering and event handling logic, but used the same backend (the crate that exposed the functions and objects needed). I think this alternative requires more code than the broadway one, because you have to:

  • separate your code into backend (GUI agnostic) and frontend (gtk stuff)
  • implement a new GUI in webassembly and probably at least some javascript (I had to)
  • setup a http server in a host computer (or host provider like linode) that will serve all the files to the client (the webassembly binary and at least a simple html file that puts everything together)

the advantages of this approach are

  • a lot of users can access your application at the same time
  • setting up the web server is as easy as istalling it and putting your app files in the right directory (probably a lot easier than setting up broadway)

Hey Roger, I perfectly understand your position. I would firstly need to understand where could I help. I plan to set up a big industrial plasma and oxy fuel cutting machine in my company in the near future, I have nearly all the parts, not yet assembled and still missing few things. So I plan to use something like linuxcnc

or maybe other free software, not decided it yet, but despite that I know some php, js, bash, C, python and my way around servers, apache and some other stuff., so I think there is plenty of room where we could cooperate.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.