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