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