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.FileIF; 28 private import glib.ConstructionException; 29 private import glib.Str; 30 private import glib.StringG; 31 private import glib.c.functions; 32 private import gobject.ObjectG; 33 private import gtk.c.functions; 34 public import gtk.c.types; 35 private import gtkd.Loader; 36 37 38 /** 39 * Defines a part of a CSS document. 40 * 41 * Because sections are nested into one another, you can use 42 * gtk_css_section_get_parent() to get the containing region. 43 */ 44 public class CssSection 45 { 46 /** the main Gtk struct */ 47 protected GtkCssSection* gtkCssSection; 48 protected bool ownedRef; 49 50 /** Get the main Gtk struct */ 51 public GtkCssSection* getCssSectionStruct(bool transferOwnership = false) 52 { 53 if (transferOwnership) 54 ownedRef = false; 55 return gtkCssSection; 56 } 57 58 /** the main Gtk struct as a void* */ 59 protected void* getStruct() 60 { 61 return cast(void*)gtkCssSection; 62 } 63 64 /** 65 * Sets our main struct and passes it to the parent class. 66 */ 67 public this (GtkCssSection* gtkCssSection, bool ownedRef = false) 68 { 69 this.gtkCssSection = gtkCssSection; 70 this.ownedRef = ownedRef; 71 } 72 73 ~this () 74 { 75 if ( Linker.isLoaded(LIBRARY_GTK) && ownedRef ) 76 gtk_css_section_unref(gtkCssSection); 77 } 78 79 80 /** */ 81 public static GType getType() 82 { 83 return gtk_css_section_get_type(); 84 } 85 86 /** 87 * Creates a new `GtkCssSection` referring to the section 88 * in the given `file` from the `start` location to the 89 * `end` location. 90 * 91 * Params: 92 * file = The file this section refers to 93 * start = The start location 94 * end = The end location 95 * 96 * Returns: a new `GtkCssSection` 97 * 98 * Throws: ConstructionException GTK+ fails to create the object. 99 */ 100 public this(FileIF file, GtkCssLocation* start, GtkCssLocation* end) 101 { 102 auto __p = gtk_css_section_new((file is null) ? null : file.getFileStruct(), start, end); 103 104 if(__p is null) 105 { 106 throw new ConstructionException("null returned by new"); 107 } 108 109 this(cast(GtkCssSection*) __p); 110 } 111 112 /** 113 * Returns the location in the CSS document where this section ends. 114 * 115 * Returns: The end location of 116 * this section 117 */ 118 public GtkCssLocation* getEndLocation() 119 { 120 return gtk_css_section_get_end_location(gtkCssSection); 121 } 122 123 /** 124 * Gets the file that @section was parsed from. 125 * 126 * If no such file exists, for example because the CSS was loaded via 127 * [method@Gtk.CssProvider.load_from_data], then `NULL` is returned. 128 * 129 * Returns: the `GFile` from which the `section` 130 * was parsed 131 */ 132 public FileIF getFile() 133 { 134 auto __p = gtk_css_section_get_file(gtkCssSection); 135 136 if(__p is null) 137 { 138 return null; 139 } 140 141 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p); 142 } 143 144 /** 145 * Gets the parent section for the given `section`. 146 * 147 * The parent section is the section that contains this `section`. A special 148 * case are sections of type `GTK_CSS_SECTION_DOCUMEN`T. Their parent will 149 * either be `NULL` if they are the original CSS document that was loaded by 150 * [method@Gtk.CssProvider.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 * Returns: the parent section 155 */ 156 public CssSection getParent() 157 { 158 auto __p = gtk_css_section_get_parent(gtkCssSection); 159 160 if(__p is null) 161 { 162 return null; 163 } 164 165 return ObjectG.getDObject!(CssSection)(cast(GtkCssSection*) __p); 166 } 167 168 /** 169 * Returns the location in the CSS document where this section starts. 170 * 171 * Returns: The start location of 172 * this section 173 */ 174 public GtkCssLocation* getStartLocation() 175 { 176 return gtk_css_section_get_start_location(gtkCssSection); 177 } 178 179 /** 180 * Prints the `section` into `string` in a human-readable form. 181 * 182 * This is a form like `gtk.css:32:1-23` to denote line 32, characters 183 * 1 to 23 in the file `gtk.css`. 184 * 185 * Params: 186 * string_ = a #GString to print to 187 */ 188 public void print(StringG string_) 189 { 190 gtk_css_section_print(gtkCssSection, (string_ is null) ? null : string_.getStringGStruct()); 191 } 192 193 alias doref = ref_; 194 /** 195 * Increments the reference count on `section`. 196 * 197 * Returns: the CSS section itself. 198 */ 199 public CssSection ref_() 200 { 201 auto __p = gtk_css_section_ref(gtkCssSection); 202 203 if(__p is null) 204 { 205 return null; 206 } 207 208 return ObjectG.getDObject!(CssSection)(cast(GtkCssSection*) __p, true); 209 } 210 211 /** 212 * Prints the section into a human-readable text form using 213 * [method@Gtk.CssSection.print]. 214 * 215 * Returns: A new string. 216 */ 217 public override string toString() 218 { 219 auto retStr = gtk_css_section_to_string(gtkCssSection); 220 221 scope(exit) Str.freeString(retStr); 222 return Str.toString(retStr); 223 } 224 225 /** 226 * Decrements the reference count on `section`, freeing the 227 * structure if the reference count reaches 0. 228 */ 229 public void unref() 230 { 231 gtk_css_section_unref(gtkCssSection); 232 } 233 }