GNOME Bugzilla – Bug 760790
gtk_widget_override_background_color does not work
Last modified: 2016-02-02 17:17:55 UTC
GdkRGBA transparent = {0, 0, 0, 0}; gtk_widget_override_background_color (GTK_WIDGET (window), 0, &transparent); Nautilus use this to make desktop window transparent and this does not work. I know that function is deprecated, but documentation does not say that it will not work.
I had a similar issue working on the SWT GTK port. We ended up moving all our background methods to CSS/gtk_render_background().
gtk_widget_override_background_color still works, as a quick test confirms. One of the limitations of this API is that it does not override background images. And there is no good way for you to know if a particular widget gets a background image in the current theme. So, I think nautilus would be well advised to move to a bit of application-specific CSS for this.
->3.20
(In reply to Matthias Clasen from comment #2) > gtk_widget_override_background_color still works, as a quick test confirms. > One of the limitations of this API is that it does not override background > images. And there is no good way for you to know if a particular widget gets > a background image in the current theme. But does nautilus set background image? I tried to search, but did not find anything. Maybe Adwaita then set background-image for windows? If not then this is not the case. It just white window instead of transparent window. > So, I think nautilus would be well advised to move to a bit of > application-specific CSS for this. Nautilus has Adwaita.css - I tired to use gtk_widget_class_set_css_name and then in .css file I added background: transparent, but it did not help.
Created attachment 319433 [details] [review] desktop-window: make notebook widget transparent This was not problem with gtk_widget_override_background_color function. Color that I am seeing comes from GtkNotebook. Attached patch fixes this by overriding background also on notebook widget.
Created attachment 319434 [details] [review] desktop-window: restore transparency Same result, but uses css.
Review of attachment 319434 [details] [review]: This one looks better, thanks! However, can you move the css part to the css file that it's already in nautilus?
Review of attachment 319433 [details] [review]: Rejecting as the one with css looks better.
(In reply to Carlos Soriano from comment #7) > Review of attachment 319434 [details] [review] [review]: > > This one looks better, thanks! > However, can you move the css part to the css file that it's already in > nautilus? If you think that it is needed then I can do it, but... Moving it to Adwaita.css will fix it only for Adwaita, but what about other themes? I think desktop window should be transparent always... How about HighContrast theme?
Created attachment 319435 [details] [review] desktop-window: restore transparency (css in Adwaita.css) Here is requested change, but I would say that this will be regression. Previously transparent background was set always, now it will be only under Adwaita. Can be tested by switching to HighContrast.
You are right, I didn't realize that.
Review of attachment 319434 [details] [review]: LGTM
I would set the background in a separate css file that is always loaded.
(In reply to Matthias Clasen from comment #13) > I would set the background in a separate css file that is always loaded. Are you saying that patch 319434 was not good way to fix this? It is always loaded except it does not use css file.
no, its fine.
Created attachment 319487 [details] [review] css: load css that nautilus always need There is some css that nautilus wants to always use regarding of the theme that is used. An example of this is the recently css added for making the desktop backgrund transparent. Additionally, the "round button" css is also always wanted. For that, create a new css file that will have the css we want to always load and load it in the application initialization.
Good idea Matthias
Comment on attachment 319487 [details] [review] css: load css that nautilus always need Attachment 319487 [details] pushed as f3ea3f0 - css: load css that nautilus always need
Created attachment 319488 [details] [review] css: fix commit 7f0e1b0c6869eb I pushed the unfinished patch in a wrong checkout. Push the faulty bits needed to make it complete.
Comment on attachment 319488 [details] [review] css: fix commit 7f0e1b0c6869eb The faulty bits are pushed now. Attachment 319488 [details] pushed as 10189e9 - css: fix commit 7f0e1b0c6869eb
Created attachment 320274 [details] [review] desktop-window: restore transparency (again) GTK+ 31cc642288a4b707bd1400dc258c47f7cfa82829 commit rewrited notebook style and now background color is set on notebook > stack. Update css rule to set transparent background on all elements for nautilus desktop window.
Review of attachment 320274 [details] [review]: hm I don't feel confident to set a transparent background to everything. I think is better to know what we want to match, even if we need to change it. What do you think?
Ok, then how about this diff? diff --git a/src/resources/css/nautilus.css b/src/resources/css/nautilus.css index c8a8fd0..6a8b9a9 100644 --- a/src/resources/css/nautilus.css +++ b/src/resources/css/nautilus.css @@ -4,6 +4,7 @@ } nautilus-desktop-window, -nautilus-desktop-window notebook { - background-color: transparent; +nautilus-desktop-window notebook, +nautilus-desktop-window notebook > stack { + background: transparent; }
(In reply to Alberts Muktupāvels from comment #23) > Ok, then how about this diff? > diff --git a/src/resources/css/nautilus.css b/src/resources/css/nautilus.css > index c8a8fd0..6a8b9a9 100644 > --- a/src/resources/css/nautilus.css > +++ b/src/resources/css/nautilus.css > @@ -4,6 +4,7 @@ > } > > nautilus-desktop-window, > -nautilus-desktop-window notebook { > - background-color: transparent; > +nautilus-desktop-window notebook, > +nautilus-desktop-window notebook > stack { > + background: transparent; > } yep, that looks good to me.
Should I update and attach patch here or can I directly push to master?
Created attachment 320279 [details] [review] desktop-window: restore transparency (again) (v2) GTK+ 31cc642288a4b707bd1400dc258c47f7cfa82829 commit rewrited notebook style and now background color is set on notebook > stack. Update css rule to remove background also from stack.
(In reply to Alberts Muktupāvels from comment #25) > Should I update and attach patch here or can I directly push to master? Better to update it as you did, so we have record of it here.
Review of attachment 320279 [details] [review]: LGTM thanks for keeping track of this issue!