GtkTreeView Size Issue
- From: Carlos Pereira <jose carlos pereira ist utl pt>
- To: gtk-app-devel-list gnome org
- Subject: GtkTreeView Size Issue
- Date: Thu, 10 Apr 2008 19:04:24 +0100
Hi,
The working code below shows a two-column list, where the second
title, "Pages", is partially overwritten by the scrolled window:
http://www.gamgi.org/treeview.png
When the scrolled window is inactive, or when gtk_widget_set_size_request
is commented out, the title "Pages" looks fine.
A simple workaround is to add three spaces to the last title,
"Pages " instead of "Pages", but this is not elegant...
I am doing something wrong? actually this is a old issue,
GtkCList had exactly the same problem, five years ago...
According to pkg-config --modversion gtk+-2.0, I am running GTK 2.12.5
Thanks!
Carlos
************ working code **********
#include <gtk/gtk.h>
int main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *scrolled;
GtkWidget *treeview;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkListStore *store;
GtkTreeIter iter;
GtkRequisition size;
int i, max;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (window), scrolled);
treeview = gtk_tree_view_new ();
gtk_container_add (GTK_CONTAINER (scrolled), treeview);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Subject", renderer,
"text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
column = gtk_tree_view_column_new_with_attributes ("Pages", renderer,
"text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
/*
* When the scrolled window is hideen (max = 10) the title Pages is fine.
*/
max = 50;
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
for (i = 0; i < max; i++)
{
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "Documentation", 1, "1", -1);
}
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
GTK_TREE_MODEL (store));
g_object_unref (store);
/*
* when gtk_widget_set_size_request is commented,
* the title Pages looks fine.
*/
gtk_widget_size_request (treeview, &size);
if (size.height < 100) size.height = 100;
if (size.height > 200) size.height = 200;
gtk_widget_set_size_request (treeview, -1, size.height);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]