submenu items activate signals... 2



hi

first, i'm sorry for the mess on the list because of my previous post...

... the context submenu still doesn't work. muppet's example works perfectly, and i copied it literaly to my 
code, and it stopped working. now, i am attaching the whole function, and maybe somebody will see what's 
wrong...

reagrds, bostjan

#####################################

sub draw_context_menu {
        my ($where,$now,$what) = @_;
        my $form = &get_form;       
        my $menu = new Gtk2::Menu;

        my %items = (gettext("Help / Wizard") => sub {
                                $form->get_widget('togglebutton_help')->set_active(1); },
                        gettext("Export to file") => sub { &on_button_base_html_clicked; },
                        gettext("Remove from list") => sub { &on_button_remove_clicked; },
                        gettext("Import from file") => sub { &on_button_base_open_clicked; },
                        gettext("Import direcory listing") => sub { &import_dir; },
                        gettext("Clear all") => sub { &clearall; }
                                        );
# this works
      my $item = Gtk2::MenuItem->new ("Baz");
      $item->signal_connect (activate => sub { print "Baz!\n" });
      $menu->append ($item);

# and this doesn't
     my $submenu = Gtk2::Menu->new;
     while (my ($label, $callback) = each %items) {
        my $item = Gtk2::MenuItem->new ($label);
        $item->signal_connect (activate => $callback);
         $item->show;
# it works, if at this point, i attach the $item to a $menu...
         $submenu->append ($item);
     }
     $item = Gtk2::MenuItem->new ("Foo");
     $item->set_submenu ($submenu);
     $menu->append ($item);

# show everything       
        $menu->show_all;     
        $menu->popup(undef,undef,undef,undef,$now->button,$now->time);
}


--
igzebedze - he who speaks loud and say nothing




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