1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.MainWindow;
26 
27 private import gdk.Event;
28 private import gtk.Main;
29 private import gtk.Widget;
30 private import gtk.Window;
31 private import gtkc.gtk;
32 public  import gtkc.gtktypes;
33 
34 
35 
36 /**
37  * A top Level window that will stop the main event cycle when it's closed.
38  * Closing the last of the windows of class "MainWindow" will end the application.
39  */
40 public class MainWindow : Window
41 {
42 	private static int countTotalMainWindows = 0;
43 	
44 	/**
45 	 * Creates a new MainWindow with a title
46 	 */
47 	public this(string title)
48 	{
49 		super(title);
50 		countTotalMainWindows++;
51 		//printf("MainWindows.this count = %d\n", countTotalMainWindows);
52 		addOnDelete(&windowDelete);
53 	}
54 	
55 	/**
56 	 * Executed when the user tries to close the window
57 	 * Returns: true to refuse to close the window
58 	 */
59 	protected bool windowDelete(Event event, Widget widget)
60 	{
61 		--countTotalMainWindows;
62 		//printf("MainWindows.windowDelete count = %d\n", countTotalMainWindows);
63 		if ( exit(0, false) || countTotalMainWindows==0 )
64 		{
65 			Main.quit();
66 			return false;
67 		}
68 		return false;
69 	}
70 	
71 	/**
72 	 * Allows the application to close and decide if it can exit
73 	 * Params:
74 	 *  code = the code reason to exit
75 	 *  force = if true the application must expect to be closed even against it's will
76 	 * Returns: false to refuse to exit
77 	 */
78 	protected bool exit(int code, bool force)
79 	{
80 		return force;
81 	}
82 }
83 
84 /**
85  */