gtk+ r20142 - in trunk: . gtk tests



Author: jap
Date: Sat May 24 23:32:13 2008
New Revision: 20142
URL: http://svn.gnome.org/viewvc/gtk+?rev=20142&view=rev

Log:
2008-05-25  Jan Arne Petersen  <jpetersen jpetersen org>

	* gtk/gtkliststore.c: (list_store_text): Use type of the correct
	column (#529535).
	* tests/buildertest.c: (test_list_store): Add test.



Modified:
   trunk/ChangeLog
   trunk/gtk/gtkliststore.c
   trunk/tests/buildertest.c

Modified: trunk/gtk/gtkliststore.c
==============================================================================
--- trunk/gtk/gtkliststore.c	(original)
+++ trunk/gtk/gtkliststore.c	Sat May 24 23:32:13 2008
@@ -2253,7 +2253,7 @@
     }
 
   if (!gtk_builder_value_from_string_type (data->builder,
-					   data->column_types[i],
+					   data->column_types[info->id],
 					   string,
 					   &data->values[i],
 					   &tmp_error))
@@ -2262,7 +2262,7 @@
 		   tmp_error->domain,
 		   tmp_error->code,
 		   "Could not convert '%s' to type %s: %s\n",
-		   text, g_type_name (data->column_types[i]),
+		   text, g_type_name (data->column_types[info->id]),
 		   tmp_error->message);
       g_error_free (tmp_error);
     }

Modified: trunk/tests/buildertest.c
==============================================================================
--- trunk/tests/buildertest.c	(original)
+++ trunk/tests/buildertest.c	Sat May 24 23:32:13 2008
@@ -550,6 +550,31 @@
     "    </data>"
     "  </object>"
     "</interface>";
+  const char buffer3[] = 
+    "<interface>"
+    "  <object class=\"GtkListStore\" id=\"liststore1\">"
+    "    <columns>"
+    "      <column type=\"gchararray\"/>"
+    "      <column type=\"gchararray\"/>"
+    "      <column type=\"gint\"/>"
+    "    </columns>"
+    "    <data>"
+    "      <row>"
+    "        <col id=\"1\" context=\"foo\">Doe</col>"
+    "        <col id=\"0\" translatable=\"yes\">John</col>"
+    "        <col id=\"2\" comment=\"foobar\">25</col>"
+    "      </row>"
+    "      <row>"
+    "        <col id=\"2\">50</col>"
+    "        <col id=\"1\">Dole</col>"
+    "        <col id=\"0\">Johan</col>"
+    "      </row>"
+    "      <row>"
+    "        <col id=\"2\">19</col>"
+    "      </row>"
+    "    </data>"
+    "  </object>"
+    "</interface>";
   GtkBuilder *builder;
   GObject *store;
   GtkTreeIter iter;
@@ -599,6 +624,52 @@
   g_assert (age == 50);
   g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter) == FALSE);
   
+  builder = builder_new_from_string (buffer3, -1, NULL);
+  store = gtk_builder_get_object (builder, "liststore1");
+  g_assert (gtk_tree_model_get_n_columns (GTK_TREE_MODEL (store)) == 3);
+  g_assert (gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), 0) == G_TYPE_STRING);
+  g_assert (gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), 1) == G_TYPE_STRING);
+  g_assert (gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), 2) == G_TYPE_INT);
+  
+  g_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter) == TRUE);
+  gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+                      0, &surname,
+                      1, &lastname,
+                      2, &age,
+                      -1);
+  g_assert (surname != NULL);
+  g_assert (strcmp (surname, "John") == 0);
+  g_free (surname);
+  g_assert (lastname != NULL);
+  g_assert (strcmp (lastname, "Doe") == 0);
+  g_free (lastname);
+  g_assert (age == 25);
+  g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter) == TRUE);
+  
+  gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+                      0, &surname,
+                      1, &lastname,
+                      2, &age,
+                      -1);
+  g_assert (surname != NULL);
+  g_assert (strcmp (surname, "Johan") == 0);
+  g_free (surname);
+  g_assert (lastname != NULL);
+  g_assert (strcmp (lastname, "Dole") == 0);
+  g_free (lastname);
+  g_assert (age == 50);
+  g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter) == TRUE);
+  
+  gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+                      0, &surname,
+                      1, &lastname,
+                      2, &age,
+                      -1);
+  g_assert (surname == NULL);
+  g_assert (lastname == NULL);
+  g_assert (age == 19);
+  g_assert (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter) == FALSE);
+
   g_object_unref (builder);
 }
 



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