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 gtk.TextAttributes;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtkc.gtk;
30 public  import gtkc.gtktypes;
31 private import gtkd.Loader;
32 
33 
34 /**
35  * Using #GtkTextAttributes directly should rarely be necessary.
36  * It’s primarily useful with gtk_text_iter_get_attributes().
37  * As with most GTK+ structs, the fields in this struct should only
38  * be read, never modified directly.
39  */
40 public class TextAttributes
41 {
42 	/** the main Gtk struct */
43 	protected GtkTextAttributes* gtkTextAttributes;
44 	protected bool ownedRef;
45 
46 	/** Get the main Gtk struct */
47 	public GtkTextAttributes* getTextAttributesStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gtkTextAttributes;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)gtkTextAttributes;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GtkTextAttributes* gtkTextAttributes, bool ownedRef = false)
64 	{
65 		this.gtkTextAttributes = gtkTextAttributes;
66 		this.ownedRef = ownedRef;
67 	}
68 
69 	~this ()
70 	{
71 		if (  Linker.isLoaded(LIBRARY_GTK) && ownedRef )
72 			gtk_text_attributes_unref(gtkTextAttributes);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return gtk_text_attributes_get_type();
80 	}
81 
82 	/**
83 	 * Creates a #GtkTextAttributes, which describes
84 	 * a set of properties on some text.
85 	 *
86 	 * Returns: a new #GtkTextAttributes,
87 	 *     free with gtk_text_attributes_unref().
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this()
92 	{
93 		auto p = gtk_text_attributes_new();
94 		
95 		if(p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 		
100 		this(cast(GtkTextAttributes*) p);
101 	}
102 
103 	/**
104 	 * Copies @src and returns a new #GtkTextAttributes.
105 	 *
106 	 * Returns: a copy of @src,
107 	 *     free with gtk_text_attributes_unref()
108 	 */
109 	public TextAttributes copy()
110 	{
111 		auto p = gtk_text_attributes_copy(gtkTextAttributes);
112 		
113 		if(p is null)
114 		{
115 			return null;
116 		}
117 		
118 		return ObjectG.getDObject!(TextAttributes)(cast(GtkTextAttributes*) p, true);
119 	}
120 
121 	/**
122 	 * Copies the values from @src to @dest so that @dest has
123 	 * the same values as @src. Frees existing values in @dest.
124 	 *
125 	 * Params:
126 	 *     dest = another #GtkTextAttributes
127 	 */
128 	public void copyValues(TextAttributes dest)
129 	{
130 		gtk_text_attributes_copy_values(gtkTextAttributes, (dest is null) ? null : dest.getTextAttributesStruct());
131 	}
132 
133 	/**
134 	 * Increments the reference count on @values.
135 	 *
136 	 * Returns: the #GtkTextAttributes that were passed in
137 	 */
138 	public TextAttributes doref()
139 	{
140 		auto p = gtk_text_attributes_ref(gtkTextAttributes);
141 		
142 		if(p is null)
143 		{
144 			return null;
145 		}
146 		
147 		return ObjectG.getDObject!(TextAttributes)(cast(GtkTextAttributes*) p, true);
148 	}
149 
150 	/**
151 	 * Decrements the reference count on @values, freeing the structure
152 	 * if the reference count reaches 0.
153 	 */
154 	public void unref()
155 	{
156 		gtk_text_attributes_unref(gtkTextAttributes);
157 	}
158 }