User avatar
ab1jx
Posts: 625
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Wonderfully simple Glade tutorial

Wed Jul 20, 2016 12:21 am

Glade is a RAD (Rapid Application Development) environment of sorts similar to Borland Delphi or Lazarus except it handles only the windows and widgets, there's no complete IDE. You use your favorite editor to write C or C++ code (or maybe other things too). The application you create is saved as an XML file plus your C, when you link it with libglade at compile time libglade replaces the XML with standard GTK widgets at runtime. The executable does have libglade as a dependency.

It doesn't write the code for you but if you've ever looked into writing GTK this is a big timesaver. There's a more complicated tutorial I gave up on several times, this is a single page that walks you through creating a simple window. But be warned that devhelp doesn't work on a Pi, you'll have to use the online version. Actually if you look in /usr/share/gtk-doc/html you'll find most of what devhelp will show you, it would be simple to make yourself an index.html file at that level that links to the index.html files in each section. I lived with dialup for years so I got used to tricks like that.

glade_ss.gif
The glade designer
glade_ss.gif (36.37 KiB) Viewed 2528 times
The simple application which does nothing actually:
ss.gif
ss.gif (3.27 KiB) Viewed 2528 times
The tutorial has some templates on another page for later use, but start at http://prognotes.net/2015/06/gtk-3-c-pr ... g-glade-3/. Some programming experience is advisable, but I've been trying for years to create anything usable with a GUI under Linux. It's easier to write CGI or stick to command line.

Napoleon_BlownApart
Posts: 2
Joined: Wed Apr 05, 2017 6:57 am

Re: Wonderfully simple Glade tutorial

Sat Feb 10, 2018 3:08 pm

Hi ab1jx,

Thanks for the tutorial, and I actually found it on prognotes.net before I found this edition. I completed your tutorial on a Mac where my 'GCC' command actually executes Clang. Using clang 5, the "-export-dynamic" does not work and needs to be replaced with "-rdynamic"

Having completed this tutorial, I'm eager to do something a little more interesting. I have a comparatively simple GUI I want to build but I haven't worked out/understood Glade 3.20.2's behaviour with regards the various types of containers and control/display widgets it provides.
I've found a variety off tutorials that either use earlier versions of Glade/GTK+, or use code to create the GUI (which isn't so bad but not what I'm looking for at the moment). So, I'm wondering if you know of any other tutorials that go further than what you've demonstrated here?

Cheers, Nap.

1dot0
Posts: 424
Joined: Mon Nov 28, 2016 12:31 pm

Re: Wonderfully simple Glade tutorial

Sat Feb 10, 2018 8:17 pm

hi,
I also found that topic already 9 months ago at prognotes.net .
Unfortunately it appeared at that time as if it didn't work in the Geany IDE, to be compiled (F8), build (F9) and run (F5) out of the IDE
- is that still true?

In case it works now though, what would be the Geany settings for compile and build (please tested + verified) ?

(standard to me is:
g++ -Wall -pthread -c "%f" "%e" ....
g++ -Wall -pthread -o "%f" "%e" -lwiringPi .....
plus some more linker flags like for openVG etc.)

User avatar
ab1jx
Posts: 625
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Wonderfully simple Glade tutorial

Sun Feb 11, 2018 3:15 pm

Personally I haven't done anything more with Glade than this. I remember another tutorial a year or more that I never could get all the steps quite right after most of a day working on it. I consider Glade a bit of a crutch and think the right thing to do is learn the GTK it makes, but this is a valid learning tool. I went from this to xlib viewtopic.php?t=174679#p1115186 to Motif then back to command line. At the time I was looking for some way to do fast graphics (10-30 frames per second) and I guessed that simpler (lower level) was probably going to be better. I could do it in xlib but need a few simple widgets like buttons too. I just have too many projects.

1dot0
Posts: 424
Joined: Mon Nov 28, 2016 12:31 pm

Re: Wonderfully simple Glade tutorial

Sun Feb 11, 2018 3:45 pm

a pity, like some others I do remember quite well the Borland C++ Buider for Windows: what a powerful and handy programming tool!
Feat. a text editor and a canvas für designing windows by just draging windows frame, gadgets and objects together, re-arranging and re-sizing them by simple mouse actions. Having done that for either object, immediately, simultaneously, and automatically the Builder had created also a enherited Windows object providing code patterns for settings and callbacks. Graphics, data base, and sound tools also had been integrated. All that could be compiled and run immediately out of the Builder's editor window. Last, but not least: no compiler or linker flags at all had to be set compellingly, additionally.
Good old times, gone by :-/

User avatar
ab1jx
Posts: 625
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Wonderfully simple Glade tutorial

Sun Feb 11, 2018 5:02 pm

I never used C++ Builder much but I spent many hours in Delphi over 10 years or more. Lazarus just isn't quite so magical. I could make a simple image viewer with 3 lines of code. Had a copy of Delphi 3 on my old 486sx laptop, brought tears to my eyes when I got it working. Visual Basic was a chore compared to that, Borland just seemed to know what code you'd most likely want to connect 2 objects and wrote it for you.

1dot0
Posts: 424
Joined: Mon Nov 28, 2016 12:31 pm

Re: Wonderfully simple Glade tutorial

Sun Feb 11, 2018 6:24 pm

as to Delphi (4), it's almost identical to C++ Builder, just a different PL syntax. I know this too (and even a little longer than C++ as I formerly came from Borland Turbo Pascal for a couple of years:
Both powerful and extremely handy, and perfectly suited to beginners and hobbyists. I regret that something similar is not available for the Pi.

User avatar
ab1jx
Posts: 625
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Wonderfully simple Glade tutorial

Sun Feb 11, 2018 7:19 pm

I've used Delphi 2 through 7 I think. Later versions are more bloated but also create more efficient executables. That was true of Turbo Pascal versions too, I think I started at 4. The thing I liked most about Delphi I think was that it handled all the messaging between Windows components, yet did it in a way in which you could modify what it had written if you wanted to. With Visual Basic and Visual C it seemed like you spent forever manually connecting things. There was a minimal Delphi 3 that sold for $99 with an educational discount, that did most of what I wanted. Add in the free Internet Component Suite and it was mostly missing some database stuff.

There is Lazarus in the Raspbian debs which is based on free pascal and tries to emulate Delphi. It has some rough edges but it mostly works. Now I prefer C though. If somebody would turn Lazarus into a C++ Builder for Linux they'd have something. Add plugin modules for different widget sets like GTK, FLTK, QT etc. Well, there's Code::Blocks http://www.codeblocks.org/ and QT Creator, haven't spent much time with them.

edit:
One reason contributing to why I gave up on Glade is that devhelp doesn't work on Pis and probably never will. I forget the reasons, but it makes looking up help on a widget more difficult.

Return to “C/C++”

Who is online

Users browsing this forum: TimWJ and 10 guests