On 29/11/2015 16:51, Edward Bartolo wrote:
> Hi Aitor,
>
> Thanks for taking some time to answer my question. I did as you
> instructed me and successfully compile and run the test program.
> However, the test program failed to close even though I closed its
> window. I had to kill it using Ctrl + C.
g_signal_connect(G_OBJECT (window), "hide", G_CALLBACK (gtk_main_quit),
NULL);
Terminates the main loop when the window is closed; replace "window"
with your toplevel window here. If you need to prompt to save unsaved
state, then implement your own handler here which does that before
quitting in place of gtk_main_quit.
https://github.com/rleigh-codelibre/ogcalc/blob/master/gtk/C/gobject-glade/ogcalc-main.c#L40
This is part of the "ogcalc" GTK+ (and now Qt) tutorial I wrote a decade
ago. It was on my people.debian.org page, but I've moved it to github
since that's no longer available.
https://github.com/rleigh-codelibre/ogcalc/ You might find the tutorial
itself useful. It's GTK+ 2.x only though; I haven't felt it worthwhile
to update for 3.x given the breakage in backward compatibility, and I
might drop GTK+ entirely in the future. Run "make html" or "make
latexpdf" in the doc directory to get the full tutorial text. I
converted it from LaTeX to Sphinx; you'll need python-sphinx installed.
I'll publish this online properly at some point.
Since I moved on from GTK+ several years ago, I re-wrote the tutorial
examples with plain Qt, with UI files (like glade) and with PyQt. I'd
definitely recommend these over GTK+.
Also, given the debate recently in this thread regarding GNU Make, the
GNU Autotools and CMake, readers of the list might be interested to see
that I wrote the Qt examples to use all three systems separately so you
can directly compare them, e.g.
https://github.com/rleigh-codelibre/ogcalc/tree/master/qt/plain/make
https://github.com/rleigh-codelibre/ogcalc/tree/master/qt/plain/automake
https://github.com/rleigh-codelibre/ogcalc/tree/master/qt/plain/cmake
[note: my early days with cmake--it can be simpler than this!]
Regards,
Roger