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