GNOME Bugzilla – Bug 617955
Make it easy for apps to have dark themes
Last modified: 2010-05-10 00:16:23 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.
Created attachment 160458 [details] normal gtk-demo
Created attachment 160459 [details] gtk-demo with Darkilouche renamed "Clearlooks-dark" This time, only with a one line change to gtk-demo.
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.
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?
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...).
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.
(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.
(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.
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.
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.
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.
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.
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.
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...
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.
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'
Pushed with small fixes to the documentation. Attachment 160576 [details] pushed as 4551509 - Make it easy for apps to have dark themes