[perl-Gtk3] Gtk3::Menu: only use a wrapper position func if needed



commit f16e9684d4a1ad2a5cbbe63652eff108e8c09b45
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sat Apr 21 20:52:24 2012 +0200

    Gtk3::Menu: only use a wrapper position func if needed
    
    When the user does not supply a position func, then we should not try to
    create a wrapper.

 lib/Gtk3.pm   |    4 ++--
 t/overrides.t |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index fabe30c..62f9ef3 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -271,7 +271,7 @@ sub Gtk3::Menu::popup {
 
 sub Gtk3::Menu::popup_for_device {
   my ($menu, $device, $parent_menu_shell, $parent_menu_item, $func, $data, $button, $activate_time) = @_;
-  my $real_func = sub {
+  my $real_func = $func ? sub {
     my @stuff = eval { $func->(@_) };
     if ($@) {
       warn "*** menu position callback ignoring error: $@";
@@ -285,7 +285,7 @@ sub Gtk3::Menu::popup_for_device {
            "(x, y) or two integers and a boolean (x, y, push_in)";
       return (0, 0, Glib::FALSE);
     }
-  };
+  } : undef;
   return Glib::Object::Introspection->invoke (
     $_GTK_BASENAME, 'Menu', 'popup_for_device',
     $menu, $device, $parent_menu_shell, $parent_menu_item, $real_func, $data, $button, $activate_time);
diff --git a/t/overrides.t b/t/overrides.t
index 3208f74..d8bd01c 100644
--- a/t/overrides.t
+++ b/t/overrides.t
@@ -62,6 +62,7 @@ SKIP: {
     isa_ok ($menu, "Gtk3::Menu");
     return @$data;
   };
+  $menu->popup (undef, undef, undef, undef, 1, 0);
   $menu->popup (undef, undef, $position_callback, [50, 50], 1, 0);
   $menu->popup_for_device (undef, undef, undef, $position_callback, [50, 50, Glib::TRUE], 1, 0);
 }



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