Like Daniel mentioned, the background-image property overrides the background-color. It's probably because of this, the API to override the background color is deprecated.
Writing a simple custom CSS would solve your problem eternally. Also once you get to know it, it's not that difficult.
Now technically you can create a CSSProvider and load a custom CSS directly from a file (which is better since you can modify it without having to rebuild your executable) then add the provider to the style context of a particular widget. I would prefer to have it apply to the whole app because then all your widgets will have uniform appearance.
May be you have already found a permanent solution. This is what I would do, in case someone is still interested.
mian.c / root window
void CMainWindow::LoadTheme(const Glib::ustring &sPath)
{
/*
* Unit Name :
* Unit ID : U-MainWindow.cpp-
* Author : mohith (25-Feb-2020, 3:20:06 pm)
* Comments (if any)
*/
{
Glib::RefPtr <Gdk::Screen> refScreen = Gdk::Display::get_default()
->get_default_screen();
Glib::RefPtr <Gtk::CssProvider> refProvider = Gtk::CssProvider::create();
//Remove existing provider
if (m_refCurrentCustomStyleProvider)
{
Gtk::StyleContext::remove_provider_for_screen(refScreen,
m_refCurrentCustomStyleProvider);
}
try
{
refProvider->load_from_path(sPath);
//Add new provider for screen
Gtk::StyleContext::add_provider_for_screen(refScreen,
refProvider,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
m_refCurrentCustomStyleProvider = refProvider;
} catch(Gtk::CssProviderError &e)
{
IDU_CMN_ERROR_OUT << "Error loading custom styles. " << e.what() << std::endl;
} catch(Glib::Error &e)
{
IDU_CMN_ERROR_OUT << "Error loading custom styles. " << e.what() << std::endl;
}
}
}
custom_styles.css
button
{
background-image: unset;
background-color: @activatable-control-color-sensitive;
}
button:overlay
{
background-color: @activatable-control-color-highlight;
}
button:backdrop
{
background-color: @activatable-control-color-insensitive;
}
@define-color activatable-control-color-sensitive white;
@define-color activatable-control-color-highlight #FF9900;
@define-color activatable-control-color-insensitive gray;
Call the CMainWindow::LoadTheme() with the path to your CSS file to load it up.
Regards,
Mohith