[perl-Gtk2] Make Gtk2::TreeStore->remove()'s return value consistent on gtk+ 2.0



commit 0e81b0f8ca70b3316d3913e2f4ffce39b51e7ed2
Author: Kevin Ryde <user42 zip com au>
Date:   Sat Jan 9 20:12:40 2010 +0100

    Make Gtk2::TreeStore->remove()'s return value consistent on gtk+ 2.0
    
    Just like in Gtk2::ListStore->remove(), when gtk+ < 2.2, emulate the later
    behavior manually.
    
    Signed-off-by: Torsten Schönfeld <kaffeetisch gmx de>

 t/GtkListStore.t   |    4 ++--
 t/GtkTreeStore.t   |   11 +++--------
 xs/GtkTreeStore.xs |   14 +++++++++-----
 3 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/t/GtkListStore.t b/t/GtkListStore.t
index 743b4e1..622e459 100644
--- a/t/GtkListStore.t
+++ b/t/GtkListStore.t
@@ -31,7 +31,7 @@ foreach (qw(bla blee bliii bloooo)) {
 my $path_model = Gtk2::TreePath -> new_from_string("0");
 my $iter_model;
 
-# remove returns boolean in >= 2.2.0, but false (actually, void) in 2.0.x.
+# boolean return even in gtk 2.0.0
 ok($model -> remove($model -> get_iter($path_model)));
 is($model -> get($model -> get_iter($path_model), 0), "blee");
 
@@ -234,5 +234,5 @@ SKIP: {
 
 __END__
 
-Copyright (C) 2003-2005 by the gtk2-perl team (see the file AUTHORS for the
+Copyright (C) 2003-2005, 2009 by the gtk2-perl team (see the file AUTHORS for the
 full list).  See LICENSE for more information.
diff --git a/t/GtkTreeStore.t b/t/GtkTreeStore.t
index d7fb344..8a05f2c 100644
--- a/t/GtkTreeStore.t
+++ b/t/GtkTreeStore.t
@@ -97,13 +97,8 @@ SKIP: {
 my $path_model = Gtk2::TreePath -> new_from_string("0");
 my $iter_model;
 
-if (! Gtk2->CHECK_VERSION (2, 2, 0)) {
-	# this always returns false on 2.0.x.
-	ok(!$model -> remove($model -> get_iter($path_model)));
-} else {
-	is($model -> remove($model -> get_iter($path_model)), 1);
-}
-
+# boolean return even in gtk 2.0.0
+is($model -> remove($model -> get_iter($path_model)), 1);
 is($model -> get($model -> get_iter($path_model), 0), "blee");
 
 $model -> clear();
@@ -148,5 +143,5 @@ SKIP: {
 
 __END__
 
-Copyright (C) 2003-2006 by the gtk2-perl team (see the file AUTHORS for the
+Copyright (C) 2003-2006, 2009 by the gtk2-perl team (see the file AUTHORS for the
 full list).  See LICENSE for more information.
diff --git a/xs/GtkTreeStore.xs b/xs/GtkTreeStore.xs
index 7c98376..846adab 100644
--- a/xs/GtkTreeStore.xs
+++ b/xs/GtkTreeStore.xs
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003-2006 by the gtk2-perl team (see the file AUTHORS)
+ * Copyright (c) 2003-2006, 2009 by the gtk2-perl team (see the file AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -124,6 +124,10 @@ gtk_tree_store_set (tree_store, iter, col1, val1, ...)
 ## void gtk_tree_store_set_valist (GtkTreeStore *tree_store, GtkTreeIter *iter, va_list var_args)
 
 ## gboolean gtk_tree_store_remove (GtkTreeStore *tree_store, GtkTreeIter *iter)
+=for apidoc
+The return is always a boolean in the style of Gtk 2.2.x and up, even
+when running on Gtk 2.0.x.
+=cut
 gboolean
 gtk_tree_store_remove (tree_store, iter)
 	GtkTreeStore *tree_store
@@ -132,11 +136,11 @@ gtk_tree_store_remove (tree_store, iter)
 #if GTK_CHECK_VERSION(2,2,0)
 	RETVAL = gtk_tree_store_remove (tree_store, iter);
 #else
-	/* void return in 2.0.x; always return FALSE from this function
-	 * in that case; FIXME the alternative is to implement the missing
-	 * functionality right here. */
+	/* void return in 2.0.x; look for stamp zapped to 0 if no more
+	 * rows, to emulate the return value of 2.2 and up
+	 */
 	gtk_tree_store_remove (tree_store, iter);
-	RETVAL = FALSE;
+	RETVAL = (iter->stamp != 0);
 #endif
     OUTPUT:
 	RETVAL



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