Re: Gtk rc file parsing question




Tom Gilbert <gilbertt@tomgilbert.freeserve.co.uk> writes:

> Hi folks,
> 
> My application parses a special rc file, assigning special styles to
> some of my widgets, using named styles, and gtk_widget_set_name.
> 
> This works beautifully.
> 
> I have two different rc files (at the moment), in separate
> directories. One uses colours to change the widgets, the other is a
> pixmap engine theme, assigning backgroung pixmaps to the widgets.
> 
> I have a properties box, allowing users to change between these rc
> files.

[ I'll avoid commenting on whether this is good user interface
  design. What happens if the user has some theme selected
  already? ]
 
> Currently, when the theme is changed, I call gtk_rc_parse with the
> newly selected rc file path, then I call
> gtk_widget_reset_rc_styles(window) where window is a pointer to the
> main window containing the widgets.
>
> This does not do quite what I wanted. This adds the new style to the
> existing ones (the rc files use the same named styles).

The "theme-switching" feature in GTK+ is done by reloading
all the RC files that the application has already loaded.

GTK+ has no provision to forget previously loaded styles.
So, you'll have to do something like the what the theme
switcher does. Create a symlink in the user's home directory
pointing at the correct RC file, read that with 
gtk_rc_parse(), then when you switch to your other
theme, switch the symlink, and call:

 gtk_rc_reparse_all();
 gtk_widget_reset_rc_styles (window);

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]