diff options
author | Jonathan Blandford <jrb@redhat.com> | 2001-03-10 01:34:48 +0000 |
---|---|---|
committer | Jonathan Blandford <jrb@src.gnome.org> | 2001-03-10 01:34:48 +0000 |
commit | 351052e1662110612b2c850977a70f2948a68496 (patch) | |
tree | 6620125ed4b3386fac6ac4d8c101f84abe5640f2 /gtk/gtkliststore.c | |
parent | 79fed460d99ffeb75d8b4f71654a01ebf657b5e9 (diff) | |
download | gtk+-351052e1662110612b2c850977a70f2948a68496.tar.gz |
Make select_all not work if you're in SINGLE mode (it doesn't make that
Fri Mar 9 20:36:21 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_select_all): Make
select_all not work if you're in SINGLE mode (it doesn't make that
much sense, anyway.)
* gtk/gtktreedatalist.c (_gtk_tree_data_list_node_to_value):
handle types more sanely.
(_gtk_tree_data_list_value_to_node): handle types more sanely.
(_gtk_tree_data_list_node_copy): handle types more sanely.
* gtk/gtkliststore.c (gtk_list_store_set_cell): fix to work with
GValue better. Converts the type as well.
* gtk/gtktreestore.c (gtk_tree_store_set_cell): fix to work with
GValue better. Converts the type as well.
Diffstat (limited to 'gtk/gtkliststore.c')
-rw-r--r-- | gtk/gtkliststore.c | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c index 53a13e29fa..123308d07e 100644 --- a/gtk/gtkliststore.c +++ b/gtk/gtkliststore.c @@ -236,7 +236,17 @@ gtk_list_store_new_with_types (gint n_columns, va_start (args, n_columns); for (i = 0; i < n_columns; i++) - gtk_list_store_set_column_type (retval, i, va_arg (args, GType)); + { + GType type = va_arg (args, GType); + if (! _gtk_tree_data_list_check_type (type)) + { + g_warning ("%s: Invalid type %s passed to gtk_list_store_new_with_types\n", G_STRLOC, g_type_name (type)); + g_object_unref (G_OBJECT (retval)); + return NULL; + } + + gtk_list_store_set_column_type (retval, i, type); + } va_end (args); @@ -287,9 +297,9 @@ gtk_list_store_set_n_columns (GtkListStore *list_store, * @type: type of the data stored in @column * * Supported types include: %G_TYPE_UINT, %G_TYPE_INT, %G_TYPE_UCHAR, - * %G_TYPE_CHAR, %G_TYPE_BOOLEAN, %G_TYPE_POINTER, %G_TYPE_FLOAT, %G_TYPE_STRING, - * %G_TYPE_OBJECT, and %G_TYPE_BOXED, along with subclasses of those types such - * as %GDK_TYPE_PIXBUF. + * %G_TYPE_CHAR, %G_TYPE_BOOLEAN, %G_TYPE_POINTER, %G_TYPE_FLOAT, + * %G_TYPE_DOUBLE, %G_TYPE_STRING, %G_TYPE_OBJECT, and %G_TYPE_BOXED, along with + * subclasses of those types such as %GDK_TYPE_PIXBUF. * **/ void @@ -300,6 +310,11 @@ gtk_list_store_set_column_type (GtkListStore *list_store, g_return_if_fail (list_store != NULL); g_return_if_fail (GTK_IS_LIST_STORE (list_store)); g_return_if_fail (column >=0 && column < list_store->n_columns); + if (!_gtk_tree_data_list_check_type (type)) + { + g_warning ("%s: Invalid type %s passed to gtk_list_store_new_with_types\n", G_STRLOC, g_type_name (type)); + return; + } list_store->column_headers[column] = type; } @@ -525,11 +540,37 @@ gtk_list_store_set_cell (GtkListStore *list_store, GtkTreeDataList *list; GtkTreeDataList *prev; GtkTreePath *path; + GValue real_value = {0, }; + gboolean converted = FALSE; g_return_if_fail (list_store != NULL); g_return_if_fail (GTK_IS_LIST_STORE (list_store)); g_return_if_fail (iter != NULL); g_return_if_fail (column >= 0 && column < list_store->n_columns); + g_return_if_fail (value != NULL); + + if (! g_type_is_a (G_VALUE_TYPE (value), column->type)) + { + if (! (g_value_type_compatible (G_VALUE_TYPE (value), column->type) && + g_value_type_compatible (column->type, G_VALUE_TYPE (value)))) + { + g_warning ("%s: Unable to convert from %s to %s\n", + G_STRLOC, + g_type_name (G_VALUE_TYPE (value)), + g_type_name (column->type)); + return; + } + if (!g_value_transform (value, &real_value)) + { + g_warning ("%s: Unable to make conversion from %s to %s\n", + G_STRLOC, + g_type_name (G_VALUE_TYPE (value)), + g_type_name (column->type)); + g_value_unset (&real_value); + return; + } + converted = TRUE; + } prev = list = G_SLIST (iter->user_data)->data; @@ -538,9 +579,14 @@ gtk_list_store_set_cell (GtkListStore *list_store, if (column == 0) { path = gtk_list_store_get_path (GTK_TREE_MODEL (list_store), iter); - _gtk_tree_data_list_value_to_node (list, value); + if (converted) + _gtk_tree_data_list_value_to_node (list, &real_value); + else + _gtk_tree_data_list_value_to_node (list, value); gtk_tree_model_changed (GTK_TREE_MODEL (list_store), path, iter); gtk_tree_path_free (path); + if (converted) + g_value_unset (&real_value); return; } @@ -569,9 +615,14 @@ gtk_list_store_set_cell (GtkListStore *list_store, } path = gtk_list_store_get_path (GTK_TREE_MODEL (list_store), iter); - _gtk_tree_data_list_value_to_node (list, value); + if (converted) + _gtk_tree_data_list_value_to_node (list, real_value); + else + _gtk_tree_data_list_value_to_node (list, value); gtk_tree_model_changed (GTK_TREE_MODEL (list_store), path, iter); gtk_tree_path_free (path); + if (converted) + g_value_unset (&real_value); } /** |