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