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 617955 - Make it easy for apps to have dark themes
Make it easy for apps to have dark themes
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2010-05-06 19:33 UTC by Bastien Nocera
Modified: 2010-05-10 00:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
normal gtk-demo (24.39 KB, image/png)
2010-05-06 19:34 UTC, Bastien Nocera
  Details
gtk-demo with Darkilouche renamed "Clearlooks-dark" (22.89 KB, image/png)
2010-05-06 19:35 UTC, Bastien Nocera
  Details
Make it easy for apps to have dark themes (9.71 KB, patch)
2010-05-06 19:38 UTC, Bastien Nocera
none Details | Review
Make it easy for apps to have dark themes (10.14 KB, patch)
2010-05-06 22:29 UTC, Bastien Nocera
none Details | Review
Make it easy for apps to have dark themes (11.10 KB, patch)
2010-05-06 22:47 UTC, Bastien Nocera
needs-work Details | Review
Make it easy for apps to have dark themes (9.38 KB, patch)
2010-05-07 15:09 UTC, Bastien Nocera
accepted-commit_now Details | Review
Make it easy for apps to have dark themes (10.38 KB, patch)
2010-05-08 14:22 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2010-05-06 19:33:54 UTC
Some types of applications would benefit from having "dark" themes, usually black backgrounds, such as:
- Movie players
- Photo management and display applications

To make it easy for those applications to prefer a dark theme, we're adding the "gtk-application-prefer-dark-theme" GtkSetting, which will make the theme loading code automatically look for a theme with the same name and a "-dark" suffix.

For example: Clearlooks becomes Clearlooks-dark

If not "-dark" theme variant is available, the normal theme will be used.
Comment 1 Bastien Nocera 2010-05-06 19:34:25 UTC
Created attachment 160458 [details]
normal gtk-demo
Comment 2 Bastien Nocera 2010-05-06 19:35:34 UTC
Created attachment 160459 [details]
gtk-demo with Darkilouche renamed "Clearlooks-dark"

This time, only with a one line change to gtk-demo.
Comment 3 Bastien Nocera 2010-05-06 19:38:01 UTC
Created attachment 160460 [details] [review]
Make it easy for apps to have dark themes

Some types of applications would benefit from having "dark" themes,
usually black backgrounds, such as:
* Movie players
* Photo management and display applications

To make it easy for those applications to prefer a dark theme,
we're adding the "gtk-application-prefer-dark-theme" GtkSetting, which
will make the theme loading code automatically look for a theme with
the same name and a "-dark" suffix.

For example: Clearlooks becomes Clearlooks-dark

If not "-dark" theme variant is available, the normal theme will
be used.
Comment 4 Bastien Nocera 2010-05-06 19:42:44 UTC
The only part I don't want to commit is the gtk-demo part. Should I add GOption support, or simply add a "if (argv[1] == --dark)" option to gtk-demo?
Comment 5 Jakub Steiner 2010-05-06 20:41:11 UTC
I think the rationale for the dark theme preference could be summarized like this:

Some applications benefit from minimizing the amount of light pollution that interferes with the content. Good candidates for dark themes are photo and video editors that make the actual content get all the attention and minimize the distraction of the chrome.

Dark themes don't work well for documents, where large spaces are white/light and the dark chrome creates too much contrast (web browser, text editor...).
Comment 6 Hylke Bons 2010-05-06 20:53:58 UTC
I think this can be implemented more cleanly. It feels a bit like shipping two icon themes like ubuntu does. Maybe we can ship two palettes in the gtkrc? so instead of looking up a different theme, we use a different palette for that app.

For example

gtk_color_scheme = ...
gtk_color_scheme_dark =

The dark variant i did for the gnome3 theme can be achieved just by replacing the colours.
Comment 7 Bastien Nocera 2010-05-06 21:15:10 UTC
(In reply to comment #6)
> I think this can be implemented more cleanly. It feels a bit like shipping two
> icon themes like ubuntu does. Maybe we can ship two palettes in the gtkrc? so
> instead of looking up a different theme, we use a different palette for that
> app.
> 
> For example
> 
> gtk_color_scheme = ...
> gtk_color_scheme_dark =
> 
> The dark variant i did for the gnome3 theme can be achieved just by replacing
> the colours.

This would be a pain to do.

We can easily change that to load a gtkrc-dark file, in the same directory as gtkrc. That should be pretty straight forward to modify.
Comment 8 Hylke Bons 2010-05-06 21:39:32 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > I think this can be implemented more cleanly. It feels a bit like shipping two
> > icon themes like ubuntu does. Maybe we can ship two palettes in the gtkrc? so
> > instead of looking up a different theme, we use a different palette for that
> > app.
> > 
> > For example
> > 
> > gtk_color_scheme = ...
> > gtk_color_scheme_dark =
> > 
> > The dark variant i did for the gnome3 theme can be achieved just by replacing
> > the colours.
> 
> This would be a pain to do.
> 
> We can easily change that to load a gtkrc-dark file, in the same directory as
> gtkrc. That should be pretty straight forward to modify.

yea that would be cool. that way we can use includes, so we don't have to keep 2 files up to date.
Comment 9 Bastien Nocera 2010-05-06 22:29:57 UTC
Created attachment 160471 [details] [review]
Make it easy for apps to have dark themes

Some types of applications would benefit from having "dark" themes,
usually black backgrounds, such as:
* Movie players
* Photo management and display applications

To make it easy for those applications to prefer a dark theme,
we're adding the "gtk-application-prefer-dark-theme" GtkSetting, which
will make the theme loading code automatically look for a "gtkrc-dark"
file in the same directory you would usually find a gtkrc file.
the same name and a "-dark" suffix.

If no "-dark" gtkrc variant is available, the normal gtkrc will
be used.
Comment 10 Bastien Nocera 2010-05-06 22:47:06 UTC
Created attachment 160472 [details] [review]
Make it easy for apps to have dark themes

Some types of applications would benefit from having "dark" themes,
usually black backgrounds, such as:
* Movie players
* Photo management and display applications

To make it easy for those applications to prefer a dark theme,
we're adding the "gtk-application-prefer-dark-theme" GtkSetting, which
will make the theme loading code automatically look for a "gtkrc-dark"
file in the same directory you would usually find a gtkrc file.
the same name and a "-dark" suffix.

If no "-dark" gtkrc variant is available, the normal gtkrc will
be used.
Comment 11 Bastien Nocera 2010-05-06 22:48:31 UTC
Same thing, but using a gtkrc-dark alongside a gtkrc file. They don't have to be in the same directory either, which is great :)

$ find /home/hadess/.themes/Clearlooks/
/home/hadess/.themes/Clearlooks/
/home/hadess/.themes/Clearlooks/gtk-2.0
/home/hadess/.themes/Clearlooks/gtk-2.0/gtkrc-dark

And a menu item to switch between dark-theme and normal theme in the appwindow part of gtk-demo.
Comment 12 Matthias Clasen 2010-05-07 13:02:24 UTC
Review of attachment 160472 [details] [review]:

::: gtk/gtksettings.c
@@ +1028,3 @@
+   * Whether the application prefers to use a dark theme, for presentation
+   * applications for example.
+   *

Please add jimmac's paragraph here about the intended use of this property.

@@ +2482,3 @@
+set_application_prefer_dark_theme (GtkSettings *settings,
+				   gboolean     value)
+{

Why are you storing this as object data ?
Just using the regular settings infrastructure should work fine and is, in fact, required to make the priorities work (to prefer eg application-set values over rc values). Look at gtk-auto-mnemonics as an example.
Comment 13 Bastien Nocera 2010-05-07 15:09:01 UTC
Created attachment 160516 [details] [review]
Make it easy for apps to have dark themes

Some types of applications would benefit from having "dark" themes,
usually black backgrounds, such as:
* Movie players
* Photo management and display applications

To make it easy for those applications to prefer a dark theme,
we're adding the "gtk-application-prefer-dark-theme" GtkSetting, which
will make the theme loading code automatically look for a "gtkrc-dark"
file in the same directory you would usually find a gtkrc file.
the same name and a "-dark" suffix.

If no "-dark" gtkrc variant is available, the normal gtkrc will
be used.
Comment 14 Matthias Clasen 2010-05-07 18:11:49 UTC
Looks good to me now. It would be nice to mention the gtkrc-dark thing somewhere in the docs, to make it more 'official'. Lacking a better place to put that info, you could add something to the property docs. Or maybe add a paragraph to the gtkrc docs, where it talks about the order of rc files that are loaded. But that doesn't really mentioning theme rc files at all in the first place...
Comment 15 Bastien Nocera 2010-05-08 14:22:09 UTC
Created attachment 160576 [details] [review]
Make it easy for apps to have dark themes

Some types of applications would benefit from having "dark" themes,
usually black backgrounds, such as:
* Movie players
* Photo management and display applications

To make it easy for those applications to prefer a dark theme,
we're adding the "gtk-application-prefer-dark-theme" GtkSetting, which
will make the theme loading code automatically look for a "gtkrc-dark"
file in the same directory you would usually find a gtkrc file.
the same name and a "-dark" suffix.

If no "-dark" gtkrc variant is available, the normal gtkrc will
be used.
Comment 16 Bastien Nocera 2010-05-08 14:23:29 UTC
I added a paragraph about the theme loading, but can't actually test it, as master fails to compile:
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_arg_flags_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_tree_view_mode_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_ctree_expander_style_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_match_type_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_clist_drag_pos_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_preview_type_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_signal_run_type_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_curve_type_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_side_type_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_cell_type_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_ctree_pos_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_button_action_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_ctree_line_style_get_type'
../../../gtk/.libs/libgtk-x11-3.0.so: undefined reference to `gtk_ctree_expansion_type_get_type'
Comment 17 Bastien Nocera 2010-05-10 00:16:20 UTC
Pushed with small fixes to the documentation.

Attachment 160576 [details] pushed as 4551509 - Make it easy for apps to have dark themes