Opened 2 years ago

Closed 23 months ago

#14759 closed defect (fixed)

Unable to set background colour for most controls with gtk3

Reported by: gnarlo Owned by:
Priority: normal Milestone:
Component: wxGTK Version: 2.9.4
Keywords: widget background, gtk3, background colour Cc:
Blocked By: Blocking:
Patch: no

Description

Under 2.9.4 compiled against gtk3, background colours for widgets cannot be set.

Steps to reproduce, after compiling:

Compile sample located in ./samples/widgets

Open widgets sample and select "Button"

Select Widget menu-> Set background and select a custom colour

See that nothing changes on button background.

Select Widget menu-> Enable/Disable: now button colour is shown with selected background. Same happens when the window losts its focus (buttons get disabled), and similar behavoir is obtained with other widgets.

Additional information:

Window background colour is set correctly.

When flat button is selected, the button is without any border.

Platform:

OpenSuse 11.2

Gnome 3.4.2

Change History (4)

comment:1 Changed 2 years ago by gnarlo

Setting background color for widgets in gtk3 required CSS styles.

See http://www.gtkforums.com/viewtopic.php?f=3&t=988&p=72089&hilit=background+color#p72089

To do so, gtk_css_provider() should be used, gtk_widget_modify_bg does not work (while it should compile).

comment:2 Changed 2 years ago by pcor

  • Status changed from new to confirmed

wxGTK3 already has support for setting background/foreground colors in a GTK3-compatible way. It works with at least the default built-in theme, but not with some others. I'm guessing the theme engine is ignoring the setting. I don't know what we can do about that.

comment:3 Changed 23 months ago by gnarlo

Here is more information:
Background colour is set using wxWindowGTK::GTKApplyStyle().
This function makes use of gtk_widget_override_background_color().

However, this function seems to be overridden by CSS styles. There is an unconfirmed bug (https://bugzilla.gnome.org/show_bug.cgi?id=656461) that shows exactly what happens here.

This is probably a GTK3 bug...
They should either remove gtk_widget_override_background_color from supported list, or make this function override theme settings.

I'll try to see what I can do with gtk3...
Just to inform you: high contrast themes (without gradients) are working fine.

CSS styles might however override this behavoir and solve the issue but... I don't know plans about that (and if it's worth it).

comment:4 Changed 23 months ago by PC

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [72881]) fix setting background color in wxGTK3 with themes which use background images or gradients, fixes #14759

Note: See TracTickets for help on using tickets.