Skip to content

Commit

Permalink
use gtk_tree_view_get_n_columns
Browse files Browse the repository at this point in the history
instead of g_list_length (gtk_tree_view_get_columns (tree))
  • Loading branch information
christopherlam committed Mar 16, 2022
1 parent 4bb16f0 commit 4eec093
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
10 changes: 2 additions & 8 deletions gnucash/gnome-utils/gnc-tree-view.c
Expand Up @@ -2154,13 +2154,7 @@ gint
gnc_tree_view_append_column (GncTreeView *view,
GtkTreeViewColumn *column)
{
GList *columns;
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);
int n = gtk_tree_view_get_n_columns (GTK_TREE_VIEW(view));

/* Ignore the initial column, the selection menu */
if (n >= 1)
Expand All @@ -2177,7 +2171,7 @@ get_column_next_to (GtkTreeView *tv, GtkTreeViewColumn **col, gboolean backward)
gboolean wrapped = FALSE;

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);
g_return_val_if_fail (node, FALSE);
Expand Down
4 changes: 1 addition & 3 deletions gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
Expand Up @@ -1646,9 +1646,7 @@ void CsvImpPriceAssist::preview_refresh_table ()

/* Start with counting the current number of columns (ntcols)
* we have in the treeview */
auto columns = gtk_tree_view_get_columns (treeview);
auto ntcols = g_list_length(columns);
g_list_free (columns);
auto ntcols = gtk_tree_view_get_n_columns (treeview);

/* 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)
Expand Down
4 changes: 1 addition & 3 deletions gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
Expand Up @@ -1572,9 +1572,7 @@ void CsvImpTransAssist::preview_refresh_table ()

/* Start with counting the current number of columns (ntcols)
* we have in the treeview */
auto columns = gtk_tree_view_get_columns (treeview);
auto ntcols = g_list_length(columns);
g_list_free (columns);
auto ntcols = gtk_tree_view_get_n_columns (treeview);

/* 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)
Expand Down

0 comments on commit 4eec093

Please sign in to comment.