The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

POE::Session::GladeXML2 - emit POE events for Gtk2 callbacks

SYNOPSIS

   package test;

   use POE::Session::GladeXML2;

   # the name of the sub needs to match with the name you entered in
   # the glade signal handler dialog.
   sub on_button1_clicked {
      print STDERR "button clicked\n";
   }

   sub new {
      [... object creation ...]
      my $session = POE::Session::GladeXML2->create (
          glade_object => $self,
          glade_file => 'test.glade',
          glade_args => 'widgetname',
          [... POE Session params ...]
        );

      return $self;
   }

   Gtk2::GladeXML->init;
   my $foo = test->new;
   $poe_kernel->run();

DESCRIPTION

A simple helper module that lets you connect callback names from your .glade file with methods of an object. These methods are called as POE callback or postback methods. POE::Session::GladeXML automatically determines whether gtk expects the signal handler to return a value. If it does, a callback is used, otherwise a postback will be used.

CONSTRUCTOR

create (%args)

creates a POE::Session that connects the callbacks from the glade file to the corresponding method of the object in the glade_object argument. The glade_file argument contains the name of the glade file to use. Optional arguments for Gtk::GladeXML->new are in the glade_args argument. See Gtk2::GladeXML for more information.

If you are using this to create your main window, you can put the name of that in a glade_mainwin argument, which will then be used to make POE exit when this window is closed.

METHODS

gladexml ()

Returns the Gtk2::GladeXML object.

SEE ALSO

POE::Session and Gtk2::GladeXML

AUTHOR

Martijn van Beers <martijn@cpan.org>

LICENSE

This module is free software; you may reproduce and/or modify it under the terms of the GPL license v2.0. See the file LICENSE in the source tarball for more information

ACKNOWLEDGEMENTS

This module wouldn't be half as good without the invaluable advice of Rocco Caputo and Scott Arrington.