-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(themes; beautiful): add partial support for GTK+3 themes #2129
Conversation
b60d204
to
d3c78d9
Compare
d3c78d9
to
6c47698
Compare
Codecov Report
@@ Coverage Diff @@
## master #2129 +/- ##
==========================================
+ Coverage 83.83% 83.95% +0.12%
==========================================
Files 464 466 +2
Lines 31798 32151 +353
==========================================
+ Hits 26657 26993 +336
- Misses 5141 5158 +17
Continue to review full report at Codecov.
|
65eda3d
to
2a17cfc
Compare
weird, locally test is passing however in travis |
560db39
to
edc1fe2
Compare
5b62f9e
to
6e59d7b
Compare
Uhm... I've seen that error before recently, on some other PR. Ah, #2119 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically "no". This code pulls a random list of colors from a random list of Gtk widgets without saying what it does in its docs, and then randomly messes with the resulting colors in a magic way to produce a color theme.
Claiming that this reads a GTK+3 theme seems a lot like a lie to me.
Anyway, I left lots of detailed comments.
.travis.yml
Outdated
@@ -42,7 +42,7 @@ install: | |||
- sudo apt-get install -y libcairo2-dev gir1.2-gtk-3.0 xmlto asciidoc libpango1.0-dev libxcb-xtest0-dev libxcb-icccm4-dev libxcb-randr0-dev libxcb-keysyms1-dev libxcb-xinerama0-dev libdbus-1-dev libxdg-basedir-dev libstartup-notification0-dev imagemagick libxcb1-dev libxcb-shape0-dev libxcb-util0-dev libx11-xcb-dev libxcb-cursor-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev | |||
|
|||
# Deps for tests. | |||
- sudo apt-get install -y dbus-x11 xterm xdotool xterm xvfb zsh | |||
- sudo apt-get install -y dbus-x11 xterm xdotool xterm xvfb zsh gtk+3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, what?
From the build log:
Note, selecting 'libgtk3.0-cil-dev' for regex 'gtk+3.0'
Note, selecting 'monodoc-gtk3.0-manual' for regex 'gtk+3.0'
Note, selecting 'libgtk3.0-cil' for regex 'gtk+3.0'
Note, selecting 'gir1.2-dbusmenu-gtk3-0.4' for regex 'gtk+3.0'
Note, selecting 'libinfgtk3-0.5-0' for regex 'gtk+3.0'
Note, selecting 'libseed-gtk3-0' for regex 'gtk+3.0'
Note, selecting 'libavahi-ui-gtk3-0' for regex 'gtk+3.0'
Note, selecting 'libwxgtk3.0-dev' for regex 'gtk+3.0'
Note, selecting 'libcanberra-gtk3-0' for regex 'gtk+3.0'
Note, selecting 'libwxgtk3.0-0' for regex 'gtk+3.0'
Note, selecting 'libwxgtk3.0-0-dbg' for regex 'gtk+3.0'
Note, selecting 'libcanberra-gtk3-0-dbg' for regex 'gtk+3.0'
libcanberra-gtk3-0 is already the newest version (0.30-0ubuntu3).
libcanberra-gtk3-0 set to manually installed.
Also see commit 98b931c.
themes/gtk/theme.lua
Outdated
|
||
theme.bg_normal = theme.gtk.menubar_bg_color | ||
theme.bg_focus = theme.gtk.selected_bg_color | ||
theme.bg_urgent = theme.xrdb.color9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this mixes the GTK theme with "random" values from xrdb? Why should the result end up being a "nice" color scheme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so far it's taking from xrdb only colors for errors, i can also try to render some kind of GtkButton with "Destroyable" role (ie red one) and use color from it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not necessary, as error and warning colors are exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since in majority of other gtk themes stylecontext values are partially missing, destructive/suggested/etc-action
-approach would be more robust
themes/gtk/theme.lua
Outdated
theme.bg_focus = theme.gtk.selected_bg_color | ||
theme.bg_urgent = theme.xrdb.color9 | ||
theme.bg_minimize = theme.gtk.wm_border_unfocused_color | ||
theme.bg_systray = theme.bg_normal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove this. systray.lua
does beautiful.bg_systray or beautiful.bg_normal
. In the other theme this might serve documentary purposes for people who want to hand-edit it, but I guess this one isn't meant for hand-editing...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's still leaving for user a lot of opportunity to customize, in this particular example — to choose for systray gtk.bg_color
, gtk.base_color
or gtk.menubar_bg_color
, etc
themes/gtk/theme.lua
Outdated
theme.fg_normal = theme.gtk.menubar_fg_color | ||
theme.fg_focus = theme.gtk.selected_fg_color | ||
theme.fg_urgent = theme.bg_normal | ||
theme.fg_minimize = theme.bg_normal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems quite random, too. Urgent / minimised clients get menubar_bg_color
as their foreground color and color9
/ wm_border_unfocused_color
as their background color? That's not how these colors are supposed to be used, I think.
themes/gtk/theme.lua
Outdated
local bg_numeric_value = tonumber("0x"..s) - darker_n | ||
if bg_numeric_value < 0 then bg_numeric_value = 0 end | ||
if bg_numeric_value > 255 then bg_numeric_value = 255 end | ||
result = result .. string.format("%2.2x", bg_numeric_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the meaning of this format string? From looking at man 3 printf
I... still have no clue. What's the difference to %02x
?
lib/beautiful/gtk.lua
Outdated
--window:set_override_redirect(true) | ||
local style_context = window:get_style_context() | ||
|
||
local font = style_context:get_font(Gtk.StateFlags.NORMAL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is deprecated: https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-get-font
(And no, I don't understand the replacement nor how to use it)
lib/beautiful/gtk.lua
Outdated
|
||
local font = style_context:get_font(Gtk.StateFlags.NORMAL) | ||
--result.font_family = font:get_family() | ||
--result.font_size = font:get_size()/1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a lot of "you should clean this up" around here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's actually related to your other coment regarding deprecation of :get_font()
lib/beautiful/gtk.lua
Outdated
entry_style_context, style_context_property, Gtk.StateFlags.NORMAL | ||
) | ||
end | ||
entry:destroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the docs for this module should say what this actually does... So the bg/fg_color
s come from the background-color and color of a GtkWindow, the border width is the border-top-width of a GtkEntry and the base_color and text_color come from the background and foreground color of a GtkEntry?!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, if you take a look on gtk3-widget-factory (or any other gtk3 app) you will see what stylecontext values bg/fg are used for windows, text/base - for entries
however if the same values are defined in stylecontext, stylecontext have a higher prority in my code (because of pixmaps/gradients issue described in the previous comment)
lib/beautiful/gtk.lua
Outdated
entry_style_context, style_context_property, Gtk.StateFlags.NORMAL | ||
) | ||
end | ||
entry:destroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I doubt that this entry:destroy()
is necessary. And from the docs for it... I doubt this even more, I think this does not actually do anything (besides setting a destroyed
flag).
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-destroy
lib/beautiful/gtk.lua
Outdated
button_style_context, style_context_property, Gtk.StateFlags.NORMAL | ||
) | ||
end | ||
button:destroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the above code be made more readable by e.g. moving it into a table?
{
object = Gtk.Button(),
properties = {
Gtk.StateFlags.NORMAL = {
border_radius = "border-radiues",
etc
}
}
That way, all that code is only needed once instead of copy&pasted three times.
Perhaps this makes more sense as a self-contained tool? It does all the magic that is done here and then writes (either on stdout or into a file) a theme for awesome? That way people can hand-edit the result if they want. |
lib/beautiful/gtk.lua
Outdated
)) | ||
local label = Gtk.Label() | ||
local label_style_context = label:get_style_context() | ||
local gdk_scale = os.getenv("GDK_SCALE") or 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need a tonumber()
?
lib/beautiful/gtk.lua
Outdated
local label = Gtk.Label() | ||
local label_style_context = label:get_style_context() | ||
local gdk_scale = os.getenv("GDK_SCALE") or 1.0 | ||
local xrdb_scale = dpi(10000) / 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm. Why not just beautiful.xresources.get_dpi() / 96
?
return darker(color, is_dark(color) and -ratio or ratio) | ||
end | ||
|
||
local function choose_contrast_color(reference, candidate1, candidate2) -- luacheck: no unused |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the no unused
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the function itself is not used in the code, but only in the theming examples in the comments
themes/gtk/theme.lua
Outdated
filter = awful.widget.tasklist.filter.currenttags, | ||
- buttons = tasklist_buttons, | ||
- widget_template = beautiful.tasklist_widget_template | ||
+ buttons = tasklist_buttons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, is the patch backwards?
themes/gtk/theme.lua
Outdated
}, | ||
id = 'background_role', | ||
widget = wibox.container.background, | ||
create_callback = function(self, c, index, objects) --luacheck: no unused args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make this function(_, c)
and you do not need the luacheck comment
themes/gtk/theme.lua
Outdated
) | ||
|
||
theme.wibar_bgimage = theme.gtk.menubar_bg_image | ||
--print(theme.wibar_bgimage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, those are leftovers from the next version, which support pixmap-ish themes better, but it wil take some time to come.. :-D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message could need some rewriting and there seem to be unrelated changes in there, but the rest does not seem tooooo bad. I am not sure all of this makes sense, but since it is just in a theme I won't look too closely.
squashed + sanitized the commit message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all my older comments have been addressed. +1
@actionless oh, an you might want to update the optional dependency section of README.md I have updated the NEWS changelog for 4.3, does this description is fine with you (or propose something better):
|
actually it reads not only colors but also border thickness and shape and few more things, however for those things support is very partial so mb your description will be fine (so users won't be expecting too much from it :-) ) yup, i'll update the readme. idk which is the minimal supported gtk3 version but the one installed inside travis seems to be compatible enough :-) |
seems at least 3.10 is supported: |
fuck :-( |
Do you want me to merge it now? Psychon is away until mid August so the review wont be updated. |
i've been testing gtk.lua code (not theme itself) for more than a year so it should be quite robust last issue which i found and resolved (about 1-2 months ago) was what it wasn't working properly in some edge cases of GTK+3 scaling + xrdb dpi |
I have been testing the new layout stuff for years too, we all have heaps of unmerged code ;) So do I press the button or not? Your call. |
yes, it's good to merge |
🥇 |
thanks! 🎉 |
Closes #1560