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