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