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.Settings;
26 
27 private import gdk.Screen;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.ParamSpec;
31 private import gtk.StyleProviderIF;
32 private import gtk.StyleProviderT;
33 private import gtkc.gtk;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * GtkSettings provide a mechanism to share global settings between
39  * applications.
40  * 
41  * On the X window system, this sharing is realized by an
42  * [XSettings](http://www.freedesktop.org/wiki/Specifications/xsettings-spec)
43  * manager that is usually part of the desktop environment, along with
44  * utilities that let the user change these settings. In the absence of
45  * an Xsettings manager, GTK+ reads default values for settings from
46  * `settings.ini` files in
47  * `/etc/gtk-3.0`, `$XDG_CONFIG_DIRS/gtk-3.0`
48  * and `$XDG_CONFIG_HOME/gtk-3.0`.
49  * These files must be valid key files (see #GKeyFile), and have
50  * a section called Settings. Themes can also provide default values
51  * for settings by installing a `settings.ini` file
52  * next to their `gtk.css` file.
53  * 
54  * Applications can override system-wide settings with
55  * gtk_settings_set_string_property(), gtk_settings_set_long_property(),
56  * etc. This should be restricted to special cases though; GtkSettings are
57  * not meant as an application configuration facility. When doing so, you
58  * need to be aware that settings that are specific to individual widgets
59  * may not be available before the widget type has been realized at least
60  * once. The following example demonstrates a way to do this:
61  * |[<!-- language="C" -->
62  * gtk_init (&argc, &argv);
63  * 
64  * // make sure the type is realized
65  * g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM));
66  * 
67  * g_object_set (gtk_settings_get_default (), "gtk-enable-animations", FALSE, NULL);
68  * ]|
69  * 
70  * There is one GtkSettings instance per screen. It can be obtained with
71  * gtk_settings_get_for_screen(), but in many cases, it is more convenient
72  * to use gtk_widget_get_settings(). gtk_settings_get_default() returns the
73  * GtkSettings instance for the default screen.
74  */
75 public class Settings : ObjectG, StyleProviderIF
76 {
77 	/** the main Gtk struct */
78 	protected GtkSettings* gtkSettings;
79 
80 	/** Get the main Gtk struct */
81 	public GtkSettings* getSettingsStruct()
82 	{
83 		return gtkSettings;
84 	}
85 
86 	/** the main Gtk struct as a void* */
87 	protected override void* getStruct()
88 	{
89 		return cast(void*)gtkSettings;
90 	}
91 
92 	protected override void setStruct(GObject* obj)
93 	{
94 		gtkSettings = cast(GtkSettings*)obj;
95 		super.setStruct(obj);
96 	}
97 
98 	/**
99 	 * Sets our main struct and passes it to the parent class.
100 	 */
101 	public this (GtkSettings* gtkSettings, bool ownedRef = false)
102 	{
103 		this.gtkSettings = gtkSettings;
104 		super(cast(GObject*)gtkSettings, ownedRef);
105 	}
106 
107 	// add the StyleProvider capabilities
108 	mixin StyleProviderT!(GtkSettings);
109 
110 	/**
111 	 */
112 
113 	public static GType getType()
114 	{
115 		return gtk_settings_get_type();
116 	}
117 
118 	/**
119 	 * Gets the #GtkSettings object for the default GDK screen, creating
120 	 * it if necessary. See gtk_settings_get_for_screen().
121 	 *
122 	 * Return: a #GtkSettings object. If there is no default
123 	 *     screen, then returns %NULL.
124 	 */
125 	public static Settings getDefault()
126 	{
127 		auto p = gtk_settings_get_default();
128 		
129 		if(p is null)
130 		{
131 			return null;
132 		}
133 		
134 		return ObjectG.getDObject!(Settings)(cast(GtkSettings*) p);
135 	}
136 
137 	/**
138 	 * Gets the #GtkSettings object for @screen, creating it if necessary.
139 	 *
140 	 * Params:
141 	 *     screen = a #GdkScreen.
142 	 *
143 	 * Return: a #GtkSettings object.
144 	 *
145 	 * Since: 2.2
146 	 */
147 	public static Settings getForScreen(Screen screen)
148 	{
149 		auto p = gtk_settings_get_for_screen((screen is null) ? null : screen.getScreenStruct());
150 		
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 		
156 		return ObjectG.getDObject!(Settings)(cast(GtkSettings*) p);
157 	}
158 
159 	public static void installProperty(ParamSpec pspec)
160 	{
161 		gtk_settings_install_property((pspec is null) ? null : pspec.getParamSpecStruct());
162 	}
163 
164 	public static void installPropertyParser(ParamSpec pspec, GtkRcPropertyParser parser)
165 	{
166 		gtk_settings_install_property_parser((pspec is null) ? null : pspec.getParamSpecStruct(), parser);
167 	}
168 
169 	public void setDoubleProperty(string name, double vDouble, string origin)
170 	{
171 		gtk_settings_set_double_property(gtkSettings, Str.toStringz(name), vDouble, Str.toStringz(origin));
172 	}
173 
174 	public void setLongProperty(string name, glong vLong, string origin)
175 	{
176 		gtk_settings_set_long_property(gtkSettings, Str.toStringz(name), vLong, Str.toStringz(origin));
177 	}
178 
179 	public void setPropertyValue(string name, GtkSettingsValue* svalue)
180 	{
181 		gtk_settings_set_property_value(gtkSettings, Str.toStringz(name), svalue);
182 	}
183 
184 	public void setStringProperty(string name, string vString, string origin)
185 	{
186 		gtk_settings_set_string_property(gtkSettings, Str.toStringz(name), Str.toStringz(vString), Str.toStringz(origin));
187 	}
188 }