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 private import gtk.Widget;
64 private import gtk.Window;
65 private import gtk.Main;
66 private import gdk.Event;
67 
68 
69 
70 /**
71  * A top Level window that will stop the main event cycle when it's closed.
72  * Closing the last of the windows of class "MainWindow" will end the application.
73  */
74 public class MainWindow : Window
75 {
76 	
77 	private static int countTotalMainWindows = 0;
78 	
79 	/**
80 	 * Creates a new MainWindow with a title
81 	 */
82 	public this(string title)
83 	{
84 		super(title);
85 		countTotalMainWindows++;
86 		//printf("MainWindows.this count = %d\n", countTotalMainWindows);
87 		addOnDelete(&windowDelete);
88 	}
89 	
90 	/**
91 	 * Executed when the user tries to close the window
92 	 * Returns: true to refuse to close the window
93 	 */
94 	protected bool windowDelete(Event event, Widget widget)
95 	{
96 		--countTotalMainWindows;
97 		//printf("MainWindows.windowDelete count = %d\n", countTotalMainWindows);
98 		if ( exit(0, false) || countTotalMainWindows==0 )
99 		{
100 			Main.quit();
101 			return false;
102 		}
103 		return false;
104 	}
105 	
106 	/**
107 	 * Allows the application to close and decide if it can exit
108 	 * Params:
109 	 *  code = the code reason to exit
110 	 *  force = if true the application must expect to be closed even against it's will
111 	 * Returns: false to refuse to exit
112 	 */
113 	protected bool exit(int code, bool force)
114 	{
115 		return force;
116 	}
117 }
118 
119 /**
120  */
121