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 gsv.SourceUndoManagerT;
26 
27 public  import gobject.Signals;
28 public  import gsv.c.functions;
29 public  import gsv.c.types;
30 public  import gsvc.gsvtypes;
31 public  import std.algorithm;
32 
33 
34 /** */
35 public template SourceUndoManagerT(TStruct)
36 {
37 	/** Get the main Gtk struct */
38 	public GtkSourceUndoManager* getSourceUndoManagerStruct(bool transferOwnership = false)
39 	{
40 		if (transferOwnership)
41 			ownedRef = false;
42 		return cast(GtkSourceUndoManager*)getStruct();
43 	}
44 
45 
46 	/**
47 	 * Begin a not undoable action on the buffer. All changes between this call
48 	 * and the call to gtk_source_undo_manager_end_not_undoable_action() cannot
49 	 * be undone. This function should be re-entrant.
50 	 *
51 	 * Since: 2.10
52 	 */
53 	public void beginNotUndoableAction()
54 	{
55 		gtk_source_undo_manager_begin_not_undoable_action(getSourceUndoManagerStruct());
56 	}
57 
58 	/**
59 	 * Get whether there are redo operations available.
60 	 *
61 	 * Returns: %TRUE if there are redo operations available, %FALSE otherwise
62 	 *
63 	 * Since: 2.10
64 	 */
65 	public bool canRedo()
66 	{
67 		return gtk_source_undo_manager_can_redo(getSourceUndoManagerStruct()) != 0;
68 	}
69 
70 	/**
71 	 * Emits the #GtkSourceUndoManager::can-redo-changed signal.
72 	 *
73 	 * Since: 2.10
74 	 */
75 	public void canRedoChanged()
76 	{
77 		gtk_source_undo_manager_can_redo_changed(getSourceUndoManagerStruct());
78 	}
79 
80 	/**
81 	 * Get whether there are undo operations available.
82 	 *
83 	 * Returns: %TRUE if there are undo operations available, %FALSE otherwise
84 	 *
85 	 * Since: 2.10
86 	 */
87 	public bool canUndo()
88 	{
89 		return gtk_source_undo_manager_can_undo(getSourceUndoManagerStruct()) != 0;
90 	}
91 
92 	/**
93 	 * Emits the #GtkSourceUndoManager::can-undo-changed signal.
94 	 *
95 	 * Since: 2.10
96 	 */
97 	public void canUndoChanged()
98 	{
99 		gtk_source_undo_manager_can_undo_changed(getSourceUndoManagerStruct());
100 	}
101 
102 	/**
103 	 * Ends a not undoable action on the buffer.
104 	 *
105 	 * Since: 2.10
106 	 */
107 	public void endNotUndoableAction()
108 	{
109 		gtk_source_undo_manager_end_not_undoable_action(getSourceUndoManagerStruct());
110 	}
111 
112 	/**
113 	 * Perform a single redo. Calling this function when there are no redo operations
114 	 * available is an error. Use gtk_source_undo_manager_can_redo() to find out
115 	 * if there are redo operations available.
116 	 *
117 	 * Since: 2.10
118 	 */
119 	public void redo()
120 	{
121 		gtk_source_undo_manager_redo(getSourceUndoManagerStruct());
122 	}
123 
124 	/**
125 	 * Perform a single undo. Calling this function when there are no undo operations
126 	 * available is an error. Use gtk_source_undo_manager_can_undo() to find out
127 	 * if there are undo operations available.
128 	 *
129 	 * Since: 2.10
130 	 */
131 	public void undo()
132 	{
133 		gtk_source_undo_manager_undo(getSourceUndoManagerStruct());
134 	}
135 
136 	protected class OnCanRedoChangedDelegateWrapper
137 	{
138 		void delegate(SourceUndoManagerIF) dlg;
139 		gulong handlerId;
140 
141 		this(void delegate(SourceUndoManagerIF) dlg)
142 		{
143 			this.dlg = dlg;
144 			onCanRedoChangedListeners ~= this;
145 		}
146 
147 		void remove(OnCanRedoChangedDelegateWrapper source)
148 		{
149 			foreach(index, wrapper; onCanRedoChangedListeners)
150 			{
151 				if (wrapper.handlerId == source.handlerId)
152 				{
153 					onCanRedoChangedListeners[index] = null;
154 					onCanRedoChangedListeners = std.algorithm.remove(onCanRedoChangedListeners, index);
155 					break;
156 				}
157 			}
158 		}
159 	}
160 	OnCanRedoChangedDelegateWrapper[] onCanRedoChangedListeners;
161 
162 	/**
163 	 * Emitted when the ability to redo has changed.
164 	 *
165 	 * Since: 2.10
166 	 */
167 	gulong addOnCanRedoChanged(void delegate(SourceUndoManagerIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
168 	{
169 		auto wrapper = new OnCanRedoChangedDelegateWrapper(dlg);
170 		wrapper.handlerId = Signals.connectData(
171 			this,
172 			"can-redo-changed",
173 			cast(GCallback)&callBackCanRedoChanged,
174 			cast(void*)wrapper,
175 			cast(GClosureNotify)&callBackCanRedoChangedDestroy,
176 			connectFlags);
177 		return wrapper.handlerId;
178 	}
179 
180 	extern(C) static void callBackCanRedoChanged(GtkSourceUndoManager* sourceundomanagerStruct, OnCanRedoChangedDelegateWrapper wrapper)
181 	{
182 		wrapper.dlg(wrapper.outer);
183 	}
184 
185 	extern(C) static void callBackCanRedoChangedDestroy(OnCanRedoChangedDelegateWrapper wrapper, GClosure* closure)
186 	{
187 		wrapper.remove(wrapper);
188 	}
189 
190 	protected class OnCanUndoChangedDelegateWrapper
191 	{
192 		void delegate(SourceUndoManagerIF) dlg;
193 		gulong handlerId;
194 
195 		this(void delegate(SourceUndoManagerIF) dlg)
196 		{
197 			this.dlg = dlg;
198 			onCanUndoChangedListeners ~= this;
199 		}
200 
201 		void remove(OnCanUndoChangedDelegateWrapper source)
202 		{
203 			foreach(index, wrapper; onCanUndoChangedListeners)
204 			{
205 				if (wrapper.handlerId == source.handlerId)
206 				{
207 					onCanUndoChangedListeners[index] = null;
208 					onCanUndoChangedListeners = std.algorithm.remove(onCanUndoChangedListeners, index);
209 					break;
210 				}
211 			}
212 		}
213 	}
214 	OnCanUndoChangedDelegateWrapper[] onCanUndoChangedListeners;
215 
216 	/**
217 	 * Emitted when the ability to undo has changed.
218 	 *
219 	 * Since: 2.10
220 	 */
221 	gulong addOnCanUndoChanged(void delegate(SourceUndoManagerIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
222 	{
223 		auto wrapper = new OnCanUndoChangedDelegateWrapper(dlg);
224 		wrapper.handlerId = Signals.connectData(
225 			this,
226 			"can-undo-changed",
227 			cast(GCallback)&callBackCanUndoChanged,
228 			cast(void*)wrapper,
229 			cast(GClosureNotify)&callBackCanUndoChangedDestroy,
230 			connectFlags);
231 		return wrapper.handlerId;
232 	}
233 
234 	extern(C) static void callBackCanUndoChanged(GtkSourceUndoManager* sourceundomanagerStruct, OnCanUndoChangedDelegateWrapper wrapper)
235 	{
236 		wrapper.dlg(wrapper.outer);
237 	}
238 
239 	extern(C) static void callBackCanUndoChangedDestroy(OnCanUndoChangedDelegateWrapper wrapper, GClosure* closure)
240 	{
241 		wrapper.remove(wrapper);
242 	}
243 }