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