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