[perl-Gtk2] Gtk2::Notebook: fix invocation of window creation hooks



commit a3f7db98d3e080666265c22e61583ad54ff6fc80
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Wed Dec 22 21:39:42 2010 +0100

    Gtk2::Notebook: fix invocation of window creation hooks

 t/GtkNotebook.t   |   42 +++++++++++++++++++++++++++++++++++-------
 xs/GtkNotebook.xs |    2 +-
 2 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/t/GtkNotebook.t b/t/GtkNotebook.t
index 6ae302b..c0b54fa 100644
--- a/t/GtkNotebook.t
+++ b/t/GtkNotebook.t
@@ -1,6 +1,4 @@
-#
-# $Id$
-#
+#!/usr/bin/env perl
 
 #########################
 # GtkNotbook Tests
@@ -126,10 +124,6 @@ SKIP: {
 
 	$nb->set_tab_detachable ($child, TRUE);
 	ok ($nb->get_tab_detachable ($child));
-
-	# FIXME: How to test the callback marshalling?
-	$nb->set_window_creation_hook (sub { warn join ", ", @_; }, 'data');
-	$nb->set_window_creation_hook (sub { warn join ", ", @_; });
 }
 
 SKIP: {
@@ -166,6 +160,40 @@ run_main sub {
 
 ok(1);
 
+=comment
+
+Here's some interactive code for testing the window creation hook.
+
+my $w = Gtk2::Window->new;
+my $nb = Gtk2::Notebook->new;
+$nb->append_page (my $c = Gtk2::Label->new ('Test'));
+$nb->set_tab_detachable ($c, TRUE);
+
+Gtk2::Notebook->set_window_creation_hook (
+  sub {
+    my ($notebook, $page, $x, $y, $data) = @_;
+
+    my $new_window = Gtk2::Window->new;
+    my $new_notebook = Gtk2::Notebook->new;
+    $new_window->add ($new_notebook);
+    $new_window->show_all;
+
+    # Either do it manually and return undef, or ...
+    #$notebook->remove ($page);
+    #$new_notebook->append_page ($page);
+    #return undef;
+
+    # ... simply return the new notebook and let gtk+ do the work.
+    return $new_notebook;
+  });
+
+$w->add ($nb);
+$w->signal_connect (destroy => sub { Gtk2->main_quit; });
+$w->show_all;
+Gtk2->main;
+
+=cut
+
 __END__
 
 Copyright (C) 2003-2006 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/xs/GtkNotebook.xs b/xs/GtkNotebook.xs
index 414bcca..e5167a7 100644
--- a/xs/GtkNotebook.xs
+++ b/xs/GtkNotebook.xs
@@ -73,7 +73,7 @@ gtk2perl_notebook_window_creation_func (GtkNotebook *source,
         GtkNotebook * retval;
         GValue value = {0, };
         g_value_init (&value, GTK_TYPE_NOTEBOOK);
-        gperl_callback_invoke ((GPerlCallback*) data, &value, source, x, y);
+        gperl_callback_invoke ((GPerlCallback*) data, &value, source, page, x, y);
         retval = g_value_get_object (&value);
         g_value_unset (&value);
         return retval;



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