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.CssSection;
26 
27 private import gio.File;
28 private import gio.FileIF;
29 private import gobject.ObjectG;
30 private import gtkc.Loader;
31 private import gtkc.gtk;
32 public  import gtkc.gtktypes;
33 private import gtkc.paths;
34 
35 
36 /**
37  * Defines a part of a CSS document. Because sections are nested into
38  * one another, you can use gtk_css_section_get_parent() to get the
39  * containing region.
40  *
41  * Since: 3.2
42  */
43 public class CssSection
44 {
45 	/** the main Gtk struct */
46 	protected GtkCssSection* gtkCssSection;
47 	protected bool ownedRef;
48 
49 	/** Get the main Gtk struct */
50 	public GtkCssSection* getCssSectionStruct()
51 	{
52 		return gtkCssSection;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct()
57 	{
58 		return cast(void*)gtkCssSection;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GtkCssSection* gtkCssSection, bool ownedRef = false)
65 	{
66 		this.gtkCssSection = gtkCssSection;
67 		this.ownedRef = ownedRef;
68 	}
69 
70 	~this ()
71 	{
72 		if ( Linker.isLoaded(LIBRARY.GTK) && ownedRef )
73 		{
74 			gtk_css_section_unref(gtkCssSection);
75 		}
76 	}
77 
78 	/**
79 	 */
80 
81 	/** */
82 	public static GType getType()
83 	{
84 		return gtk_css_section_get_type();
85 	}
86 
87 	/**
88 	 * Returns the line in the CSS document where this section end.
89 	 * The line number is 0-indexed, so the first line of the document
90 	 * will return 0.
91 	 * This value may change in future invocations of this function if
92 	 * @section is not yet parsed completely. This will for example
93 	 * happen in the GtkCssProvider::parsing-error signal.
94 	 * The end position and line may be identical to the start
95 	 * position and line for sections which failed to parse anything
96 	 * successfully.
97 	 *
98 	 * Return: the line number
99 	 *
100 	 * Since: 3.2
101 	 */
102 	public uint getEndLine()
103 	{
104 		return gtk_css_section_get_end_line(gtkCssSection);
105 	}
106 
107 	/**
108 	 * Returns the offset in bytes from the start of the current line
109 	 * returned via gtk_css_section_get_end_line().
110 	 * This value may change in future invocations of this function if
111 	 * @section is not yet parsed completely. This will for example
112 	 * happen in the GtkCssProvider::parsing-error signal.
113 	 * The end position and line may be identical to the start
114 	 * position and line for sections which failed to parse anything
115 	 * successfully.
116 	 *
117 	 * Return: the offset in bytes from the start of the line.
118 	 *
119 	 * Since: 3.2
120 	 */
121 	public uint getEndPosition()
122 	{
123 		return gtk_css_section_get_end_position(gtkCssSection);
124 	}
125 
126 	/**
127 	 * Gets the file that @section was parsed from. If no such file exists,
128 	 * for example because the CSS was loaded via
129 	 * @gtk_css_provider_load_from_data(), then %NULL is returned.
130 	 *
131 	 * Return: the #GFile that @section was parsed from
132 	 *     or %NULL if @section was parsed from other data
133 	 *
134 	 * Since: 3.2
135 	 */
136 	public FileIF getFile()
137 	{
138 		auto p = gtk_css_section_get_file(gtkCssSection);
139 		
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 		
145 		return ObjectG.getDObject!(File, FileIF)(cast(GFile*) p);
146 	}
147 
148 	/**
149 	 * Gets the parent section for the given @section. The parent section is
150 	 * the section that contains this @section. A special case are sections of
151 	 * type #GTK_CSS_SECTION_DOCUMENT. Their parent will either be %NULL
152 	 * if they are the original CSS document that was loaded by
153 	 * gtk_css_provider_load_from_file() or a section of type
154 	 * #GTK_CSS_SECTION_IMPORT if it was loaded with an import rule from
155 	 * a different file.
156 	 *
157 	 * Return: the parent section or %NULL if none
158 	 *
159 	 * Since: 3.2
160 	 */
161 	public CssSection getParent()
162 	{
163 		auto p = gtk_css_section_get_parent(gtkCssSection);
164 		
165 		if(p is null)
166 		{
167 			return null;
168 		}
169 		
170 		return ObjectG.getDObject!(CssSection)(cast(GtkCssSection*) p);
171 	}
172 
173 	/**
174 	 * Gets the type of information that @section describes.
175 	 *
176 	 * Return: the type of @section
177 	 *
178 	 * Since: 3.2
179 	 */
180 	public GtkCssSectionType getSectionType()
181 	{
182 		return gtk_css_section_get_section_type(gtkCssSection);
183 	}
184 
185 	/**
186 	 * Returns the line in the CSS document where this section starts.
187 	 * The line number is 0-indexed, so the first line of the document
188 	 * will return 0.
189 	 *
190 	 * Return: the line number
191 	 *
192 	 * Since: 3.2
193 	 */
194 	public uint getStartLine()
195 	{
196 		return gtk_css_section_get_start_line(gtkCssSection);
197 	}
198 
199 	/**
200 	 * Returns the offset in bytes from the start of the current line
201 	 * returned via gtk_css_section_get_start_line().
202 	 *
203 	 * Return: the offset in bytes from the start of the line.
204 	 *
205 	 * Since: 3.2
206 	 */
207 	public uint getStartPosition()
208 	{
209 		return gtk_css_section_get_start_position(gtkCssSection);
210 	}
211 
212 	/**
213 	 * Increments the reference count on @section.
214 	 *
215 	 * Return: @section itself.
216 	 *
217 	 * Since: 3.2
218 	 */
219 	public CssSection doref()
220 	{
221 		auto p = gtk_css_section_ref(gtkCssSection);
222 		
223 		if(p is null)
224 		{
225 			return null;
226 		}
227 		
228 		return ObjectG.getDObject!(CssSection)(cast(GtkCssSection*) p, true);
229 	}
230 
231 	/**
232 	 * Decrements the reference count on @section, freeing the
233 	 * structure if the reference count reaches 0.
234 	 *
235 	 * Since: 3.2
236 	 */
237 	public void unref()
238 	{
239 		gtk_css_section_unref(gtkCssSection);
240 	}
241 }