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.ShortcutsWindow; 26 27 private import gobject.Signals; 28 private import gtk.Window; 29 private import gtk.c.functions; 30 public import gtk.c.types; 31 public import gtkc.gtktypes; 32 private import std.algorithm; 33 34 35 /** 36 * A GtkShortcutsWindow shows brief information about the keyboard shortcuts 37 * and gestures of an application. The shortcuts can be grouped, and you can 38 * have multiple sections in this window, corresponding to the major modes of 39 * your application. 40 * 41 * Additionally, the shortcuts can be filtered by the current view, to avoid 42 * showing information that is not relevant in the current application context. 43 * 44 * The recommended way to construct a GtkShortcutsWindow is with GtkBuilder, 45 * by populating a #GtkShortcutsWindow with one or more #GtkShortcutsSection 46 * objects, which contain #GtkShortcutsGroups that in turn contain objects of 47 * class #GtkShortcutsShortcut. 48 * 49 * # A simple example: 50 * 51 * ![](gedit-shortcuts.png) 52 * 53 * This example has as single section. As you can see, the shortcut groups 54 * are arranged in columns, and spread across several pages if there are too 55 * many to find on a single page. 56 * 57 * The .ui file for this example can be found [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-gedit.ui). 58 * 59 * # An example with multiple views: 60 * 61 * ![](clocks-shortcuts.png) 62 * 63 * This example shows a #GtkShortcutsWindow that has been configured to show only 64 * the shortcuts relevant to the "stopwatch" view. 65 * 66 * The .ui file for this example can be found [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-clocks.ui). 67 * 68 * # An example with multiple sections: 69 * 70 * ![](builder-shortcuts.png) 71 * 72 * This example shows a #GtkShortcutsWindow with two sections, "Editor Shortcuts" 73 * and "Terminal Shortcuts". 74 * 75 * The .ui file for this example can be found [here](https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/shortcuts-builder.ui). 76 */ 77 public class ShortcutsWindow : Window 78 { 79 /** the main Gtk struct */ 80 protected GtkShortcutsWindow* gtkShortcutsWindow; 81 82 /** Get the main Gtk struct */ 83 public GtkShortcutsWindow* getShortcutsWindowStruct(bool transferOwnership = false) 84 { 85 if (transferOwnership) 86 ownedRef = false; 87 return gtkShortcutsWindow; 88 } 89 90 /** the main Gtk struct as a void* */ 91 protected override void* getStruct() 92 { 93 return cast(void*)gtkShortcutsWindow; 94 } 95 96 /** 97 * Sets our main struct and passes it to the parent class. 98 */ 99 public this (GtkShortcutsWindow* gtkShortcutsWindow, bool ownedRef = false) 100 { 101 this.gtkShortcutsWindow = gtkShortcutsWindow; 102 super(cast(GtkWindow*)gtkShortcutsWindow, ownedRef); 103 } 104 105 106 /** */ 107 public static GType getType() 108 { 109 return gtk_shortcuts_window_get_type(); 110 } 111 112 protected class OnCloseDelegateWrapper 113 { 114 void delegate(ShortcutsWindow) dlg; 115 gulong handlerId; 116 117 this(void delegate(ShortcutsWindow) dlg) 118 { 119 this.dlg = dlg; 120 onCloseListeners ~= this; 121 } 122 123 void remove(OnCloseDelegateWrapper source) 124 { 125 foreach(index, wrapper; onCloseListeners) 126 { 127 if (wrapper.handlerId == source.handlerId) 128 { 129 onCloseListeners[index] = null; 130 onCloseListeners = std.algorithm.remove(onCloseListeners, index); 131 break; 132 } 133 } 134 } 135 } 136 OnCloseDelegateWrapper[] onCloseListeners; 137 138 /** 139 * The ::close signal is a 140 * [keybinding signal][GtkBindingSignal] 141 * which gets emitted when the user uses a keybinding to close 142 * the window. 143 * 144 * The default binding for this signal is the Escape key. 145 */ 146 gulong addOnClose(void delegate(ShortcutsWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 147 { 148 auto wrapper = new OnCloseDelegateWrapper(dlg); 149 wrapper.handlerId = Signals.connectData( 150 this, 151 "close", 152 cast(GCallback)&callBackClose, 153 cast(void*)wrapper, 154 cast(GClosureNotify)&callBackCloseDestroy, 155 connectFlags); 156 return wrapper.handlerId; 157 } 158 159 extern(C) static void callBackClose(GtkShortcutsWindow* shortcutswindowStruct, OnCloseDelegateWrapper wrapper) 160 { 161 wrapper.dlg(wrapper.outer); 162 } 163 164 extern(C) static void callBackCloseDestroy(OnCloseDelegateWrapper wrapper, GClosure* closure) 165 { 166 wrapper.remove(wrapper); 167 } 168 169 protected class OnSearchDelegateWrapper 170 { 171 void delegate(ShortcutsWindow) dlg; 172 gulong handlerId; 173 174 this(void delegate(ShortcutsWindow) dlg) 175 { 176 this.dlg = dlg; 177 onSearchListeners ~= this; 178 } 179 180 void remove(OnSearchDelegateWrapper source) 181 { 182 foreach(index, wrapper; onSearchListeners) 183 { 184 if (wrapper.handlerId == source.handlerId) 185 { 186 onSearchListeners[index] = null; 187 onSearchListeners = std.algorithm.remove(onSearchListeners, index); 188 break; 189 } 190 } 191 } 192 } 193 OnSearchDelegateWrapper[] onSearchListeners; 194 195 /** 196 * The ::search signal is a 197 * [keybinding signal][GtkBindingSignal] 198 * which gets emitted when the user uses a keybinding to start a search. 199 * 200 * The default binding for this signal is Control-F. 201 */ 202 gulong addOnSearch(void delegate(ShortcutsWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 203 { 204 auto wrapper = new OnSearchDelegateWrapper(dlg); 205 wrapper.handlerId = Signals.connectData( 206 this, 207 "search", 208 cast(GCallback)&callBackSearch, 209 cast(void*)wrapper, 210 cast(GClosureNotify)&callBackSearchDestroy, 211 connectFlags); 212 return wrapper.handlerId; 213 } 214 215 extern(C) static void callBackSearch(GtkShortcutsWindow* shortcutswindowStruct, OnSearchDelegateWrapper wrapper) 216 { 217 wrapper.dlg(wrapper.outer); 218 } 219 220 extern(C) static void callBackSearchDestroy(OnSearchDelegateWrapper wrapper, GClosure* closure) 221 { 222 wrapper.remove(wrapper); 223 } 224 }