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