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 = gtk-Accelerator-Maps.html 27 * outPack = gtk 28 * outFile = AccelMap 29 * strct = GtkAccelMap 30 * realStrct= 31 * ctorStrct= 32 * clss = AccelMap 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_accel_map_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ScannerG 49 * - gtk.AccelMap 50 * structWrap: 51 * - GScanner* -> ScannerG 52 * - GtkAccelMap* -> AccelMap 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gtk.AccelMap; 59 60 public import gtkc.gtktypes; 61 62 private import gtkc.gtk; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 private import gobject.Signals; 67 public import gtkc.gdktypes; 68 69 private import glib.Str; 70 private import glib.ScannerG; 71 private import gtk.AccelMap; 72 73 74 75 private import gobject.ObjectG; 76 77 /** 78 * Description 79 */ 80 public class AccelMap : ObjectG 81 { 82 83 /** the main Gtk struct */ 84 protected GtkAccelMap* gtkAccelMap; 85 86 87 public GtkAccelMap* getAccelMapStruct() 88 { 89 return gtkAccelMap; 90 } 91 92 93 /** the main Gtk struct as a void* */ 94 protected override void* getStruct() 95 { 96 return cast(void*)gtkAccelMap; 97 } 98 99 /** 100 * Sets our main struct and passes it to the parent class 101 */ 102 public this (GtkAccelMap* gtkAccelMap) 103 { 104 super(cast(GObject*)gtkAccelMap); 105 this.gtkAccelMap = gtkAccelMap; 106 } 107 108 protected override void setStruct(GObject* obj) 109 { 110 super.setStruct(obj); 111 gtkAccelMap = cast(GtkAccelMap*)obj; 112 } 113 114 /** 115 */ 116 int[string] connectedSignals; 117 118 void delegate(string, guint, GdkModifierType, AccelMap)[] onChangedListeners; 119 /** 120 * Notifies of a change in the global accelerator map. 121 * The path is also used as the detail for the signal, 122 * so it is possible to connect to 123 * changed::accel_path. 124 * Since 2.4 125 */ 126 void addOnChanged(void delegate(string, guint, GdkModifierType, AccelMap) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 127 { 128 if ( !("changed" in connectedSignals) ) 129 { 130 Signals.connectData( 131 getStruct(), 132 "changed", 133 cast(GCallback)&callBackChanged, 134 cast(void*)this, 135 null, 136 connectFlags); 137 connectedSignals["changed"] = 1; 138 } 139 onChangedListeners ~= dlg; 140 } 141 extern(C) static void callBackChanged(GtkAccelMap* objectStruct, gchar* accelPath, guint accelKey, GdkModifierType accelMods, AccelMap _accelMap) 142 { 143 foreach ( void delegate(string, guint, GdkModifierType, AccelMap) dlg ; _accelMap.onChangedListeners ) 144 { 145 dlg(Str.toString(accelPath), accelKey, accelMods, _accelMap); 146 } 147 } 148 149 150 /** 151 * Registers a new accelerator with the global accelerator map. 152 * This function should only be called once per accel_path 153 * with the canonical accel_key and accel_mods for this path. 154 * To change the accelerator during runtime programatically, use 155 * gtk_accel_map_change_entry(). 156 * The accelerator path must consist of "<WINDOWTYPE>/Category1/Category2/.../Action", 157 * where <WINDOWTYPE> should be a unique application-specific identifier, that 158 * corresponds to the kind of window the accelerator is being used in, e.g. "Gimp-Image", 159 * "Abiword-Document" or "Gnumeric-Settings". 160 * The Category1/.../Action portion is most appropriately chosen by the action the 161 * accelerator triggers, i.e. for accelerators on menu items, choose the item's menu path, 162 * e.g. "File/Save As", "Image/View/Zoom" or "Edit/Select All". 163 * Params: 164 * accelPath = valid accelerator path 165 * accelKey = the accelerator key 166 * accelMods = the accelerator modifiers 167 */ 168 public static void addEntry(string accelPath, uint accelKey, GdkModifierType accelMods) 169 { 170 // void gtk_accel_map_add_entry (const gchar *accel_path, guint accel_key, GdkModifierType accel_mods); 171 gtk_accel_map_add_entry(Str.toStringz(accelPath), accelKey, accelMods); 172 } 173 174 /** 175 * Looks up the accelerator entry for accel_path and fills in key. 176 * Params: 177 * accelPath = a valid accelerator path 178 * key = the accelerator key to be filled in (optional) 179 * Returns: TRUE if accel_path is known, FALSE otherwise 180 */ 181 public static int lookupEntry(string accelPath, out GtkAccelKey key) 182 { 183 // gboolean gtk_accel_map_lookup_entry (const gchar *accel_path, GtkAccelKey *key); 184 return gtk_accel_map_lookup_entry(Str.toStringz(accelPath), &key); 185 } 186 187 /** 188 * Changes the accel_key and accel_mods currently associated with accel_path. 189 * Due to conflicts with other accelerators, a change may not always be possible, 190 * replace indicates whether other accelerators may be deleted to resolve such 191 * conflicts. A change will only occur if all conflicts could be resolved (which 192 * might not be the case if conflicting accelerators are locked). Successful 193 * changes are indicated by a TRUE return value. 194 * Note that accel_path string will be stored in a GQuark. Therefore, if you 195 * pass a static string, you can save some memory by interning it first with 196 * g_intern_static_string(). 197 * Params: 198 * accelPath = a valid accelerator path 199 * accelKey = the new accelerator key 200 * accelMods = the new accelerator modifiers 201 * replace = TRUE if other accelerators may be deleted upon conflicts 202 * Returns: TRUE if the accelerator could be changed, FALSE otherwise 203 */ 204 public static int changeEntry(string accelPath, uint accelKey, GdkModifierType accelMods, int replace) 205 { 206 // gboolean gtk_accel_map_change_entry (const gchar *accel_path, guint accel_key, GdkModifierType accel_mods, gboolean replace); 207 return gtk_accel_map_change_entry(Str.toStringz(accelPath), accelKey, accelMods, replace); 208 } 209 210 /** 211 * Parses a file previously saved with gtk_accel_map_save() for 212 * accelerator specifications, and propagates them accordingly. 213 * Params: 214 * fileName = a file containing accelerator specifications, 215 * in the GLib file name encoding 216 */ 217 public static void load(string fileName) 218 { 219 // void gtk_accel_map_load (const gchar *file_name); 220 gtk_accel_map_load(Str.toStringz(fileName)); 221 } 222 223 /** 224 * Saves current accelerator specifications (accelerator path, key 225 * and modifiers) to file_name. 226 * The file is written in a format suitable to be read back in by 227 * gtk_accel_map_load(). 228 * Params: 229 * fileName = the name of the file to contain accelerator specifications, 230 * in the GLib file name encoding 231 */ 232 public static void save(string fileName) 233 { 234 // void gtk_accel_map_save (const gchar *file_name); 235 gtk_accel_map_save(Str.toStringz(fileName)); 236 } 237 238 /** 239 * Loops over the entries in the accelerator map whose accel path 240 * doesn't match any of the filters added with gtk_accel_map_add_filter(), 241 * and execute foreach_func on each. The signature of foreach_func is 242 * that of GtkAccelMapForeach, the changed parameter indicates whether 243 * this accelerator was changed during runtime (thus, would need 244 * saving during an accelerator map dump). 245 * Params: 246 * data = data to be passed into foreach_func 247 * foreachFunc = function to be executed for each accel map entry which 248 * is not filtered out 249 */ 250 public static void foreac(void* data, GtkAccelMapForeach foreachFunc) 251 { 252 // void gtk_accel_map_foreach (gpointer data, GtkAccelMapForeach foreach_func); 253 gtk_accel_map_foreach(data, foreachFunc); 254 } 255 256 /** 257 * Filedescriptor variant of gtk_accel_map_load(). 258 * Note that the file descriptor will not be closed by this function. 259 * Params: 260 * fd = a valid readable file descriptor 261 */ 262 public static void loadFd(int fd) 263 { 264 // void gtk_accel_map_load_fd (gint fd); 265 gtk_accel_map_load_fd(fd); 266 } 267 268 /** 269 * Filedescriptor variant of gtk_accel_map_save(). 270 * Note that the file descriptor will not be closed by this function. 271 * Params: 272 * fd = a valid writable file descriptor 273 */ 274 public static void saveFd(int fd) 275 { 276 // void gtk_accel_map_save_fd (gint fd); 277 gtk_accel_map_save_fd(fd); 278 } 279 280 /** 281 * GScanner variant of gtk_accel_map_load(). 282 * Params: 283 * scanner = a GScanner which has already been provided with an input file 284 */ 285 public static void loadScanner(ScannerG scanner) 286 { 287 // void gtk_accel_map_load_scanner (GScanner *scanner); 288 gtk_accel_map_load_scanner((scanner is null) ? null : scanner.getScannerGStruct()); 289 } 290 291 /** 292 * Adds a filter to the global list of accel path filters. 293 * Accel map entries whose accel path matches one of the filters 294 * are skipped by gtk_accel_map_foreach(). 295 * This function is intended for GTK+ modules that create their own 296 * menus, but don't want them to be saved into the applications accelerator 297 * map dump. 298 * Params: 299 * filterPattern = a pattern (see GPatternSpec) 300 */ 301 public static void addFilter(string filterPattern) 302 { 303 // void gtk_accel_map_add_filter (const gchar *filter_pattern); 304 gtk_accel_map_add_filter(Str.toStringz(filterPattern)); 305 } 306 307 /** 308 * Loops over all entries in the accelerator map, and execute 309 * foreach_func on each. The signature of foreach_func is that of 310 * GtkAccelMapForeach, the changed parameter indicates whether 311 * this accelerator was changed during runtime (thus, would need 312 * saving during an accelerator map dump). 313 * Params: 314 * data = data to be passed into foreach_func 315 * foreachFunc = function to be executed for each accel map entry 316 */ 317 public static void foreachUnfiltered(void* data, GtkAccelMapForeach foreachFunc) 318 { 319 // void gtk_accel_map_foreach_unfiltered (gpointer data, GtkAccelMapForeach foreach_func); 320 gtk_accel_map_foreach_unfiltered(data, foreachFunc); 321 } 322 323 /** 324 * Gets the singleton global GtkAccelMap object. This object 325 * is useful only for notification of changes to the accelerator 326 * map via the ::changed signal; it isn't a parameter to the 327 * other accelerator map functions. 328 * Since 2.4 329 * Returns: the global GtkAccelMap object 330 */ 331 public static AccelMap get() 332 { 333 // GtkAccelMap * gtk_accel_map_get (void); 334 auto p = gtk_accel_map_get(); 335 336 if(p is null) 337 { 338 return null; 339 } 340 341 return ObjectG.getDObject!(AccelMap)(cast(GtkAccelMap*) p); 342 } 343 344 /** 345 * Locks the given accelerator path. If the accelerator map doesn't yet contain 346 * an entry for accel_path, a new one is created. 347 * Locking an accelerator path prevents its accelerator from being changed 348 * during runtime. A locked accelerator path can be unlocked by 349 * gtk_accel_map_unlock_path(). Refer to gtk_accel_map_change_entry() 350 * for information about runtime accelerator changes. 351 * If called more than once, accel_path remains locked until 352 * gtk_accel_map_unlock_path() has been called an equivalent number 353 * of times. 354 * Note that locking of individual accelerator paths is independent from 355 * locking the GtkAccelGroup containing them. For runtime accelerator 356 * changes to be possible both the accelerator path and its GtkAccelGroup 357 * have to be unlocked. 358 * Since 2.4 359 * Params: 360 * accelPath = a valid accelerator path 361 */ 362 public static void lockPath(string accelPath) 363 { 364 // void gtk_accel_map_lock_path (const gchar *accel_path); 365 gtk_accel_map_lock_path(Str.toStringz(accelPath)); 366 } 367 368 /** 369 * Undoes the last call to gtk_accel_map_lock_path() on this accel_path. 370 * Refer to gtk_accel_map_lock_path() for information about accelerator path locking. 371 * Since 2.4 372 * Signal Details 373 * The "changed" signal 374 * void user_function (GtkAccelMap *object, 375 * gchar *accel_path, 376 * guint accel_key, 377 * GdkModifierType accel_mods, 378 * gpointer user_data) : Run Last / Has Details 379 * Notifies of a change in the global accelerator map. 380 * The path is also used as the detail for the signal, 381 * so it is possible to connect to 382 * changed::accel_path. 383 * Since 2.4 384 * Params: 385 * accelPath = a valid accelerator path 386 * accelPath = the path of the accelerator that changed 387 */ 388 public static void unlockPath(string accelPath) 389 { 390 // void gtk_accel_map_unlock_path (const gchar *accel_path); 391 gtk_accel_map_unlock_path(Str.toStringz(accelPath)); 392 } 393 }