Mercurial > dwindows
changeset 1353:f4ad4ba39b61
Apparently it is unsafe to set properties in the GTK3 size allocate callback.
Start an idle timer and set the splitbar position at an idle time later.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 16 Nov 2011 20:31:35 +0000 |
parents | 08de3c1f4ae4 |
children | 1f22addc2722 |
files | gtk3/dw.c |
diffstat | 1 files changed, 23 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/gtk3/dw.c Wed Nov 16 19:47:17 2011 +0000 +++ b/gtk3/dw.c Wed Nov 16 20:31:35 2011 +0000 @@ -9500,6 +9500,28 @@ DW_MUTEX_UNLOCK; } +/* Function to do delayed positioning */ +gboolean _splitbar_set_percent(gpointer data) +{ + GtkWidget *widget = data; + float *percent = (float *)g_object_get_data(G_OBJECT(widget), "_dw_percent"); + + if(percent) + { + GtkAllocation alloc; + + gtk_widget_get_allocation(widget, &alloc); + + if(GTK_IS_HPANED(widget)) + gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.width * (*percent / 100.0))); + if(GTK_IS_VPANED(widget)) + gtk_paned_set_position(GTK_PANED(widget), (int)(alloc.height * (*percent / 100.0))); + g_object_set_data(G_OBJECT(widget), "_dw_percent", NULL); + free(percent); + } + return FALSE; +} + /* Reposition the bar according to the percentage */ static gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data) { @@ -9509,12 +9531,7 @@ if(!percent || event->width < 20 || event->height < 20) return FALSE; - if(GTK_IS_HPANED(widget)) - gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0))); - if(GTK_IS_VPANED(widget)) - gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0))); - g_object_set_data(G_OBJECT(widget), "_dw_percent", NULL); - free(percent); + g_idle_add(_splitbar_set_percent, widget); return FALSE; }