Getting column index out of GtkTreeViewColumn



Hi!

I really missed a function that would return the index of a GtkTreeViewColumn given as an argument, so I wrote (a very inefficient and probably even messy but functional) routine myself; maybe someone would use it too, so here it goes:



gint gtk_tree_view_column_get_index (GtkTreeViewColumn *column)
	{
	GtkTreeView *tree = GTK_TREE_VIEW (column->tree_view);
	GList *cols = gtk_tree_view_get_columns (tree);
	int counter = 0;
	
	while (cols != NULL)
		{
		if (column == GTK_TREE_VIEW_COLUMN (cols->data))
			{
			g_list_free (cols);
			return counter;
			}
		cols = cols->next;
		counter++;
		}

	g_list_free (cols);
	return -1;
	}

Best regards,

Andrej



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]