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