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