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);
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 		return Str.toString(gtk_source_mark_attributes_get_tooltip_markup(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()));
206 	}
207 
208 	/**
209 	 * Queries for a tooltip by emitting
210 	 * a #GtkSourceMarkAttributes::query-tooltip-text signal. The tooltip is a plain
211 	 * text.
212 	 *
213 	 * Params:
214 	 *     mark = a #GtkSourceMark.
215 	 *
216 	 * Return: A tooltip. The returned string should be freed by
217 	 *     using g_free() when done with it.
218 	 */
219 	public string getTooltipText(SourceMark mark)
220 	{
221 		return Str.toString(gtk_source_mark_attributes_get_tooltip_text(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()));
222 	}
223 
224 	/**
225 	 * Renders an icon of given size. The base of the icon is set by the last call
226 	 * to one of: gtk_source_mark_attributes_set_pixbuf(),
227 	 * gtk_source_mark_attributes_set_gicon(),
228 	 * gtk_source_mark_attributes_set_icon_name() or
229 	 * gtk_source_mark_attributes_set_stock_id(). @size cannot be lower than 1.
230 	 *
231 	 * Params:
232 	 *     widget = widget of which style settings may be used.
233 	 *     size = size of the rendered icon.
234 	 *
235 	 * Return: A rendered pixbuf. The pixbuf belongs to @attributes
236 	 *     and should not be unreffed.
237 	 */
238 	public Pixbuf renderIcon(Widget widget, int size)
239 	{
240 		auto p = gtk_source_mark_attributes_render_icon(gtkSourceMarkAttributes, (widget is null) ? null : widget.getWidgetStruct(), size);
241 		
242 		if(p is null)
243 		{
244 			return null;
245 		}
246 		
247 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
248 	}
249 
250 	/**
251 	 * Sets background color to the one given in @background.
252 	 *
253 	 * Params:
254 	 *     background = a #GdkRGBA.
255 	 */
256 	public void setBackground(RGBA background)
257 	{
258 		gtk_source_mark_attributes_set_background(gtkSourceMarkAttributes, (background is null) ? null : background.getRGBAStruct());
259 	}
260 
261 	/**
262 	 * Sets an icon to be used as a base for rendered icon.
263 	 *
264 	 * Params:
265 	 *     gicon = a #GIcon to be used.
266 	 */
267 	public void setGicon(IconIF gicon)
268 	{
269 		gtk_source_mark_attributes_set_gicon(gtkSourceMarkAttributes, (gicon is null) ? null : gicon.getIconStruct());
270 	}
271 
272 	/**
273 	 * Sets a name of an icon to be used as a base for rendered icon.
274 	 *
275 	 * Params:
276 	 *     iconName = name of an icon to be used.
277 	 */
278 	public void setIconName(string iconName)
279 	{
280 		gtk_source_mark_attributes_set_icon_name(gtkSourceMarkAttributes, Str.toStringz(iconName));
281 	}
282 
283 	/**
284 	 * Sets a pixbuf to be used as a base for rendered icon.
285 	 *
286 	 * Params:
287 	 *     pixbuf = a #GdkPixbuf to be used.
288 	 */
289 	public void setPixbuf(Pixbuf pixbuf)
290 	{
291 		gtk_source_mark_attributes_set_pixbuf(gtkSourceMarkAttributes, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
292 	}
293 
294 	/**
295 	 * Sets stock id to be used as a base for rendered icon.
296 	 *
297 	 * Deprecated: Don't use this function.
298 	 *
299 	 * Params:
300 	 *     stockId = a stock id.
301 	 */
302 	public void setStockId(string stockId)
303 	{
304 		gtk_source_mark_attributes_set_stock_id(gtkSourceMarkAttributes, Str.toStringz(stockId));
305 	}
306 
307 	int[string] connectedSignals;
308 
309 	string delegate(SourceMark, SourceMarkAttributes)[] onQueryTooltipMarkupListeners;
310 	/**
311 	 * The code should connect to this signal to provide a tooltip for given
312 	 * @mark. The tooltip can contain a markup.
313 	 *
314 	 * Params:
315 	 *     mark = The #GtkSourceMark.
316 	 *
317 	 * Return: A tooltip. The string should be freed with
318 	 *     g_free() when done with it.
319 	 */
320 	void addOnQueryTooltipMarkup(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
321 	{
322 		if ( "query-tooltip-markup" !in connectedSignals )
323 		{
324 			Signals.connectData(
325 				this,
326 				"query-tooltip-markup",
327 				cast(GCallback)&callBackQueryTooltipMarkup,
328 				cast(void*)this,
329 				null,
330 				connectFlags);
331 			connectedSignals["query-tooltip-markup"] = 1;
332 		}
333 		onQueryTooltipMarkupListeners ~= dlg;
334 	}
335 	extern(C) static string callBackQueryTooltipMarkup(GtkSourceMarkAttributes* sourcemarkattributesStruct, GtkSourceMark* mark, SourceMarkAttributes _sourcemarkattributes)
336 	{
337 		return _sourcemarkattributes.onQueryTooltipMarkupListeners[0](ObjectG.getDObject!(SourceMark)(mark), _sourcemarkattributes);
338 	}
339 
340 	string delegate(SourceMark, SourceMarkAttributes)[] onQueryTooltipTextListeners;
341 	/**
342 	 * The code should connect to this signal to provide a tooltip for given
343 	 * @mark. The tooltip should be just a plain text.
344 	 *
345 	 * Params:
346 	 *     mark = The #GtkSourceMark.
347 	 *
348 	 * Return: A tooltip. The string should be freed with
349 	 *     g_free() when done with it.
350 	 */
351 	void addOnQueryTooltipText(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
352 	{
353 		if ( "query-tooltip-text" !in connectedSignals )
354 		{
355 			Signals.connectData(
356 				this,
357 				"query-tooltip-text",
358 				cast(GCallback)&callBackQueryTooltipText,
359 				cast(void*)this,
360 				null,
361 				connectFlags);
362 			connectedSignals["query-tooltip-text"] = 1;
363 		}
364 		onQueryTooltipTextListeners ~= dlg;
365 	}
366 	extern(C) static string callBackQueryTooltipText(GtkSourceMarkAttributes* sourcemarkattributesStruct, GtkSourceMark* mark, SourceMarkAttributes _sourcemarkattributes)
367 	{
368 		return _sourcemarkattributes.onQueryTooltipTextListeners[0](ObjectG.getDObject!(SourceMark)(mark), _sourcemarkattributes);
369 	}
370 }