Gtkmm - Creating simpler window
Creating Gtk3 simple window was easy, isn’t it? In Gtkmm it is easier. I’ll show you.
main.cpp contents
#include <gtkmm.h>
int main (int argc, char *argv[])
{
//Set up Gtk
Gtk::Main kit(argc, argv);
//Prepare window to display
Gtk::Window window;
//Run program using created window
kit.run(window);
return 0;
}
Makefile contents
Nearly same as before. Only one change is in the third line. Instead of calling for gtk+-3.0 package we will use now gtkmm-3.0.
CC = g++
FLAGS = -Wall -pedantic -std=c++0x
FLAGS += `pkg-config gtkmm-3.0 --cflags --libs`
OBJECTS = main.o
main : $(OBJECTS)
$(CC) $(FLAGS) $(OBJECTS) -o main
clean :
@rm -f $(OBJECTS) *~ *#
%.o: %.cpp
$(CC) $(FLAGS) -c $< -o $@
Compilation
As before, just enter in terminal:
make main ; ./main
Outro
This is the simplest of window applications in gtkmm. If you want to create more complicated one, you should play with inheritance of Gtk::Window or/and Gtk::Application (or any other class in gtkmm). See gtkmm docs for more informations.