Hello,
Just to note your code has a number of errors in it. Mainly code related, but you have also missed out the function call to gtk_init() to initialise GTK+. You are also using C++ in an odd way. Try using "class" instead of "struct", use more of the memory management facilities as that can ease your coding and be less error prone. I would also suggest using gtkmm which is a C++ binding for the GTK+ API if you continue to use C++ as they interface very well. It is based on GObject and is very object orientated.
Below is your code rewritten using classes and gtkmm
gtktools.h
Code:
#include <gtkmm.h>
class gtktools : public Gtk::Window {
public:
gtktools();
virtual ~gtktools();
};
app.cc
Code:
#include <gtkmm.h>
#include "gtktools.h" //which in turn includes my component structs
int main(int argc, char **argv)
{
Gtk::Main kit(argc, argv);
gtktools window;
kit.run(window);
return 0;
}
gtktools.cc
Code:
#include "gtktools.h"
gtktools::gtktools()
{
set_default_size(400, 400);
set_position(Gtk::WIN_POS_CENTER);
show_all();
}
gtktools::~gtktools()
{
}
I used the command line
g++ `pkg-config --cflags --libs gtkmm-3.0` app.cc gtktools.cc
to build.
If you have used Java before some of the concepts should be familiar.
The web site for gtkmm is
http://www.gtkmm.org/ and the documentation is at
http://www.gtkmm.org/en/documentation.html.
There are many examples which show how to use gtkmm, but the main thing to is learn from the examples.