1Gtk2::Window(3) User Contributed Perl Documentation Gtk2::Window(3)
2
3
4
6 Gtk2::Window - wrapper for GtkWindow
7
9 A Gtk2::Window is a top-level window displayed on the root window and
10 interacting (or not) with the window manager. It can be an
11 application's main window, a dialog, or a temporary such as a popup
12 splash window.
13
14 Delete Event and Destroy
15 The default action for a "delete-event" (normally from the window
16 manager close button) is to destroy the window with "$window->destroy".
17 In your main window you might want to exit the main loop when that
18 happens.
19
20 $toplevel->signal_connect (destroy => sub { Gtk2->main_quit });
21
22 If you install a handler for "delete-event" and return true, meaning
23 "don't propagate", you can do something other than destroy the window.
24 For example
25
26 $toplevel->signal_connect (delete_event => sub {
27 if (any_unsaved_documents()) {
28 popup_ask_save_before_exit_dialog();
29 return Gtk2::EVENT_STOP; # don't go to default destroy
30 } else {
31 return Gtk2::EVENT_PROPAGATE;
32 }
33 });
34
35 In a dialog or secondary app window you might not want to destroy but
36 instead just hide ready for later re-use.
37
38 $dialog->signal_connect
39 (delete_event => \&Gtk2::Widget::hide_on_delete);
40
41 The choice between destroying or hiding is normally just a matter of
42 memory saved against the time to re-create, and how likely the dialog
43 might be needed again. (However if you build windows with Glade it's
44 not particularly easy to re-create them there, so you'll mostly want to
45 just hide in that case.)
46
47 A hidden toplevel window is still in "Gtk2::Window->list_toplevels" and
48 that's a good place to search for an existing window of a desired type
49 to "$window->present" again.
50
52 Glib::Object
53 +----Glib::InitiallyUnowned
54 +----Gtk2::Object
55 +----Gtk2::Widget
56 +----Gtk2::Container
57 +----Gtk2::Bin
58 +----Gtk2::Window
59
61 Glib::Object::_Unregistered::AtkImplementorIface
62 Gtk2::Buildable
63
65 widget = Gtk2::Window->new ($type=GTK_WINDOW_TOPLEVEL)
66 • $type (Gtk2::WindowType)
67
68 boolean = $window->get_accept_focus
69 Since: gtk+ 2.4
70
71 $window->set_accept_focus ($setting)
72 • $setting (boolean)
73
74 Since: gtk+ 2.4
75
76 boolean = $window->activate_default
77 boolean = $window->activate_focus
78 boolean = $window->activate_key ($event)
79 • $event (Gtk2::Gdk::Event::Key)
80
81 Since: gtk+ 2.4
82
83 $window->add_accel_group ($accel_group)
84 • $accel_group (Gtk2::AccelGroup)
85
86 $window->add_embedded_xid ($xid)
87 • $xid (integer)
88
89 $window->add_mnemonic ($keyval, $target)
90 • $keyval (integer)
91
92 • $target (Gtk2::Widget)
93
94 Gtk2::Window->set_auto_startup_notification ($setting)
95 • $setting (boolean)
96
97 Since: gtk+ 2.2
98
99 $window->begin_move_drag ($button, $root_x, $root_y, $timestamp)
100 • $button (integer)
101
102 • $root_x (integer)
103
104 • $root_y (integer)
105
106 • $timestamp (unsigned)
107
108 $window->begin_resize_drag ($edge, $button, $root_x, $root_y, $timestamp)
109 • $edge (Gtk2::Gdk::WindowEdge)
110
111 • $button (integer)
112
113 • $root_x (integer)
114
115 • $root_y (integer)
116
117 • $timestamp (unsigned)
118
119 boolean = $window->get_decorated
120 $window->set_decorated ($setting)
121 • $setting (boolean)
122
123 Gtk2::Window->set_default_icon_from_file ($filename)
124 $window->set_default_icon_from_file ($filename)
125 • $filename (localized file name)
126
127 May croak with a Glib::Error in $@ on failure.
128
129 Since: gtk+ 2.2
130
131 list = Gtk2::Window->get_default_icon_list
132 Gets the value set by $window->set_default_icon_list.
133
134 $window->set_default_icon_list ($pixbuf1, ...)
135 • ... (list)
136
137 • $pixbuf1 (Gtk2::Gdk::Pixbuf)
138
139 string or undef = Gtk2::Window->get_default_icon_name
140 Gets the value set by "Gtk2::Window->set_default_icon_name".
141
142 Since: gtk+ 2.16
143
144 Gtk2::Window->set_default_icon_name ($name)
145 • $name (string or undef)
146
147 Since: gtk+ 2.6
148
149 Gtk2::Window->set_default_icon ($icon)
150 • $icon (Gtk2::Gdk::Pixbuf)
151
152 Since: gtk+ 2.4
153
154 $window->set_default ($default_widget)
155 • $default_widget (Gtk2::Widget or undef)
156
157 (width, height) = $window->get_default_size
158 $window->set_default_size ($width, $height)
159 • $width (integer)
160
161 • $height (integer)
162
163 widget or undef = $window->get_default_widget
164 Since: gtk+ 2.14
165
166 $window->deiconify
167 boolean = $window->get_deletable
168 Since: gtk+ 2.10
169
170 $window->set_deletable ($setting)
171 • $setting (boolean)
172
173 Since: gtk+ 2.10
174
175 boolean = $window->get_destroy_with_parent
176 $window->set_destroy_with_parent ($setting)
177 • $setting (boolean)
178
179 widget or undef = $window->get_focus
180 boolean = $window->get_focus_on_map
181 Since: gtk+ 2.6
182
183 $window->set_focus_on_map ($setting)
184 • $setting (boolean)
185
186 Since: gtk+ 2.6
187
188 $window->set_focus ($focus=undef)
189 • $focus (Gtk2::Widget or undef)
190
191 (left, top, right, bottom) = $window->get_frame_dimensions
192 $window->set_frame_dimensions ($left, $top, $right, $bottom)
193 • $left (integer)
194
195 • $top (integer)
196
197 • $right (integer)
198
199 • $bottom (integer)
200
201 $window->fullscreen
202 Since: gtk+ 2.2
203
204 $window->set_geometry_hints ($geometry_widget, $geometry)
205 $window->set_geometry_hints ($geometry_widget, $geometry, $geom_mask)
206 • $geometry_widget (Gtk2::Widget)
207
208 • $geom_mask (Gtk2::Gdk::WindowHints) optional, usually inferred from
209 $geometry
210
211 • $geometry (scalar) Gtk2::Gdk::Geometry or hashref
212
213 See "Gtk2::Gdk::Window::set_geometry_hints" on the $geometry and
214 $geom_mask arguments.
215
216 gravity = $window->get_gravity
217 $window->set_gravity ($gravity)
218 • $gravity (Gtk2::Gdk::Gravity)
219
220 windowgroup or undef = $window->get_group
221 Since: gtk+ 2.10
222
223 boolean = $window->get_has_frame
224 $window->set_has_frame ($setting)
225 • $setting (boolean)
226
227 boolean = $window->has_group
228 Since: gtk+ 2.22
229
230 boolean = $window->has_toplevel_focus
231 Since: gtk+ 2.4
232
233 $window->set_icon_from_file ($filename)
234 • $filename (localized file name)
235
236 May croak with a Glib::Error in $@ on failure.
237
238 Since: gtk+ 2.2
239
240 pixbuf or undef = $window->get_icon
241 list = $window->get_icon_list
242 Retrieves the list of icons set by set_icon_list().
243
244 $window->set_icon_list (...)
245 • ... (list) of Gtk2::Gdk::Pixbuf's
246
247 Sets up the icon representing a Gtk2::Window. The icon is used when the
248 window is minimized (also known as iconified). Some window managers or
249 desktop environments may also place it in the window frame, or display
250 it in other contexts.
251
252 set_icon_list () allows you to pass in the same icon in several hand-
253 drawn sizes. The list should contain the natural sizes your icon is
254 available in; that is, don't scale the image before passing it to GTK+.
255 Scaling is postponed until the last minute, when the desired final size
256 is known, to allow best quality.
257
258 By passing several sizes, you may improve the final image quality of
259 the icon, by reducing or eliminating automatic image scaling.
260
261 Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and
262 larger images (64x64, 128x128) if you have them.
263
264 string or undef = $window->get_icon_name
265 Since: gtk+ 2.6
266
267 $window->set_icon_name ($name)
268 • $name (string)
269
270 Since: gtk+ 2.6
271
272 $window->set_icon ($icon)
273 • $icon (Gtk2::Gdk::Pixbuf or undef)
274
275 $window->iconify
276 boolean = $window->is_active
277 Since: gtk+ 2.4
278
279 $window->set_keep_above ($setting)
280 • $setting (boolean)
281
282 Since: gtk+ 2.4
283
284 $window->set_keep_below ($setting)
285 • $setting (boolean)
286
287 Since: gtk+ 2.4
288
289 list = Gtk2::Window->list_toplevels
290 Returns a list of all existing toplevel windows.
291
292 $window->maximize
293 boolean = $window->mnemonic_activate ($keyval, $modifier)
294 • $keyval (integer)
295
296 • $modifier (Gtk2::Gdk::ModifierType)
297
298 modifiertype = $window->get_mnemonic_modifier
299 $window->set_mnemonic_modifier ($modifier)
300 • $modifier (Gtk2::Gdk::ModifierType)
301
302 boolean = $window->get_mnemonics_visible
303 Since: gtk+ 2.20
304
305 $window->set_mnemonics_visible ($setting)
306 • $setting (boolean)
307
308 Since: gtk+ 2.20
309
310 boolean = $window->get_modal
311 $window->set_modal ($modal)
312 • $modal (boolean)
313
314 $window->move ($x, $y)
315 • $x (integer)
316
317 • $y (integer)
318
319 double = $window->get_opacity
320 Since: gtk+ 2.12
321
322 $window->set_opacity ($opacity)
323 • $opacity (double)
324
325 Since: gtk+ 2.12
326
327 boolean = $window->parse_geometry ($geometry)
328 • $geometry (string)
329
330 (root_x, root_y) = $window->get_position
331 $window->set_position ($position)
332 • $position (Gtk2::WindowPosition)
333
334 $window->present
335 $window->present_with_time ($timestamp)
336 • $timestamp (unsigned)
337
338 Since: gtk+ 2.8
339
340 boolean = $window->propagate_key_event ($event)
341 • $event (Gtk2::Gdk::Event::Key)
342
343 Since: gtk+ 2.4
344
345 $window->remove_accel_group ($accel_group)
346 • $accel_group (Gtk2::AccelGroup)
347
348 $window->remove_embedded_xid ($xid)
349 • $xid (integer)
350
351 $window->remove_mnemonic ($keyval, $target)
352 • $keyval (integer)
353
354 • $target (Gtk2::Widget)
355
356 $window->reshow_with_initial_size
357 boolean = $window->get_resizable
358 $window->set_resizable ($resizable)
359 • $resizable (boolean)
360
361 $window->resize ($width, $height)
362 • $width (integer)
363
364 • $height (integer)
365
366 string = $window->get_role
367 $window->set_role ($role)
368 • $role (string)
369
370 screen = $window->get_screen
371 Since: gtk+ 2.2
372
373 $window->set_screen ($screen)
374 • $screen (Gtk2::Gdk::Screen)
375
376 Since: gtk+ 2.2
377
378 (width, height) = $window->get_size
379 boolean = $window->get_skip_pager_hint
380 Since: gtk+ 2.2
381
382 $window->set_skip_pager_hint ($setting)
383 • $setting (boolean)
384
385 Since: gtk+ 2.2
386
387 boolean = $window->get_skip_taskbar_hint
388 Since: gtk+ 2.2
389
390 $window->set_skip_taskbar_hint ($setting)
391 • $setting (boolean)
392
393 Since: gtk+ 2.2
394
395 $window->set_startup_id ($startup_id)
396 • $startup_id (string)
397
398 Since: gtk+ 2.12
399
400 $window->stick
401 string = $window->get_title
402 $window->set_title ($title=undef)
403 • $title (string or undef)
404
405 window or undef = $window->get_transient_for
406 $window->set_transient_for ($parent)
407 • $parent (Gtk2::Window or undef)
408
409 windowtypehint = $window->get_type_hint
410 $window->set_type_hint ($hint)
411 • $hint (Gtk2::Gdk::WindowTypeHint)
412
413 $window->unfullscreen
414 Since: gtk+ 2.2
415
416 $window->unmaximize
417 $window->unstick
418 boolean = $window->get_urgency_hint
419 Since: gtk+ 2.8
420
421 $window->set_urgency_hint ($setting)
422 • $setting (boolean)
423
424 Since: gtk+ 2.8
425
426 windowtype = $window->get_window_type
427 Since: gtk+ 2.20
428
429 $window->set_wmclass ($wmclass_name, $wmclass_class)
430 • $wmclass_name (string)
431
432 • $wmclass_class (string)
433
435 'accept-focus' (boolean : default true : readable / writable / private
436 / static-nick / static-blurb)
437 TRUE if the window should receive the input focus.
438
439 'allow-grow' (boolean : default true : readable / writable / private /
440 static-nick / static-blurb / deprecated)
441 If TRUE, users can expand the window beyond its minimum size
442
443 'allow-shrink' (boolean : default false : readable / writable / private
444 / static-nick / static-blurb / deprecated)
445 If TRUE, the window has no mimimum size. Setting this to TRUE is
446 99% of the time a bad idea
447
448 'decorated' (boolean : default true : readable / writable / private /
449 static-nick / static-blurb)
450 Whether the window should be decorated by the window manager
451
452 'default-height' (integer : default -1 : readable / writable / private
453 / static-nick / static-blurb)
454 The default height of the window, used when initially showing the
455 window
456
457 'default-width' (integer : default -1 : readable / writable / private /
458 static-nick / static-blurb)
459 The default width of the window, used when initially showing the
460 window
461
462 'deletable' (boolean : default true : readable / writable / private /
463 static-nick / static-blurb)
464 Whether the window frame should have a close button
465
466 'destroy-with-parent' (boolean : default false : readable / writable /
467 private / static-nick / static-blurb)
468 If this window should be destroyed when the parent is destroyed
469
470 'focus-on-map' (boolean : default true : readable / writable / private
471 / static-nick / static-blurb)
472 TRUE if the window should receive the input focus when mapped.
473
474 'gravity' (Gtk2::Gdk::Gravity : default "north-west" : readable /
475 writable / private / static-nick / static-blurb)
476 The window gravity of the window
477
478 'has-toplevel-focus' (boolean : default false : readable / private /
479 static-nick / static-blurb)
480 Whether the input focus is within this GtkWindow
481
482 'icon' (Gtk2::Gdk::Pixbuf : default undef : readable / writable /
483 private / static-nick / static-blurb)
484 Icon for this window
485
486 'icon-name' (string : default undef : readable / writable / private /
487 static-nick / static-blurb)
488 Name of the themed icon for this window
489
490 'is-active' (boolean : default false : readable / private / static-nick
491 / static-blurb)
492 Whether the toplevel is the current active window
493
494 'mnemonics-visible' (boolean : default true : readable / writable /
495 private / static-nick / static-blurb)
496 Whether mnemonics are currently visible in this window
497
498 'modal' (boolean : default false : readable / writable / private /
499 static-nick / static-blurb)
500 If TRUE, the window is modal (other windows are not usable while
501 this one is up)
502
503 'opacity' (double : default 1 : readable / writable / private / static-
504 nick / static-blurb)
505 The opacity of the window, from 0 to 1
506
507 'resizable' (boolean : default true : readable / writable / private /
508 static-nick / static-blurb)
509 If TRUE, users can resize the window
510
511 'role' (string : default undef : readable / writable / private /
512 static-nick / static-blurb)
513 Unique identifier for the window to be used when restoring a
514 session
515
516 'screen' (Gtk2::Gdk::Screen : default undef : readable / writable /
517 private / static-nick / static-blurb)
518 The screen where this window will be displayed
519
520 'skip-pager-hint' (boolean : default false : readable / writable /
521 private / static-nick / static-blurb)
522 TRUE if the window should not be in the pager.
523
524 'skip-taskbar-hint' (boolean : default false : readable / writable /
525 private / static-nick / static-blurb)
526 TRUE if the window should not be in the task bar.
527
528 'startup-id' (string : default undef : writable / private / static-nick
529 / static-blurb)
530 Unique startup identifier for the window used by startup-
531 notification
532
533 'title' (string : default undef : readable / writable / private /
534 static-nick / static-blurb)
535 The title of the window
536
537 'transient-for' (Gtk2::Window : default undef : readable / writable /
538 construct / private / static-nick / static-blurb)
539 The transient parent of the dialog
540
541 'type' (Gtk2::WindowType : default "toplevel" : readable / writable /
542 construct-only / private / static-nick / static-blurb)
543 The type of the window
544
545 'type-hint' (Gtk2::Gdk::WindowTypeHint : default "normal" : readable /
546 writable / private / static-nick / static-blurb)
547 Hint to help the desktop environment understand what kind of window
548 this is and how to treat it.
549
550 'urgency-hint' (boolean : default false : readable / writable / private
551 / static-nick / static-blurb)
552 TRUE if the window should be brought to the user's attention.
553
554 'window-position' (Gtk2::WindowPosition : default "none" : readable /
555 writable / private / static-nick / static-blurb)
556 The initial position of the window
557
559 activate-default (Gtk2::Window)
560 activate-focus (Gtk2::Window)
561 boolean = frame-event (Gtk2::Window, Gtk2::Gdk::Event)
562 keys-changed (Gtk2::Window)
563 set-focus (Gtk2::Window, Gtk2::Widget)
564
566 enum Gtk2::Gdk::Gravity
567 • 'north-west' / 'GDK_GRAVITY_NORTH_WEST'
568
569 • 'north' / 'GDK_GRAVITY_NORTH'
570
571 • 'north-east' / 'GDK_GRAVITY_NORTH_EAST'
572
573 • 'west' / 'GDK_GRAVITY_WEST'
574
575 • 'center' / 'GDK_GRAVITY_CENTER'
576
577 • 'east' / 'GDK_GRAVITY_EAST'
578
579 • 'south-west' / 'GDK_GRAVITY_SOUTH_WEST'
580
581 • 'south' / 'GDK_GRAVITY_SOUTH'
582
583 • 'south-east' / 'GDK_GRAVITY_SOUTH_EAST'
584
585 • 'static' / 'GDK_GRAVITY_STATIC'
586
587 flags Gtk2::Gdk::ModifierType
588 • 'shift-mask' / 'GDK_SHIFT_MASK'
589
590 • 'lock-mask' / 'GDK_LOCK_MASK'
591
592 • 'control-mask' / 'GDK_CONTROL_MASK'
593
594 • 'mod1-mask' / 'GDK_MOD1_MASK'
595
596 • 'mod2-mask' / 'GDK_MOD2_MASK'
597
598 • 'mod3-mask' / 'GDK_MOD3_MASK'
599
600 • 'mod4-mask' / 'GDK_MOD4_MASK'
601
602 • 'mod5-mask' / 'GDK_MOD5_MASK'
603
604 • 'button1-mask' / 'GDK_BUTTON1_MASK'
605
606 • 'button2-mask' / 'GDK_BUTTON2_MASK'
607
608 • 'button3-mask' / 'GDK_BUTTON3_MASK'
609
610 • 'button4-mask' / 'GDK_BUTTON4_MASK'
611
612 • 'button5-mask' / 'GDK_BUTTON5_MASK'
613
614 • 'super-mask' / 'GDK_SUPER_MASK'
615
616 • 'hyper-mask' / 'GDK_HYPER_MASK'
617
618 • 'meta-mask' / 'GDK_META_MASK'
619
620 • 'release-mask' / 'GDK_RELEASE_MASK'
621
622 • 'modifier-mask' / 'GDK_MODIFIER_MASK'
623
624 enum Gtk2::Gdk::WindowEdge
625 • 'north-west' / 'GDK_WINDOW_EDGE_NORTH_WEST'
626
627 • 'north' / 'GDK_WINDOW_EDGE_NORTH'
628
629 • 'north-east' / 'GDK_WINDOW_EDGE_NORTH_EAST'
630
631 • 'west' / 'GDK_WINDOW_EDGE_WEST'
632
633 • 'east' / 'GDK_WINDOW_EDGE_EAST'
634
635 • 'south-west' / 'GDK_WINDOW_EDGE_SOUTH_WEST'
636
637 • 'south' / 'GDK_WINDOW_EDGE_SOUTH'
638
639 • 'south-east' / 'GDK_WINDOW_EDGE_SOUTH_EAST'
640
641 flags Gtk2::Gdk::WindowHints
642 • 'pos' / 'GDK_HINT_POS'
643
644 • 'min-size' / 'GDK_HINT_MIN_SIZE'
645
646 • 'max-size' / 'GDK_HINT_MAX_SIZE'
647
648 • 'base-size' / 'GDK_HINT_BASE_SIZE'
649
650 • 'aspect' / 'GDK_HINT_ASPECT'
651
652 • 'resize-inc' / 'GDK_HINT_RESIZE_INC'
653
654 • 'win-gravity' / 'GDK_HINT_WIN_GRAVITY'
655
656 • 'user-pos' / 'GDK_HINT_USER_POS'
657
658 • 'user-size' / 'GDK_HINT_USER_SIZE'
659
660 enum Gtk2::Gdk::WindowTypeHint
661 • 'normal' / 'GDK_WINDOW_TYPE_HINT_NORMAL'
662
663 • 'dialog' / 'GDK_WINDOW_TYPE_HINT_DIALOG'
664
665 • 'menu' / 'GDK_WINDOW_TYPE_HINT_MENU'
666
667 • 'toolbar' / 'GDK_WINDOW_TYPE_HINT_TOOLBAR'
668
669 • 'splashscreen' / 'GDK_WINDOW_TYPE_HINT_SPLASHSCREEN'
670
671 • 'utility' / 'GDK_WINDOW_TYPE_HINT_UTILITY'
672
673 • 'dock' / 'GDK_WINDOW_TYPE_HINT_DOCK'
674
675 • 'desktop' / 'GDK_WINDOW_TYPE_HINT_DESKTOP'
676
677 • 'dropdown-menu' / 'GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU'
678
679 • 'popup-menu' / 'GDK_WINDOW_TYPE_HINT_POPUP_MENU'
680
681 • 'tooltip' / 'GDK_WINDOW_TYPE_HINT_TOOLTIP'
682
683 • 'notification' / 'GDK_WINDOW_TYPE_HINT_NOTIFICATION'
684
685 • 'combo' / 'GDK_WINDOW_TYPE_HINT_COMBO'
686
687 • 'dnd' / 'GDK_WINDOW_TYPE_HINT_DND'
688
689 enum Gtk2::WindowPosition
690 • 'none' / 'GTK_WIN_POS_NONE'
691
692 • 'center' / 'GTK_WIN_POS_CENTER'
693
694 • 'mouse' / 'GTK_WIN_POS_MOUSE'
695
696 • 'center-always' / 'GTK_WIN_POS_CENTER_ALWAYS'
697
698 • 'center-on-parent' / 'GTK_WIN_POS_CENTER_ON_PARENT'
699
700 enum Gtk2::WindowType
701 • 'toplevel' / 'GTK_WINDOW_TOPLEVEL'
702
703 • 'popup' / 'GTK_WINDOW_POPUP'
704
706 Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget,
707 Gtk2::Container, Gtk2::Bin
708
710 Copyright (C) 2003-2011 by the gtk2-perl team.
711
712 This software is licensed under the LGPL. See Gtk2 for a full notice.
713
714
715
716perl v5.34.0 2022-01-21 Gtk2::Window(3)