perl-Gtk2 r2076 - in trunk: . t xs



Author: tsch
Date: Sun Oct 26 10:35:22 2008
New Revision: 2076
URL: http://svn.gnome.org/viewvc/perl-Gtk2?rev=2076&view=rev

Log:
Handle undef for callbacks correctly in
Gtk2::TreeView::set_column_drag_function() and set_row_separator_func().


Modified:
   trunk/ChangeLog
   trunk/t/GtkTreeView.t
   trunk/xs/GtkTreeView.xs

Modified: trunk/t/GtkTreeView.t
==============================================================================
--- trunk/t/GtkTreeView.t	(original)
+++ trunk/t/GtkTreeView.t	Sun Oct 26 10:35:22 2008
@@ -361,7 +361,7 @@
 			unless $been_here++;
 	}
 
-	$view -> set_search_equal_func(undef);
+	$view -> set_search_equal_func(sub {});
 }
 
 # set_search_position_func
@@ -446,7 +446,7 @@
 			unless $i_know_this_place++;
 	}
 
-	# FIXME: $view->set_row_separator_func (undef);
+	$view->set_row_separator_func (undef);
 }
 
 SKIP: {

Modified: trunk/xs/GtkTreeView.xs
==============================================================================
--- trunk/xs/GtkTreeView.xs	(original)
+++ trunk/xs/GtkTreeView.xs	Sun Oct 26 10:35:22 2008
@@ -368,13 +368,23 @@
 	SV * func
 	SV * data
     PREINIT:
-	GPerlCallback * callback;
-    CODE:
-	callback = gtk2perl_tree_view_column_drop_func_create (func, data);
+	GtkTreeViewColumnDropFunc real_func;
+	gpointer real_data;
+	GtkDestroyNotify destroy;
+    CODE:
+	if (gperl_sv_is_defined (func)) {
+		real_func = gtk2perl_tree_view_column_drop_func;
+		real_data =
+			gtk2perl_tree_view_column_drop_func_create
+				(func, data);
+		destroy = (GDestroyNotify) gperl_callback_destroy;
+	} else {
+		real_func = real_data = destroy = NULL;
+	}
 	gtk_tree_view_set_column_drag_function (tree_view,
-						gtk2perl_tree_view_column_drop_func,
-						callback,
-						(GDestroyNotify) gperl_callback_destroy);
+						real_func,
+						real_data,
+						destroy);
 
 #### also allow undef instead of -1 to specify no scrolling
 ## void gtk_tree_view_scroll_to_point (GtkTreeView *tree_view, gint tree_x, gint tree_y)
@@ -778,14 +788,21 @@
 void
 gtk_tree_view_set_row_separator_func (GtkTreeView *tree_view, SV * func, SV * data=NULL);
     PREINIT:
-	GPerlCallback * callback;
-    CODE:
-	callback = gtk2perl_tree_view_row_separator_func_create (func, data);
-	gtk_tree_view_set_row_separator_func
-				(tree_view, 
-				 gtk2perl_tree_view_row_separator_func,
-				 callback,
-				 (GDestroyNotify) gperl_callback_destroy);
+	GtkTreeViewRowSeparatorFunc real_func;
+	gpointer real_data;
+	GtkDestroyNotify destroy;
+    CODE:
+	if (gperl_sv_is_defined (func)) {
+		real_func = gtk2perl_tree_view_row_separator_func;
+		real_data =
+			gtk2perl_tree_view_row_separator_func_create (
+				func, data);
+		destroy = (GtkDestroyNotify) gperl_callback_destroy;
+        } else {
+                real_func = real_data = destroy = NULL;
+        }
+	gtk_tree_view_set_row_separator_func (
+		tree_view, real_func, real_data, destroy);
 
 
 #endif



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