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

-- 


-- 
*Please consider the Environment before printing this e-mail.*




        
        
        
        
The information contained in this message 
(including any attachments) is 
confidential and may be privileged or 
otherwise protected from disclosure. 
 If you are not the intended 
recipient, you must not copy this message or 
attachment or disclose the 
contents to any other person.  If you have 
received this transmission in
 error, please notify the sender immediately 
by return e-mail and 
permanently delete this message and any attachments 
from your system.  
Any dissemination, use, review, distribution, printing 
or copying of 
this message in whole or in part is strictly prohibited.  
Please note 
that e-mails are susceptible to change. 
 
*SKANRAY* 
<http://www.skanray.com>*(including
 its group of companies) shall not be 
liable for any omission or error 
in the message, improper or incomplete 
transmission of the information 
contained in this communication or for any 
delay in its receipt or 
damage to your system. * *SKANRAY* 
<http://www.skanray.com>*(or
 its group of companies) does not guarantee 
that the integrity of this 
communication has been maintained or that this 
communication is free of 
viruses, interceptions or interference.*
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to