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