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