App::Chart::Gtk2::Ex::ToplevelSingleton -- single instance of toplevel window
package MyToplevel; use Gtk2; use Glib::Object::Subclass 'Gtk2::Window'; use base 'App::Chart::Gtk2::Ex::ToplevelSingleton'; use App::Chart::Gtk2::Ex::ToplevelSingleton hide_on_delete => 1; $toplevel = MyToplevel->instance; if (MyToplevel->has_instance) { do_something() }
This package is designed as a multi-inheritance mix-in for subclasses of Gtk2::Window which normally want only a single window instance, to be used throughout a program.
Gtk2::Window
After adding ToplevelSingleton to your @ISA, MyToplevel->instance returns a single shared instance of a MyToplevel window.
ToplevelSingleton
@ISA
MyToplevel->instance
MyToplevel
Class::Singleton
To install App::Chart, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Chart
CPAN shell
perl -MCPAN -e shell install App::Chart
For more information on module installation, please visit the detailed CPAN module installation guide.