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.SourceCompletion; 26 27 private import glib.ErrorG; 28 private import glib.GException; 29 private import glib.ListG; 30 private import gobject.ObjectG; 31 private import gobject.Signals; 32 private import gsv.SourceCompletionContext; 33 private import gsv.SourceCompletionInfo; 34 private import gsv.SourceCompletionProviderIF; 35 private import gsv.SourceView; 36 private import gsv.c.functions; 37 public import gsv.c.types; 38 public import gsvc.gsvtypes; 39 private import gtk.BuildableIF; 40 private import gtk.BuildableT; 41 private import gtk.TextIter; 42 private import std.algorithm; 43 44 45 /** */ 46 public class SourceCompletion : ObjectG, BuildableIF 47 { 48 /** the main Gtk struct */ 49 protected GtkSourceCompletion* gtkSourceCompletion; 50 51 /** Get the main Gtk struct */ 52 public GtkSourceCompletion* getSourceCompletionStruct(bool transferOwnership = false) 53 { 54 if (transferOwnership) 55 ownedRef = false; 56 return gtkSourceCompletion; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)gtkSourceCompletion; 63 } 64 65 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (GtkSourceCompletion* gtkSourceCompletion, bool ownedRef = false) 69 { 70 this.gtkSourceCompletion = gtkSourceCompletion; 71 super(cast(GObject*)gtkSourceCompletion, ownedRef); 72 } 73 74 // add the Buildable capabilities 75 mixin BuildableT!(GtkSourceCompletion); 76 77 78 /** */ 79 public static GType getType() 80 { 81 return gtk_source_completion_get_type(); 82 } 83 84 /** 85 * Add a new #GtkSourceCompletionProvider to the completion object. This will 86 * add a reference @provider, so make sure to unref your own copy when you 87 * no longer need it. 88 * 89 * Params: 90 * provider = a #GtkSourceCompletionProvider. 91 * 92 * Returns: %TRUE if @provider was successfully added, otherwise if @error 93 * is provided, it will be set with the error and %FALSE is returned. 94 * 95 * Throws: GException on failure. 96 */ 97 public bool addProvider(SourceCompletionProviderIF provider) 98 { 99 GError* err = null; 100 101 auto p = gtk_source_completion_add_provider(gtkSourceCompletion, (provider is null) ? null : provider.getSourceCompletionProviderStruct(), &err) != 0; 102 103 if (err !is null) 104 { 105 throw new GException( new ErrorG(err) ); 106 } 107 108 return p; 109 } 110 111 /** 112 * Block interactive completion. This can be used to disable interactive 113 * completion when inserting or deleting text from the buffer associated with 114 * the completion. Use gtk_source_completion_unblock_interactive() to enable 115 * interactive completion again. 116 * 117 * This function may be called multiple times. It will continue to block 118 * interactive completion until gtk_source_completion_unblock_interactive() 119 * has been called the same number of times. 120 */ 121 public void blockInteractive() 122 { 123 gtk_source_completion_block_interactive(gtkSourceCompletion); 124 } 125 126 /** 127 * Create a new #GtkSourceCompletionContext for @completion. The position where 128 * the completion occurs can be specified by @position. If @position is %NULL, 129 * the current cursor position will be used. 130 * 131 * Params: 132 * position = a #GtkTextIter, or %NULL. 133 * 134 * Returns: a new #GtkSourceCompletionContext. 135 * The reference being returned is a 'floating' reference, 136 * so if you invoke gtk_source_completion_show() with this context 137 * you don't need to unref it. 138 */ 139 public SourceCompletionContext createContext(TextIter position) 140 { 141 auto p = gtk_source_completion_create_context(gtkSourceCompletion, (position is null) ? null : position.getTextIterStruct()); 142 143 if(p is null) 144 { 145 return null; 146 } 147 148 return ObjectG.getDObject!(SourceCompletionContext)(cast(GtkSourceCompletionContext*) p); 149 } 150 151 /** 152 * The info widget is the window where the completion displays optional extra 153 * information of the proposal. 154 * 155 * Returns: The #GtkSourceCompletionInfo window 156 * associated with @completion. 157 */ 158 public SourceCompletionInfo getInfoWindow() 159 { 160 auto p = gtk_source_completion_get_info_window(gtkSourceCompletion); 161 162 if(p is null) 163 { 164 return null; 165 } 166 167 return ObjectG.getDObject!(SourceCompletionInfo)(cast(GtkSourceCompletionInfo*) p); 168 } 169 170 /** 171 * Get list of providers registered on @completion. The returned list is owned 172 * by the completion and should not be freed. 173 * 174 * Returns: list of #GtkSourceCompletionProvider. 175 */ 176 public ListG getProviders() 177 { 178 auto p = gtk_source_completion_get_providers(gtkSourceCompletion); 179 180 if(p is null) 181 { 182 return null; 183 } 184 185 return new ListG(cast(GList*) p); 186 } 187 188 /** 189 * The #GtkSourceView associated with @completion, or %NULL if the view has been 190 * destroyed. 191 * 192 * Returns: The #GtkSourceView associated with 193 * @completion, or %NULL. 194 */ 195 public SourceView getView() 196 { 197 auto p = gtk_source_completion_get_view(gtkSourceCompletion); 198 199 if(p is null) 200 { 201 return null; 202 } 203 204 return ObjectG.getDObject!(SourceView)(cast(GtkSourceView*) p); 205 } 206 207 /** 208 * Hides the completion if it is active (visible). 209 */ 210 public void hide() 211 { 212 gtk_source_completion_hide(gtkSourceCompletion); 213 } 214 215 /** 216 * Move the completion window to a specific iter. 217 * 218 * Deprecated: Use gtk_source_completion_provider_get_start_iter() instead. 219 * 220 * Params: 221 * iter = a #GtkTextIter. 222 */ 223 public void moveWindow(TextIter iter) 224 { 225 gtk_source_completion_move_window(gtkSourceCompletion, (iter is null) ? null : iter.getTextIterStruct()); 226 } 227 228 /** 229 * Remove @provider from the completion. 230 * 231 * Params: 232 * provider = a #GtkSourceCompletionProvider. 233 * 234 * Returns: %TRUE if @provider was successfully removed, otherwise if @error 235 * is provided, it will be set with the error and %FALSE is returned. 236 * 237 * Throws: GException on failure. 238 */ 239 public bool removeProvider(SourceCompletionProviderIF provider) 240 { 241 GError* err = null; 242 243 auto p = gtk_source_completion_remove_provider(gtkSourceCompletion, (provider is null) ? null : provider.getSourceCompletionProviderStruct(), &err) != 0; 244 245 if (err !is null) 246 { 247 throw new GException( new ErrorG(err) ); 248 } 249 250 return p; 251 } 252 253 /** 254 * Starts a new completion with the specified #GtkSourceCompletionContext and 255 * a list of potential candidate providers for completion. 256 * 257 * It can be convenient for showing a completion on-the-fly, without the need to 258 * add or remove providers to the #GtkSourceCompletion. 259 * 260 * Another solution is to add providers with 261 * gtk_source_completion_add_provider(), and implement 262 * gtk_source_completion_provider_match() for each provider. 263 * 264 * Params: 265 * providers = a list of #GtkSourceCompletionProvider, or %NULL. 266 * context = The #GtkSourceCompletionContext 267 * with which to start the completion. 268 * 269 * Returns: %TRUE if it was possible to the show completion window. 270 */ 271 public bool show(ListG providers, SourceCompletionContext context) 272 { 273 return gtk_source_completion_show(gtkSourceCompletion, (providers is null) ? null : providers.getListGStruct(), (context is null) ? null : context.getSourceCompletionContextStruct()) != 0; 274 } 275 276 /** 277 * Unblock interactive completion. This can be used after using 278 * gtk_source_completion_block_interactive() to enable interactive completion 279 * again. 280 */ 281 public void unblockInteractive() 282 { 283 gtk_source_completion_unblock_interactive(gtkSourceCompletion); 284 } 285 286 /** 287 * The #GtkSourceCompletion::activate-proposal signal is a 288 * keybinding signal which gets emitted when the user initiates 289 * a proposal activation. 290 * 291 * Applications should not connect to it, but may emit it with 292 * g_signal_emit_by_name() if they need to control the proposal 293 * activation programmatically. 294 */ 295 gulong addOnActivateProposal(void delegate(SourceCompletion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 296 { 297 return Signals.connect(this, "activate-proposal", dlg, connectFlags ^ ConnectFlags.SWAPPED); 298 } 299 300 /** 301 * Emitted when the completion window is hidden. The default handler 302 * will actually hide the window. 303 */ 304 gulong addOnHide(void delegate(SourceCompletion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 305 { 306 return Signals.connect(this, "hide", dlg, connectFlags ^ ConnectFlags.SWAPPED); 307 } 308 309 /** 310 * The #GtkSourceCompletion::move-cursor signal is a keybinding 311 * signal which gets emitted when the user initiates a cursor 312 * movement. 313 * 314 * The <keycap>Up</keycap>, <keycap>Down</keycap>, 315 * <keycap>PageUp</keycap>, <keycap>PageDown</keycap>, 316 * <keycap>Home</keycap> and <keycap>End</keycap> keys are bound to the 317 * normal behavior expected by those keys. 318 * 319 * When @step is equal to %GTK_SCROLL_PAGES, the page size is defined by 320 * the #GtkSourceCompletion:proposal-page-size property. It is used for 321 * the <keycap>PageDown</keycap> and <keycap>PageUp</keycap> keys. 322 * 323 * Applications should not connect to it, but may emit it with 324 * g_signal_emit_by_name() if they need to control the cursor 325 * programmatically. 326 * 327 * Params: 328 * step = The #GtkScrollStep by which to move the cursor 329 * num = The amount of steps to move the cursor 330 */ 331 gulong addOnMoveCursor(void delegate(GtkScrollStep, int, SourceCompletion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 332 { 333 return Signals.connect(this, "move-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 334 } 335 336 /** 337 * The #GtkSourceCompletion::move-page signal is a keybinding 338 * signal which gets emitted when the user initiates a page 339 * movement (i.e. switches between provider pages). 340 * 341 * <keycombo><keycap>Control</keycap><keycap>Left</keycap></keycombo> 342 * is for going to the previous provider. 343 * <keycombo><keycap>Control</keycap><keycap>Right</keycap></keycombo> 344 * is for going to the next provider. 345 * <keycombo><keycap>Control</keycap><keycap>Home</keycap></keycombo> 346 * is for displaying all the providers. 347 * <keycombo><keycap>Control</keycap><keycap>End</keycap></keycombo> 348 * is for going to the last provider. 349 * 350 * When @step is equal to #GTK_SCROLL_PAGES, the page size is defined by 351 * the #GtkSourceCompletion:provider-page-size property. 352 * 353 * Applications should not connect to it, but may emit it with 354 * g_signal_emit_by_name() if they need to control the page selection 355 * programmatically. 356 * 357 * Params: 358 * step = The #GtkScrollStep by which to move the page 359 * num = The amount of steps to move the page 360 */ 361 gulong addOnMovePage(void delegate(GtkScrollStep, int, SourceCompletion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 362 { 363 return Signals.connect(this, "move-page", dlg, connectFlags ^ ConnectFlags.SWAPPED); 364 } 365 366 /** 367 * Emitted just before starting to populate the completion with providers. 368 * You can use this signal to add additional attributes in the context. 369 * 370 * Params: 371 * context = The #GtkSourceCompletionContext for the current completion 372 */ 373 gulong addOnPopulateContext(void delegate(SourceCompletionContext, SourceCompletion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 374 { 375 return Signals.connect(this, "populate-context", dlg, connectFlags ^ ConnectFlags.SWAPPED); 376 } 377 378 /** 379 * Emitted when the completion window is shown. The default handler 380 * will actually show the window. 381 */ 382 gulong addOnShow(void delegate(SourceCompletion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 383 { 384 return Signals.connect(this, "show", dlg, connectFlags ^ ConnectFlags.SWAPPED); 385 } 386 }