1 /* 2 * This file is part of d-handy. 3 * 4 * d-handy 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 * d-handy 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 d-handy; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module handy.Dialog; 20 21 private import glib.ConstructionException; 22 private import gobject.ObjectG; 23 private import gtk.BuildableIF; 24 private import gtk.BuildableT; 25 private import gtk.Dialog : GtkDiag = Dialog; 26 private import gtk.Widget; 27 private import gtk.Window; 28 private import handy.c.functions; 29 public import handy.c.types; 30 31 32 /** */ 33 public class Dialog : GtkDiag 34 { 35 /** the main Gtk struct */ 36 protected HdyDialog* hdyDialog; 37 38 /** Get the main Gtk struct */ 39 public HdyDialog* getHandyDialogStruct(bool transferOwnership = false) 40 { 41 if (transferOwnership) 42 ownedRef = false; 43 return hdyDialog; 44 } 45 46 /** the main Gtk struct as a void* */ 47 protected override void* getStruct() 48 { 49 return cast(void*)hdyDialog; 50 } 51 52 /** 53 * Sets our main struct and passes it to the parent class. 54 */ 55 public this (HdyDialog* hdyDialog, bool ownedRef = false) 56 { 57 this.hdyDialog = hdyDialog; 58 super(cast(GtkDialog*)hdyDialog, ownedRef); 59 } 60 61 62 /** */ 63 public static GType getType() 64 { 65 return hdy_dialog_get_type(); 66 } 67 68 /** 69 * Create a #HdyDialog with #GtkWindow:transient-for set to parent 70 * 71 * C Usage 72 * |[<!-- language="C" --> 73 * GtkWidget *dlg = hdy_dialog_new (GTK_WINDOW (main_window)); 74 * ]| 75 * 76 * Vala Usage 77 * |[<!-- language="Vala" --> 78 * var dlg = new Hdy.Dialog (main_window); 79 * ]| 80 * 81 * Python Usage 82 * |[<!-- language="Python" --> 83 * dlg = Handy.Dialog.new (main_window); 84 * ]| 85 * 86 * Params: 87 * parent = #GtkWindow this dialog is a child of 88 * 89 * Since: 0.0.7 90 * 91 * Throws: ConstructionException GTK+ fails to create the object. 92 */ 93 public this(Window parent) 94 { 95 auto p = hdy_dialog_new((parent is null) ? null : parent.getWindowStruct()); 96 97 if(p is null) 98 { 99 throw new ConstructionException("null returned by new"); 100 } 101 102 this(cast(HdyDialog*) p); 103 } 104 105 /** 106 * Gets whether @self is narrow. 107 * 108 * Returns: %TRUE if @self is narrow, %FALSE otherwise. 109 * 110 * Since: 0.0.11 111 */ 112 public bool getNarrow() 113 { 114 return hdy_dialog_get_narrow(hdyDialog) != 0; 115 } 116 }