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