how to limit the size of a window?
- From: WEBER Luc <luc weber obs unige ch>
- To: gtk-app-devel-list gnome org
- Subject: how to limit the size of a window?
- Date: Thu, 10 Jan 2002 11:42:39 +0100
Hi,
I'm trying to limit the size of a window containing a drawing area at
the maximum size of this drawing area. I want to accept a smaller window
but I want to limit the size in both axes if the user try to make a
window larger.
I do that in a configure_event with a gtk_widget_set_usize().
The problem is:  the system goes in a infinite loop when I modify the
size of the widow with the mouse.
In this example, I want to limit the size to 256x256 pixels.
Many thanks in advance
Luc Weber
main()
{
...
 gtk_signal_connect (GTK_OBJECT(image_drawing_area),"configure_event",
        (GtkSignalFunc) configure_event, NULL);
...
}
static gint configure_event( GtkWidget         *widget,
                             GdkEventConfigure *event )
{
 gint  width, height;
 gint  width_r, height_r;
 GdkWindow *window;
  width_r   = widget->parent->requisition.width;
  height_r  = widget->parent->requisition.height;
  printf("configure_event %d requisition  %d %d\n", widget, width_r,
height_r);
  width   = widget->parent->allocation.width;
  height  = widget->parent->allocation.height;
  printf("configure_event %d allocation  %d %d\n", widget, width,
height);
  if(width_r == width && height_r == height)
        return TRUE;
  gtk_window_set_policy(GTK_WINDOW (image_window), FALSE, FALSE, TRUE);
  gtk_widget_set_usize(image_window, -1, -1);
  if(width>256)
           width = 256;
  if(height>256)
           height = 256;
  printf("-----> size %d %d\n",width,height);
  gtk_widget_set_usize(image_window, width,height);
  gtk_window_set_policy(GTK_WINDOW (image_window), TRUE, TRUE, TRUE);
 return TRUE;
}
--
luc weber obs unige ch
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]