use gtk_tree_view_get_n_columns

instead of g_list_length (gtk_tree_view_get_columns (tree))
This commit is contained in:
Christopher Lam 2022-03-16 21:44:30 +08:00
parent 4bb16f03a5
commit 4eec093acc
3 changed files with 4 additions and 14 deletions

View File

@ -2154,13 +2154,7 @@ gint
gnc_tree_view_append_column (GncTreeView *view, gnc_tree_view_append_column (GncTreeView *view,
GtkTreeViewColumn *column) GtkTreeViewColumn *column)
{ {
GList *columns; int n = gtk_tree_view_get_n_columns (GTK_TREE_VIEW(view));
int n;
/* There's no easy way to get this number. */
columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
n = g_list_length (columns);
g_list_free (columns);
/* Ignore the initial column, the selection menu */ /* Ignore the initial column, the selection menu */
if (n >= 1) if (n >= 1)
@ -2177,7 +2171,7 @@ get_column_next_to (GtkTreeView *tv, GtkTreeViewColumn **col, gboolean backward)
gboolean wrapped = FALSE; gboolean wrapped = FALSE;
cols = gtk_tree_view_get_columns (tv); cols = gtk_tree_view_get_columns (tv);
g_return_val_if_fail (g_list_length (cols) > 0, FALSE); g_return_val_if_fail (cols != NULL, FALSE);
node = g_list_find (cols, *col); node = g_list_find (cols, *col);
g_return_val_if_fail (node, FALSE); g_return_val_if_fail (node, FALSE);

View File

@ -1646,9 +1646,7 @@ void CsvImpPriceAssist::preview_refresh_table ()
/* Start with counting the current number of columns (ntcols) /* Start with counting the current number of columns (ntcols)
* we have in the treeview */ * we have in the treeview */
auto columns = gtk_tree_view_get_columns (treeview); auto ntcols = gtk_tree_view_get_n_columns (treeview);
auto ntcols = g_list_length(columns);
g_list_free (columns);
/* Drop redundant columns if the model has less data columns than the new model /* Drop redundant columns if the model has less data columns than the new model
* ntcols = n° of columns in treeview (1 error column + x data columns) * ntcols = n° of columns in treeview (1 error column + x data columns)

View File

@ -1572,9 +1572,7 @@ void CsvImpTransAssist::preview_refresh_table ()
/* Start with counting the current number of columns (ntcols) /* Start with counting the current number of columns (ntcols)
* we have in the treeview */ * we have in the treeview */
auto columns = gtk_tree_view_get_columns (treeview); auto ntcols = gtk_tree_view_get_n_columns (treeview);
auto ntcols = g_list_length(columns);
g_list_free (columns);
/* Drop redundant columns if the model has less data columns than the new model /* Drop redundant columns if the model has less data columns than the new model
* ntcols = n° of columns in treeview (1 error column + x data columns) * ntcols = n° of columns in treeview (1 error column + x data columns)