PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/generated/sourceview/gsv/SourceCompletion.d

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