Date: Tue, 6 Jun 2006 09:08:51 +0200 From: Maxence Guesdon To: David MENTRE Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: How to automatically save windows position/size? Message-ID: <20060606090851.0ac114be at tintin.inria.fr> In-Reply-To: <87ac8rze8p.fsf at linux-france.org> References: <87ac8rze8p.fsf at linux-france.org> Organization: INRIA Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Content-Length: 1596 On Mon, 05 Jun 2006 19:47:18 +0200 David MENTRE wrote: > Hello, Hello, > I would like to add automatic saving of windows position and size in my > Lablgtk application: windows are restored to the size and position as > set at the previous application launch. > > I looked at GTK web site but did not succeed in finding a way to do > that. Any hint? Here's how i do in cameleon2: let handle_window win name = let (x,y) = Gdk.Window.get_position win#misc#window in let (w,h) = Gdk.Drawable.get_size win#misc#window in ignore (win#event#connect#configure (fun _ -> let (x,y) = Gdk.Window.get_position win#misc#window in let (w,h) = Gdk.Drawable.get_size win#misc#window in (* update internal information : *) set_window_info name (w,h,x,y); (* save gui information in a file *) save_gui (); false ) ); let (width,height,x,y) = try (* retrieve internal information about this window name *) get_window_info name with Not_found -> (w,h,x,y) in win#move ~x ~y ; win#resize ~width ~height So, I store the position and size information about each "named" window every time it changes, so it is kept aven if the application crashes. (the name is specific to my application, it must be unique). I ommited some details about handling the possible offset of x and y due to the window manager. Hope this helps, Maxence -- Maxence Guesdon http://yquem.inria.fr/~guesdon/ http://devel.inria.fr/rocq/