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