/usr/include/d/gtkd-3/gtk/AccelMap.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gtk.AccelMap;
private import glib.ScannerG;
private import glib.Str;
private import gobject.ObjectG;
private import gobject.Signals;
private import gtk.c.functions;
public import gtk.c.types;
public import gtkc.gtktypes;
private import std.algorithm;
/**
* Accelerator maps are used to define runtime configurable accelerators.
* Functions for manipulating them are are usually used by higher level
* convenience mechanisms like #GtkUIManager and are thus considered
* “low-level”. You’ll want to use them if you’re manually creating menus that
* should have user-configurable accelerators.
*
* An accelerator is uniquely defined by:
* - accelerator path
* - accelerator key
* - accelerator modifiers
*
* The accelerator path must consist of
* “<WINDOWTYPE>/Category1/Category2/.../Action”, where WINDOWTYPE
* should be a unique application-specific identifier that corresponds
* to the kind of window the accelerator is being used in, e.g.
* “Gimp-Image”, “Abiword-Document” or “Gnumeric-Settings”.
* The “Category1/.../Action” portion is most appropriately chosen by
* the action the accelerator triggers, i.e. for accelerators on menu
* items, choose the item’s menu path, e.g. “File/Save As”,
* “Image/View/Zoom” or “Edit/Select All”. So a full valid accelerator
* path may look like: “<Gimp-Toolbox>/File/Dialogs/Tool Options...”.
*
* All accelerators are stored inside one global #GtkAccelMap that can
* be obtained using gtk_accel_map_get(). See
* [Monitoring changes][monitoring-changes] for additional
* details.
*
* # Manipulating accelerators
*
* New accelerators can be added using gtk_accel_map_add_entry().
* To search for specific accelerator, use gtk_accel_map_lookup_entry().
* Modifications of existing accelerators should be done using
* gtk_accel_map_change_entry().
*
* In order to avoid having some accelerators changed, they can be
* locked using gtk_accel_map_lock_path(). Unlocking is done using
* gtk_accel_map_unlock_path().
*
* # Saving and loading accelerator maps
*
* Accelerator maps can be saved to and loaded from some external
* resource. For simple saving and loading from file,
* gtk_accel_map_save() and gtk_accel_map_load() are provided.
* Saving and loading can also be done by providing file descriptor
* to gtk_accel_map_save_fd() and gtk_accel_map_load_fd().
*
* # Monitoring changes
*
* #GtkAccelMap object is only useful for monitoring changes of
* accelerators. By connecting to #GtkAccelMap::changed signal, one
* can monitor changes of all accelerators. It is also possible to
* monitor only single accelerator path by using it as a detail of
* the #GtkAccelMap::changed signal.
*/
public class AccelMap : ObjectG
{
/** the main Gtk struct */
protected GtkAccelMap* gtkAccelMap;
/** Get the main Gtk struct */
public GtkAccelMap* getAccelMapStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gtkAccelMap;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gtkAccelMap;
}
protected override void setStruct(GObject* obj)
{
gtkAccelMap = cast(GtkAccelMap*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GtkAccelMap* gtkAccelMap, bool ownedRef = false)
{
this.gtkAccelMap = gtkAccelMap;
super(cast(GObject*)gtkAccelMap, ownedRef);
}
/** */
public static GType getType()
{
return gtk_accel_map_get_type();
}
/**
* Registers a new accelerator with the global accelerator map.
* This function should only be called once per @accel_path
* with the canonical @accel_key and @accel_mods for this path.
* To change the accelerator during runtime programatically, use
* gtk_accel_map_change_entry().
*
* Set @accel_key and @accel_mods to 0 to request a removal of
* the accelerator.
*
* Note that @accel_path string will be stored in a #GQuark. Therefore, if you
* pass a static string, you can save some memory by interning it first with
* g_intern_static_string().
*
* Params:
* accelPath = valid accelerator path
* accelKey = the accelerator key
* accelMods = the accelerator modifiers
*/
public static void addEntry(string accelPath, uint accelKey, GdkModifierType accelMods)
{
gtk_accel_map_add_entry(Str.toStringz(accelPath), accelKey, accelMods);
}
/**
* Adds a filter to the global list of accel path filters.
*
* Accel map entries whose accel path matches one of the filters
* are skipped by gtk_accel_map_foreach().
*
* This function is intended for GTK+ modules that create their own
* menus, but don’t want them to be saved into the applications accelerator
* map dump.
*
* Params:
* filterPattern = a pattern (see #GPatternSpec)
*/
public static void addFilter(string filterPattern)
{
gtk_accel_map_add_filter(Str.toStringz(filterPattern));
}
/**
* Changes the @accel_key and @accel_mods currently associated with @accel_path.
* Due to conflicts with other accelerators, a change may not always be possible,
* @replace indicates whether other accelerators may be deleted to resolve such
* conflicts. A change will only occur if all conflicts could be resolved (which
* might not be the case if conflicting accelerators are locked). Successful
* changes are indicated by a %TRUE return value.
*
* Note that @accel_path string will be stored in a #GQuark. Therefore, if you
* pass a static string, you can save some memory by interning it first with
* g_intern_static_string().
*
* Params:
* accelPath = a valid accelerator path
* accelKey = the new accelerator key
* accelMods = the new accelerator modifiers
* replace = %TRUE if other accelerators may be deleted upon conflicts
*
* Returns: %TRUE if the accelerator could be changed, %FALSE otherwise
*/
public static bool changeEntry(string accelPath, uint accelKey, GdkModifierType accelMods, bool replace)
{
return gtk_accel_map_change_entry(Str.toStringz(accelPath), accelKey, accelMods, replace) != 0;
}
/**
* Loops over the entries in the accelerator map whose accel path
* doesn’t match any of the filters added with gtk_accel_map_add_filter(),
* and execute @foreach_func on each. The signature of @foreach_func is
* that of #GtkAccelMapForeach, the @changed parameter indicates whether
* this accelerator was changed during runtime (thus, would need
* saving during an accelerator map dump).
*
* Params:
* data = data to be passed into @foreach_func
* foreachFunc = function to be executed for each accel
* map entry which is not filtered out
*/
public static void foreac(void* data, GtkAccelMapForeach foreachFunc)
{
gtk_accel_map_foreach(data, foreachFunc);
}
/**
* Loops over all entries in the accelerator map, and execute
* @foreach_func on each. The signature of @foreach_func is that of
* #GtkAccelMapForeach, the @changed parameter indicates whether
* this accelerator was changed during runtime (thus, would need
* saving during an accelerator map dump).
*
* Params:
* data = data to be passed into @foreach_func
* foreachFunc = function to be executed for each accel
* map entry
*/
public static void foreachUnfiltered(void* data, GtkAccelMapForeach foreachFunc)
{
gtk_accel_map_foreach_unfiltered(data, foreachFunc);
}
/**
* Gets the singleton global #GtkAccelMap object. This object
* is useful only for notification of changes to the accelerator
* map via the ::changed signal; it isn’t a parameter to the
* other accelerator map functions.
*
* Returns: the global #GtkAccelMap object
*
* Since: 2.4
*/
public static AccelMap get()
{
auto p = gtk_accel_map_get();
if(p is null)
{
return null;
}
return ObjectG.getDObject!(AccelMap)(cast(GtkAccelMap*) p);
}
/**
* Parses a file previously saved with gtk_accel_map_save() for
* accelerator specifications, and propagates them accordingly.
*
* Params:
* fileName = a file containing accelerator specifications,
* in the GLib file name encoding
*/
public static void load(string fileName)
{
gtk_accel_map_load(Str.toStringz(fileName));
}
/**
* Filedescriptor variant of gtk_accel_map_load().
*
* Note that the file descriptor will not be closed by this function.
*
* Params:
* fd = a valid readable file descriptor
*/
public static void loadFd(int fd)
{
gtk_accel_map_load_fd(fd);
}
/**
* #GScanner variant of gtk_accel_map_load().
*
* Params:
* scanner = a #GScanner which has already been provided with an input file
*/
public static void loadScanner(ScannerG scanner)
{
gtk_accel_map_load_scanner((scanner is null) ? null : scanner.getScannerGStruct());
}
/**
* Locks the given accelerator path. If the accelerator map doesn’t yet contain
* an entry for @accel_path, a new one is created.
*
* Locking an accelerator path prevents its accelerator from being changed
* during runtime. A locked accelerator path can be unlocked by
* gtk_accel_map_unlock_path(). Refer to gtk_accel_map_change_entry()
* for information about runtime accelerator changes.
*
* If called more than once, @accel_path remains locked until
* gtk_accel_map_unlock_path() has been called an equivalent number
* of times.
*
* Note that locking of individual accelerator paths is independent from
* locking the #GtkAccelGroup containing them. For runtime accelerator
* changes to be possible, both the accelerator path and its #GtkAccelGroup
* have to be unlocked.
*
* Params:
* accelPath = a valid accelerator path
*
* Since: 2.4
*/
public static void lockPath(string accelPath)
{
gtk_accel_map_lock_path(Str.toStringz(accelPath));
}
/**
* Looks up the accelerator entry for @accel_path and fills in @key.
*
* Params:
* accelPath = a valid accelerator path
* key = the accelerator key to be filled in (optional)
*
* Returns: %TRUE if @accel_path is known, %FALSE otherwise
*/
public static bool lookupEntry(string accelPath, out GtkAccelKey key)
{
return gtk_accel_map_lookup_entry(Str.toStringz(accelPath), &key) != 0;
}
/**
* Saves current accelerator specifications (accelerator path, key
* and modifiers) to @file_name.
* The file is written in a format suitable to be read back in by
* gtk_accel_map_load().
*
* Params:
* fileName = the name of the file to contain
* accelerator specifications, in the GLib file name encoding
*/
public static void save(string fileName)
{
gtk_accel_map_save(Str.toStringz(fileName));
}
/**
* Filedescriptor variant of gtk_accel_map_save().
*
* Note that the file descriptor will not be closed by this function.
*
* Params:
* fd = a valid writable file descriptor
*/
public static void saveFd(int fd)
{
gtk_accel_map_save_fd(fd);
}
/**
* Undoes the last call to gtk_accel_map_lock_path() on this @accel_path.
* Refer to gtk_accel_map_lock_path() for information about accelerator path locking.
*
* Params:
* accelPath = a valid accelerator path
*
* Since: 2.4
*/
public static void unlockPath(string accelPath)
{
gtk_accel_map_unlock_path(Str.toStringz(accelPath));
}
protected class OnChangedDelegateWrapper
{
void delegate(string, uint, GdkModifierType, AccelMap) dlg;
gulong handlerId;
this(void delegate(string, uint, GdkModifierType, AccelMap) dlg)
{
this.dlg = dlg;
onChangedListeners ~= this;
}
void remove(OnChangedDelegateWrapper source)
{
foreach(index, wrapper; onChangedListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onChangedListeners[index] = null;
onChangedListeners = std.algorithm.remove(onChangedListeners, index);
break;
}
}
}
}
OnChangedDelegateWrapper[] onChangedListeners;
/**
* Notifies of a change in the global accelerator map.
* The path is also used as the detail for the signal,
* so it is possible to connect to
* changed::`accel_path`.
*
* Params:
* accelPath = the path of the accelerator that changed
* accelKey = the key value for the new accelerator
* accelMods = the modifier mask for the new accelerator
*
* Since: 2.4
*/
gulong addOnChanged(void delegate(string, uint, GdkModifierType, AccelMap) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnChangedDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"changed",
cast(GCallback)&callBackChanged,
cast(void*)wrapper,
cast(GClosureNotify)&callBackChangedDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackChanged(GtkAccelMap* accelmapStruct, char* accelPath, uint accelKey, GdkModifierType accelMods, OnChangedDelegateWrapper wrapper)
{
wrapper.dlg(Str.toString(accelPath), accelKey, accelMods, wrapper.outer);
}
extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
}
|