Re: How to get width and height while resizing window?

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

 



LiNuCE, many thanks!

configure-event is what I need.

There are no duplicates for this signal.

I am still curious though to find out why the size-allocate signal consistently produces duplicates. Feature or bug?

Ken
 





--- On Sat, 16/1/10, LiNuCe <linuce@xxxxxxxxx> wrote:

From: LiNuCe <linuce@xxxxxxxxx>
Subject: Re: How to get width and height while resizing window?
To: "Ken Resander" <kresander@xxxxxxxxx>
Date: Saturday, 16 January, 2010, 12:44 PM

http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget-configure-event

2010/1/15, Ken Resander <kresander@xxxxxxxxx>:
> #include <gtk/gtk.h>
>
> How to get width and height while resizing window?
>
> I used size-allocate event as in the test program below:
>
>
> static gboolean szalloccallback ( GtkWidget * w,
>                                   GtkAllocation * a,
>                                   char * data )
>    {
>  printf ( " szalloc (x,y)=(%d,%d) (w,h)=(%d,%d)\n" ,
>           a->x , a->y , a->width , a->height ) ;
>    return false;
>    }
>
> int main ( int argc , char * argv[] )
>    {
>    gtk_init(&argc, &argv);
>
>    GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
>    gtk_window_set_default_size(GTK_WINDOW(window), 250, 180);
>    gtk_window_set_title(GTK_WINDOW(window), "Testing");
>
>    g_signal_connect(window, "size-allocate" ,
>                     G_CALLBACK (szalloccallback), NULL);
>
>    gtk_widget_show_all(window);
>    gtk_main();
>
>    return 0;
>    }
>
> and found that the size-allocate callback was always called twice with the
> same parameters. For example, got the following when increasing the height:
>
>  szalloc (x,y)=(0,0) (w,h)=(250,181)
>  szalloc (x,y)=(0,0) (w,h)=(250,181)
>  szalloc (x,y)=(0,0) (w,h)=(250,182)
>  szalloc (x,y)=(0,0) (w,h)=(250,182)
>  szalloc (x,y)=(0,0) (w,h)=(250,183)
>  szalloc (x,y)=(0,0) (w,h)=(250,183)
>  szalloc (x,y)=(0,0) (w,h)=(250,184)
>  szalloc (x,y)=(0,0) (w,h)=(250,184)
>
> I don't understand why there is a second call. Of course I only need one.
> How can I stop the second?
>
> OR is there a better way, perhaps using different signals, to get
> width and height while resizing a window?
>
> Ken
>
>
>
>
>
>       Get your new Email address!
> Grab the Email name you've always wanted before someone else does!
> http://mail.promotions.yahoo.com/newdomains/aa/


New Email names for you!
Get the Email name you've always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux