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  * Conversion parameters:
26  * inFile  = 
27  * outPack = gtk
28  * outFile = MainWindow
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = 
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * omit structs:
41  * omit prefixes:
42  * omit code:
43  * omit signals:
44  * imports:
45  * 	- gtk.Widget
46  * 	- gtk.Window
47  * 	- gtk.Main
48  * 	- gdk.Event
49  * structWrap:
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gtk.MainWindow;
56 
57 public  import gtkc.gtktypes;
58 
59 private import gtkc.gtk;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 
64 private import gtk.Widget;
65 private import gtk.Window;
66 private import gtk.Main;
67 private import gdk.Event;
68 
69 
70 
71 
72 /**
73  * A top Level window that will stop the main event cycle when it's closed.
74  * Closing the last of the windows of class "MainWindow" will end the application.
75  */
76 public class MainWindow : Window
77 {
78 	
79 	private static int countTotalMainWindows = 0;
80 	
81 	/**
82 	 * Creates a new MainWindow with a title
83 	 */
84 	public this(string title)
85 	{
86 		super(title);
87 		countTotalMainWindows++;
88 		//printf("MainWindows.this count = %d\n", countTotalMainWindows);
89 		addOnDelete(&windowDelete);
90 	}
91 	
92 	/**
93 	 * Executed when the user tries to close the window
94 	 * Returns: true to refuse to close the window
95 	 */
96 	protected bool windowDelete(Event event, Widget widget)
97 	{
98 		--countTotalMainWindows;
99 		//printf("MainWindows.windowDelete count = %d\n", countTotalMainWindows);
100 		if ( exit(0, false) || countTotalMainWindows==0 )
101 		{
102 			Main.quit();
103 			return false;
104 		}
105 		return false;
106 	}
107 	
108 	/**
109 	 * Allows the application to close and decide if it can exit
110 	 * Params:
111 	 *  code = the code reason to exit
112 	 *  force = if true the application must expect to be closed even against it's will
113 	 * Returns: false to refuse to exit
114 	 */
115 	protected bool exit(int code, bool force)
116 	{
117 		return force;
118 	}
119 }
120 
121 /**
122  */
123