So I finally got around to learning GTK+, and it seemed like a decent time to start documenting it. The documentation for it isn’t very helpful, but I figured it out eventually. Here’s my first practice program. It shows a text entry box, and if you try an integer into it and click “Go”, it will open a dialogue with the answer squared in it. If it’s not an integer, it will complain that it’s not an integer.

A screenshot of the program
The hardest part of writing this was figuring out what “m_button.signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::on_button_clicked));” means — it makes it so when you click on m_button (a Gtk::Button), it calls MainWindow::on_button_clicked().
The next hardest part was figuring out how to convert a ustring(what Gtk::Entry gives me) to an int. The answer was to convert it to a char* then use atoi() to convert that to an int.
So here it is:
square.tar.gz – The source and compiled version. It requires gtkmm-2.4 to compile, and should run on any platform that supports GTK+. The compiled version will only run on x86 with GTK+.
Things like this are why I’m hoping web applications are truly the future of GUI’s
Yeah seriously. To do the same thing in php would be:
< ?phpif(isset($_GET['number'])){
$result = $_GET['number'] * $_GET['number'];
echo "{$_GET['number']} squared is $result";
}
?>
<form method="get">
Enter a number and it will be squared:
<input type="text" name="number" />
<input type="submit" value="Go" />
</form>
But then.. it would be slower.