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.SourceMarkAttributes;
26 
27 private import gdk.RGBA;
28 private import gdkpixbuf.Pixbuf;
29 private import gio.Icon;
30 private import gio.IconIF;
31 private import glib.ConstructionException;
32 private import glib.Str;
33 private import gobject.ObjectG;
34 private import gobject.Signals;
35 private import gsv.SourceMark;
36 private import gsvc.gsv;
37 public  import gsvc.gsvtypes;
38 private import gtk.Widget;
39 public  import gtkc.gdktypes;
40 
41 
42 public class SourceMarkAttributes : ObjectG
43 {
44 	/** the main Gtk struct */
45 	protected GtkSourceMarkAttributes* gtkSourceMarkAttributes;
46 
47 	/** Get the main Gtk struct */
48 	public GtkSourceMarkAttributes* getSourceMarkAttributesStruct()
49 	{
50 		return gtkSourceMarkAttributes;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected override void* getStruct()
55 	{
56 		return cast(void*)gtkSourceMarkAttributes;
57 	}
58 
59 	protected override void setStruct(GObject* obj)
60 	{
61 		gtkSourceMarkAttributes = cast(GtkSourceMarkAttributes*)obj;
62 		super.setStruct(obj);
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GtkSourceMarkAttributes* gtkSourceMarkAttributes, bool ownedRef = false)
69 	{
70 		this.gtkSourceMarkAttributes = gtkSourceMarkAttributes;
71 		super(cast(GObject*)gtkSourceMarkAttributes, ownedRef);
72 	}
73 
74 	/** */
75 	public void setStockId(StockID stockId)
76 	{
77 		setStockId(cast(string)stockId);
78 	}
79 
80 	/**
81 	 */
82 
83 	public static GType getType()
84 	{
85 		return gtk_source_mark_attributes_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new source mark attributes.
90 	 *
91 	 * Return: a new source mark attributes.
92 	 *
93 	 * Throws: ConstructionException GTK+ fails to create the object.
94 	 */
95 	public this()
96 	{
97 		auto p = gtk_source_mark_attributes_new();
98 		
99 		if(p is null)
100 		{
101 			throw new ConstructionException("null returned by new");
102 		}
103 		
104 		this(cast(GtkSourceMarkAttributes*) p, true);
105 	}
106 
107 	/**
108 	 * Stores background color in @background.
109 	 *
110 	 * Params:
111 	 *     background = a #GdkRGBA.
112 	 *
113 	 * Return: whether background color for @attributes was set.
114 	 */
115 	public bool getBackground(out RGBA background)
116 	{
117 		GdkRGBA* outbackground = new GdkRGBA;
118 		
119 		auto p = gtk_source_mark_attributes_get_background(gtkSourceMarkAttributes, outbackground) != 0;
120 		
121 		background = ObjectG.getDObject!(RGBA)(outbackground);
122 		
123 		return p;
124 	}
125 
126 	/**
127 	 * Gets a #GIcon to be used as a base for rendered icon. Note that the icon can
128 	 * be %NULL if it wasn't set earlier.
129 	 *
130 	 * Return: An icon. The icon belongs to @attributes and should
131 	 *     not be unreffed.
132 	 */
133 	public IconIF getGicon()
134 	{
135 		auto p = gtk_source_mark_attributes_get_gicon(gtkSourceMarkAttributes);
136 		
137 		if(p is null)
138 		{
139 			return null;
140 		}
141 		
142 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
143 	}
144 
145 	/**
146 	 * Gets a name of an icon to be used as a base for rendered icon. Note that the
147 	 * icon name can be %NULL if it wasn't set earlier.
148 	 *
149 	 * Return: An icon name. The string belongs to @attributes and
150 	 *     should not be freed.
151 	 */
152 	public string getIconName()
153 	{
154 		return Str.toString(gtk_source_mark_attributes_get_icon_name(gtkSourceMarkAttributes));
155 	}
156 
157 	/**
158 	 * Gets a #GdkPixbuf to be used as a base for rendered icon. Note that the
159 	 * pixbuf can be %NULL if it wasn't set earlier.
160 	 *
161 	 * Return: A pixbuf. The pixbuf belongs to @attributes and
162 	 *     should not be unreffed.
163 	 */
164 	public Pixbuf getPixbuf()
165 	{
166 		auto p = gtk_source_mark_attributes_get_pixbuf(gtkSourceMarkAttributes);
167 		
168 		if(p is null)
169 		{
170 			return null;
171 		}
172 		
173 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
174 	}
175 
176 	/**
177 	 * Gets a stock id of an icon used by this attributes. Note that the stock id can
178 	 * be %NULL if it wasn't set earlier.
179 	 *
180 	 * Deprecated: Don't use this function.
181 	 *
182 	 * Return: Stock id. Returned string is owned by @attributes and
183 	 *     shouldn't be freed.
184 	 */
185 	public string getStockId()
186 	{
187 		return Str.toString(gtk_source_mark_attributes_get_stock_id(gtkSourceMarkAttributes));
188 	}
189 
190 	/**
191 	 * Queries for a tooltip by emitting
192 	 * a #GtkSourceMarkAttributes::query-tooltip-markup signal. The tooltip may contain
193 	 * a markup.
194 	 *
195 	 * Params:
196 	 *     mark = a #GtkSourceMark.
197 	 *
198 	 * Return: A tooltip. The returned string should be freed by
199 	 *     using g_free() when done with it.
200 	 */
201 	public string getTooltipMarkup(SourceMark mark)
202 	{
203 		return Str.toString(gtk_source_mark_attributes_get_tooltip_markup(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()));
204 	}
205 
206 	/**
207 	 * Queries for a tooltip by emitting
208 	 * a #GtkSourceMarkAttributes::query-tooltip-text signal. The tooltip is a plain
209 	 * text.
210 	 *
211 	 * Params:
212 	 *     mark = a #GtkSourceMark.
213 	 *
214 	 * Return: A tooltip. The returned string should be freed by
215 	 *     using g_free() when done with it.
216 	 */
217 	public string getTooltipText(SourceMark mark)
218 	{
219 		return Str.toString(gtk_source_mark_attributes_get_tooltip_text(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()));
220 	}
221 
222 	/**
223 	 * Renders an icon of given size. The base of the icon is set by the last call
224 	 * to one of: gtk_source_mark_attributes_set_pixbuf(),
225 	 * gtk_source_mark_attributes_set_gicon(),
226 	 * gtk_source_mark_attributes_set_icon_name() or
227 	 * gtk_source_mark_attributes_set_stock_id(). @size cannot be lower than 1.
228 	 *
229 	 * Params:
230 	 *     widget = widget of which style settings may be used.
231 	 *     size = size of the rendered icon.
232 	 *
233 	 * Return: A rendered pixbuf. The pixbuf belongs to @attributes
234 	 *     and should not be unreffed.
235 	 */
236 	public Pixbuf renderIcon(Widget widget, int size)
237 	{
238 		auto p = gtk_source_mark_attributes_render_icon(gtkSourceMarkAttributes, (widget is null) ? null : widget.getWidgetStruct(), size);
239 		
240 		if(p is null)
241 		{
242 			return null;
243 		}
244 		
245 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
246 	}
247 
248 	/**
249 	 * Sets background color to the one given in @background.
250 	 *
251 	 * Params:
252 	 *     background = a #GdkRGBA.
253 	 */
254 	public void setBackground(RGBA background)
255 	{
256 		gtk_source_mark_attributes_set_background(gtkSourceMarkAttributes, (background is null) ? null : background.getRGBAStruct());
257 	}
258 
259 	/**
260 	 * Sets an icon to be used as a base for rendered icon.
261 	 *
262 	 * Params:
263 	 *     gicon = a #GIcon to be used.
264 	 */
265 	public void setGicon(IconIF gicon)
266 	{
267 		gtk_source_mark_attributes_set_gicon(gtkSourceMarkAttributes, (gicon is null) ? null : gicon.getIconStruct());
268 	}
269 
270 	/**
271 	 * Sets a name of an icon to be used as a base for rendered icon.
272 	 *
273 	 * Params:
274 	 *     iconName = name of an icon to be used.
275 	 */
276 	public void setIconName(string iconName)
277 	{
278 		gtk_source_mark_attributes_set_icon_name(gtkSourceMarkAttributes, Str.toStringz(iconName));
279 	}
280 
281 	/**
282 	 * Sets a pixbuf to be used as a base for rendered icon.
283 	 *
284 	 * Params:
285 	 *     pixbuf = a #GdkPixbuf to be used.
286 	 */
287 	public void setPixbuf(Pixbuf pixbuf)
288 	{
289 		gtk_source_mark_attributes_set_pixbuf(gtkSourceMarkAttributes, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
290 	}
291 
292 	/**
293 	 * Sets stock id to be used as a base for rendered icon.
294 	 *
295 	 * Deprecated: Don't use this function.
296 	 *
297 	 * Params:
298 	 *     stockId = a stock id.
299 	 */
300 	public void setStockId(string stockId)
301 	{
302 		gtk_source_mark_attributes_set_stock_id(gtkSourceMarkAttributes, Str.toStringz(stockId));
303 	}
304 
305 	int[string] connectedSignals;
306 
307 	string delegate(SourceMark, SourceMarkAttributes)[] onQueryTooltipMarkupListeners;
308 	/**
309 	 * The code should connect to this signal to provide a tooltip for given
310 	 * @mark. The tooltip can contain a markup.
311 	 *
312 	 * Params:
313 	 *     mark = The #GtkSourceMark.
314 	 *
315 	 * Return: A tooltip. The string should be freed with
316 	 *     g_free() when done with it.
317 	 */
318 	void addOnQueryTooltipMarkup(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
319 	{
320 		if ( "query-tooltip-markup" !in connectedSignals )
321 		{
322 			Signals.connectData(
323 				this,
324 				"query-tooltip-markup",
325 				cast(GCallback)&callBackQueryTooltipMarkup,
326 				cast(void*)this,
327 				null,
328 				connectFlags);
329 			connectedSignals["query-tooltip-markup"] = 1;
330 		}
331 		onQueryTooltipMarkupListeners ~= dlg;
332 	}
333 	extern(C) static string callBackQueryTooltipMarkup(GtkSourceMarkAttributes* sourcemarkattributesStruct, GtkSourceMark* mark, SourceMarkAttributes _sourcemarkattributes)
334 	{
335 		return _sourcemarkattributes.onQueryTooltipMarkupListeners[0](ObjectG.getDObject!(SourceMark)(mark), _sourcemarkattributes);
336 	}
337 
338 	string delegate(SourceMark, SourceMarkAttributes)[] onQueryTooltipTextListeners;
339 	/**
340 	 * The code should connect to this signal to provide a tooltip for given
341 	 * @mark. The tooltip should be just a plain text.
342 	 *
343 	 * Params:
344 	 *     mark = The #GtkSourceMark.
345 	 *
346 	 * Return: A tooltip. The string should be freed with
347 	 *     g_free() when done with it.
348 	 */
349 	void addOnQueryTooltipText(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
350 	{
351 		if ( "query-tooltip-text" !in connectedSignals )
352 		{
353 			Signals.connectData(
354 				this,
355 				"query-tooltip-text",
356 				cast(GCallback)&callBackQueryTooltipText,
357 				cast(void*)this,
358 				null,
359 				connectFlags);
360 			connectedSignals["query-tooltip-text"] = 1;
361 		}
362 		onQueryTooltipTextListeners ~= dlg;
363 	}
364 	extern(C) static string callBackQueryTooltipText(GtkSourceMarkAttributes* sourcemarkattributesStruct, GtkSourceMark* mark, SourceMarkAttributes _sourcemarkattributes)
365 	{
366 		return _sourcemarkattributes.onQueryTooltipTextListeners[0](ObjectG.getDObject!(SourceMark)(mark), _sourcemarkattributes);
367 	}
368 }