Commit 10e8e7d2 authored by Jan Arne Petersen's avatar Jan Arne Petersen Committed by Jan Arne Petersen

Use type of the correct column (#529535). Add test.

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.


svn path=/trunk/; revision=20142
parent c30e303c
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.
2008-05-24 Matthias Clasen <mclasen@redhat.com>
Bug 520989 – icon factory buildable too strict
......
......@@ -2253,7 +2253,7 @@ list_store_text (GMarkupParseContext *context,
}
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 @@ list_store_text (GMarkupParseContext *context,
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);
}
......
......@@ -550,6 +550,31 @@ test_list_store (void)
" </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 @@ test_list_store (void)
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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment