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  * Conversion parameters:
26  * inFile  = GtkSourceMarkAttributes.html
27  * outPack = gsv
28  * outFile = SourceMarkAttributes
29  * strct   = GtkSourceMarkAttributes
30  * realStrct=
31  * ctorStrct=
32  * clss    = SourceMarkAttributes
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_source_mark_attributes_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gio.Icon
48  * 	- gio.IconIF
49  * 	- gdk.Pixbuf
50  * 	- gdk.RGBA
51  * 	- gsv.SourceMark
52  * 	- gtk.Widget
53  * structWrap:
54  * 	- GIcon* -> IconIF
55  * 	- GdkPixbuf* -> Pixbuf
56  * 	- GdkRGBA* -> RGBA
57  * 	- GtkSourceMark* -> SourceMark
58  * 	- GtkWidget* -> Widget
59  * module aliases:
60  * local aliases:
61  * overrides:
62  */
63 
64 module gsv.SourceMarkAttributes;
65 
66 public  import gsvc.gsvtypes;
67 
68 private import gsvc.gsv;
69 private import glib.ConstructionException;
70 private import gobject.ObjectG;
71 
72 private import gobject.Signals;
73 public  import gtkc.gdktypes;
74 
75 private import glib.Str;
76 private import gio.Icon;
77 private import gio.IconIF;
78 private import gdk.Pixbuf;
79 private import gdk.RGBA;
80 private import gsv.SourceMark;
81 private import gtk.Widget;
82 
83 
84 
85 private import gobject.ObjectG;
86 
87 /**
88  * GtkSourceMarkAttributes is an object specifying attributes used by
89  * a GtkSourceView to visually show lines marked with GtkSourceMarks
90  * of a specific category. It allows you to define a background color of a line,
91  * an icon shown in gutter and tooltips.
92  *
93  * The background color is used as a background of a line where a mark is placed
94  * and it can be set with gtk_source_mark_attributes_set_background(). To check
95  * if any custom background color was defined and what color it is, use
96  * gtk_source_mark_attributes_get_background().
97  *
98  * An icon is a graphic element which is shown in the gutter of a view. An
99  * example use is showing a red filled circle in a debugger to show that a
100  * breakpoint was set in certain line. To get an icon that will be placed in
101  * a gutter, first a base for it must be specified and then
102  * gtk_source_mark_attributes_render_icon() must be called.
103  * There are several ways to specify a base for an icon:
104  *
105  *  gtk_source_mark_attributes_set_icon_name()
106  *
107  *  gtk_source_mark_attributes_set_stock_id()
108  *
109  *  gtk_source_mark_attributes_set_gicon()
110  *
111  *  gtk_source_mark_attributes_set_pixbuf()
112  *
113  * Using any of the above functions overrides the one used earlier. But note
114  * that a getter counterpart of earlier used function can still return some
115  * value, but it is just not used when rendering the proper icon.
116  *
117  * To provide meaningful tooltips for a given mark of a category, you should
118  * connect to "query-tooltip-text" or
119  * "query-tooltip-markup" where the latter
120  * takes precedence.
121  */
122 public class SourceMarkAttributes : ObjectG
123 {
124 	
125 	/** the main Gtk struct */
126 	protected GtkSourceMarkAttributes* gtkSourceMarkAttributes;
127 	
128 	
129 	public GtkSourceMarkAttributes* getSourceMarkAttributesStruct()
130 	{
131 		return gtkSourceMarkAttributes;
132 	}
133 	
134 	
135 	/** the main Gtk struct as a void* */
136 	protected override void* getStruct()
137 	{
138 		return cast(void*)gtkSourceMarkAttributes;
139 	}
140 	
141 	/**
142 	 * Sets our main struct and passes it to the parent class
143 	 */
144 	public this (GtkSourceMarkAttributes* gtkSourceMarkAttributes)
145 	{
146 		super(cast(GObject*)gtkSourceMarkAttributes);
147 		this.gtkSourceMarkAttributes = gtkSourceMarkAttributes;
148 	}
149 	
150 	protected override void setStruct(GObject* obj)
151 	{
152 		super.setStruct(obj);
153 		gtkSourceMarkAttributes = cast(GtkSourceMarkAttributes*)obj;
154 	}
155 	
156 	/** */
157 	public void setStockId(StockID stockId)
158 	{
159 		setStockId(StockDesc[stockId]);
160 	}
161 	
162 	/**
163 	 */
164 	int[string] connectedSignals;
165 	
166 	string delegate(SourceMark, SourceMarkAttributes)[] onQueryTooltipMarkupListeners;
167 	/**
168 	 * The code should connect to this signal to provide a tooltip for given
169 	 * mark. The tooltip can contain a markup.
170 	 */
171 	void addOnQueryTooltipMarkup(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
172 	{
173 		if ( !("query-tooltip-markup" in connectedSignals) )
174 		{
175 			Signals.connectData(
176 			getStruct(),
177 			"query-tooltip-markup",
178 			cast(GCallback)&callBackQueryTooltipMarkup,
179 			cast(void*)this,
180 			null,
181 			connectFlags);
182 			connectedSignals["query-tooltip-markup"] = 1;
183 		}
184 		onQueryTooltipMarkupListeners ~= dlg;
185 	}
186 	extern(C) static void callBackQueryTooltipMarkup(GtkSourceMarkAttributes* attributesStruct, GtkSourceMark* mark, SourceMarkAttributes _sourceMarkAttributes)
187 	{
188 		foreach ( string delegate(SourceMark, SourceMarkAttributes) dlg ; _sourceMarkAttributes.onQueryTooltipMarkupListeners )
189 		{
190 			dlg(ObjectG.getDObject!(SourceMark)(mark), _sourceMarkAttributes);
191 		}
192 	}
193 	
194 	string delegate(SourceMark, SourceMarkAttributes)[] onQueryTooltipTextListeners;
195 	/**
196 	 * The code should connect to this signal to provide a tooltip for given
197 	 * mark. The tooltip should be just a plain text.
198 	 * See Also
199 	 * GtkSourceMark
200 	 */
201 	void addOnQueryTooltipText(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
202 	{
203 		if ( !("query-tooltip-text" in connectedSignals) )
204 		{
205 			Signals.connectData(
206 			getStruct(),
207 			"query-tooltip-text",
208 			cast(GCallback)&callBackQueryTooltipText,
209 			cast(void*)this,
210 			null,
211 			connectFlags);
212 			connectedSignals["query-tooltip-text"] = 1;
213 		}
214 		onQueryTooltipTextListeners ~= dlg;
215 	}
216 	extern(C) static void callBackQueryTooltipText(GtkSourceMarkAttributes* attributesStruct, GtkSourceMark* mark, SourceMarkAttributes _sourceMarkAttributes)
217 	{
218 		foreach ( string delegate(SourceMark, SourceMarkAttributes) dlg ; _sourceMarkAttributes.onQueryTooltipTextListeners )
219 		{
220 			dlg(ObjectG.getDObject!(SourceMark)(mark), _sourceMarkAttributes);
221 		}
222 	}
223 	
224 	
225 	/**
226 	 * Creates a new source mark attributes.
227 	 * Throws: ConstructionException GTK+ fails to create the object.
228 	 */
229 	public this ()
230 	{
231 		// GtkSourceMarkAttributes * gtk_source_mark_attributes_new  (void);
232 		auto p = gtk_source_mark_attributes_new();
233 		if(p is null)
234 		{
235 			throw new ConstructionException("null returned by gtk_source_mark_attributes_new()");
236 		}
237 		this(cast(GtkSourceMarkAttributes*) p);
238 	}
239 	
240 	/**
241 	 * Sets background color to the one given in background.
242 	 * Params:
243 	 * background = a GdkRGBA.
244 	 */
245 	public void setBackground(RGBA background)
246 	{
247 		// void gtk_source_mark_attributes_set_background  (GtkSourceMarkAttributes *attributes,  const GdkRGBA *background);
248 		gtk_source_mark_attributes_set_background(gtkSourceMarkAttributes, (background is null) ? null : background.getRGBAStruct());
249 	}
250 	
251 	/**
252 	 * Stores background color in background.
253 	 * Params:
254 	 * background = a GdkRGBA. [out caller-allocates]
255 	 * Returns: whether background color for attributes was set.
256 	 */
257 	public int getBackground(RGBA background)
258 	{
259 		// gboolean gtk_source_mark_attributes_get_background  (GtkSourceMarkAttributes *attributes,  GdkRGBA *background);
260 		return gtk_source_mark_attributes_get_background(gtkSourceMarkAttributes, (background is null) ? null : background.getRGBAStruct());
261 	}
262 	
263 	/**
264 	 * Warning
265 	 * gtk_source_mark_attributes_set_stock_id has been deprecated since version 3.10 and should not be used in newly-written code. Don't use this function.
266 	 * Sets stock id to be used as a base for rendered icon.
267 	 * Params:
268 	 * stockId = a stock id.
269 	 */
270 	public void setStockId(string stockId)
271 	{
272 		// void gtk_source_mark_attributes_set_stock_id  (GtkSourceMarkAttributes *attributes,  const gchar *stock_id);
273 		gtk_source_mark_attributes_set_stock_id(gtkSourceMarkAttributes, Str.toStringz(stockId));
274 	}
275 	
276 	/**
277 	 * Warning
278 	 * gtk_source_mark_attributes_get_stock_id has been deprecated since version 3.10 and should not be used in newly-written code. Don't use this function.
279 	 * Gets a stock id of an icon used by this attributes. Note that the stock id can
280 	 * be NULL if it wasn't set earlier.
281 	 * Returns: Stock id. Returned string is owned by attributes and shouldn't be freed. [transfer none]
282 	 */
283 	public string getStockId()
284 	{
285 		// const gchar * gtk_source_mark_attributes_get_stock_id  (GtkSourceMarkAttributes *attributes);
286 		return Str.toString(gtk_source_mark_attributes_get_stock_id(gtkSourceMarkAttributes));
287 	}
288 	
289 	/**
290 	 * Sets a name of an icon to be used as a base for rendered icon.
291 	 * Params:
292 	 * iconName = name of an icon to be used.
293 	 */
294 	public void setIconName(string iconName)
295 	{
296 		// void gtk_source_mark_attributes_set_icon_name  (GtkSourceMarkAttributes *attributes,  const gchar *icon_name);
297 		gtk_source_mark_attributes_set_icon_name(gtkSourceMarkAttributes, Str.toStringz(iconName));
298 	}
299 	
300 	/**
301 	 * Gets a name of an icon to be used as a base for rendered icon. Note that the
302 	 * icon name can be NULL if it wasn't set earlier.
303 	 * Returns: An icon name. The string belongs to attributes and should not be freed. [transfer none]
304 	 */
305 	public string getIconName()
306 	{
307 		// const gchar * gtk_source_mark_attributes_get_icon_name  (GtkSourceMarkAttributes *attributes);
308 		return Str.toString(gtk_source_mark_attributes_get_icon_name(gtkSourceMarkAttributes));
309 	}
310 	
311 	/**
312 	 * Sets an icon to be used as a base for rendered icon.
313 	 * Params:
314 	 * gicon = a GIcon to be used.
315 	 */
316 	public void setGicon(IconIF gicon)
317 	{
318 		// void gtk_source_mark_attributes_set_gicon  (GtkSourceMarkAttributes *attributes,  GIcon *gicon);
319 		gtk_source_mark_attributes_set_gicon(gtkSourceMarkAttributes, (gicon is null) ? null : gicon.getIconTStruct());
320 	}
321 	
322 	/**
323 	 * Gets a GIcon to be used as a base for rendered icon. Note that the icon can
324 	 * be NULL if it wasn't set earlier.
325 	 * Returns: An icon. The icon belongs to attributes and should not be unreffed. [transfer none]
326 	 */
327 	public IconIF getGicon()
328 	{
329 		// GIcon * gtk_source_mark_attributes_get_gicon  (GtkSourceMarkAttributes *attributes);
330 		auto p = gtk_source_mark_attributes_get_gicon(gtkSourceMarkAttributes);
331 		
332 		if(p is null)
333 		{
334 			return null;
335 		}
336 		
337 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
338 	}
339 	
340 	/**
341 	 * Sets a pixbuf to be used as a base for rendered icon.
342 	 * Params:
343 	 * pixbuf = a GdkPixbuf to be used.
344 	 */
345 	public void setPixbuf(Pixbuf pixbuf)
346 	{
347 		// void gtk_source_mark_attributes_set_pixbuf  (GtkSourceMarkAttributes *attributes,  const GdkPixbuf *pixbuf);
348 		gtk_source_mark_attributes_set_pixbuf(gtkSourceMarkAttributes, (pixbuf is null) ? null : pixbuf.getPixbufStruct());
349 	}
350 	
351 	/**
352 	 * Gets a GdkPixbuf to be used as a base for rendered icon. Note that the
353 	 * pixbuf can be NULL if it wasn't set earlier.
354 	 * Returns: A pixbuf. The pixbuf belongs to attributes and should not be unreffed. [transfer none]
355 	 */
356 	public Pixbuf getPixbuf()
357 	{
358 		// const GdkPixbuf * gtk_source_mark_attributes_get_pixbuf  (GtkSourceMarkAttributes *attributes);
359 		auto p = gtk_source_mark_attributes_get_pixbuf(gtkSourceMarkAttributes);
360 		
361 		if(p is null)
362 		{
363 			return null;
364 		}
365 		
366 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
367 	}
368 	
369 	/**
370 	 * Renders an icon of given size. The base of the icon is set by the last call
371 	 * to one of: gtk_source_mark_attributes_set_pixbuf(),
372 	 * gtk_source_mark_attributes_set_gicon(),
373 	 * gtk_source_mark_attributes_set_icon_name() or
374 	 * gtk_source_mark_attributes_set_stock_id(). size cannot be lower than 1.
375 	 * Params:
376 	 * widget = widget of which style settings may be used.
377 	 * size = size of the rendered icon.
378 	 * Returns: A rendered pixbuf. The pixbuf belongs to attributes and should not be unreffed. [transfer none]
379 	 */
380 	public Pixbuf renderIcon(Widget widget, int size)
381 	{
382 		// const GdkPixbuf * gtk_source_mark_attributes_render_icon  (GtkSourceMarkAttributes *attributes,  GtkWidget *widget,  gint size);
383 		auto p = gtk_source_mark_attributes_render_icon(gtkSourceMarkAttributes, (widget is null) ? null : widget.getWidgetStruct(), size);
384 		
385 		if(p is null)
386 		{
387 			return null;
388 		}
389 		
390 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
391 	}
392 	
393 	/**
394 	 * Queries for a tooltip by emitting
395 	 * a "query-tooltip-text" signal. The tooltip is a plain
396 	 * text.
397 	 * Params:
398 	 * mark = a GtkSourceMark.
399 	 * Returns: A tooltip. The returned string should be freed by using g_free() when done with it. [transfer full]
400 	 */
401 	public string getTooltipText(SourceMark mark)
402 	{
403 		// gchar * gtk_source_mark_attributes_get_tooltip_text  (GtkSourceMarkAttributes *attributes,  GtkSourceMark *mark);
404 		return Str.toString(gtk_source_mark_attributes_get_tooltip_text(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()));
405 	}
406 	
407 	/**
408 	 * Queries for a tooltip by emitting
409 	 * a "query-tooltip-markup" signal. The tooltip may contain
410 	 * a markup.
411 	 * Params:
412 	 * mark = a GtkSourceMark.
413 	 * Returns: A tooltip. The returned string should be freed by using g_free() when done with it. [transfer full]
414 	 */
415 	public string getTooltipMarkup(SourceMark mark)
416 	{
417 		// gchar * gtk_source_mark_attributes_get_tooltip_markup  (GtkSourceMarkAttributes *attributes,  GtkSourceMark *mark);
418 		return Str.toString(gtk_source_mark_attributes_get_tooltip_markup(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()));
419 	}
420 }