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 by setting the property
55  * of the GtkSettings object with g_object_set(). This should be restricted
56  * to special cases though; GtkSettings are not meant as an application
57  * configuration facility. When doing so, you need to be aware that settings
58  * that are specific to individual widgets may not be available before the
59  * widget type has been realized at least once. The following example
60  * 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(bool transferOwnership = false)
82 	{
83 		if (transferOwnership)
84 			ownedRef = false;
85 		return gtkSettings;
86 	}
87 
88 	/** the main Gtk struct as a void* */
89 	protected override void* getStruct()
90 	{
91 		return cast(void*)gtkSettings;
92 	}
93 
94 	protected override void setStruct(GObject* obj)
95 	{
96 		gtkSettings = cast(GtkSettings*)obj;
97 		super.setStruct(obj);
98 	}
99 
100 	/**
101 	 * Sets our main struct and passes it to the parent class.
102 	 */
103 	public this (GtkSettings* gtkSettings, bool ownedRef = false)
104 	{
105 		this.gtkSettings = gtkSettings;
106 		super(cast(GObject*)gtkSettings, ownedRef);
107 	}
108 
109 	// add the StyleProvider capabilities
110 	mixin StyleProviderT!(GtkSettings);
111 
112 
113 	/** */
114 	public static GType getType()
115 	{
116 		return gtk_settings_get_type();
117 	}
118 
119 	/**
120 	 * Gets the #GtkSettings object for the default GDK screen, creating
121 	 * it if necessary. See gtk_settings_get_for_screen().
122 	 *
123 	 * Returns: a #GtkSettings object. If there is
124 	 *     no default screen, then returns %NULL.
125 	 */
126 	public static Settings getDefault()
127 	{
128 		auto p = gtk_settings_get_default();
129 		
130 		if(p is null)
131 		{
132 			return null;
133 		}
134 		
135 		return ObjectG.getDObject!(Settings)(cast(GtkSettings*) p);
136 	}
137 
138 	/**
139 	 * Gets the #GtkSettings object for @screen, creating it if necessary.
140 	 *
141 	 * Params:
142 	 *     screen = a #GdkScreen.
143 	 *
144 	 * Returns: a #GtkSettings object.
145 	 *
146 	 * Since: 2.2
147 	 */
148 	public static Settings getForScreen(Screen screen)
149 	{
150 		auto p = gtk_settings_get_for_screen((screen is null) ? null : screen.getScreenStruct());
151 		
152 		if(p is null)
153 		{
154 			return null;
155 		}
156 		
157 		return ObjectG.getDObject!(Settings)(cast(GtkSettings*) p);
158 	}
159 
160 	/**
161 	 *
162 	 *
163 	 * Deprecated: This function is not useful outside GTK+.
164 	 */
165 	public static void installProperty(ParamSpec pspec)
166 	{
167 		gtk_settings_install_property((pspec is null) ? null : pspec.getParamSpecStruct());
168 	}
169 
170 	/**
171 	 *
172 	 *
173 	 * Deprecated: This function is not useful outside GTK+.
174 	 */
175 	public static void installPropertyParser(ParamSpec pspec, GtkRcPropertyParser parser)
176 	{
177 		gtk_settings_install_property_parser((pspec is null) ? null : pspec.getParamSpecStruct(), parser);
178 	}
179 
180 	/**
181 	 * Undoes the effect of calling g_object_set() to install an
182 	 * application-specific value for a setting. After this call,
183 	 * the setting will again follow the session-wide value for
184 	 * this setting.
185 	 *
186 	 * Params:
187 	 *     name = the name of the setting to reset
188 	 *
189 	 * Since: 3.20
190 	 */
191 	public void resetProperty(string name)
192 	{
193 		gtk_settings_reset_property(gtkSettings, Str.toStringz(name));
194 	}
195 
196 	/**
197 	 *
198 	 *
199 	 * Deprecated: Use g_object_set() instead.
200 	 */
201 	public void setDoubleProperty(string name, double vDouble, string origin)
202 	{
203 		gtk_settings_set_double_property(gtkSettings, Str.toStringz(name), vDouble, Str.toStringz(origin));
204 	}
205 
206 	/**
207 	 *
208 	 *
209 	 * Deprecated: Use g_object_set() instead.
210 	 */
211 	public void setLongProperty(string name, glong vLong, string origin)
212 	{
213 		gtk_settings_set_long_property(gtkSettings, Str.toStringz(name), vLong, Str.toStringz(origin));
214 	}
215 
216 	/**
217 	 *
218 	 *
219 	 * Deprecated: Use g_object_set() instead.
220 	 */
221 	public void setPropertyValue(string name, GtkSettingsValue* svalue)
222 	{
223 		gtk_settings_set_property_value(gtkSettings, Str.toStringz(name), svalue);
224 	}
225 
226 	/**
227 	 *
228 	 *
229 	 * Deprecated: Use g_object_set() instead.
230 	 */
231 	public void setStringProperty(string name, string vString, string origin)
232 	{
233 		gtk_settings_set_string_property(gtkSettings, Str.toStringz(name), Str.toStringz(vString), Str.toStringz(origin));
234 	}
235 }