Gtk2::Window(3)
β¨ Gtk2::Window(3) π
okay bestie, this is the Gtk2::Window page from User Contributed Perl Documentation β and it's part 1, so don't panic when it keeps going. π
πΈ NAME πΈ
Gtk2::Window β wrapper for GtkWindow. it's giving "top-level window but make it Perl". πͺβ¨
π¦ DESCRIPTION π¦
A Gtk2::Window is a top-level window displayed on the root window and interacting (or not) with the window manager. It can be an application's main window, a dialog, or a temporary such as a popup splash window. basically it's the whole vibe of a window, bestie. πͺ
ποΈ Delete Event and Destroy π
The default action for a "delete-event" (normally from the window manager close button) is to destroy the window with $window->destroy. In your main window you might want to exit the main loop when that happens. slay.
$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
If you install a handler for "delete-event" and return true, meaning "don't propagate", you can do something other than destroy the window. For example:
$toplevel->signal_connect (delete_event => sub {
if (any_unsaved_documents()) {
popup_ask_save_before_exit_dialog();
return Gtk2::EVENT_STOP; # don't go to default destroy
} else {
return Gtk2::EVENT_PROPAGATE;
}
});
In a dialog or secondary app window you might not want to destroy but instead just hide ready for later re-use. lowkey smart.
$dialog->signal_connect
(delete_event => \&Gtk2::Widget::hide_on_delete);
The choice between destroying or hiding is normally just a matter of memory saved against the time to re-create, and how likely the dialog might be needed again. (However if you build windows with Glade it's not particularly easy to re-create them there, so you'll mostly want to just hide in that case.)
A hidden toplevel window is still in Gtk2::Window->list_toplevels and that's a good place to search for an existing window of a desired type to $window->present again. iconic.
π HIERARCHY π
Glib::Object
+----Glib::InitiallyUnowned
+----Gtk2::Object
+----Gtk2::Widget
+----Gtk2::Container
+----Gtk2::Bin
+----Gtk2::Window
π INTERFACES π
Glib::Object::_Unregistered::AtkImplementorIface
Gtk2::Buildable
π₯ METHODS π₯
okay bestie, here's the full method dump, no skips. π
widget = Gtk2::Window->new ($type=GTK_WINDOW_TOPLEVEL)β new window, who dis? β¨$type(Gtk2::WindowType)
boolean = $window->get_accept_focus- Since: gtk+ 2.4
$window->set_accept_focus ($setting)$setting(boolean)- Since: gtk+ 2.4
boolean = $window->activate_defaultboolean = $window->activate_focusboolean = $window->activate_key ($event)$event(Gtk2::Gdk::Event::Key)- Since: gtk+ 2.4
$window->add_accel_group ($accel_group)$accel_group(Gtk2::AccelGroup)
$window->add_embedded_xid ($xid)$xid(integer)
$window->add_mnemonic ($keyval, $target)$keyval(integer)$target(Gtk2::Widget)
Gtk2::Window->set_auto_startup_notification ($setting)$setting(boolean)- Since: gtk+ 2.2
$window->begin_move_drag ($button, $root_x, $root_y, $timestamp)$button(integer)$root_x(integer)$root_y(integer)$timestamp(unsigned)
$window->begin_resize_drag ($edge, $button, $root_x, $root_y, $timestamp)$edge(Gtk2::Gdk::WindowEdge)$button(integer)$root_x(integer)$root_y(integer)$timestamp(unsigned)
boolean = $window->get_decorated$window->set_decorated ($setting)$setting(boolean)
Gtk2::Window->set_default_icon_from_file ($filename)/$window->set_default_icon_from_file ($filename)$filename(localized file name)- May croak with a
Glib::Errorin$@on failure. - Since: gtk+ 2.2
list = Gtk2::Window->get_default_icon_listβ gets the value set by$window->set_default_icon_list.$window->set_default_icon_list ($pixbuf1, ...)...(list)$pixbuf1(Gtk2::Gdk::Pixbuf)
string or undef = Gtk2::Window->get_default_icon_nameβ gets the value set byGtk2::Window->set_default_icon_name.- Since: gtk+ 2.16
Gtk2::Window->set_default_icon_name ($name)$name(string or undef)- Since: gtk+ 2.6
Gtk2::Window->set_default_icon ($icon)$icon(Gtk2::Gdk::Pixbuf)- Since: gtk+ 2.4
$window->set_default ($default_widget)$default_widget(Gtk2::Widgetor undef)
(width, height) = $window->get_default_size$window->set_default_size ($width, $height)$width(integer)$height(integer)
widget or undef = $window->get_default_widget- Since: gtk+ 2.14
$window->deiconifyboolean = $window->get_deletable- Since: gtk+ 2.10
$window->set_deletable ($setting)$setting(boolean)- Since: gtk+ 2.10
boolean = $window->get_destroy_with_parent$window->set_destroy_with_parent ($setting)$setting(boolean)
widget or undef = $window->get_focusboolean = $window->get_focus_on_map- Since: gtk+ 2.6
$window->set_focus_on_map ($setting)$setting(boolean)- Since: gtk+ 2.6
$window->set_focus ($focus=undef)$focus(Gtk2::Widgetor undef)
(left, top, right, bottom) = $window->get_frame_dimensions$window->set_frame_dimensions ($left, $top, $right, $bottom)$left(integer)$top(integer)$right(integer)$bottom(integer)
$window->fullscreen- Since: gtk+ 2.2
$window->set_geometry_hints ($geometry_widget, $geometry)$window->set_geometry_hints ($geometry_widget, $geometry, $geom_mask)$geometry_widget(Gtk2::Widget)$geom_mask(Gtk2::Gdk::WindowHints) optional, usually inferred from$geometry$geometry(scalar)Gtk2::Gdk::Geometryor hashref- See
Gtk2::Gdk::Window::set_geometry_hintson the$geometryand$geom_maskarguments.
gravity = $window->get_gravity$window->set_gravity ($gravity)$gravity(Gtk2::Gdk::Gravity)
windowgroup or undef = $window->get_group- Since: gtk+ 2.10
boolean = $window->get_has_frame$window->set_has_frame ($setting)$setting(boolean)
boolean = $window->has_group- Since: gtk+ 2.22
boolean = $window->has_toplevel_focus- Since: gtk+ 2.4
$window->set_icon_from_file ($filename)$filename(localized file name)- May croak with a
Glib::Errorin$@on failure. - Since: gtk+ 2.2
pixbuf or undef = $window->get_iconlist = $window->get_icon_listβ retrieves the list of icons set byset_icon_list().$window->set_icon_list (...)β sets up the icon representing aGtk2::Window. The icon is used when the window is minimized (also known as iconified). Some window managers or desktop environments may also place it in the window frame, or display it in other contexts....(list) ofGtk2::Gdk::Pixbuf's
set_icon_list () allows you to pass in the same icon in several hand-drawn sizes. The list should contain the natural sizes your icon is available in; that is, don't scale the image before passing it to GTK+. Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.
By passing several sizes, you may improve the final image quality of the icon, by reducing or eliminating automatic image scaling.
Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and larger images (64x64, 128x128) if you have them.
string or undef = $window->get_icon_name- Since: gtk+ 2.6
$window->set_icon_name ($name)$name(string)- Since: gtk+ 2.6
$window->set_icon ($icon)$icon(Gtk2::Gdk::Pixbufor undef)
$window->iconifyboolean = $window->is_active- Since: gtk+ 2.4
$window->set_keep_above ($setting)$setting(boolean)- Since: gtk+ 2.4
$window->set_keep_below ($setting)$setting(boolean)- Since: gtk+ 2.4
list = Gtk2::Window->list_toplevelsβ returns a list of all existing toplevel windows.$window->maximizeboolean = $window->mnemonic_activate ($keyval, $modifier)$keyval(integer)$modifier(Gtk2::Gdk::ModifierType)
modifiertype = $window->get_mnemonic_modifier$window->set_mnemonic_modifier ($modifier)$modifier(Gtk2::Gdk::ModifierType)
boolean = $window->get_mnemonics_visible- Since: gtk+ 2.20
$window->set_mnemonics_visible ($setting)$setting(boolean)- Since: gtk+ 2.20
boolean = $window->get_modal$window->set_modal ($modal)$modal(boolean)
$window->move ($x, $y)$x(integer)$y(integer)
double = $window->get_opacity- Since: gtk+ 2.12
$window->set_opacity ($opacity)$opacity(double)- Since: gtk+ 2.12
boolean = $window->parse_geometry ($geometry)$geometry(string)
(root_x, root_y) = $window->get_position$window->set_position ($position)$position(Gtk2::WindowPosition)
$window->present$window->present_with_time ($timestamp)$timestamp(unsigned)- Since: gtk+ 2.8
boolean = $window->propagate_key_event ($event)$event(Gtk2::Gdk::Event::Key)- Since: gtk+ 2.4
$window->remove_accel_group ($accel_group)$accel_group(Gtk2::AccelGroup)
$window->remove_embedded_xid ($xid)$xid(integer)
$window->remove_mnemonic ($keyval, $target)$keyval(integer)$target(Gtk2::Widget)
$window->reshow_with_initial_sizeboolean = $window->get_resizable$window->set_resizable ($resizable)$resizable(boolean)
$window->resize ($width, $height)$width(integer)$height(integer)
string = $window->get_role$window->set_role ($role)$role(string)
screen = $window->get_screen- Since: gtk+ 2.2
$window->set_screen ($screen)$screen(Gtk2::Gdk::Screen)- Since: gtk+ 2.2
(width, height) = $window->get_sizeboolean = $window->get_skip_pager_hint- Since: gtk+ 2.2
$window->set_skip_pager_hint ($setting)$setting(boolean)- Since: gtk+ 2.2
boolean = $window->get_skip_taskbar_hint- Since: gtk+ 2.2
$window->set_skip_taskbar_hint ($setting)$setting(boolean)- Since: gtk+ 2.2
$window->set_startup_id ($startup_id)$startup_id(string)- Since: gtk+ 2.12
$window->stickstring = $window->get_title$window->set_title ($title=undef)$title(string or undef)
window or undef = $window->get_transient_for$window->set_transient_for ($parent)$parent(Gtk2::Windowor undef)
windowtypehint = $window->get_type_hint$window->set_type_hint ($hint)$hint(Gtk2::Gdk::WindowTypeHint)
$window->unfullscreen- Since: gtk+ 2.2
$window->unmaximize$window->unstickboolean = $window->get_urgency_hint- Since: gtk+ 2.8
$window->set_urgency_hint ($setting)$setting(boolean)- Since: gtk+ 2.8
windowtype = $window->get_window_type- Since: gtk+ 2.20
$window->set_wmclass ($wmclass_name, $wmclass_class)$wmclass_name(string)$wmclass_class(string)
π PROPERTIES π
ok so every one of these is a GObject property you can get/set on a Gtk2::Window, and they all come with the same lil metadata stamp: private / static-nick / static-blurb unless noted otherwise. Here's the whole roster, no skips, bestie π
'accept-focus'β boolean, defaulttrue,readable / writable / private / static-nick / static-blurb.TRUEif the window should receive the input focus. β¨'allow-grow'β boolean, defaulttrue,readable / writable / private / static-nick / static-blurb / deprecated. IfTRUE, users can expand the window beyond its minimum size. β οΈ it's deprecated, so maybe don't make it your whole personality'allow-shrink'β boolean, defaultfalse,readable / writable / private / static-nick / static-blurb / deprecated. IfTRUE, the window has no mimimum size. Setting this toTRUEis 99% of the time a bad idea. π deprecated too, and the docs are literally begging you
fr fr: that "99% of the time a bad idea" is the original's own words. take the warning seriously, bestie π«Ά
'decorated'β boolean, defaulttrue,readable / writable / private / static-nick / static-blurb. Whether the window should be decorated by the window manager. π'default-height'β integer, default-1,readable / writable / private / static-nick / static-blurb. The default height of the window, used when initially showing the window. π'default-width'β integer, default-1,readable / writable / private / static-nick / static-blurb. The default width of the window, used when initially showing the window. π'deletable'β boolean, defaulttrue,readable / writable / private / static-nick / static-blurb. Whether the window frame should have a close button. β'destroy-with-parent'β boolean, defaultfalse,readable / writable / private / static-nick / static-blurb. If this window should be destroyed when the parent is destroyed. π'focus-on-map'β boolean, defaulttrue,readable / writable / private / static-nick / static-blurb.TRUEif the window should receive the input focus when mapped. π'gravity'βGtk2::Gdk::Gravity, default"north-west",readable / writable / private / static-nick / static-blurb. The window gravity of the window. π§²'has-toplevel-focus'β boolean, defaultfalse,readable / private / static-nick / static-blurb. Whether the input focus is within thisGtkWindow. read-only, so you can look but not touch π'icon'βGtk2::Gdk::Pixbuf, defaultundef,readable / writable / private / static-nick / static-blurb. Icon for this window. πΌοΈ'icon-name'β string, defaultundef,readable / writable / private / static-nick / static-blurb. Name of the themed icon for this window. πΈ'is-active'β boolean, defaultfalse,readable / private / static-nick / static-blurb. Whether the toplevel is the current active window. also read-only, main character energy only, you don't set it π'mnemonics-visible'β boolean, defaulttrue,readable / writable / private / static-nick / static-blurb. Whether mnemonics are currently visible in this window. π€'modal'β boolean, defaultfalse,readable / writable / private / static-nick / static-blurb. IfTRUE, the window is modal (other windows are not usable while this one is up). π§'opacity'β double, default1,readable / writable / private / static-nick / static-blurb. The opacity of the window, from0to1. π¦'resizable'β boolean, defaulttrue,readable / writable / private / static-nick / static-blurb. IfTRUE, users can resize the window. βοΈ'role'β string, defaultundef,readable / writable / private / static-nick / static-blurb. Unique identifier for the window to be used when restoring a session. πͺͺ'screen'βGtk2::Gdk::Screen, defaultundef,readable / writable / private / static-nick / static-blurb. The screen where this window will be displayed. π₯οΈ'skip-pager-hint'β boolean, defaultfalse,readable / writable / private / static-nick / static-blurb.TRUEif the window should not be in the pager. π'skip-taskbar-hint'β boolean, defaultfalse,readable / writable / private / static-nick / static-blurb.TRUEif the window should not be in the task bar. π'startup-id'β string, defaultundef,writable / private / static-nick / static-blurb. Unique startup identifier for the window used by startup-notification. note it's writable only β no peeking β¨'title'β string, defaultundef,readable / writable / private / static-nick / static-blurb. The title of the window. π·οΈ'transient-for'βGtk2::Window, defaultundef,readable / writable / construct / private / static-nick / static-blurb. The transient parent of the dialog. π'type'βGtk2::WindowType, default"toplevel",readable / writable / construct-only / private / static-nick / static-blurb. The type of the window.construct-only, so it's a "decide at birth" situation, no take-backs π«'type-hint'βGtk2::Gdk::WindowTypeHint, default"normal",readable / writable / private / static-nick / static-blurb. Hint to help the desktop environment understand what kind of window this is and how to treat it. π€'urgency-hint'β boolean, defaultfalse,readable / writable / private / static-nick / static-blurb.TRUEif the window should be brought to the user's attention. π¨'window-position'βGtk2::WindowPosition, default"none",readable / writable / private / static-nick / static-blurb. The initial position of the window. π
π SIGNALS π
the windows are TALKING, bestie, here's everything they'll yell at you about:
activate-default (Gtk2::Window)activate-focus (Gtk2::Window)boolean = frame-event (Gtk2::Window, Gtk2::Gdk::Event)keys-changed (Gtk2::Window)set-focus (Gtk2::Window, Gtk2::Widget)
π ENUMS AND FLAGS π
all the little constant vocabularies you'll be passing around. first name is the perl side, second is the C side, iykyk π«Ά
enum Gtk2::Gdk::Gravity
'north-west'/'GDK_GRAVITY_NORTH_WEST''north'/'GDK_GRAVITY_NORTH''north-east'/'GDK_GRAVITY_NORTH_EAST''west'/'GDK_GRAVITY_WEST''center'/'GDK_GRAVITY_CENTER''east'/'GDK_GRAVITY_EAST''south-west'/'GDK_GRAVITY_SOUTH_WEST''south'/'GDK_GRAVITY_SOUTH''south-east'/'GDK_GRAVITY_SOUTH_EAST''static'/'GDK_GRAVITY_STATIC'
flags Gtk2::Gdk::ModifierType
'shift-mask'/'GDK_SHIFT_MASK''lock-mask'/'GDK_LOCK_MASK''control-mask'/'GDK_CONTROL_MASK''mod1-mask'/'GDK_MOD1_MASK''mod2-mask'/'GDK_MOD2_MASK''mod3-mask'/'GDK_MOD3_MASK''mod4-mask'/'GDK_MOD4_MASK''mod5-mask'/'GDK_MOD5_MASK''button1-mask'/'GDK_BUTTON1_MASK''button2-mask'/'GDK_BUTTON2_MASK''button3-mask'/'GDK_BUTTON3_MASK''button4-mask'/'GDK_BUTTON4_MASK''button5-mask'/'GDK_BUTTON5_MASK''super-mask'/'GDK_SUPER_MASK''hyper-mask'/'GDK_HYPER_MASK''meta-mask'/'GDK_META_MASK''release-mask'/'GDK_RELEASE_MASK''modifier-mask'/'GDK_MODIFIER_MASK'
enum Gtk2::Gdk::WindowEdge
'north-west'/'GDK_WINDOW_EDGE_NORTH_WEST''north'/'GDK_WINDOW_EDGE_NORTH''north-east'/'GDK_WINDOW_EDGE_NORTH_EAST''west'/'GDK_WINDOW_EDGE_WEST''east'/'GDK_WINDOW_EDGE_EAST''south-west'/'GDK_WINDOW_EDGE_SOUTH_WEST''south'/'GDK_WINDOW_EDGE_SOUTH''south-east'/'GDK_WINDOW_EDGE_SOUTH_EAST'
flags Gtk2::Gdk::WindowHints
'pos'/'GDK_HINT_POS''min-size'/'GDK_HINT_MIN_SIZE''max-size'/'GDK_HINT_MAX_SIZE''base-size'/'GDK_HINT_BASE_SIZE''aspect'/'GDK_HINT_ASPECT''resize-inc'/'GDK_HINT_RESIZE_INC''win-gravity'/'GDK_HINT_WIN_GRAVITY''user-pos'/'GDK_HINT_USER_POS''user-size'/'GDK_HINT_USER_SIZE'
enum Gtk2::Gdk::WindowTypeHint
'normal'/'GDK_WINDOW_TYPE_HINT_NORMAL''dialog'/'GDK_WINDOW_TYPE_HINT_DIALOG''menu'/'GDK_WINDOW_TYPE_HINT_MENU''toolbar'/'GDK_WINDOW_TYPE_HINT_TOOLBAR''splashscreen'/'GDK_WINDOW_TYPE_HINT_SPLASHSCREEN''utility'/'GDK_WINDOW_TYPE_HINT_UTILITY''dock'/'GDK_WINDOW_TYPE_HINT_DOCK''desktop'/'GDK_WINDOW_TYPE_HINT_DESKTOP''dropdown-menu'/'GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU''popup-menu'/'GDK_WINDOW_TYPE_HINT_POPUP_MENU''tooltip'/'GDK_WINDOW_TYPE_HINT_TOOLTIP''notification'/'GDK_WINDOW_TYPE_HINT_NOTIFICATION''combo'/'GDK_WINDOW_TYPE_HINT_COMBO''dnd'/'GDK_WINDOW_TYPE_HINT_DND'
enum Gtk2::WindowPosition
'none'/'GTK_WIN_POS_NONE''center'/'GTK_WIN_POS_CENTER''mouse'/'GTK_WIN_POS_MOUSE''center-always'/'GTK_WIN_POS_CENTER_ALWAYS''center-on-parent'/'GTK_WIN_POS_CENTER_ON_PARENT'
enum Gtk2::WindowType
'toplevel'/'GTK_WINDOW_TOPLEVEL''popup'/'GTK_WINDOW_POPUP'
π SEE ALSO π
go read these next, bestie, they're the whole friend group:
Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Container, Gtk2::Bin
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.
and that's a wrap on Gtk2::Window(3), bestie!! π this one shipped with perl v5.42.0 and it's dated 2025-07-25 β so yeah, fresh-ish lore, go forth and make windows, you absolute icon ππ
π¦ where this page comes from
- fedora 43: perl-Gtk2 1.24993-23.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms