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.RcStyle; 26 27 private import gdk.Color; 28 private import glib.ConstructionException; 29 private import glib.ScannerG; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import gtk.Settings; 33 private import gtk.Style; 34 private import gtk.Widget; 35 private import gtkc.gtk; 36 public import gtkc.gtktypes; 37 38 39 /** 40 * The #GtkRcStyle-struct is used to represent a set 41 * of information about the appearance of a widget. 42 * This can later be composited together with other 43 * #GtkRcStyle-struct<!-- -->s to form a #GtkStyle. 44 */ 45 public class RcStyle : ObjectG 46 { 47 /** the main Gtk struct */ 48 protected GtkRcStyle* gtkRcStyle; 49 50 /** Get the main Gtk struct */ 51 public GtkRcStyle* getRcStyleStruct() 52 { 53 return gtkRcStyle; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)gtkRcStyle; 60 } 61 62 protected override void setStruct(GObject* obj) 63 { 64 gtkRcStyle = cast(GtkRcStyle*)obj; 65 super.setStruct(obj); 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkRcStyle* gtkRcStyle, bool ownedRef = false) 72 { 73 this.gtkRcStyle = gtkRcStyle; 74 super(cast(GObject*)gtkRcStyle, ownedRef); 75 } 76 77 deprecated: 78 79 /** 80 */ 81 82 /** */ 83 public static GType getType() 84 { 85 return gtk_rc_style_get_type(); 86 } 87 88 /** 89 * Creates a new #GtkRcStyle with no fields set and 90 * a reference count of 1. 91 * 92 * Deprecated: Use #GtkCssProvider instead. 93 * 94 * Return: the newly-created #GtkRcStyle 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this() 99 { 100 auto p = gtk_rc_style_new(); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GtkRcStyle*) p, true); 108 } 109 110 /** 111 * Makes a copy of the specified #GtkRcStyle. This function 112 * will correctly copy an RC style that is a member of a class 113 * derived from #GtkRcStyle. 114 * 115 * Deprecated: Use #GtkCssProvider instead. 116 * 117 * Return: the resulting #GtkRcStyle 118 */ 119 public RcStyle copy() 120 { 121 auto p = gtk_rc_style_copy(gtkRcStyle); 122 123 if(p is null) 124 { 125 return null; 126 } 127 128 return ObjectG.getDObject!(RcStyle)(cast(GtkRcStyle*) p, true); 129 } 130 131 /** 132 * Adds a file to the list of files to be parsed at the 133 * end of gtk_init(). 134 * 135 * Deprecated: Use #GtkStyleContext with a custom #GtkStyleProvider instead 136 * 137 * Params: 138 * filename = the pathname to the file. If @filename 139 * is not absolute, it is searched in the current directory. 140 */ 141 public static void addDefaultFile(string filename) 142 { 143 gtk_rc_add_default_file(Str.toStringz(filename)); 144 } 145 146 /** 147 * Searches for a theme engine in the GTK+ search path. This function 148 * is not useful for applications and should not be used. 149 * 150 * Deprecated: Use #GtkCssProvider instead. 151 * 152 * Params: 153 * moduleFile = name of a theme engine 154 * 155 * Return: The filename, if found (must be 156 * freed with g_free()), otherwise %NULL. 157 */ 158 public static string findModuleInPath(string moduleFile) 159 { 160 return Str.toString(gtk_rc_find_module_in_path(Str.toStringz(moduleFile))); 161 } 162 163 /** 164 * Looks up a file in pixmap path for the specified #GtkSettings. 165 * If the file is not found, it outputs a warning message using 166 * g_warning() and returns %NULL. 167 * 168 * Deprecated: Use #GtkCssProvider instead. 169 * 170 * Params: 171 * settings = a #GtkSettings 172 * scanner = Scanner used to get line number information for the 173 * warning message, or %NULL 174 * pixmapFile = name of the pixmap file to locate. 175 * 176 * Return: the filename. 177 */ 178 public static string findPixmapInPath(Settings settings, ScannerG scanner, string pixmapFile) 179 { 180 return Str.toString(gtk_rc_find_pixmap_in_path((settings is null) ? null : settings.getSettingsStruct(), (scanner is null) ? null : scanner.getScannerGStruct(), Str.toStringz(pixmapFile))); 181 } 182 183 /** 184 * Retrieves the current list of RC files that will be parsed 185 * at the end of gtk_init(). 186 * 187 * Deprecated: Use #GtkStyleContext instead 188 * 189 * Return: A %NULL-terminated array of filenames. This memory is owned 190 * by GTK+ and must not be freed by the application. If you want 191 * to store this information, you should make a copy. 192 */ 193 public static string[] getDefaultFiles() 194 { 195 return Str.toStringArray(gtk_rc_get_default_files()); 196 } 197 198 /** 199 * Obtains the path to the IM modules file. See the documentation 200 * of the `GTK_IM_MODULE_FILE` 201 * environment variable for more details. 202 * 203 * Deprecated: Use #GtkCssProvider instead. 204 * 205 * Return: a newly-allocated string containing the 206 * name of the file listing the IM modules available for loading 207 */ 208 public static string getImModuleFile() 209 { 210 return Str.toString(gtk_rc_get_im_module_file()); 211 } 212 213 /** 214 * Obtains the path in which to look for IM modules. See the documentation 215 * of the `GTK_PATH` 216 * environment variable for more details about looking up modules. This 217 * function is useful solely for utilities supplied with GTK+ and should 218 * not be used by applications under normal circumstances. 219 * 220 * Deprecated: Use #GtkCssProvider instead. 221 * 222 * Return: a newly-allocated string containing the 223 * path in which to look for IM modules. 224 */ 225 public static string getImModulePath() 226 { 227 return Str.toString(gtk_rc_get_im_module_path()); 228 } 229 230 /** 231 * Returns a directory in which GTK+ looks for theme engines. 232 * For full information about the search for theme engines, 233 * see the docs for `GTK_PATH` in [Running GTK+ Applications][gtk-running]. 234 * 235 * Deprecated: Use #GtkCssProvider instead. 236 * 237 * Return: the directory. (Must be freed with g_free()) 238 */ 239 public static string getModuleDir() 240 { 241 return Str.toString(gtk_rc_get_module_dir()); 242 } 243 244 /** 245 * Finds all matching RC styles for a given widget, 246 * composites them together, and then creates a 247 * #GtkStyle representing the composite appearance. 248 * (GTK+ actually keeps a cache of previously 249 * created styles, so a new style may not be 250 * created.) 251 * 252 * Deprecated: Use #GtkStyleContext instead 253 * 254 * Params: 255 * widget = a #GtkWidget 256 * 257 * Return: the resulting style. No refcount is added 258 * to the returned style, so if you want to save this style around, 259 * you should add a reference yourself. 260 */ 261 public static Style getStyle(Widget widget) 262 { 263 auto p = gtk_rc_get_style((widget is null) ? null : widget.getWidgetStruct()); 264 265 if(p is null) 266 { 267 return null; 268 } 269 270 return ObjectG.getDObject!(Style)(cast(GtkStyle*) p); 271 } 272 273 /** 274 * Creates up a #GtkStyle from styles defined in a RC file by providing 275 * the raw components used in matching. This function may be useful 276 * when creating pseudo-widgets that should be themed like widgets but 277 * don’t actually have corresponding GTK+ widgets. An example of this 278 * would be items inside a GNOME canvas widget. 279 * 280 * The action of gtk_rc_get_style() is similar to: 281 * |[<!-- language="C" --> 282 * gtk_widget_path (widget, NULL, &path, NULL); 283 * gtk_widget_class_path (widget, NULL, &class_path, NULL); 284 * gtk_rc_get_style_by_paths (gtk_widget_get_settings (widget), 285 * path, class_path, 286 * G_OBJECT_TYPE (widget)); 287 * ]| 288 * 289 * Deprecated: Use #GtkStyleContext instead 290 * 291 * Params: 292 * settings = a #GtkSettings object 293 * widgetPath = the widget path to use when looking up the 294 * style, or %NULL if no matching against the widget path should be done 295 * classPath = the class path to use when looking up the style, 296 * or %NULL if no matching against the class path should be done. 297 * type = a type that will be used along with parent types of this type 298 * when matching against class styles, or #G_TYPE_NONE 299 * 300 * Return: A style created by matching 301 * with the supplied paths, or %NULL if nothing matching was 302 * specified and the default style should be used. The returned 303 * value is owned by GTK+ as part of an internal cache, so you 304 * must call g_object_ref() on the returned value if you want to 305 * keep a reference to it. 306 */ 307 public static Style getStyleByPath(Settings settings, string widgetPath, string classPath, GType type) 308 { 309 auto p = gtk_rc_get_style_by_paths((settings is null) ? null : settings.getSettingsStruct(), Str.toStringz(widgetPath), Str.toStringz(classPath), type); 310 311 if(p is null) 312 { 313 return null; 314 } 315 316 return ObjectG.getDObject!(Style)(cast(GtkStyle*) p); 317 } 318 319 /** 320 * Returns the standard directory in which themes should 321 * be installed. (GTK+ does not actually use this directory 322 * itself.) 323 * 324 * Deprecated: Use #GtkCssProvider instead. 325 * 326 * Return: The directory (must be freed with g_free()). 327 */ 328 public static string getThemeDir() 329 { 330 return Str.toString(gtk_rc_get_theme_dir()); 331 } 332 333 /** 334 * Parses a given resource file. 335 * 336 * Deprecated: Use #GtkCssProvider instead. 337 * 338 * Params: 339 * filename = the filename of a file to parse. If @filename is not absolute, it 340 * is searched in the current directory. 341 */ 342 public static void parse(string filename) 343 { 344 gtk_rc_parse(Str.toStringz(filename)); 345 } 346 347 /** 348 * Parses a color in the format expected 349 * in a RC file. 350 * 351 * Note that theme engines should use gtk_rc_parse_color_full() in 352 * order to support symbolic colors. 353 * 354 * Deprecated: Use #GtkCssProvider instead 355 * 356 * Params: 357 * scanner = a #GScanner 358 * color = a pointer to a #GdkColor in which to store 359 * the result 360 * 361 * Return: %G_TOKEN_NONE if parsing succeeded, otherwise the token 362 * that was expected but not found 363 */ 364 public static uint parseColor(ScannerG scanner, out Color color) 365 { 366 GdkColor* outcolor = gMalloc!GdkColor(); 367 368 auto p = gtk_rc_parse_color((scanner is null) ? null : scanner.getScannerGStruct(), outcolor); 369 370 color = ObjectG.getDObject!(Color)(outcolor); 371 372 return p; 373 } 374 375 /** 376 * Parses a color in the format expected 377 * in a RC file. If @style is not %NULL, it will be consulted to resolve 378 * references to symbolic colors. 379 * 380 * Deprecated: Use #GtkCssProvider instead 381 * 382 * Params: 383 * scanner = a #GScanner 384 * style = a #GtkRcStyle, or %NULL 385 * color = a pointer to a #GdkColor in which to store 386 * the result 387 * 388 * Return: %G_TOKEN_NONE if parsing succeeded, otherwise the token 389 * that was expected but not found 390 * 391 * Since: 2.12 392 */ 393 public static uint parseColorFull(ScannerG scanner, RcStyle style, out Color color) 394 { 395 GdkColor* outcolor = gMalloc!GdkColor(); 396 397 auto p = gtk_rc_parse_color_full((scanner is null) ? null : scanner.getScannerGStruct(), (style is null) ? null : style.getRcStyleStruct(), outcolor); 398 399 color = ObjectG.getDObject!(Color)(outcolor); 400 401 return p; 402 } 403 404 /** 405 * Parses a #GtkPathPriorityType variable from the format expected 406 * in a RC file. 407 * 408 * Deprecated: Use #GtkCssProvider instead 409 * 410 * Params: 411 * scanner = a #GScanner (must be initialized for parsing an RC file) 412 * priority = A pointer to #GtkPathPriorityType variable in which 413 * to store the result. 414 * 415 * Return: %G_TOKEN_NONE if parsing succeeded, otherwise the token 416 * that was expected but not found. 417 */ 418 public static uint parsePriority(ScannerG scanner, GtkPathPriorityType* priority) 419 { 420 return gtk_rc_parse_priority((scanner is null) ? null : scanner.getScannerGStruct(), priority); 421 } 422 423 /** 424 * Parses a #GtkStateType variable from the format expected 425 * in a RC file. 426 * 427 * Deprecated: Use #GtkCssProvider instead 428 * 429 * Params: 430 * scanner = a #GScanner (must be initialized for parsing an RC file) 431 * state = A pointer to a #GtkStateType variable in which to 432 * store the result. 433 * 434 * Return: %G_TOKEN_NONE if parsing succeeded, otherwise the token 435 * that was expected but not found. 436 */ 437 public static uint parseState(ScannerG scanner, out GtkStateType state) 438 { 439 return gtk_rc_parse_state((scanner is null) ? null : scanner.getScannerGStruct(), &state); 440 } 441 442 /** 443 * Parses resource information directly from a string. 444 * 445 * Deprecated: Use #GtkCssProvider instead. 446 * 447 * Params: 448 * rcString = a string to parse. 449 */ 450 public static void parseString(string rcString) 451 { 452 gtk_rc_parse_string(Str.toStringz(rcString)); 453 } 454 455 /** 456 * If the modification time on any previously read file for the 457 * default #GtkSettings has changed, discard all style information 458 * and then reread all previously read RC files. 459 * 460 * Deprecated: Use #GtkCssProvider instead. 461 * 462 * Return: %TRUE if the files were reread. 463 */ 464 public static bool reparseAll() 465 { 466 return gtk_rc_reparse_all() != 0; 467 } 468 469 /** 470 * If the modification time on any previously read file 471 * for the given #GtkSettings has changed, discard all style information 472 * and then reread all previously read RC files. 473 * 474 * Deprecated: Use #GtkCssProvider instead. 475 * 476 * Params: 477 * settings = a #GtkSettings 478 * forceLoad = load whether or not anything changed 479 * 480 * Return: %TRUE if the files were reread. 481 */ 482 public static bool reparseAllForSettings(Settings settings, bool forceLoad) 483 { 484 return gtk_rc_reparse_all_for_settings((settings is null) ? null : settings.getSettingsStruct(), forceLoad) != 0; 485 } 486 487 /** 488 * This function recomputes the styles for all widgets that use a 489 * particular #GtkSettings object. (There is one #GtkSettings object 490 * per #GdkScreen, see gtk_settings_get_for_screen()); It is useful 491 * when some global parameter has changed that affects the appearance 492 * of all widgets, because when a widget gets a new style, it will 493 * both redraw and recompute any cached information about its 494 * appearance. As an example, it is used when the default font size 495 * set by the operating system changes. Note that this function 496 * doesn’t affect widgets that have a style set explicitly on them 497 * with gtk_widget_set_style(). 498 * 499 * Deprecated: Use #GtkCssProvider instead. 500 * 501 * Params: 502 * settings = a #GtkSettings 503 * 504 * Since: 2.4 505 */ 506 public static void resetStyles(Settings settings) 507 { 508 gtk_rc_reset_styles((settings is null) ? null : settings.getSettingsStruct()); 509 } 510 511 /** 512 * 513 * 514 * Deprecated: Use #GtkCssProvider instead 515 */ 516 public static ScannerG scannerNew() 517 { 518 auto p = gtk_rc_scanner_new(); 519 520 if(p is null) 521 { 522 return null; 523 } 524 525 return new ScannerG(cast(GScanner*) p); 526 } 527 528 /** 529 * Sets the list of files that GTK+ will read at the 530 * end of gtk_init(). 531 * 532 * Deprecated: Use #GtkStyleContext with a custom #GtkStyleProvider instead 533 * 534 * Params: 535 * filenames = A 536 * %NULL-terminated list of filenames. 537 */ 538 public static void setDefaultFiles(string[] filenames) 539 { 540 gtk_rc_set_default_files(Str.toStringzArray(filenames)); 541 } 542 }