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

GtkTreeView total height.



Hi Vivien!

For to compute the total height of a treeview based on the
amount of rows its model has,  I've tried with the following
code but I had to set some constants that obviously works in my
specific setting but I would like to know to what correspond
that unknowns.

I couldn't find any info about how to do that.

Besides, being that the header window in the treeview is private,
I've tested a very very rude method of obtaining the header size.
(PS treeview must be realized).

----------------------------------------------------------------
static gint
get_header_height (GtkTreeView  *tree_view)
{

    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree_view), TRUE);
                
    GdkWindow *bin_window;
    bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW(tree_view));
                
    gint bin_height;
    gdk_drawable_get_size (GDK_DRAWABLE(bin_window), NULL, &bin_height);
                
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree_view), FALSE);
                
    gint bin_height1;
    gdk_drawable_get_size (GDK_DRAWABLE(bin_window), NULL, &bin_height1);
                
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree_view), TRUE);

    return (bin_height - bin_height1);
}

static guint
get_row_height (GtkTreeView  *tree_view)
{
	
	guint row_height = 0;
	
	GList *columns = gtk_tree_view_get_columns (tree_view);
	
	GList *current = columns;
	while (current) {
		GtkTreeViewColumn *renderers = gtk_tree_view_column_get_cell_renderers
			((GtkTreeViewColumn *) current->data);
		
		guint cell_height = 0;
		
		GList *current1 = renderers;
		while (current1) {
			GtkCellRenderer *renderer = (GtkCellRenderer *) current1->data;
			
			guint height;
			
			gtk_cell_renderer_get_size (renderer, GTK_TREE_VIEW(tree_view),
						    NULL, NULL, NULL, NULL, &height);
			
			if (height > cell_height)
				cell_height = height;
			
			current1 = g_list_next (current1);
		}
		
		g_list_free (renderers);
		
		if (cell_height > row_height)
			row_height = cell_height;
		
		current = g_list_next (current);
	}
	g_list_free (columns);
	
	row_height += 4;  /* horizontal-separator ? */
	
	return row_height;
}

---
	
	gint grid_height = n_rows * get_row_height (tree_view)
		+ get_header_height (tree_view);  /* header height ? */
---

-----------------------------------------------------------------

Thanks!

Carlos Savoretti.




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