Skip to content

Commit

Permalink
Conditionally use font size unit depending on Gtk version
Browse files Browse the repository at this point in the history
We managed to not do these kind of things for a long time, but here
we go - older versions don't allow it and new versions require it.
  • Loading branch information
nilnor committed Oct 14, 2016
1 parent 57ddf63 commit 25c5543
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/howl/ui/theme.moon
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ parse_color = (spec, alpha = 1) ->
tostring(c)

parse_font = (font = {}) ->
font_size_unit = 'px'

if Gtk.get_major_version! == 3 and Gtk.get_minor_version! < 10
font_size_unit = ''

size = config.font_size
decls = {
"font-family: #{config.font};"
}

if size
append decls, "font-size: #{config.font_size}px;"
append decls, "font-size: #{config.font_size}#{font_size_unit};"

if font.italic
append decls, "font-style: italic;"
Expand Down
4 changes: 4 additions & 0 deletions lib/ljglibs/cdefs/gtk.moon
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,8 @@ ffi.cdef [[
/* Misc */
gboolean gtk_cairo_should_draw_window (cairo_t *cr,
GdkWindow *window);
guint gtk_get_major_version (void);
guint gtk_get_minor_version (void);
guint gtk_get_micro_version (void);
]]
4 changes: 4 additions & 0 deletions lib/ljglibs/gtk/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ core.auto_loading 'gtk', {

cairo_should_draw_window: (cr, window) ->
C.gtk_cairo_should_draw_window(cr, window) != 0

get_major_version: -> tonumber C.gtk_get_major_version!
get_minor_version: -> tonumber C.gtk_get_minor_version!
get_micro_version: -> tonumber C.gtk_get_micro_version!
}

0 comments on commit 25c5543

Please sign in to comment.