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.SourceCompletionInfo; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gsvc.gsv; 31 public import gsvc.gsvtypes; 32 private import gtk.BuildableIF; 33 private import gtk.BuildableT; 34 private import gtk.TextIter; 35 private import gtk.TextView; 36 private import gtk.Widget; 37 private import gtk.Window; 38 public import gtkc.gdktypes; 39 private import std.algorithm; 40 41 42 /** */ 43 public class SourceCompletionInfo : Window 44 { 45 /** the main Gtk struct */ 46 protected GtkSourceCompletionInfo* gtkSourceCompletionInfo; 47 48 /** Get the main Gtk struct */ 49 public GtkSourceCompletionInfo* getSourceCompletionInfoStruct() 50 { 51 return gtkSourceCompletionInfo; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected override void* getStruct() 56 { 57 return cast(void*)gtkSourceCompletionInfo; 58 } 59 60 protected override void setStruct(GObject* obj) 61 { 62 gtkSourceCompletionInfo = cast(GtkSourceCompletionInfo*)obj; 63 super.setStruct(obj); 64 } 65 66 /** 67 * Sets our main struct and passes it to the parent class. 68 */ 69 public this (GtkSourceCompletionInfo* gtkSourceCompletionInfo, bool ownedRef = false) 70 { 71 this.gtkSourceCompletionInfo = gtkSourceCompletionInfo; 72 super(cast(GtkWindow*)gtkSourceCompletionInfo, ownedRef); 73 } 74 75 76 /** */ 77 public static GType getType() 78 { 79 return gtk_source_completion_info_get_type(); 80 } 81 82 /** 83 * Return: a new GtkSourceCompletionInfo. 84 * 85 * Throws: ConstructionException GTK+ fails to create the object. 86 */ 87 public this() 88 { 89 auto p = gtk_source_completion_info_new(); 90 91 if(p is null) 92 { 93 throw new ConstructionException("null returned by new"); 94 } 95 96 this(cast(GtkSourceCompletionInfo*) p); 97 } 98 99 /** 100 * Get the current content widget. 101 * 102 * Deprecated: Use gtk_bin_get_child() instead. 103 * 104 * Return: The current content widget. 105 */ 106 public Widget getWidget() 107 { 108 auto p = gtk_source_completion_info_get_widget(gtkSourceCompletionInfo); 109 110 if(p is null) 111 { 112 return null; 113 } 114 115 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 116 } 117 118 /** 119 * Moves the #GtkSourceCompletionInfo to @iter. If @iter is %NULL @info is 120 * moved to the cursor position. Moving will respect the #GdkGravity setting 121 * of the info window and will ensure the line at @iter is not occluded by 122 * the window. 123 * 124 * Params: 125 * view = a #GtkTextView on which the info window should be positioned. 126 * iter = a #GtkTextIter. 127 */ 128 public void moveToIter(TextView view, TextIter iter) 129 { 130 gtk_source_completion_info_move_to_iter(gtkSourceCompletionInfo, (view is null) ? null : view.getTextViewStruct(), (iter is null) ? null : iter.getTextIterStruct()); 131 } 132 133 /** 134 * Sets the content widget of the info window. See that the previous widget will 135 * lose a reference and it can be destroyed, so if you do not want this to 136 * happen you must use g_object_ref() before calling this method. 137 * 138 * Deprecated: Use gtk_container_add() instead. If there is already a child 139 * widget, remove it with gtk_container_remove(). 140 * 141 * Params: 142 * widget = a #GtkWidget. 143 */ 144 public void setWidget(Widget widget) 145 { 146 gtk_source_completion_info_set_widget(gtkSourceCompletionInfo, (widget is null) ? null : widget.getWidgetStruct()); 147 } 148 149 protected class OnBeforeShowDelegateWrapper 150 { 151 void delegate(SourceCompletionInfo) dlg; 152 gulong handlerId; 153 ConnectFlags flags; 154 this(void delegate(SourceCompletionInfo) dlg, gulong handlerId, ConnectFlags flags) 155 { 156 this.dlg = dlg; 157 this.handlerId = handlerId; 158 this.flags = flags; 159 } 160 } 161 protected OnBeforeShowDelegateWrapper[] onBeforeShowListeners; 162 163 /** 164 * This signal is emitted before any "show" management. You can connect 165 * to this signal if you want to change some properties or position 166 * before the real "show". 167 * 168 * Deprecated: This signal should not be used. 169 */ 170 gulong addOnBeforeShow(void delegate(SourceCompletionInfo) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 171 { 172 onBeforeShowListeners ~= new OnBeforeShowDelegateWrapper(dlg, 0, connectFlags); 173 onBeforeShowListeners[onBeforeShowListeners.length - 1].handlerId = Signals.connectData( 174 this, 175 "before-show", 176 cast(GCallback)&callBackBeforeShow, 177 cast(void*)onBeforeShowListeners[onBeforeShowListeners.length - 1], 178 cast(GClosureNotify)&callBackBeforeShowDestroy, 179 connectFlags); 180 return onBeforeShowListeners[onBeforeShowListeners.length - 1].handlerId; 181 } 182 183 extern(C) static void callBackBeforeShow(GtkSourceCompletionInfo* sourcecompletioninfoStruct,OnBeforeShowDelegateWrapper wrapper) 184 { 185 wrapper.dlg(wrapper.outer); 186 } 187 188 extern(C) static void callBackBeforeShowDestroy(OnBeforeShowDelegateWrapper wrapper, GClosure* closure) 189 { 190 wrapper.outer.internalRemoveOnBeforeShow(wrapper); 191 } 192 193 protected void internalRemoveOnBeforeShow(OnBeforeShowDelegateWrapper source) 194 { 195 foreach(index, wrapper; onBeforeShowListeners) 196 { 197 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 198 { 199 onBeforeShowListeners[index] = null; 200 onBeforeShowListeners = std.algorithm.remove(onBeforeShowListeners, index); 201 break; 202 } 203 } 204 } 205 206 }