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 * Conversion parameters: 26 * inFile = GtkSettings.html 27 * outPack = gtk 28 * outFile = Settings 29 * strct = GtkSettings 30 * realStrct= 31 * ctorStrct= 32 * clss = Settings 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - StyleProviderIF 40 * prefixes: 41 * - gtk_settings_ 42 * - gtk_ 43 * omit structs: 44 * omit prefixes: 45 * omit code: 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - gobject.ParamSpec 50 * - gobject.Value 51 * - glib.StringG 52 * - gdk.Screen 53 * - gtk.StyleProviderT 54 * - gtk.StyleProviderIF 55 * structWrap: 56 * - GParamSpec* -> ParamSpec 57 * - GString* -> StringG 58 * - GValue* -> Value 59 * - GdkScreen* -> Screen 60 * - GtkSettings* -> Settings 61 * module aliases: 62 * local aliases: 63 * overrides: 64 */ 65 66 module gtk.Settings; 67 68 public import gtkc.gtktypes; 69 70 private import gtkc.gtk; 71 private import glib.ConstructionException; 72 private import gobject.ObjectG; 73 74 75 private import glib.Str; 76 private import gobject.ParamSpec; 77 private import gobject.Value; 78 private import glib.StringG; 79 private import gdk.Screen; 80 private import gtk.StyleProviderT; 81 private import gtk.StyleProviderIF; 82 83 84 85 private import gobject.ObjectG; 86 87 /** 88 * GtkSettings provide a mechanism to share global settings between 89 * applications. 90 * 91 * On the X window system, this sharing is realized by an 92 * XSettings 93 * manager that is usually part of the desktop environment, along with 94 * utilities that let the user change these settings. In the absence of 95 * an Xsettings manager, GTK+ reads default values for settings from 96 * settings.ini files in 97 * /etc/gtk-3.0, $XDG_CONFIG_DIRS/gtk-3.0 98 * and $XDG_CONFIG_HOME/gtk-3.0. 99 * These files must be valid key files (see GKeyFile), and have 100 * a section called Settings. Themes can also provide default values 101 * for settings by installing a settings.ini file 102 * next to their gtk.css file. 103 * 104 * Applications can override system-wide settings with 105 * gtk_settings_set_string_property(), gtk_settings_set_long_property(), 106 * etc. This should be restricted to special cases though; GtkSettings are 107 * not meant as an application configuration facility. When doing so, you 108 * need to be aware that settings that are specific to individual widgets 109 * may not be available before the widget type has been realized at least 110 * once. The following example demonstrates a way to do this: 111 * 112 * $(DDOC_COMMENT example) 113 * 114 * There is one GtkSettings instance per screen. It can be obtained with 115 * gtk_settings_get_for_screen(), but in many cases, it is more convenient 116 * to use gtk_widget_get_settings(). gtk_settings_get_default() returns the 117 * GtkSettings instance for the default screen. 118 */ 119 public class Settings : ObjectG, StyleProviderIF 120 { 121 122 /** the main Gtk struct */ 123 protected GtkSettings* gtkSettings; 124 125 126 public GtkSettings* getSettingsStruct() 127 { 128 return gtkSettings; 129 } 130 131 132 /** the main Gtk struct as a void* */ 133 protected override void* getStruct() 134 { 135 return cast(void*)gtkSettings; 136 } 137 138 /** 139 * Sets our main struct and passes it to the parent class 140 */ 141 public this (GtkSettings* gtkSettings) 142 { 143 super(cast(GObject*)gtkSettings); 144 this.gtkSettings = gtkSettings; 145 } 146 147 protected override void setStruct(GObject* obj) 148 { 149 super.setStruct(obj); 150 gtkSettings = cast(GtkSettings*)obj; 151 } 152 153 // add the StyleProvider capabilities 154 mixin StyleProviderT!(GtkSettings); 155 156 /** 157 */ 158 159 /** 160 * Gets the GtkSettings object for the default GDK screen, creating 161 * it if necessary. See gtk_settings_get_for_screen(). 162 * Returns: a GtkSettings object. If there is no default screen, then returns NULL. [transfer none] 163 */ 164 public static Settings getDefault() 165 { 166 // GtkSettings * gtk_settings_get_default (void); 167 auto p = gtk_settings_get_default(); 168 169 if(p is null) 170 { 171 return null; 172 } 173 174 return ObjectG.getDObject!(Settings)(cast(GtkSettings*) p); 175 } 176 177 /** 178 * Gets the GtkSettings object for screen, creating it if necessary. 179 * Since 2.2 180 * Params: 181 * screen = a GdkScreen. 182 * Returns: a GtkSettings object. [transfer none] 183 */ 184 public static Settings getForScreen(Screen screen) 185 { 186 // GtkSettings * gtk_settings_get_for_screen (GdkScreen *screen); 187 auto p = gtk_settings_get_for_screen((screen is null) ? null : screen.getScreenStruct()); 188 189 if(p is null) 190 { 191 return null; 192 } 193 194 return ObjectG.getDObject!(Settings)(cast(GtkSettings*) p); 195 } 196 197 /** 198 */ 199 public static void installProperty(ParamSpec pspec) 200 { 201 // void gtk_settings_install_property (GParamSpec *pspec); 202 gtk_settings_install_property((pspec is null) ? null : pspec.getParamSpecStruct()); 203 } 204 205 /** 206 * Params: 207 * parser = . [scope call] 208 */ 209 public static void installPropertyParser(ParamSpec pspec, GtkRcPropertyParser parser) 210 { 211 // void gtk_settings_install_property_parser (GParamSpec *pspec, GtkRcPropertyParser parser); 212 gtk_settings_install_property_parser((pspec is null) ? null : pspec.getParamSpecStruct(), parser); 213 } 214 215 /** 216 * A GtkRcPropertyParser for use with gtk_settings_install_property_parser() 217 * or gtk_widget_class_install_style_property_parser() which parses a 218 * color given either by its name or in the form 219 * { red, green, blue } where red, green and 220 * blue are integers between 0 and 65535 or floating-point numbers 221 * between 0 and 1. 222 * Params: 223 * pspec = a GParamSpec 224 * gstring = the GString to be parsed 225 * propertyValue = a GValue which must hold GdkColor values. 226 * Returns: TRUE if gstring could be parsed and property_value has been set to the resulting GdkColor. 227 */ 228 public static int rcPropertyParseColor(ParamSpec pspec, StringG gstring, Value propertyValue) 229 { 230 // gboolean gtk_rc_property_parse_color (const GParamSpec *pspec, const GString *gstring, GValue *property_value); 231 return gtk_rc_property_parse_color((pspec is null) ? null : pspec.getParamSpecStruct(), (gstring is null) ? null : gstring.getStringGStruct(), (propertyValue is null) ? null : propertyValue.getValueStruct()); 232 } 233 234 /** 235 * A GtkRcPropertyParser for use with gtk_settings_install_property_parser() 236 * or gtk_widget_class_install_style_property_parser() which parses a single 237 * enumeration value. 238 * The enumeration value can be specified by its name, its nickname or 239 * its numeric value. For consistency with flags parsing, the value 240 * may be surrounded by parentheses. 241 * Params: 242 * pspec = a GParamSpec 243 * gstring = the GString to be parsed 244 * propertyValue = a GValue which must hold enum values. 245 * Returns: TRUE if gstring could be parsed and property_value has been set to the resulting GEnumValue. 246 */ 247 public static int rcPropertyParseEnum(ParamSpec pspec, StringG gstring, Value propertyValue) 248 { 249 // gboolean gtk_rc_property_parse_enum (const GParamSpec *pspec, const GString *gstring, GValue *property_value); 250 return gtk_rc_property_parse_enum((pspec is null) ? null : pspec.getParamSpecStruct(), (gstring is null) ? null : gstring.getStringGStruct(), (propertyValue is null) ? null : propertyValue.getValueStruct()); 251 } 252 253 /** 254 * A GtkRcPropertyParser for use with gtk_settings_install_property_parser() 255 * or gtk_widget_class_install_style_property_parser() which parses flags. 256 * Flags can be specified by their name, their nickname or 257 * numerically. Multiple flags can be specified in the form 258 * "( flag1 | flag2 | ... )". 259 * Params: 260 * pspec = a GParamSpec 261 * gstring = the GString to be parsed 262 * propertyValue = a GValue which must hold flags values. 263 * Returns: TRUE if gstring could be parsed and property_value has been set to the resulting flags value. 264 */ 265 public static int rcPropertyParseFlags(ParamSpec pspec, StringG gstring, Value propertyValue) 266 { 267 // gboolean gtk_rc_property_parse_flags (const GParamSpec *pspec, const GString *gstring, GValue *property_value); 268 return gtk_rc_property_parse_flags((pspec is null) ? null : pspec.getParamSpecStruct(), (gstring is null) ? null : gstring.getStringGStruct(), (propertyValue is null) ? null : propertyValue.getValueStruct()); 269 } 270 271 /** 272 * A GtkRcPropertyParser for use with gtk_settings_install_property_parser() 273 * or gtk_widget_class_install_style_property_parser() which parses a 274 * requisition in the form 275 * "{ width, height }" for integers width and height. 276 * Params: 277 * pspec = a GParamSpec 278 * gstring = the GString to be parsed 279 * propertyValue = a GValue which must hold boxed values. 280 * Returns: TRUE if gstring could be parsed and property_value has been set to the resulting GtkRequisition. 281 */ 282 public static int rcPropertyParseRequisition(ParamSpec pspec, StringG gstring, Value propertyValue) 283 { 284 // gboolean gtk_rc_property_parse_requisition (const GParamSpec *pspec, const GString *gstring, GValue *property_value); 285 return gtk_rc_property_parse_requisition((pspec is null) ? null : pspec.getParamSpecStruct(), (gstring is null) ? null : gstring.getStringGStruct(), (propertyValue is null) ? null : propertyValue.getValueStruct()); 286 } 287 288 /** 289 * A GtkRcPropertyParser for use with gtk_settings_install_property_parser() 290 * or gtk_widget_class_install_style_property_parser() which parses 291 * borders in the form 292 * "{ left, right, top, bottom }" for integers 293 * left, right, top and bottom. 294 * Params: 295 * pspec = a GParamSpec 296 * gstring = the GString to be parsed 297 * propertyValue = a GValue which must hold boxed values. 298 * Returns: TRUE if gstring could be parsed and property_value has been set to the resulting GtkBorder. 299 */ 300 public static int rcPropertyParseBorder(ParamSpec pspec, StringG gstring, Value propertyValue) 301 { 302 // gboolean gtk_rc_property_parse_border (const GParamSpec *pspec, const GString *gstring, GValue *property_value); 303 return gtk_rc_property_parse_border((pspec is null) ? null : pspec.getParamSpecStruct(), (gstring is null) ? null : gstring.getStringGStruct(), (propertyValue is null) ? null : propertyValue.getValueStruct()); 304 } 305 306 /** 307 */ 308 public void setPropertyValue(string name, out GtkSettingsValue svalue) 309 { 310 // void gtk_settings_set_property_value (GtkSettings *settings, const gchar *name, const GtkSettingsValue *svalue); 311 gtk_settings_set_property_value(gtkSettings, Str.toStringz(name), &svalue); 312 } 313 314 /** 315 */ 316 public void setStringProperty(string name, string vString, string origin) 317 { 318 // void gtk_settings_set_string_property (GtkSettings *settings, const gchar *name, const gchar *v_string, const gchar *origin); 319 gtk_settings_set_string_property(gtkSettings, Str.toStringz(name), Str.toStringz(vString), Str.toStringz(origin)); 320 } 321 322 /** 323 */ 324 public void setLongProperty(string name, glong vLong, string origin) 325 { 326 // void gtk_settings_set_long_property (GtkSettings *settings, const gchar *name, glong v_long, const gchar *origin); 327 gtk_settings_set_long_property(gtkSettings, Str.toStringz(name), vLong, Str.toStringz(origin)); 328 } 329 330 /** 331 */ 332 public void setDoubleProperty(string name, double vDouble, string origin) 333 { 334 // void gtk_settings_set_double_property (GtkSettings *settings, const gchar *name, gdouble v_double, const gchar *origin); 335 gtk_settings_set_double_property(gtkSettings, Str.toStringz(name), vDouble, Str.toStringz(origin)); 336 } 337 }