Commit 351052e1 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

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.
parent 79fed460
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.
Wed Mar 7 20:47:41 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtkoldeditable.[ch] gdk/gdk.[ch]
......
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.
Wed Mar 7 20:47:41 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtkoldeditable.[ch] gdk/gdk.[ch]
......
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.
Wed Mar 7 20:47:41 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtkoldeditable.[ch] gdk/gdk.[ch]
......
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.
Wed Mar 7 20:47:41 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtkoldeditable.[ch] gdk/gdk.[ch]
......
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.
Wed Mar 7 20:47:41 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtkoldeditable.[ch] gdk/gdk.[ch]
......
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.
Wed Mar 7 20:47:41 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtkoldeditable.[ch] gdk/gdk.[ch]
......
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.
Wed Mar 7 20:47:41 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktext.c gtk/gtkoldeditable.[ch] gdk/gdk.[ch]
......
......@@ -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);
}
/**
......
......@@ -126,17 +126,12 @@ _gtk_tree_data_list_free (GtkTreeDataList *list,
for (tmp = list; tmp; tmp = tmp->next)
{
switch (column_headers [i])
{
case G_TYPE_STRING:
g_free ((gchar *) tmp->data.v_pointer);
break;
case G_TYPE_OBJECT:
g_object_unref (G_OBJECT (tmp->data.v_pointer));
break;
default:
break;
}
if (g_type_is_a (column_headers [i], G_TYPE_STRING))
g_free ((gchar *) tmp->data.v_pointer);
else if (g_type_is_a (column_headers [i], G_TYPE_OBJECT))
g_object_unref (G_OBJECT (tmp->data.v_pointer));
else if (g_type_is_a (column_headers [i], G_TYPE_BOXED))
g_boxed_free (column_headers [i], (gpointer) tmp->data.v_pointer);
i++;
}
......@@ -146,6 +141,38 @@ _gtk_tree_data_list_free (GtkTreeDataList *list,
G_UNLOCK (current_allocator);
}
gboolean
_gtk_tree_data_list_check_type (GType type)
{
gint i = 0;
static GType type_list[] =
{
G_TYPE_BOOLEAN,
G_TYPE_CHAR,
G_TYPE_UCHAR,
G_TYPE_INT,
G_TYPE_UINT,
G_TYPE_ENUM,
G_TYPE_FLAGS,
G_TYPE_FLOAT,
G_TYPE_DOUBLE,
G_TYPE_STRING,
G_TYPE_POINTER,
G_TYPE_BOXED,
G_TYPE_OBJECT,
G_TYPE_INVALID
};
while (type_list[i] != G_TYPE_INVALID)
{
if (g_type_is_a (type, type_list[i]))
return TRUE;
i++;
}
return FALSE;
}
void
_gtk_tree_data_list_node_to_value (GtkTreeDataList *list,
GType type,
......@@ -153,83 +180,68 @@ _gtk_tree_data_list_node_to_value (GtkTreeDataList *list,
{
g_value_init (value, type);
switch (type)
{
case G_TYPE_BOOLEAN:
g_value_set_boolean (value, (gboolean) list->data.v_int);
break;
case G_TYPE_CHAR:
g_value_set_char (value, list->data.v_char);
break;
case G_TYPE_UCHAR:
g_value_set_uchar (value, list->data.v_uchar);
break;
case G_TYPE_INT:
g_value_set_int (value, list->data.v_int);
break;
case G_TYPE_UINT:
g_value_set_uint (value, list->data.v_uint);
break;
case G_TYPE_POINTER:
g_value_set_pointer (value, (gpointer) list->data.v_pointer);
break;
case G_TYPE_FLOAT:
g_value_set_float (value, list->data.v_float);
break;
case G_TYPE_STRING:
g_value_set_string (value, (gchar *) list->data.v_pointer);
break;
default:
if (g_type_is_a (type, G_TYPE_OBJECT))
g_value_set_object (value, (GObject *) list->data.v_pointer);
else if (g_type_is_a (type, G_TYPE_BOXED))
g_value_set_boxed (value, (GObject *) list->data.v_pointer);
else
g_warning ("Unsupported type (%s) retrieved.", g_type_name (value->g_type));
break;
}
if (g_type_is_a (type, G_TYPE_BOOLEAN))
g_value_set_boolean (value, (gboolean) list->data.v_int);
else if (g_type_is_a (type, G_TYPE_CHAR))
g_value_set_char (value, (gchar) list->data.v_char);
else if (g_type_is_a (type, G_TYPE_UCHAR))
g_value_set_uchar (value, (guchar) list->data.v_uchar);
else if (g_type_is_a (type, G_TYPE_INT))
g_value_set_int (value, (gint) list->data.v_int);
else if (g_type_is_a (type, G_TYPE_UINT))
g_value_set_uint (value, (guint) list->data.v_uint);
else if (g_type_is_a (type, G_TYPE_ENUM))
g_value_set_enum (value, list->data.v_int);
else if (g_type_is_a (type, G_TYPE_FLAGS))
g_value_set_flags (value, (int) list->data.v_int);
else if (g_type_is_a (type, G_TYPE_FLOAT))
g_value_set_float (value, (gfloat) list->data.v_float);
else if (g_type_is_a (type, G_TYPE_DOUBLE))
g_value_set_double (value, (gdouble) list->data.v_double);
else if (g_type_is_a (type, G_TYPE_STRING))
g_value_set_string (value, (gchar *) list->data.v_pointer);
else if (g_type_is_a (type, G_TYPE_POINTER))
g_value_set_pointer (value, (gpointer) list->data.v_pointer);
else if (g_type_is_a (type, G_TYPE_BOXED))
g_value_set_boxed (value, (gpointer) list->data.v_pointer);
else if (g_type_is_a (type, G_TYPE_OBJECT))
g_value_set_object (value, (GObject *) list->data.v_pointer);
else
g_warning ("%s: Unsupported type (%s) retrieved.", G_STRLOC, g_type_name (value->g_type));
}
void
_gtk_tree_data_list_value_to_node (GtkTreeDataList *list,
GValue *value)
{
switch (value->g_type)
{
case G_TYPE_BOOLEAN:
list->data.v_int = g_value_get_boolean (value);
break;
case G_TYPE_CHAR:
list->data.v_char = g_value_get_char (value);
break;
case G_TYPE_UCHAR:
list->data.v_uchar = g_value_get_uchar (value);
break;
case G_TYPE_INT:
list->data.v_int = g_value_get_int (value);
break;
case G_TYPE_UINT:
list->data.v_uint = g_value_get_uint (value);
break;
case G_TYPE_POINTER:
list->data.v_pointer = g_value_get_pointer (value);
break;
case G_TYPE_FLOAT:
list->data.v_float = g_value_get_float (value);
break;
case G_TYPE_STRING:
list->data.v_pointer = g_value_dup_string (value);
break;
default:
if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_OBJECT))
list->data.v_pointer = g_value_dup_object (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_BOXED))
list->data.v_pointer = g_value_dup_boxed (value);
else
g_warning ("Unsupported type (%s) stored.", g_type_name (value->g_type));
break;
}
if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_BOOLEAN))
list->data.v_int = g_value_get_boolean (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_CHAR))
list->data.v_char = g_value_get_char (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_UCHAR))
list->data.v_uchar = g_value_get_uchar (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_INT))
list->data.v_int = g_value_get_int (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_ENUM))
list->data.v_int = g_value_get_enum (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_FLAGS))
list->data.v_int = g_value_get_flags (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_UINT))
list->data.v_uint = g_value_get_uint (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_POINTER))
list->data.v_pointer = g_value_get_pointer (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_FLOAT))
list->data.v_float = g_value_get_float (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_DOUBLE))
list->data.v_double = g_value_get_double (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_STRING))
list->data.v_pointer = g_value_dup_string (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_OBJECT))
list->data.v_pointer = g_value_dup_object (value);
else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_BOXED))
list->data.v_pointer = g_value_dup_boxed (value);
else
g_warning ("%s: Unsupported type (%s) stored.", G_STRLOC, g_type_name (G_VALUE_TYPE (value)));
}
GtkTreeDataList*
......@@ -243,41 +255,34 @@ _gtk_tree_data_list_node_copy (GtkTreeDataList *list,
new_list = _gtk_tree_data_list_alloc ();
new_list->next = NULL;
switch (type)
{
case G_TYPE_UINT:
case G_TYPE_INT:
case G_TYPE_UCHAR:
case G_TYPE_CHAR:
case G_TYPE_BOOLEAN:
case G_TYPE_POINTER:
case G_TYPE_FLOAT:
new_list->data = list->data;
break;
if ((g_type_is_a (type, G_TYPE_UINT)) ||
(g_type_is_a (type, G_TYPE_INT)) ||
(g_type_is_a (type, G_TYPE_UCHAR)) ||
(g_type_is_a (type, G_TYPE_CHAR)) ||
(g_type_is_a (type, G_TYPE_BOOLEAN)) ||
(g_type_is_a (type, G_TYPE_POINTER)) ||
(g_type_is_a (type, G_TYPE_FLOAT)) ||
(g_type_is_a (type, G_TYPE_DOUBLE)))
new_list->data = list->data;
case G_TYPE_STRING:
new_list->data.v_pointer = g_strdup (list->data.v_pointer);
break;
default:
if (g_type_is_a (type, G_TYPE_OBJECT))
{
new_list->data.v_pointer = list->data.v_pointer;
if (new_list->data.v_pointer)
g_object_ref (G_OBJECT (new_list->data.v_pointer));
}
else if (g_type_is_a (type, G_TYPE_BOXED))
{
if (list->data.v_pointer)
new_list->data.v_pointer = g_boxed_copy (type, list->data.v_pointer);
else
new_list->data.v_pointer = NULL;
}
else if (g_type_is_a (type, G_TYPE_STRING))
new_list->data.v_pointer = g_strdup (list->data.v_pointer);
else if (g_type_is_a (type, G_TYPE_OBJECT))
{
new_list->data.v_pointer = list->data.v_pointer;
if (new_list->data.v_pointer)
g_object_ref (G_OBJECT (new_list->data.v_pointer));
}
else if (g_type_is_a (type, G_TYPE_BOXED))
{
if (list->data.v_pointer)
new_list->data.v_pointer = g_boxed_copy (type, list->data.v_pointer);
else
g_warning ("Unsupported node type (%s) copied.", g_type_name (type));
break;
new_list->data.v_pointer = NULL;
}
else
g_warning ("Unsupported node type (%s) copied.", g_type_name (type));
return new_list;
}
......
......@@ -35,15 +35,18 @@ struct _GtkTreeDataList
guint8 v_uchar;
guint v_uint;
gfloat v_float;
gdouble v_double;
gpointer v_pointer;
} data;
};
void _gtk_tree_data_list_push_allocator (GAllocator *allocator);
void _gtk_tree_data_list_pop_allocator (void);
GtkTreeDataList *_gtk_tree_data_list_alloc (void);
void _gtk_tree_data_list_free (GtkTreeDataList *list,
GType *column_headers);
gboolean _gtk_tree_data_list_check_type (GType type);
void _gtk_tree_data_list_node_to_value (GtkTreeDataList *list,
GType type,
GValue *value);
......
......@@ -602,68 +602,35 @@ static gint
gtk_tree_selection_real_select_all (GtkTreeSelection *selection)
{
struct _TempTuple *tuple;
if (selection->tree_view->priv->tree == NULL)
return FALSE;
if (selection->type == GTK_TREE_SELECTION_SINGLE)
{
GtkRBTree *tree;
GtkRBNode *node;
gint dirty;
/* Just select the last row */
dirty = gtk_tree_selection_real_unselect_all (selection);
tree = selection->tree_view->priv->tree;
node = tree->root;
do
{
while (node->right != selection->tree_view->priv->tree->nil)
node = node->right;
if (node->children)
{
tree = node->children;
node = tree->root;
}
else
break;
} while (TRUE);
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
return dirty;
}
else
/* Mark all nodes selected */
tuple = g_new (struct _TempTuple, 1);
tuple->selection = selection;
tuple->dirty = FALSE;
_gtk_rbtree_traverse (selection->tree_view->priv->tree,
selection->tree_view->priv->tree->root,
G_PRE_ORDER,
select_all_helper,
tuple);
if (tuple->dirty)
{
/* Mark all nodes selected */
tuple = g_new (struct _TempTuple, 1);
tuple->selection = selection;
tuple->dirty = FALSE;
_gtk_rbtree_traverse (selection->tree_view->priv->tree,
selection->tree_view->priv->tree->root,
G_PRE_ORDER,
select_all_helper,
tuple);
if (tuple->dirty)
{
g_free (tuple);
return TRUE;
}
g_free (tuple);
return FALSE;
return TRUE;
}
g_free (tuple);
return FALSE;
}
/**
* gtk_tree_selection_select_all:
* @selection: A #GtkTreeSelection.
*
* Selects all the nodes. If the type of @selection is
* #GTK_TREE_SELECTION_SINGLE, then the last row is selected.
* Selects all the nodes. @selection is must be set to
* #GTK_TREE_SELECTION_MULTI mode.
**/
void
gtk_tree_selection_select_all (GtkTreeSelection *selection)
......@@ -672,6 +639,7 @@ gtk_tree_selection_select_all (GtkTreeSelection *selection)
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
g_return_if_fail (selection->tree_view->priv->tree != NULL);
g_return_if_fail (selection->type != GTK_TREE_SELECTION_MULTI);
if (gtk_tree_selection_real_select_all (selection))
gtk_signal_emit (GTK_OBJECT (selection), tree_selection_signals[SELECTION_CHANGED]);
......
......@@ -213,8 +213,16 @@ gtk_tree_store_new_with_types (gint n_columns,
va_start (args, n_columns);
for (i = 0; i < n_columns; i++)
gtk_tree_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_tree_store_new_with_types\n", G_STRLOC, g_type_name (type));
g_object_unref (G_OBJECT (retval));
return NULL;
}
gtk_tree_store_set_column_type (retval, i, type);
}
va_end (args);
return retval;
......@@ -248,6 +256,18 @@ gtk_tree_store_set_n_columns (GtkTreeStore *tree_store,
tree_store->n_columns = n_columns;
}
/**
* gtk_tree_store_set_column_type:
* @tree_store: a #GtkTreeStore
* @column: column number
* @type: type of the data to be 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_DOUBLE, %G_TYPE_STRING, %G_TYPE_OBJECT, and %G_TYPE_BOXED, along with
* subclasses of those types such as %GDK_TYPE_PIXBUF.
*
**/
void
gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
gint column,
......@@ -256,7 +276,11 @@ gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
g_return_if_fail (tree_store != NULL);
g_return_if_fail (GTK_IS_TREE_STORE (tree_store));
g_return_if_fail (column >=0 && column < tree_store->n_columns);
if (!_gtk_tree_data_list_check_type (type))
{
g_warning ("%s: Invalid type %s passed to gtk_tree_store_new_with_types\n", G_STRLOC, g_type_name (type));
return;
}
tree_store->column_headers[column] = type;
}
......@@ -533,10 +557,36 @@ gtk_tree_store_set_cell (GtkTreeStore *tree_store,
GtkTreeDataList *list;
GtkTreeDataList *prev;
GtkTreePath *path = NULL;
GValue real_value = {0, };
gboolean converted = FALSE;
g_return_if_fail (tree_store != NULL);
g_return_if_fail (GTK_IS_TREE_STORE (tree_store));
g_return_if_fail (column >= 0 && column < tree_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_NODE (iter->user_data)->data;
......@@ -546,9 +596,14 @@ gtk_tree_store_set_cell (GtkTreeStore *tree_store,
{
if (column == 0)
{
_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 (tree_store), path, iter);
gtk_tree_path_free (path);
if (converted)