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 protected override void setStruct(GObject* obj) 97 { 98 gtkShortcutsWindow = cast(GtkShortcutsWindow*)obj; 99 super.setStruct(obj); 100 } 101 102 /** 103 * Sets our main struct and passes it to the parent class. 104 */ 105 public this (GtkShortcutsWindow* gtkShortcutsWindow, bool ownedRef = false) 106 { 107 this.gtkShortcutsWindow = gtkShortcutsWindow; 108 super(cast(GtkWindow*)gtkShortcutsWindow, ownedRef); 109 } 110 111 112 /** */ 113 public static GType getType() 114 { 115 return gtk_shortcuts_window_get_type(); 116 } 117 118 protected class OnCloseDelegateWrapper 119 { 120 void delegate(ShortcutsWindow) dlg; 121 gulong handlerId; 122 123 this(void delegate(ShortcutsWindow) dlg) 124 { 125 this.dlg = dlg; 126 onCloseListeners ~= this; 127 } 128 129 void remove(OnCloseDelegateWrapper source) 130 { 131 foreach(index, wrapper; onCloseListeners) 132 { 133 if (wrapper.handlerId == source.handlerId) 134 { 135 onCloseListeners[index] = null; 136 onCloseListeners = std.algorithm.remove(onCloseListeners, index); 137 break; 138 } 139 } 140 } 141 } 142 OnCloseDelegateWrapper[] onCloseListeners; 143 144 /** 145 * The ::close signal is a 146 * [keybinding signal][GtkBindingSignal] 147 * which gets emitted when the user uses a keybinding to close 148 * the window. 149 * 150 * The default binding for this signal is the Escape key. 151 */ 152 gulong addOnClose(void delegate(ShortcutsWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 153 { 154 auto wrapper = new OnCloseDelegateWrapper(dlg); 155 wrapper.handlerId = Signals.connectData( 156 this, 157 "close", 158 cast(GCallback)&callBackClose, 159 cast(void*)wrapper, 160 cast(GClosureNotify)&callBackCloseDestroy, 161 connectFlags); 162 return wrapper.handlerId; 163 } 164 165 extern(C) static void callBackClose(GtkShortcutsWindow* shortcutswindowStruct, OnCloseDelegateWrapper wrapper) 166 { 167 wrapper.dlg(wrapper.outer); 168 } 169 170 extern(C) static void callBackCloseDestroy(OnCloseDelegateWrapper wrapper, GClosure* closure) 171 { 172 wrapper.remove(wrapper); 173 } 174 175 protected class OnSearchDelegateWrapper 176 { 177 void delegate(ShortcutsWindow) dlg; 178 gulong handlerId; 179 180 this(void delegate(ShortcutsWindow) dlg) 181 { 182 this.dlg = dlg; 183 onSearchListeners ~= this; 184 } 185 186 void remove(OnSearchDelegateWrapper source) 187 { 188 foreach(index, wrapper; onSearchListeners) 189 { 190 if (wrapper.handlerId == source.handlerId) 191 { 192 onSearchListeners[index] = null; 193 onSearchListeners = std.algorithm.remove(onSearchListeners, index); 194 break; 195 } 196 } 197 } 198 } 199 OnSearchDelegateWrapper[] onSearchListeners; 200 201 /** 202 * The ::search signal is a 203 * [keybinding signal][GtkBindingSignal] 204 * which gets emitted when the user uses a keybinding to start a search. 205 * 206 * The default binding for this signal is Control-F. 207 */ 208 gulong addOnSearch(void delegate(ShortcutsWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 209 { 210 auto wrapper = new OnSearchDelegateWrapper(dlg); 211 wrapper.handlerId = Signals.connectData( 212 this, 213 "search", 214 cast(GCallback)&callBackSearch, 215 cast(void*)wrapper, 216 cast(GClosureNotify)&callBackSearchDestroy, 217 connectFlags); 218 return wrapper.handlerId; 219 } 220 221 extern(C) static void callBackSearch(GtkShortcutsWindow* shortcutswindowStruct, OnSearchDelegateWrapper wrapper) 222 { 223 wrapper.dlg(wrapper.outer); 224 } 225 226 extern(C) static void callBackSearchDestroy(OnSearchDelegateWrapper wrapper, GClosure* closure) 227 { 228 wrapper.remove(wrapper); 229 } 230 }