Gtk2::Ex::PopupWindow - A popupwindow that can be attached to any arbitrary widget and controlled programatically.
Widgets such as Gtk2::Menu and Gtk2::ComboBox function by popping open a new window containing additional controls. Won't it be nice if you could have your own popup windows containing your own custom widgets ? Gtk2::Ex::PopupWindow does just that.
Gtk2::Ex::PopupWindow gives you a popup window that can be attached to any arbitrary widget. The window itself can be shown and hidden programatically (Typically on a button click event on the parent widget).
use Gtk2::Ex::PopupWindow; # The parent widget should be pre-defined. We'll choose a button # as the parent here. my $openbutton = Gtk2::Button->new_from_stock('gtk-open'); # Create a popupwindow with the button as the parent my $popupwindow = Gtk2::Ex::PopupWindow->new($openbutton); # Open the window on button-release $openbutton->signal_connect('button-release-event' => sub { $popupwindow->show; return 0; } ); # You can add other widgets into the window itself my $text = Gtk2::TextView->new; $text->set_buffer(Gtk2::TextBuffer->new); $popupwindow->{window}->add($text);
The $parent is the widget to which the popup window will be attached. When the window is open, it'll be hanging from this parent widget
$parent
my $popupwindow = Gtk2::Ex::PopupWindow->new($parent);
Show the window.
$popupwindow->show;
Hide the window.
$popupwindow->hide;
Toggle between show and hide.
$popupwindow->toggle;
For most cases, you want the popup window to be closed when the user clicks outside the window itself. For example, Gtk2::Menu and Gtk2::ComboBox behave this way.
But may be you would like the window to stay open until explicitly closed. In that case, you can call set_move_with_parent(TRUE). If this flag is set, then the popup window stays open until explicitly closed using the hide method.
set_move_with_parent(TRUE)
hide
$popupwindow->set_move_with_parent(TRUE);
Returns the value of the flag described above. By default, the flag is set to FALSE.
FALSE
print $popupwindow->get_move_with_parent;
See the SIGNALS section to see the supported signals.
This signal gets emitted whenever the popupwindow is shown.
This signal gets emitted whenever the popupwindow is hidden.
Lee Aylward
Ofey Aikon, <ofey.aikon at gmail dot com>
<ofey.aikon at gmail dot com>
Copyright 2005 Lee Aylward, Ofey Aikon, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.
To install Gtk2::Ex::PopupWindow, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gtk2::Ex::PopupWindow
CPAN shell
perl -MCPAN -e shell install Gtk2::Ex::PopupWindow
For more information on module installation, please visit the detailed CPAN module installation guide.