GtkHPanel double click resize



I'd like to have an hpanel responde to a double click by either
minimizing to the left or restoring to a default position.
I have the following which works most of the time, but seems to have
a problem with occasionally resizing back to the location the user double
clicks because the widget still thinks the button is pressed and so it drags
the hpanel handle back to the location of the mouse cursor. How can i disable
this functionality temporarily or somehow prevent it from occuring during a
double click signal.

here's the code i used to get the hpanel to repsonde to the double click:

// in main
//....
gtk_widget_add_events( hpaned, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK ); g_signal_connect( G_OBJECT( hpaned ), "button-release-event", G_CALLBACK( detect_double_click ), hpaned ); g_signal_connect( G_OBJECT( hpaned ), "button-press-event", G_CALLBACK( detect_double_click ), hpaned );

//....


static gboolean
detect_double_click( GtkWidget *widget, GdkEventButton *event, GtkHPaned *hpaned )
{
 static GTimeVal last_click = { 0, 0 };
 GTimeVal cur_time;
 g_get_current_time( &cur_time );
 if( GTK_IS_HPANED( widget ) &&
     gdk_window_at_pointer( NULL, NULL ) == GTK_PANED(hpaned)->handle &&
( event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS ) &&
     cur_time.tv_sec > (last_click.tv_sec + 1) )
 {
//    g_object_freeze_notify( G_OBJECT( hpaned ) );
   if( gtk_paned_get_position( GTK_PANED( hpaned ) ) == 0 ){
     g_print( "expand\n" );
     gtk_paned_set_position( GTK_PANED( hpaned ), 200 );
   }
   else{
     g_print( "shrink\n" );
     gtk_paned_set_position( GTK_PANED( hpaned ), 0 );
   }
//    g_object_thaw_notify( G_OBJECT( hpaned ) );
   g_get_current_time( &last_click );
   return FALSE;
 }
 return FALSE;
}





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