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 /**
38  * A top Level window that will stop the main event cycle when it's closed.
39  * Closing the last of the windows of class "MainWindow" will end the application.
40  */
41 public class MainWindow : Window
42 {
43 	private static int countTotalMainWindows = 0;
44 	
45 	/**
46 	 * Creates a new MainWindow with a title
47 	 */
48 	public this(string title)
49 	{
50 		super(title);
51 		countTotalMainWindows++;
52 		//printf("MainWindows.this count = %d\n", countTotalMainWindows);
53 		addOnDelete(&windowDelete);
54 	}
55 	
56 	/**
57 	 * Executed when the user tries to close the window
58 	 * Returns: true to refuse to close the window
59 	 */
60 	protected bool windowDelete(Event event, Widget widget)
61 	{
62 		--countTotalMainWindows;
63 		//printf("MainWindows.windowDelete count = %d\n", countTotalMainWindows);
64 		if ( exit(0, false) || countTotalMainWindows==0 )
65 		{
66 			Main.quit();
67 			return false;
68 		}
69 		return false;
70 	}
71 	
72 	/**
73 	 * Allows the application to close and decide if it can exit
74 	 * Params:
75 	 *  code = the code reason to exit
76 	 *  force = if true the application must expect to be closed even against it's will
77 	 * Returns: false to refuse to exit
78 	 */
79 	protected bool exit(int code, bool force)
80 	{
81 		return force;
82 	}
83 }
84 
85 /**
86  */