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

(setting and getting window sizes) Final solution



OK, I have got the solution about this problem (I think).
At least the code does work on my system.
My suggestion is to set window policy as:

gtk_window_set_policy( GTK_WINDOW( mywindow ), FALSE, TRUE, FALSE );

and use 

gtk_window_set_default_size(GtkWindow   *window,
			     gint         width,
			     gint         height)

to set the default size of the window. while:

gtk_widget_set_usize (GtkWidget *widget,
		      gint	 width,
		      gint	 height)

can be used to setting the minimum allowable size of the window, windows
manager can not resize the window smaller than this size. But it can be 
resized smaller than the default size. This is quite useful, if you do
not use gtk_widget_set_usize() to set the minimum size, the system will
compute a minimum size for you, it is OK.

if you want to get the window size, you can connect the "size_allocate"
signal with a callback function like this:

static int window_resize_callback(GtkWidget *w, 
				GtkAllocation *size, 
				gpointer data);
{
	g_message("x = %d, y = %d, width = %d, height = %d, data = %x\n",
			  size->x,size->y,size->width,size->height,data);
	return 0;
}

it does work on my system.

when can we add this problem to our FAQ?

BTW: I don't like to use session manager to do these things for me.
First, I'd like to let my program run well on all the systems no matter
have session manager or not. Second, my session manager never work 
properly as I see. It did nothing useful but launch 8 netscape window,
32 xterm, 4 login , 6 xosview window for me. So now I wrote a shell 
script to do this:

cp ~/.gnome/session.bak ~/.gnome/session
gnome-session&

It is OK now. :)

-- 
 
 No brain, no pain.



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