Some applications can respond live to GTK+ theme changes. For example, Thunar, Geany, lxrandr, Hexchat will all update their UI when a theme is changed, for example in lxappearance. These are all GTK+ 2 programs.
On the other hand, evey GTK+ 3 program I have tried so far (including baobab, moserial gucharmap, ghex, pamac, evince, xreader) seems to not be able to reload the theme and requires an application restart.
lxappearance (compiled with gtk2
on my system) is sending a GTK+ "signal" (not 100% on the terminology here in GTK-land) to cause the application reload:
// src/lxappearance.c line 198
static void reload_all_programs()
{
#if GTK_CHECK_VERSION(3, 0, 0)
/* TODO Port this to something else than gdk_event_send_clientmessage_toall */
#else
GdkEventClient event;
event.type = GDK_CLIENT_EVENT;
event.send_event = TRUE;
event.window = NULL;
if( app.use_lxsession )
{
event.message_type = gdk_atom_intern_static_string("_LXSESSION");
event.data.b[0] = 0; /* LXS_RELOAD */
}
else
{
/* if( icon_only )
event.message_type = gdk_atom_intern("_GTK_LOAD_ICONTHEMES", FALSE);
*/
event.message_type = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
}
event.data_format = 8;
gdk_event_send_clientmessage_toall((GdkEvent *)&event);
#endif
}
The _GTK_READ_RCFILES
event is what evidently causes a theme update for all programs in GTK+ 2, but GTK+ 3 programs appear insensitive to it.
The _GTK_READ_RCFILES
approach was also recommended here (in Python).
What would be an equivalent in GTK+ 3 and later?