tags:

views:

8

answers:

1

In a pygtk app, I'm using rc_parse_string to adjust the appearance of my GUI. (Mostly to make it look more native under Windows, and to theme individual widgets.) This, for example, would change the icon theme for my application:

    gtk.rc_parse_string("""
        gtk-icon-theme-name = "Galaxy"
    """)

This works under Windows, but it only works under Linux when gnome-settings-daemon is not running. How do I override the theme settings made by gnome-settings-daemon? (In my application only, without changing system-wide settings!)

(By the way, the same problem occurs when you try to theme an individual app by setting GTK2_RC_FILES. It works for non-native apps like OpenOffice, but fails for native gnome apps as soon as the settings daemon is running.)

A: 

I eventually found out how to do it. To override the icon theme:

settings = gtk.settings_get_default()
settings.set_string_property("gtk-icon-theme-name", "galaxy", "")

There is a list of all possible settings in the GtkSettings documentation.

If you want to package the icon theme with your application, add the script directory to the icon search path before changing the property:

theme = gtk.icon_theme_get_default()
theme.prepend_search_path(sys.path[0])
jdm