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