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