gtkmm

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Gtkmm
Platform GTK+
Type language binding
License GNU Lesser General Public License
Website www.gtkmm.org

gtkmm (formerly known as gtk-- or gtk minus minus[1]) is the official C++ interface for the popular GUI library GTK+. gtkmm is free software distributed under the GNU Lesser General Public License (LGPL).

gtkmm allows the creation of user interfaces either in code or with the Glade Interface Designer, using the Gtk::Builder class. Other features include typesafe callbacks, a comprehensive set of graphical control elements, and the extensibility of widgets via inheritance.

Features[edit]

Due to the fact that gtkmm is the official C++ interface of the GUI library GTK+, C++ programmers can use the common OOP techniques such as inheritance, and C++-specific facilities such as STL (In fact, many of the gtkmm interfaces, especially those for widget containers, are designed to be similar to the Standard Template Library (STL)).

Main features of gtkmm are listed as follows:

Hello World in Gtkmm[edit]

//HelloWorldWindow.h
#ifndef HELLOWORLDWINDOW_H
#define HELLOWORLDWINDOW_H
 
#include <gtkmm/window.h>
#include <gtkmm/button.h>
 
// Derive a new window widget from an existing one.
// This window will only contain a button labelled "Hello World"
class HelloWorldWindow : public Gtk::Window
{
  public:
    HelloWorldWindow();
    ~HelloWorldWindow();
 
  protected:
    void on_button_clicked(); //event handler
 
    Gtk::Button hello_world;
};
 
#endif
//HelloWorldWindow.cc
#include <iostream>
#include "HelloWorldWindow.h"
 
HelloWorldWindow::HelloWorldWindow()
 : hello_world("Hello World")
{
    // Set the title of the window.
    set_title("Hello World");
 
    // Add the member button to the window,
    add(hello_world);
 
    // Handle the 'click' event.
    hello_world.signal_clicked().connect(
        sigc::mem_fun(*this, &HelloWorldWindow::on_button_clicked));
 
    // Display all the child widgets of the window.
    show_all_children();
}
 
void HelloWorldWindow::on_button_clicked()
{
    std::cout << "Hello world" << std::endl;
}
 
HelloWorldWindow::~HelloWorldWindow()
{
}
//main.cc
 
#include <gtkmm/main.h>
#include "HelloWorldWindow.h"
 
int main(int argc, char *argv[]) 
{
    // Initialization
    Gtk::Main kit(argc, argv);
 
    // Create a hello world window object
    HelloWorldWindow example;
 
    // gtkmm main loop
    Gtk::Main::run(example);
    return 0;
}

This program will create a window with a button labeled "Hello World". The button sends "Hello world" to standard output when clicked.

To run this program, just type the following command at your terminal:

$ g++ *.cc -o example `pkg-config gtkmm-2.4 --cflags --libs`
$ ./example

or you can write a simple makefile.

To run gtkmm programs on Windows, see official manual.[2]

Applications[edit]

Some notable applications that use Gtkmm include:

  • Inkscape Vector graphics drawing.
  • K-3D, for 3D modeling and animation.
  • Workrave Assists in recovery and prevention of RSI.
  • GParted disk partitioning tool.
  • Gobby Collaborative text editor.
  • Nemiver GUI for the GNU debugger gdb.
  • Referencer document organiser and bibliography manager
  • MySQL Administrator Database GUI.
  • Ardour Open Source digital audio workstation (DAW) for Linux and MacOS.
  • Gnote desktop notetaking application.

See also[edit]

References[edit]

External links[edit]