/usr/include/d/gtkd-3/gtk/CssProvider.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gtk.CssProvider;
private import gio.FileIF;
private import glib.ConstructionException;
private import glib.ErrorG;
private import glib.GException;
private import glib.Str;
private import gobject.ObjectG;
private import gobject.Signals;
private import gtk.CssSection;
private import gtk.StyleProviderIF;
private import gtk.StyleProviderT;
private import gtk.c.functions;
public import gtk.c.types;
public import gtkc.gtktypes;
private import std.algorithm;
/**
* GtkCssProvider is an object implementing the #GtkStyleProvider interface.
* It is able to parse [CSS-like][css-overview] input in order to style widgets.
*
* An application can make GTK+ parse a specific CSS style sheet by calling
* gtk_css_provider_load_from_file() or gtk_css_provider_load_from_resource()
* and adding the provider with gtk_style_context_add_provider() or
* gtk_style_context_add_provider_for_screen().
*
* In addition, certain files will be read when GTK+ is initialized. First, the
* file `$XDG_CONFIG_HOME/gtk-3.0/gtk.css` is loaded if it exists. Then, GTK+
* loads the first existing file among
* `XDG_DATA_HOME/themes/theme-name/gtk-VERSION/gtk.css`,
* `$HOME/.themes/theme-name/gtk-VERSION/gtk.css`,
* `$XDG_DATA_DIRS/themes/theme-name/gtk-VERSION/gtk.css` and
* `DATADIR/share/themes/THEME/gtk-VERSION/gtk.css`, where `THEME` is the name of
* the current theme (see the #GtkSettings:gtk-theme-name setting), `DATADIR`
* is the prefix configured when GTK+ was compiled (unless overridden by the
* `GTK_DATA_PREFIX` environment variable), and `VERSION` is the GTK+ version number.
* If no file is found for the current version, GTK+ tries older versions all the
* way back to 3.0.
*
* In the same way, GTK+ tries to load a gtk-keys.css file for the current
* key theme, as defined by #GtkSettings:gtk-key-theme-name.
*/
public class CssProvider : ObjectG, StyleProviderIF
{
/** the main Gtk struct */
protected GtkCssProvider* gtkCssProvider;
/** Get the main Gtk struct */
public GtkCssProvider* getCssProviderStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gtkCssProvider;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gtkCssProvider;
}
protected override void setStruct(GObject* obj)
{
gtkCssProvider = cast(GtkCssProvider*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GtkCssProvider* gtkCssProvider, bool ownedRef = false)
{
this.gtkCssProvider = gtkCssProvider;
super(cast(GObject*)gtkCssProvider, ownedRef);
}
// add the StyleProvider capabilities
mixin StyleProviderT!(GtkCssProvider);
/** */
public static GType getType()
{
return gtk_css_provider_get_type();
}
/**
* Returns a newly created #GtkCssProvider.
*
* Returns: A new #GtkCssProvider
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this()
{
auto p = gtk_css_provider_new();
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GtkCssProvider*) p, true);
}
/**
* Returns the provider containing the style settings used as a
* fallback for all widgets.
*
* Returns: The provider used for fallback styling.
* This memory is owned by GTK+, and you must not free it.
*/
public static CssProvider getDefault()
{
auto p = gtk_css_provider_get_default();
if(p is null)
{
return null;
}
return ObjectG.getDObject!(CssProvider)(cast(GtkCssProvider*) p);
}
/**
* Loads a theme from the usual theme paths
*
* Params:
* name = A theme name
* variant = variant to load, for example, "dark", or
* %NULL for the default
*
* Returns: a #GtkCssProvider with the theme loaded.
* This memory is owned by GTK+, and you must not free it.
*/
public static CssProvider getNamed(string name, string variant)
{
auto p = gtk_css_provider_get_named(Str.toStringz(name), Str.toStringz(variant));
if(p is null)
{
return null;
}
return ObjectG.getDObject!(CssProvider)(cast(GtkCssProvider*) p);
}
/**
* Loads @data into @css_provider, and by doing so clears any previously loaded
* information.
*
* Params:
* data = CSS data loaded in memory
*
* Returns: %TRUE. The return value is deprecated and %FALSE will only be
* returned for backwards compatibility reasons if an @error is not
* %NULL and a loading error occurred. To track errors while loading
* CSS, connect to the #GtkCssProvider::parsing-error signal.
*
* Throws: GException on failure.
*/
public bool loadFromData(string data)
{
GError* err = null;
auto p = gtk_css_provider_load_from_data(gtkCssProvider, Str.toStringz(data), cast(ptrdiff_t)data.length, &err) != 0;
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Loads the data contained in @file into @css_provider, making it
* clear any previously loaded information.
*
* Params:
* file = #GFile pointing to a file to load
*
* Returns: %TRUE. The return value is deprecated and %FALSE will only be
* returned for backwards compatibility reasons if an @error is not
* %NULL and a loading error occurred. To track errors while loading
* CSS, connect to the #GtkCssProvider::parsing-error signal.
*
* Throws: GException on failure.
*/
public bool loadFromFile(FileIF file)
{
GError* err = null;
auto p = gtk_css_provider_load_from_file(gtkCssProvider, (file is null) ? null : file.getFileStruct(), &err) != 0;
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Loads the data contained in @path into @css_provider, making it clear
* any previously loaded information.
*
* Params:
* path = the path of a filename to load, in the GLib filename encoding
*
* Returns: %TRUE. The return value is deprecated and %FALSE will only be
* returned for backwards compatibility reasons if an @error is not
* %NULL and a loading error occurred. To track errors while loading
* CSS, connect to the #GtkCssProvider::parsing-error signal.
*
* Throws: GException on failure.
*/
public bool loadFromPath(string path)
{
GError* err = null;
auto p = gtk_css_provider_load_from_path(gtkCssProvider, Str.toStringz(path), &err) != 0;
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Loads the data contained in the resource at @resource_path into
* the #GtkCssProvider, clearing any previously loaded information.
*
* To track errors while loading CSS, connect to the
* #GtkCssProvider::parsing-error signal.
*
* Params:
* resourcePath = a #GResource resource path
*
* Since: 3.16
*/
public void loadFromResource(string resourcePath)
{
gtk_css_provider_load_from_resource(gtkCssProvider, Str.toStringz(resourcePath));
}
/**
* Converts the @provider into a string representation in CSS
* format.
*
* Using gtk_css_provider_load_from_data() with the return value
* from this function on a new provider created with
* gtk_css_provider_new() will basically create a duplicate of
* this @provider.
*
* Returns: a new string representing the @provider.
*
* Since: 3.2
*/
public override string toString()
{
auto retStr = gtk_css_provider_to_string(gtkCssProvider);
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
protected class OnParsingErrorDelegateWrapper
{
void delegate(CssSection, ErrorG, CssProvider) dlg;
gulong handlerId;
this(void delegate(CssSection, ErrorG, CssProvider) dlg)
{
this.dlg = dlg;
onParsingErrorListeners ~= this;
}
void remove(OnParsingErrorDelegateWrapper source)
{
foreach(index, wrapper; onParsingErrorListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onParsingErrorListeners[index] = null;
onParsingErrorListeners = std.algorithm.remove(onParsingErrorListeners, index);
break;
}
}
}
}
OnParsingErrorDelegateWrapper[] onParsingErrorListeners;
/**
* Signals that a parsing error occurred. the @path, @line and @position
* describe the actual location of the error as accurately as possible.
*
* Parsing errors are never fatal, so the parsing will resume after
* the error. Errors may however cause parts of the given
* data or even all of it to not be parsed at all. So it is a useful idea
* to check that the parsing succeeds by connecting to this signal.
*
* Note that this signal may be emitted at any time as the css provider
* may opt to defer parsing parts or all of the input to a later time
* than when a loading function was called.
*
* Params:
* section = section the error happened in
* error = The parsing error
*/
gulong addOnParsingError(void delegate(CssSection, ErrorG, CssProvider) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnParsingErrorDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"parsing-error",
cast(GCallback)&callBackParsingError,
cast(void*)wrapper,
cast(GClosureNotify)&callBackParsingErrorDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackParsingError(GtkCssProvider* cssproviderStruct, GtkCssSection* section, GError* error, OnParsingErrorDelegateWrapper wrapper)
{
wrapper.dlg(ObjectG.getDObject!(CssSection)(section), new ErrorG(error), wrapper.outer);
}
extern(C) static void callBackParsingErrorDestroy(OnParsingErrorDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
}
|