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