Re: pop menu with a right-click in a gtktreeview

so the point is catching the destroy signal and return 0? Can I reuse the gtkmenu widget created by glade? It's compulsory create the widget in the signal sub as you do here?

The last code, it works at the first time, maybe returing 0 at the destroy signal it works, i'll try later...

thanks anyway :)

On Wed, Jun 25, 2008 at 3:08 PM, muppet <scott asofyet org> wrote:

anguila wrote:
> create a fresh? destroy an create again the widget?

gtk_menu_popup() consumes the menu widget (that is, calls destroy on it) for
itself.  Click in this window and watch when the lolcat complains on stdout:

use strict;
use warnings;
use Gtk2 -init;

my $window = Gtk2::Window->new;
$window->add_events (['button-press-mask', 'button-release-mask']);
$window->signal_connect (button_release_event => \&do_menu);
$window->signal_connect (destroy => sub { Gtk2->main_quit });

sub do_menu {
   my ($widget, $event) = @_;

   my $menu = Gtk2::Menu->new;
   $menu->signal_connect (destroy => sub {
       print "halp, i'z bein destroyeded!\n";
       return 0;
   my $item = Gtk2::MenuItem->new ("Cheezburger");
   $menu->append ($item);
   $menu->popup (undef, undef, undef, undef, $event->button, $event->time);

   # $menu will be destroyed when the user quits interacting with it.

   return 0;


muppet <scott at asofyet dot org>

gtk-perl-list mailing list
gtk-perl-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]