NAME
Gtk2::Ex::PopupWindow - A popupwindow that can be attached to any arbitrary widget and controlled programatically.
DESCRIPTION
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).
SYNOPSIS
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);
METHODS
new($parent);
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
my $popupwindow = Gtk2::Ex::PopupWindow->new($parent);
show;
Show the window.
$popupwindow->show;
hide;
Hide the window.
$popupwindow->hide;
toggle;
Toggle between show and hide.
$popupwindow->toggle;
set_move_with_parent;
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.
$popupwindow->set_move_with_parent(TRUE);
get_move_with_parent;
Returns the value of the flag described above. By default, the flag is set to FALSE
.
print $popupwindow->get_move_with_parent;
signal_connect($signal, $callback);
See the SIGNALS section to see the supported signals.
SIGNALS
show;
This signal gets emitted whenever the popupwindow is shown.
hide;
This signal gets emitted whenever the popupwindow is hidden.
ORIGINAL AUTHOR
Lee Aylward
CURRENT MAINTAINER
Ofey Aikon, <ofey.aikon at gmail dot com>
COPYRIGHT & LICENSE
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.