Commit 21b381a2 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

Fix #399071, suggestion from Benoit Dejean.

2007-06-05  Kristian Rietveld  <kris@gtk.org>

	Fix #399071, suggestion from Benoit Dejean.

	* gtk/gtkliststore.[ch] (gtk_list_store_set_vector_internal): new
	function, factored out code iterating (columns, values) vectors from
	gtk_list_store_new_with_valuesv to here,
	(gtk_list_store_set_valuesv): new public function to set list store
	values using (columns, values) vectors,
	(gtk_list_store_new_with_valuesv): call new _set_vector_internal
	instead.

	* gtk/gtktreestore.[ch] (gtk_tree_store_set_vector_internal),
	(gtk_tree_store_set_valuesv), (gtk_tree_store_new_with_valuesv):
	likewise.

	* gtk/gtk.symbols: updated.


svn path=/trunk/; revision=18041
parent 3337ee8f
2007-06-05 Kristian Rietveld <kris@gtk.org>
Fix #399071, suggestion from Benoit Dejean.
* gtk/gtkliststore.[ch] (gtk_list_store_set_vector_internal): new
function, factored out code iterating (columns, values) vectors from
gtk_list_store_new_with_valuesv to here,
(gtk_list_store_set_valuesv): new public function to set list store
values using (columns, values) vectors,
(gtk_list_store_new_with_valuesv): call new _set_vector_internal
instead.
* gtk/gtktreestore.[ch] (gtk_tree_store_set_vector_internal),
(gtk_tree_store_set_valuesv), (gtk_tree_store_new_with_valuesv):
likewise.
* gtk/gtk.symbols: updated.
2007-06-04 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkwindow-quartz.c:
......
......@@ -2138,6 +2138,7 @@ gtk_list_store_set
gtk_list_store_set_column_types
gtk_list_store_set_valist
gtk_list_store_set_value
gtk_list_store_set_valuesv
gtk_list_store_swap
#endif
#endif
......@@ -4259,6 +4260,7 @@ gtk_tree_store_set
gtk_tree_store_set_column_types
gtk_tree_store_set_valist
gtk_tree_store_set_value
gtk_tree_store_set_valuesv
gtk_tree_store_swap
#endif
#endif
......
......@@ -710,6 +710,36 @@ gtk_list_store_get_compare_func (GtkListStore *list_store)
return func;
}
static void
gtk_list_store_set_vector_internal (GtkListStore *list_store,
GtkTreeIter *iter,
gboolean *emit_signal,
gboolean *maybe_need_sort,
gint *columns,
GValue *values,
gint n_values)
{
gint i;
GtkTreeIterCompareFunc func = NULL;
func = gtk_list_store_get_compare_func (list_store);
if (func != _gtk_tree_data_list_compare_func)
*maybe_need_sort = TRUE;
for (i = 0; i < n_values; i++)
{
*emit_signal = gtk_list_store_real_set_value (list_store,
iter,
columns[i],
&values[i],
FALSE) || *emit_signal;
if (func == _gtk_tree_data_list_compare_func &&
columns[i] == list_store->sort_column_id)
*maybe_need_sort = TRUE;
}
}
static void
gtk_list_store_set_valist_internal (GtkListStore *list_store,
GtkTreeIter *iter,
......@@ -767,6 +797,53 @@ gtk_list_store_set_valist_internal (GtkListStore *list_store,
}
}
/**
* gtk_list_store_set_valuesv:
* @list_store: A #GtkListStore
* @iter: A valid #GtkTreeIter for the row being modified
* @columns: an array of column numbers
* @values: an array of GValues
* @n_values: the length of the @columns and @values arrays
*
* A variant of gtk_list_store_set_valist() which
* takes the columns and values as two arrays, instead of
* varargs. This function is mainly intended for
* language-bindings and in case the number of columns to
* change is not known until run-time.
*
* Since: 2.12
*/
void
gtk_list_store_set_valuesv (GtkListStore *list_store,
GtkTreeIter *iter,
gint *columns,
GValue *values,
gint n_values)
{
gboolean emit_signal = FALSE;
gboolean maybe_need_sort = FALSE;
g_return_if_fail (GTK_IS_LIST_STORE (list_store));
g_return_if_fail (VALID_ITER (iter, list_store));
gtk_list_store_set_vector_internal (list_store, iter,
&emit_signal,
&maybe_need_sort,
columns, values, n_values);
if (maybe_need_sort && GTK_LIST_STORE_IS_SORTED (list_store))
gtk_list_store_sort_iter_changed (list_store, iter, list_store->sort_column_id);
if (emit_signal)
{
GtkTreePath *path;
path = gtk_list_store_get_path (GTK_TREE_MODEL (list_store), iter);
gtk_tree_model_row_changed (GTK_TREE_MODEL (list_store), path, iter);
gtk_tree_path_free (path);
}
}
/**
* gtk_list_store_set_valist:
* @list_store: A #GtkListStore
......@@ -1888,8 +1965,6 @@ gtk_list_store_insert_with_valuesv (GtkListStore *list_store,
gint length;
gboolean changed = FALSE;
gboolean maybe_need_sort = FALSE;
GtkTreeIterCompareFunc func = NULL;
gint i;
/* FIXME refactor to reduce overlap with
* gtk_list_store_insert_with_values()
......@@ -1917,22 +1992,9 @@ gtk_list_store_insert_with_valuesv (GtkListStore *list_store,
list_store->length++;
func = gtk_list_store_get_compare_func (list_store);
if (func != _gtk_tree_data_list_compare_func)
maybe_need_sort = TRUE;
for (i = 0; i < n_values; i++)
{
changed = gtk_list_store_real_set_value (list_store,
iter,
columns[i],
&values[i],
FALSE) || changed;
if (func == _gtk_tree_data_list_compare_func &&
columns[i] == list_store->sort_column_id)
maybe_need_sort = TRUE;
}
gtk_list_store_set_vector_internal (list_store, iter,
&changed, &maybe_need_sort,
columns, values, n_values);
/* Don't emit rows_reordered here */
if (maybe_need_sort && GTK_LIST_STORE_IS_SORTED (list_store))
......
......@@ -87,6 +87,11 @@ void gtk_list_store_set_value (GtkListStore *list_store,
void gtk_list_store_set (GtkListStore *list_store,
GtkTreeIter *iter,
...);
void gtk_list_store_set_valuesv (GtkListStore *list_store,
GtkTreeIter *iter,
gint *columns,
GValue *values,
gint n_values);
void gtk_list_store_set_valist (GtkListStore *list_store,
GtkTreeIter *iter,
va_list var_args);
......
......@@ -863,6 +863,34 @@ gtk_tree_store_get_compare_func (GtkTreeStore *tree_store)
return func;
}
static void
gtk_tree_store_set_vector_internal (GtkTreeStore *tree_store,
GtkTreeIter *iter,
gboolean *emit_signal,
gboolean *maybe_need_sort,
gint *columns,
GValue *values,
gint n_values)
{
gint i;
GtkTreeIterCompareFunc func = NULL;
func = gtk_tree_store_get_compare_func (tree_store);
if (func != _gtk_tree_data_list_compare_func)
*maybe_need_sort = TRUE;
for (i = 0; i < n_values; i++)
{
*emit_signal = gtk_tree_store_real_set_value (tree_store, iter,
columns[i], &values[i],
FALSE) || *emit_signal;
if (func == _gtk_tree_data_list_compare_func &&
columns[i] == tree_store->sort_column_id)
*maybe_need_sort = TRUE;
}
}
static void
gtk_tree_store_set_valist_internal (GtkTreeStore *tree_store,
GtkTreeIter *iter,
......@@ -919,6 +947,52 @@ gtk_tree_store_set_valist_internal (GtkTreeStore *tree_store,
}
}
/**
* gtk_tree_store_set_valuesv:
* @tree_store: A #GtkTreeStore
* @iter: A valid #GtkTreeIter for the row being modified
* @columns: an array of column numbers
* @values: an array of GValues
* @n_values: the length of the @columns and @values arrays
*
* A variant of gtk_tree_store_set_valist() which takes
* the columns and values as two arrays, instead of varargs. This
* function is mainly intended for language bindings or in case
* the number of columns to change is not known until run-time.
*
* Since: 2.12
**/
void
gtk_tree_store_set_valuesv (GtkTreeStore *tree_store,
GtkTreeIter *iter,
gint *columns,
GValue *values,
gint n_values)
{
gboolean emit_signal = FALSE;
gboolean maybe_need_sort = FALSE;
g_return_if_fail (GTK_IS_TREE_STORE (tree_store));
g_return_if_fail (VALID_ITER (iter, tree_store));
gtk_tree_store_set_vector_internal (tree_store, iter,
&emit_signal,
&maybe_need_sort,
columns, values, n_values);
if (maybe_need_sort && GTK_TREE_STORE_IS_SORTED (tree_store))
gtk_tree_store_sort_iter_changed (tree_store, iter, tree_store->sort_column_id, TRUE);
if (emit_signal)
{
GtkTreePath *path;
path = gtk_tree_store_get_path (GTK_TREE_MODEL (tree_store), iter);
gtk_tree_model_row_changed (GTK_TREE_MODEL (tree_store), path, iter);
gtk_tree_path_free (path);
}
}
/**
* gtk_tree_store_set_valist:
* @tree_store: A #GtkTreeStore
......@@ -1394,8 +1468,6 @@ gtk_tree_store_insert_with_valuesv (GtkTreeStore *tree_store,
GtkTreeIter tmp_iter;
gboolean changed = FALSE;
gboolean maybe_need_sort = FALSE;
GtkTreeIterCompareFunc func = NULL;
gint i;
g_return_if_fail (GTK_IS_TREE_STORE (tree_store));
......@@ -1418,20 +1490,9 @@ gtk_tree_store_insert_with_valuesv (GtkTreeStore *tree_store,
iter->user_data = new_node;
g_node_insert (parent_node, position, new_node);
func = gtk_tree_store_get_compare_func (tree_store);
if (func != _gtk_tree_data_list_compare_func)
maybe_need_sort = TRUE;
for (i = 0; i < n_values; i++)
{
changed = gtk_tree_store_real_set_value (tree_store, iter,
columns[i], &values[i],
FALSE) || changed;
if (func == _gtk_tree_data_list_compare_func &&
columns[i] == tree_store->sort_column_id)
maybe_need_sort = TRUE;
}
gtk_tree_store_set_vector_internal (tree_store, iter,
&changed, &maybe_need_sort,
columns, values, n_values);
if (maybe_need_sort && GTK_TREE_STORE_IS_SORTED (tree_store))
gtk_tree_store_sort_iter_changed (tree_store, iter, tree_store->sort_column_id, FALSE);
......
......@@ -86,6 +86,11 @@ void gtk_tree_store_set_value (GtkTreeStore *tree_store,
void gtk_tree_store_set (GtkTreeStore *tree_store,
GtkTreeIter *iter,
...);
void gtk_tree_store_set_valuesv (GtkTreeStore *tree_store,
GtkTreeIter *iter,
gint *columns,
GValue *values,
gint n_values);
void gtk_tree_store_set_valist (GtkTreeStore *tree_store,
GtkTreeIter *iter,
va_list var_args);
......
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