Mercurial > dwindows
changeset 1330:c63069148357
Mostly fixed dw_listbox_set_top() on GTK3.
It still doesn't seem to want to scroll to the very last line though.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 10 Nov 2011 14:24:37 +0000 |
parents | 19bfcdbab74e |
children | 4c12170f003f |
files | gtk3/dw.c |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gtk3/dw.c Thu Nov 10 13:30:14 2011 +0000 +++ b/gtk3/dw.c Thu Nov 10 14:24:37 2011 +0000 @@ -9140,27 +9140,32 @@ if(tmp) handle2 = tmp; } - /* Make sure it is the correct tree type */ if(handle2 && GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX)) { - GtkAdjustment *adjust = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(handle2)); + GtkAdjustment *adjust = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); GtkListStore *store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2)); if(store && adjust) { /* Get the number of children at the top level */ gint rowcount = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); - gdouble upper = gtk_adjustment_get_upper(adjust); + gdouble pagesize = gtk_adjustment_get_page_size(adjust); + gdouble upper = gtk_adjustment_get_upper(adjust) - pagesize; gdouble lower = gtk_adjustment_get_lower(adjust); gdouble change; - + /* Safety check */ - if(rowcount < 1) + if(rowcount < 2) { DW_MUTEX_UNLOCK; return; } + + /* Verify the range */ + rowcount--; + if(top > rowcount) + top = rowcount; change = ((gdouble)top/(gdouble)rowcount) * (upper - lower);