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 = GtkStatusbar.html 27 * outPack = gtk 28 * outFile = Statusbar 29 * strct = GtkStatusbar 30 * realStrct= 31 * ctorStrct= 32 * clss = Statusbar 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_statusbar_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - gtk_statusbar_get_message_area 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtk.Box 49 * - gtk.Widget 50 * structWrap: 51 * - GtkWidget* -> Widget 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gtk.Statusbar; 58 59 public import gtkc.gtktypes; 60 61 private import gtkc.gtk; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 private import gobject.Signals; 66 public import gtkc.gdktypes; 67 68 private import glib.Str; 69 private import gtk.Box; 70 private import gtk.Widget; 71 72 73 74 private import gtk.Box; 75 76 /** 77 * A GtkStatusbar is usually placed along the bottom of an application's 78 * main GtkWindow. It may provide a regular commentary of the application's 79 * status (as is usually the case in a web browser, for example), or may be 80 * used to simply output a message when the status changes, (when an upload 81 * is complete in an FTP client, for example). 82 * 83 * Status bars in GTK+ maintain a stack of messages. The message at 84 * the top of the each bar's stack is the one that will currently be displayed. 85 * 86 * Any messages added to a statusbar's stack must specify a 87 * context id that is used to uniquely identify 88 * the source of a message. This context id can be generated by 89 * gtk_statusbar_get_context_id(), given a message and the statusbar that 90 * it will be added to. Note that messages are stored in a stack, and when 91 * choosing which message to display, the stack structure is adhered to, 92 * regardless of the context identifier of a message. 93 * 94 * One could say that a statusbar maintains one stack of messages for 95 * display purposes, but allows multiple message producers to maintain 96 * sub-stacks of the messages they produced (via context ids). 97 * 98 * Status bars are created using gtk_statusbar_new(). 99 * 100 * Messages are added to the bar's stack with gtk_statusbar_push(). 101 * 102 * The message at the top of the stack can be removed using 103 * gtk_statusbar_pop(). A message can be removed from anywhere in the 104 * stack if its message id was recorded at the time it was added. This 105 * is done using gtk_statusbar_remove(). 106 */ 107 public class Statusbar : Box 108 { 109 110 /** the main Gtk struct */ 111 protected GtkStatusbar* gtkStatusbar; 112 113 114 public GtkStatusbar* getStatusbarStruct() 115 { 116 return gtkStatusbar; 117 } 118 119 120 /** the main Gtk struct as a void* */ 121 protected override void* getStruct() 122 { 123 return cast(void*)gtkStatusbar; 124 } 125 126 /** 127 * Sets our main struct and passes it to the parent class 128 */ 129 public this (GtkStatusbar* gtkStatusbar) 130 { 131 super(cast(GtkBox*)gtkStatusbar); 132 this.gtkStatusbar = gtkStatusbar; 133 } 134 135 protected override void setStruct(GObject* obj) 136 { 137 super.setStruct(obj); 138 gtkStatusbar = cast(GtkStatusbar*)obj; 139 } 140 141 /** 142 * Retrieves the box containing the label widget. 143 * Since 2.20 144 * Returns: a GtkBox. [transfer none] 145 */ 146 public Box getMessageArea() 147 { 148 // GtkWidget * gtk_statusbar_get_message_area (GtkStatusbar *statusbar); 149 auto p = gtk_statusbar_get_message_area(gtkStatusbar); 150 if(p is null) 151 { 152 return null; 153 } 154 return new Box(cast(GtkBox*) p); 155 } 156 157 /** 158 */ 159 int[string] connectedSignals; 160 161 void delegate(guint, string, Statusbar)[] onTextPoppedListeners; 162 /** 163 * Is emitted whenever a new message is popped off a statusbar's stack. 164 */ 165 void addOnTextPopped(void delegate(guint, string, Statusbar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 166 { 167 if ( !("text-popped" in connectedSignals) ) 168 { 169 Signals.connectData( 170 getStruct(), 171 "text-popped", 172 cast(GCallback)&callBackTextPopped, 173 cast(void*)this, 174 null, 175 connectFlags); 176 connectedSignals["text-popped"] = 1; 177 } 178 onTextPoppedListeners ~= dlg; 179 } 180 extern(C) static void callBackTextPopped(GtkStatusbar* statusbarStruct, guint contextId, gchar* text, Statusbar _statusbar) 181 { 182 foreach ( void delegate(guint, string, Statusbar) dlg ; _statusbar.onTextPoppedListeners ) 183 { 184 dlg(contextId, Str.toString(text), _statusbar); 185 } 186 } 187 188 void delegate(guint, string, Statusbar)[] onTextPushedListeners; 189 /** 190 * Is emitted whenever a new message gets pushed onto a statusbar's stack. 191 */ 192 void addOnTextPushed(void delegate(guint, string, Statusbar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 193 { 194 if ( !("text-pushed" in connectedSignals) ) 195 { 196 Signals.connectData( 197 getStruct(), 198 "text-pushed", 199 cast(GCallback)&callBackTextPushed, 200 cast(void*)this, 201 null, 202 connectFlags); 203 connectedSignals["text-pushed"] = 1; 204 } 205 onTextPushedListeners ~= dlg; 206 } 207 extern(C) static void callBackTextPushed(GtkStatusbar* statusbarStruct, guint contextId, gchar* text, Statusbar _statusbar) 208 { 209 foreach ( void delegate(guint, string, Statusbar) dlg ; _statusbar.onTextPushedListeners ) 210 { 211 dlg(contextId, Str.toString(text), _statusbar); 212 } 213 } 214 215 216 /** 217 * Creates a new GtkStatusbar ready for messages. 218 * Throws: ConstructionException GTK+ fails to create the object. 219 */ 220 public this () 221 { 222 // GtkWidget * gtk_statusbar_new (void); 223 auto p = gtk_statusbar_new(); 224 if(p is null) 225 { 226 throw new ConstructionException("null returned by gtk_statusbar_new()"); 227 } 228 this(cast(GtkStatusbar*) p); 229 } 230 231 /** 232 * Returns a new context identifier, given a description 233 * of the actual context. Note that the description is 234 * not shown in the UI. 235 * Params: 236 * contextDescription = textual description of what context 237 * the new message is being used in 238 * Returns: an integer id 239 */ 240 public uint getContextId(string contextDescription) 241 { 242 // guint gtk_statusbar_get_context_id (GtkStatusbar *statusbar, const gchar *context_description); 243 return gtk_statusbar_get_context_id(gtkStatusbar, Str.toStringz(contextDescription)); 244 } 245 246 /** 247 * Pushes a new message onto a statusbar's stack. 248 * Params: 249 * contextId = the message's context id, as returned by 250 * gtk_statusbar_get_context_id() 251 * text = the message to add to the statusbar 252 * Returns: a message id that can be used with gtk_statusbar_remove(). 253 */ 254 public uint push(uint contextId, string text) 255 { 256 // guint gtk_statusbar_push (GtkStatusbar *statusbar, guint context_id, const gchar *text); 257 return gtk_statusbar_push(gtkStatusbar, contextId, Str.toStringz(text)); 258 } 259 260 /** 261 * Removes the first message in the GtkStatusbar's stack 262 * with the given context id. 263 * Note that this may not change the displayed message, if 264 * the message at the top of the stack has a different 265 * context id. 266 * Params: 267 * contextId = a context identifier 268 */ 269 public void pop(uint contextId) 270 { 271 // void gtk_statusbar_pop (GtkStatusbar *statusbar, guint context_id); 272 gtk_statusbar_pop(gtkStatusbar, contextId); 273 } 274 275 /** 276 * Forces the removal of a message from a statusbar's stack. 277 * The exact context_id and message_id must be specified. 278 * Params: 279 * contextId = a context identifier 280 * messageId = a message identifier, as returned by gtk_statusbar_push() 281 */ 282 public void remove(uint contextId, uint messageId) 283 { 284 // void gtk_statusbar_remove (GtkStatusbar *statusbar, guint context_id, guint message_id); 285 gtk_statusbar_remove(gtkStatusbar, contextId, messageId); 286 } 287 288 /** 289 * Forces the removal of all messages from a statusbar's 290 * stack with the exact context_id. 291 * Since 2.22 292 * Params: 293 * contextId = a context identifier 294 */ 295 public void removeAll(uint contextId) 296 { 297 // void gtk_statusbar_remove_all (GtkStatusbar *statusbar, guint context_id); 298 gtk_statusbar_remove_all(gtkStatusbar, contextId); 299 } 300 }