NAME

Gtk3 - Perl interface to the 3.x series of the gtk+ toolkit

SYNOPSIS

use Gtk3 -init; my $window = Gtk3::Window->new (toplevel); my $button = Gtk3::Button->new (Quit); $button->signal_connect (clicked => sub { Gtk3::main_quit }); $window->add ($button); $window->show_all; Gtk3::main;

ABSTRACT

Perl bindings to the 3.x series of the gtk+ toolkit. This module allows you to write graphical user interfaces in a Perlish and object-oriented way, freeing you from the casting and memory management in C, yet remaining very close in spirit to original API.

DESCRIPTION

The Gtk3 module allows a Perl developer to use the gtk+ graphical user interface library. Find out more about gtk+ at <http://www.gtk.org>.

The gtk+ reference manual is also a handy companion when writing Gtk3 programs in Perl: <http://developer.gnome.org/gtk3/stable/>. The Perl bindings follow the C API very closely, and the C reference documentation should be considered the canonical source. The principles underlying the mapping from C to Perl are explained in the documentation of Glib::Object::Introspection, on which Gtk3 is based.

Glib::Object::Introspection also comes with the perli11ndoc program which displays the API reference documentation of all installed libraries organized in accordance with these principles.

Wrapped libraries

Gtk3 automatically sets up the following correspondence between C libraries and Perl packages:

Library | Package --------------+---------- Gtk-3.0 | Gtk3 Gdk-3.0 | Gtk3::Gdk GdkPixbuf-2.0 | Gtk3::Gdk GdkPixdata-2.0| Gtk3::Gdk Pango-1.0 | Pango

Import arguments

When importing Gtk3, you can pass -init as in use Gtk3 -init; to have Gtk3::init automatically called. You can also pass a version number to require a certain version of Gtk3.

Customizations and overrides

In order to make things more Perlish or to make porting from Gtk2 to Gtk3 easier, Gtk3 customizes the API generated by Glib::Object::Introspection in a few spots:

The following functions normally return a boolean and additional out arguments, where the boolean indicates whether the out arguments are valid. They are altered such that when the boolean is true, only the additional out arguments are returned, and when the boolean is false, an empty list is returned.

Gtk3::TextBuffer::get_selection_bounds
Gtk3::TreeModel::get_iter
Gtk3::TreeModel::get_iter_first
Gtk3::TreeModel::get_iter_from_string
Gtk3::TreeModel::iter_children
Gtk3::TreeModel::iter_nth_child
Gtk3::TreeModel::iter_parent
Gtk3::TreeModelFilter::convert_child_iter_to_iter
Gtk3::TreeModelSort::convert_child_iter_to_iter
Gtk3::TreeSelection::get_selected
Gtk3::TreeView::get_dest_row_at_pos
Gtk3::TreeView::get_path_at_pos
Gtk3::TreeView::get_tooltip_context
Gtk3::TreeView::get_visible_range
Gtk3::TreeViewColumn::cell_get_position
Gtk3::stock_lookup
Gtk3::Gdk::Event::get_axis
Gtk3::Gdk::Event::get_button
Gtk3::Gdk::Event::get_click_count
Gtk3::Gdk::Event::get_coords
Gtk3::Gdk::Event::get_keycode
Gtk3::Gdk::Event::get_keyval
Gtk3::Gdk::Event::get_scroll_direction
Gtk3::Gdk::Event::get_scroll_deltas
Gtk3::Gdk::Event::get_state
Gtk3::Gdk::Event::get_root_coords
Gtk3::Gdk::Window::get_origin

Values of type Gtk3::ResponseType are converted to and from nick names if possible, while still allowing raw IDs, in the following places:

- For Gtk3::Dialog and Gtk3::InfoBar: the signal "response" as well as the methods "add_action_widget", "add_button", "add_buttons", "response", "set_default_response" and "set_response_sensitive".
- For Gtk3::Dialog: the methods "get_response_for_widget", "get_widget_for_response", "run" and "set_alternative_button_order".

Values of type Gtk3::IconSize are converted to and from nick names if possible, while still allowing raw IDs, in the following places:

- Gtk3::Image: the constructors new_from_stock, new_from_icon_set, new_from_icon_name and new_from_gicon, the getters get_stock, get_icon_set, get_icon_name and get_gicon and the setters set_from_stock, set_from_icon_set, set_from_icon_name, set_from_gicon.
- Gtk3::Widget: the method render_icon.

The constants Gtk3::EVENT_PROPAGATE and Gtk3::EVENT_STOP can be used in handlers for event signals like key-press-event to indicate whether or not the event should continue propagating through the widget hierarchy.

Perl compatibility

As of 5.20.0, perl does not automatically re-check the locale environment for changes. If a function thus changes the locale behind perl's back, problems might arise whenever numbers are formatted, for example when checking versions. To ensure perl's assumption about the locale are up-to-date, the functions Gtk3::init, init_check, init_with_args and parse_args are amended to let perl know of any changes.

Porting from Gtk2 to Gtk3

The majority of the API has not changed, so as a first approximation you can run s/Gtk2/Gtk3/ on your application. A big exception to this rule is APIs that were deprecated in gtk+ 2.x Ω- these were all removed from gtk+ 3.0 and thus from Gtk3. The migration guide at <http://developer.gnome.org/gtk3/stable/migrating.html> describes what to use instead. Apart from this, here is a list of some other incompatible differences between Gtk2 and Gtk3:

Note also that Gtk3::CHECK_VERSION will always fail when passed 2.y.z, so if you have any existing version checks in your code, you will most likely need to remove them.

SEE ALSO

AUTHORS

Torsten Schönfeld <kaffeetisch@gmx.de>

COPYRIGHT AND LICENSE

Copyright (C) 2011-2015 by Torsten Schoenfeld <kaffeetisch@gmx.de>

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.