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 = GtkAccelLabel.html 27 * outPack = gtk 28 * outFile = AccelLabel 29 * strct = GtkAccelLabel 30 * realStrct= 31 * ctorStrct= 32 * clss = AccelLabel 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_accel_label_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gobject.Closure 48 * - gtk.Widget 49 * structWrap: 50 * - GClosure* -> Closure 51 * - GtkWidget* -> Widget 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gtk.AccelLabel; 58 59 public import gtkc.gtktypes; 60 61 private import gtkc.gtk; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 66 private import glib.Str; 67 private import gobject.Closure; 68 private import gtk.Widget; 69 70 71 72 private import gtk.Label; 73 74 /** 75 * The GtkAccelLabel widget is a subclass of GtkLabel that also displays an 76 * accelerator key on the right of the label text, e.g. 'Ctl+S'. 77 * It is commonly used in menus to show the keyboard short-cuts for commands. 78 * 79 * The accelerator key to display is not set explicitly. 80 * Instead, the GtkAccelLabel displays the accelerators which have been added to 81 * a particular widget. This widget is set by calling 82 * gtk_accel_label_set_accel_widget(). 83 * 84 * For example, a GtkMenuItem widget may have an accelerator added to emit the 85 * "activate" signal when the 'Ctl+S' key combination is pressed. 86 * A GtkAccelLabel is created and added to the GtkMenuItem, and 87 * gtk_accel_label_set_accel_widget() is called with the GtkMenuItem as the 88 * second argument. The GtkAccelLabel will now display 'Ctl+S' after its label. 89 * 90 * Note that creating a GtkMenuItem with gtk_menu_item_new_with_label() (or 91 * one of the similar functions for GtkCheckMenuItem and GtkRadioMenuItem) 92 * automatically adds a GtkAccelLabel to the GtkMenuItem and calls 93 * gtk_accel_label_set_accel_widget() to set it up for you. 94 * 95 * A GtkAccelLabel will only display accelerators which have GTK_ACCEL_VISIBLE 96 * set (see GtkAccelFlags). 97 * A GtkAccelLabel can display multiple accelerators and even signal names, 98 * though it is almost always used to display just one accelerator key. 99 * 100 * $(DDOC_COMMENT example) 101 */ 102 public class AccelLabel : Label 103 { 104 105 /** the main Gtk struct */ 106 protected GtkAccelLabel* gtkAccelLabel; 107 108 109 public GtkAccelLabel* getAccelLabelStruct() 110 { 111 return gtkAccelLabel; 112 } 113 114 115 /** the main Gtk struct as a void* */ 116 protected override void* getStruct() 117 { 118 return cast(void*)gtkAccelLabel; 119 } 120 121 /** 122 * Sets our main struct and passes it to the parent class 123 */ 124 public this (GtkAccelLabel* gtkAccelLabel) 125 { 126 super(cast(GtkLabel*)gtkAccelLabel); 127 this.gtkAccelLabel = gtkAccelLabel; 128 } 129 130 protected override void setStruct(GObject* obj) 131 { 132 super.setStruct(obj); 133 gtkAccelLabel = cast(GtkAccelLabel*)obj; 134 } 135 136 /** 137 */ 138 139 /** 140 * Creates a new GtkAccelLabel. 141 * Params: 142 * string = the label string. Must be non-NULL. 143 * Throws: ConstructionException GTK+ fails to create the object. 144 */ 145 public this (string string) 146 { 147 // GtkWidget * gtk_accel_label_new (const gchar *string); 148 auto p = gtk_accel_label_new(Str.toStringz(string)); 149 if(p is null) 150 { 151 throw new ConstructionException("null returned by gtk_accel_label_new(Str.toStringz(string))"); 152 } 153 this(cast(GtkAccelLabel*) p); 154 } 155 156 /** 157 * Sets the closure to be monitored by this accelerator label. The closure 158 * must be connected to an accelerator group; see gtk_accel_group_connect(). 159 * Params: 160 * accelClosure = the closure to monitor for accelerator changes. 161 */ 162 public void setAccelClosure(Closure accelClosure) 163 { 164 // void gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label, GClosure *accel_closure); 165 gtk_accel_label_set_accel_closure(gtkAccelLabel, (accelClosure is null) ? null : accelClosure.getClosureStruct()); 166 } 167 168 /** 169 * Fetches the widget monitored by this accelerator label. See 170 * gtk_accel_label_set_accel_widget(). 171 * Returns: the object monitored by the accelerator label, or NULL. [transfer none] 172 */ 173 public Widget getAccelWidget() 174 { 175 // GtkWidget * gtk_accel_label_get_accel_widget (GtkAccelLabel *accel_label); 176 auto p = gtk_accel_label_get_accel_widget(gtkAccelLabel); 177 178 if(p is null) 179 { 180 return null; 181 } 182 183 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 184 } 185 186 /** 187 * Sets the widget to be monitored by this accelerator label. 188 * Params: 189 * accelWidget = the widget to be monitored. 190 */ 191 public void setAccelWidget(Widget accelWidget) 192 { 193 // void gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label, GtkWidget *accel_widget); 194 gtk_accel_label_set_accel_widget(gtkAccelLabel, (accelWidget is null) ? null : accelWidget.getWidgetStruct()); 195 } 196 197 /** 198 * Returns the width needed to display the accelerator key(s). 199 * This is used by menus to align all of the GtkMenuItem widgets, and shouldn't 200 * be needed by applications. 201 * Returns: the width needed to display the accelerator key(s). 202 */ 203 public uint getAccelWidth() 204 { 205 // guint gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label); 206 return gtk_accel_label_get_accel_width(gtkAccelLabel); 207 } 208 209 /** 210 * Manually sets a keyval and modifier mask as the accelerator rendered 211 * by accel_label. 212 * If a keyval and modifier are explicitly set then these values are 213 * used regardless of any associated accel closure or widget. 214 * Providing an accelerator_key of 0 removes the manual setting. 215 * Params: 216 * acceleratorKey = a keyval, or 0 217 * acceleratorMods = the modifier mask for the accel 218 * Since 3.6 219 */ 220 public void setAccel(uint acceleratorKey, GdkModifierType acceleratorMods) 221 { 222 // void gtk_accel_label_set_accel (GtkAccelLabel *accel_label, guint accelerator_key, GdkModifierType accelerator_mods); 223 gtk_accel_label_set_accel(gtkAccelLabel, acceleratorKey, acceleratorMods); 224 } 225 226 /** 227 * Recreates the string representing the accelerator keys. 228 * This should not be needed since the string is automatically updated whenever 229 * accelerators are added or removed from the associated widget. 230 * Returns: always returns FALSE. 231 */ 232 public int refetch() 233 { 234 // gboolean gtk_accel_label_refetch (GtkAccelLabel *accel_label); 235 return gtk_accel_label_refetch(gtkAccelLabel); 236 } 237 }