After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760790 - gtk_widget_override_background_color does not work
gtk_widget_override_background_color does not work
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: Desktop
unspecified
Other Linux
: Normal normal
: 3.20
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-18 16:54 UTC by Alberts Muktupāvels
Modified: 2016-02-02 17:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
desktop-window: make notebook widget transparent (1.44 KB, patch)
2016-01-20 09:25 UTC, Alberts Muktupāvels
rejected Details | Review
desktop-window: restore transparency (2.50 KB, patch)
2016-01-20 09:46 UTC, Alberts Muktupāvels
committed Details | Review
desktop-window: restore transparency (css in Adwaita.css) (2.05 KB, patch)
2016-01-20 10:06 UTC, Alberts Muktupāvels
none Details | Review
css: load css that nautilus always need (4.54 KB, patch)
2016-01-21 09:41 UTC, Carlos Soriano
committed Details | Review
css: fix commit 7f0e1b0c6869eb (1.67 KB, patch)
2016-01-21 09:58 UTC, Carlos Soriano
committed Details | Review
desktop-window: restore transparency (again) (937 bytes, patch)
2016-02-02 16:58 UTC, Alberts Muktupāvels
none Details | Review
desktop-window: restore transparency (again) (v2) (952 bytes, patch)
2016-02-02 17:15 UTC, Alberts Muktupāvels
committed Details | Review

Description Alberts Muktupāvels 2016-01-18 16:54:31 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.
Comment 1 Eric Williams 2016-01-18 17:08:10 UTC
I had a similar issue working on the SWT GTK port. We ended up moving all our background methods to CSS/gtk_render_background().
Comment 2 Matthias Clasen 2016-01-18 21:23:02 UTC
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.
Comment 3 Carlos Soriano 2016-01-19 09:20:54 UTC
->3.20
Comment 4 Alberts Muktupāvels 2016-01-19 10:54:09 UTC
(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.
Comment 5 Alberts Muktupāvels 2016-01-20 09:25:52 UTC
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.
Comment 6 Alberts Muktupāvels 2016-01-20 09:46:24 UTC
Created attachment 319434 [details] [review]
desktop-window: restore transparency

Same result, but uses css.
Comment 7 Carlos Soriano 2016-01-20 09:49:01 UTC
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?
Comment 8 Carlos Soriano 2016-01-20 09:49:35 UTC
Review of attachment 319433 [details] [review]:

Rejecting as the one with css looks better.
Comment 9 Alberts Muktupāvels 2016-01-20 09:54:48 UTC
(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?
Comment 10 Alberts Muktupāvels 2016-01-20 10:06:31 UTC
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.
Comment 11 Carlos Soriano 2016-01-20 10:25:12 UTC
You are right, I didn't realize that.
Comment 12 Carlos Soriano 2016-01-20 10:26:41 UTC
Review of attachment 319434 [details] [review]:

LGTM
Comment 13 Matthias Clasen 2016-01-20 15:17:02 UTC
I would set the background in a separate css file that is always loaded.
Comment 14 Alberts Muktupāvels 2016-01-20 15:20:36 UTC
(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.
Comment 15 Matthias Clasen 2016-01-20 16:14:37 UTC
no, its fine.
Comment 16 Carlos Soriano 2016-01-21 09:41:26 UTC
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.
Comment 17 Carlos Soriano 2016-01-21 09:42:05 UTC
Good idea Matthias
Comment 18 Carlos Soriano 2016-01-21 09:42:59 UTC
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
Comment 19 Carlos Soriano 2016-01-21 09:58:05 UTC
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 20 Carlos Soriano 2016-01-21 09:59:33 UTC
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
Comment 21 Alberts Muktupāvels 2016-02-02 16:58:20 UTC
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.
Comment 22 Carlos Soriano 2016-02-02 17:04:42 UTC
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?
Comment 23 Alberts Muktupāvels 2016-02-02 17:10:40 UTC
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;
 }
Comment 24 Carlos Soriano 2016-02-02 17:11:51 UTC
(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.
Comment 25 Alberts Muktupāvels 2016-02-02 17:12:49 UTC
Should I update and attach patch here or can I directly push to master?
Comment 26 Alberts Muktupāvels 2016-02-02 17:15:31 UTC
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.
Comment 27 Carlos Soriano 2016-02-02 17:16:21 UTC
(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.
Comment 28 Carlos Soriano 2016-02-02 17:16:49 UTC
Review of attachment 320279 [details] [review]:

LGTM thanks for keeping track of this issue!