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

Gtk2::ItemFactory, pt 2



Hi Scott, I installed 0.24 this evening and all the errors I got with
the item factory menus were resolved. Excellent!

Here's another one :-)

The attached script is almost identical to the original script I sent to
the list before, except that it now has a submenu. What happens for me,
is that while the top-level items work fine, the callback for items in
the submenu doesn't get called. Perl doesn't spit out any error
messages, and nothing crashes, it just doesn't run the callback.

Regards,

Gavin.

-- 
Gavin Brown
e: gavin brown uk com
w: http://jodrell.net/
PGP/GPG key ID: 891D8FCA
#!/usr/bin/perl
use Gtk2;
use strict;

Gtk2->init;

my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event', sub { exit });

my $button = Gtk2::Button->new('Menu');

my @items = (
	[
		'/',
		undef,
		undef,
		undef,
		'<Branch>'
	],
	[
		'/Run Galeon',
		undef,
		sub { system('galeon &') },
		undef,
		'<StockItem>',
		'gtk-execute'
	],
	[
		'/Run Terminal',
		undef,
		sub { system('gnome-terminal &') },
		undef,
		'<StockItem>',
		'gtk-execute'
	],	[
		'/Run GIMP',
		undef,
		sub { system('gimp &') },
		undef,
		'<StockItem>',
		'gtk-execute'
	],
	[
		'/Editors',
		undef,
		undef,
		undef,
		'<Branch>',
	],
	[
		'/Editors/Run Gedit',
		undef,
		sub { system('gedit --new-window &') },
		undef,
		'<StockItem>',
		'gtk-execute'
	],
	[
		'/Editors/Run Emacs',
		undef,
		sub { system('gnome-terminal -e emacs &') },
		undef,
		'<StockItem>',
		'gtk-execute'
	],
	[
		'/Editors/Run nipples',
		undef,
		sub { system('xnipples &') },
		undef,
		'<StockItem>',
		'gtk-execute'
	],
);

my $factory = Gtk2::ItemFactory->new('Gtk2::Menu', '<main>', undef);

$factory->create_items(@items);

my $menu = $factory->get_widget('<main>');

$button->signal_connect('clicked', sub { $menu->popup(undef, undef, undef, undef, $button, undef) });

$window->add($button);

$window->show_all;

Gtk2->main;

Attachment: signature.asc
Description: This is a digitally signed message part



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