1 /* 2 * This file is part of d-dazzle. 3 * 4 * d-dazzle 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-dazzle 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-dazzle; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module dazzle.SimplePopover; 20 21 private import dazzle.c.functions; 22 public import dazzle.c.types; 23 private import glib.ConstructionException; 24 private import glib.Str; 25 private import gobject.ObjectG; 26 private import gobject.Signals; 27 private import gtk.BuildableIF; 28 private import gtk.BuildableT; 29 private import gtk.Popover; 30 private import gtk.Widget; 31 private import std.algorithm; 32 33 34 /** */ 35 public class SimplePopover : Popover 36 { 37 /** the main Gtk struct */ 38 protected DzlSimplePopover* dzlSimplePopover; 39 40 /** Get the main Gtk struct */ 41 public DzlSimplePopover* getSimplePopoverStruct(bool transferOwnership = false) 42 { 43 if (transferOwnership) 44 ownedRef = false; 45 return dzlSimplePopover; 46 } 47 48 /** the main Gtk struct as a void* */ 49 protected override void* getStruct() 50 { 51 return cast(void*)dzlSimplePopover; 52 } 53 54 /** 55 * Sets our main struct and passes it to the parent class. 56 */ 57 public this (DzlSimplePopover* dzlSimplePopover, bool ownedRef = false) 58 { 59 this.dzlSimplePopover = dzlSimplePopover; 60 super(cast(GtkPopover*)dzlSimplePopover, ownedRef); 61 } 62 63 64 /** */ 65 public static GType getType() 66 { 67 return dzl_simple_popover_get_type(); 68 } 69 70 /** */ 71 public this() 72 { 73 auto p = dzl_simple_popover_new(); 74 75 if(p is null) 76 { 77 throw new ConstructionException("null returned by new"); 78 } 79 80 this(cast(DzlSimplePopover*) p); 81 } 82 83 /** */ 84 public string getButtonText() 85 { 86 return Str.toString(dzl_simple_popover_get_button_text(dzlSimplePopover)); 87 } 88 89 /** */ 90 public string getMessage() 91 { 92 return Str.toString(dzl_simple_popover_get_message(dzlSimplePopover)); 93 } 94 95 /** */ 96 public bool getReady() 97 { 98 return dzl_simple_popover_get_ready(dzlSimplePopover) != 0; 99 } 100 101 /** */ 102 public string getText() 103 { 104 return Str.toString(dzl_simple_popover_get_text(dzlSimplePopover)); 105 } 106 107 /** */ 108 public string getTitle() 109 { 110 return Str.toString(dzl_simple_popover_get_title(dzlSimplePopover)); 111 } 112 113 /** */ 114 public void setButtonText(string buttonText) 115 { 116 dzl_simple_popover_set_button_text(dzlSimplePopover, Str.toStringz(buttonText)); 117 } 118 119 /** */ 120 public void setMessage(string message) 121 { 122 dzl_simple_popover_set_message(dzlSimplePopover, Str.toStringz(message)); 123 } 124 125 /** */ 126 public void setReady(bool ready) 127 { 128 dzl_simple_popover_set_ready(dzlSimplePopover, ready); 129 } 130 131 /** */ 132 public void setText(string text) 133 { 134 dzl_simple_popover_set_text(dzlSimplePopover, Str.toStringz(text)); 135 } 136 137 /** */ 138 public void setTitle(string title) 139 { 140 dzl_simple_popover_set_title(dzlSimplePopover, Str.toStringz(title)); 141 } 142 143 /** 144 * This signal is emitted when the popover's forward button is activated. 145 * Connect to this signal to perform your forward progress. 146 * 147 * Params: 148 * text = The text at the time of activation. 149 */ 150 gulong addOnActivate(void delegate(string, SimplePopover) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 151 { 152 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 153 } 154 155 /** 156 * This signal is emitted when the entry text changes. 157 */ 158 gulong addOnChanged(void delegate(SimplePopover) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 159 { 160 return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 161 } 162 163 /** 164 * Use this signal to determine if text should be allowed to be inserted 165 * into the text buffer. Return GDK_EVENT_STOP to prevent the text from 166 * being inserted. 167 * 168 * Params: 169 * position = the position in UTF-8 characters. 170 * chars = the NULL terminated UTF-8 text to insert. 171 * nChars = the number of UTF-8 characters in chars. 172 */ 173 gulong addOnInsertText(bool delegate(uint, string, uint, SimplePopover) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 174 { 175 return Signals.connect(this, "insert-text", dlg, connectFlags ^ ConnectFlags.SWAPPED); 176 } 177 }