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