Re: TrayIcon on Win32 Entry point error
- From: Emmanuel Rodriguez <emmanuel rodriguez gmail com>
- To: gtk-perl-list gnome org
- Subject: Re: TrayIcon on Win32 Entry point error
- Date: Wed, 29 Oct 2008 18:45:58 +0100
zentara wrote:
On Wed, 29 Oct 2008 13:04:56 -0400
zentara <zentara1 sbcglobal net> wrote:
Would you happen to know how to pop the menu at an offset from the mouse position?
Thanks,
zentara
Never mind, I found it by experimenting.
my ($x, $y, $push_in) = Gtk2::StatusIcon::position_menu($menu, $statusicon);
# print "$x, $y, $push_in\n";
$menu->popup( undef, undef, sub{return ($x,$y,0)} , undef, 0, 0 );
Try passing a reference to Gtk2::StatusIcon::position_menu directly as
the function that calculates the position. Here's an example that works
fine for me.
#!/usr/bin/perl
use strict;
use warnings;
use Glib qw(TRUE FALSE);
use Gtk2 '-init';
exit main();
sub main {
# Create a system tray icon
my $tray = Gtk2::StatusIcon->new_from_stock('gtk-color-picker');
# Build the tray's popup menu
my $tray_menu = Gtk2::Menu->new();
$tray_menu->append(Gtk2::SeparatorMenuItem->new());
# Add a close menu item
my $menu_item_close = Gtk2::ImageMenuItem->new_from_stock('gtk-close');
$menu_item_close->signal_connect(activate => sub {
Gtk2->main_quit();
});
$tray_menu->append($menu_item_close);
$tray_menu->show_all();
# Show the menu when there's a right click
$tray->signal_connect('popup-menu' => sub {
my ($tray, $button, $time) = @_;
$tray_menu->popup(
undef,
undef,
\&Gtk2::StatusIcon::position_menu,
$tray,
$button,
$time
);
});
# Start the main loop
Gtk2->main();
return 0;
}
Emmanuel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]