man PerlPanel::MenuBase (Fonctions bibliothèques) - a base class for PerlPanel menu applets.
NAME
PerlPanel::MenuBase - a base class for PerlPanel menu applets.
SYNOPSIS
package PerlPanel::Applet::MyMenu; use base 'PerlPanel::MenuBase'; use strict;
sub create_menu {
my $self = shift;
$self->menu->append($self->menu_item( 'Hello World!', $icon, sub { print "Hello World!\n" } )); return 1; }
1;
DESCRIPTION
CWPerlPanel::MenuBase is a base class that does as much as possible to abstract the nuts-and-bolts details of building a PerlPanel menu applet. If you use CWPerlPanel::MenuBase to write a menu applet, you don't need to worry about menu hierarchies or icons - all that's done for you. Instead to can concentrate on building your menu backend.
USAGE
CWPerlPanel::MenuBase is a base class - that means, you must write a Perl module that inherits from it. The CWuse base line in the example above is one way you can do this. Then you simply override the CWconfigure() and CWcreate_menu() methods with your own.
STANDARD METHODS
$self->add_control_items;
This method appends the standard set of PerlPanel control options to the menu. The menu will subsequently look like this:
| | | ----------------------------- | | Lock Screen | | Run Program... | | Take Screenshot... | | ----------------------------- | | Shut Down... | | Reboot... | | ----------------------------- | | Configure... | | Close Panel | | Add To Panel > | | ----------------------------- | | About... | +-------------------------------+
my $item = $self->menu_item($label, $icon, $callback);
This returns a ready-prepared Gtk2::ImageMenuItem. This method does a lot of hard work for you - CW$label is set as the text label for the item, and if defined, CW$callback is connected to the CW'activate' signal.
CW$icon can be either a file, a CWGtk::Gdk::Pixbuf, or a stock ID. CWmenu_item will automagically resize the icon to fit in with the rest of the menu.
my $icon = $self->get_icon($string, $is_submenu_parent);
This method is deprecated and is no longer available. Use PerlPanel::lookup_icon() instead.
SEE ALSO
- * perlpanel
- * perlpanel-applet-howto
- * Gtk2