Resize History List based on the requested size

This commit is contained in:
André Stösel 2010-11-23 23:22:47 +01:00 committed by Christian Dywan
parent 97a7ae9955
commit cb5bdb8646

View file

@ -57,7 +57,6 @@ private class TabWindow : HistoryWindow {
this.add (hbox); this.add (hbox);
var sw = new Gtk.ScrolledWindow (null, null); var sw = new Gtk.ScrolledWindow (null, null);
sw.set_size_request (320, 20);
sw.set_policy (PolicyType.NEVER , PolicyType.AUTOMATIC); sw.set_policy (PolicyType.NEVER , PolicyType.AUTOMATIC);
sw.set_shadow_type (ShadowType.ETCHED_IN); sw.set_shadow_type (ShadowType.ETCHED_IN);
hbox.pack_start (sw, true, true, 0); hbox.pack_start (sw, true, true, 0);
@ -81,7 +80,6 @@ private class TabWindow : HistoryWindow {
TabTreeCells.TREE_CELL_POINTER, view); TabTreeCells.TREE_CELL_POINTER, view);
} }
this.set_default_size (320, list.len > 10 ? 232 : (int) list.len * 23 + 2);
this.treeview = new Gtk.TreeView.with_model (store); this.treeview = new Gtk.TreeView.with_model (store);
this.treeview.set_fixed_height_mode (true); this.treeview.set_fixed_height_mode (true);
sw.add (treeview); sw.add (treeview);
@ -96,6 +94,17 @@ private class TabWindow : HistoryWindow {
TabTreeCells.TREE_CELL_STRING, "Title", TabTreeCells.TREE_CELL_STRING, "Title",
new CellRendererText (), "text", 1); new CellRendererText (), "text", 1);
Requisition requisition;
int height;
int max_lines = 10;
this.treeview.size_request (out requisition);
if ((int)list.len > max_lines) {
height = requisition.height / (int)list.len * max_lines + 2;
} else {
height = requisition.height + 2;
}
sw.set_size_request (320, height);
this.show_all (); this.show_all ();
} }
public override void make_update () { public override void make_update () {