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