Gtk2::main(3)
π Gtk2::main β the manual page, but make it make sense π
okay bestie, so this is Gtk2::main from the Gtk2 Perl module β the User Contributed Perl Documentation girlies wrote it, and it's the page that holds all the top-level Gtk2 class methods: init-ing the toolkit, running the main loop, grabbing stuff, snooping keys, all of it. Grab a strawberry drink and let's go πβ¨
β¨ NAME β¨
Gtk2::main β the main-loop / init / lifecycle methods on the Gtk2 class itself, no cap π
π METHODS π
Okay so here's the whole roster, one by one, in order, don't skip π«Ά
boolean = Gtk2->alternative_dialog_button_order ($screen=undef)β tells you whether the alternative dialog button order is in play.$screen(Gtk2::Gdk::Screen or undef)- Since: gtk+ 2.6
event or undef = Gtk2->get_current_eventβ hands you the event that's currently being processed (or undef, no drama).modifiertype = Gtk2->get_current_event_stateβ the modifier state of the current event, as a modifiertype.unsigned = Gtk2->get_current_event_timeβ the timestamp of the current event, as an unsigned.language = Gtk2->get_default_languageβ the default language, as a language.Gtk2->disable_setlocaleβ turns off the setlocale behaviour. that's it, that's the whole vibe.widget or undef = Gtk2->get_event_widget ($event)β which widget the event was for (or undef).$event(Gtk2::Gdk::Event or undef)
integer = Gtk2->events_pendingβ how many events are sitting in the queue waiting for you, as an integer.Gtk2->grab_add ($widget)β adds a grab on a widget.$widget(Gtk2::Widget)
widget or undef = Gtk2->grab_get_currentβ the widget that currently holds the grab (or undef).Gtk2->grab_remove ($widget)β removes the grab from a widget.$widget(Gtk2::Widget)
boolean = Gtk2->initβ initialize Gtk+, bestie. This must be called before any other Gtk2 functions in a GUI application; the Gtk2 module's import method allows you to pass-initin theusestatement to do this automatically. This function also scans@ARGVfor any options it knows, and will remove them automagically. π
Note: this function will terminate your program if it is unable to initialize the gui for any reason. If you want your program to fall back to some other interface, you want to use Gtk2->init_check instead. π (yes, fr, it will just end you)
Gtk2->init_add ($function, $data=undef)β registers a function to be called at init time.$function(scalar)$data(scalar)
boolean = Gtk2->init_checkβ this is the non-fatal version ofGtk2->init; instead of callingexitif Gtk+ initialization fails,Gtk2->init_checkreturns false. This allows your application to fall back on some other means of communication with the user β for example a curses or command-line interface. π the responsible icon behaviour.integer = Gtk2->key_snooper_install ($snooper, $func_data=undef)β install a key "snooper" function which will get called on all key events before those events are delivered normally. These snoopers can be used to implement custom key event handling. π΅οΈββοΈ
key_snooper_install returns an id that may be used with key_snooper_remove (below). snooper is called as
stopbool = &snooper ($widget, $event, $func_data);
It should return true to stop event propagation, the same as Gtk2::Widget event signal handlers. The Gtk2::EVENT_STOP and Gtk2::EVENT_PROPAGATE constants can be used for the return (see Gtk2::Widget).
$snooper(subroutine) function to call on every event$func_data(scalar)
Gtk2->key_snooper_remove ($snooper_handler_id)β uninstalls that snooper you installed, by its id.$snooper_handler_id(integer)
string = Gtk2->set_localeβ does the locale thing and gives you back a string.Gtk2->mainβ the main loop. this is the one that runs your app until it quits. main character energy, literally. π₯Gtk2->main_do_event ($event)β this is the event handler that GTK+ registers with GDK. GTK+ exposes it to allow filtering of events between GDK and GTK+; it is rare that you would need this, except if you are usingGtk2::Gdk::Event::handler_set.$event(Gtk2::Gdk::Event)
boolean = Gtk2->main_iterationβ runs one iteration of the main loop.boolean = Gtk2->main_iteration_do ($blocking)β same energy, but you choose whether it blocks.$blocking(boolean)
integer = Gtk2->main_levelβ how deep the main-loop nesting goes, as an integer.Gtk2->main_quitβ makes the main loop stop. bye bestie πoptiongroup = Gtk2->get_option_group ($open_default_display)β hands you an optiongroup for command-line parsing.$open_default_display(boolean)- Since: gtk+ 2.6
boolean = Gtk2->parse_argsβ parses the args.- Since: gtk+ 2.4
integer = Gtk2->quit_add ($main_level, $function, $data=undef)β registers a function to run when quitting, at a given main level. returns an integer.$main_level(integer)$function(scalar)$data(scalar)
Gtk2->quit_add_destroy ($main_level, $object)β quit-time hook tied to destroying an object.$main_level(integer)$object(Gtk2::Object)
Gtk2->quit_remove ($quit_handler_id)β removes a previously added quit handler by id.$quit_handler_id(integer)
Gtk2::show_uri ($screen, $uri, $timestamp=GDK_CURRENT_TIME)β shows a URI, with a timestamp defaulting toGDK_CURRENT_TIME. π$screen(Gtk2::Gdk::Screen or undef)$uri(string)$timestamp(unsigned)
π§ ENUMS AND FLAGS π§
π¦ flags Gtk2::Gdk::ModifierType
all the modifier masks, spelled both ways so you can use whichever vibe you prefer π
'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'
πΈ SEE ALSO πΈ
- Gtk2 β go read that one next, iykyk π
π 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 the whole page, bestie β written by the perl girlies at perl v5.42.0 on 2025-07-25, and it ate, fr fr πβ¨π
π¦ 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