Merge pull request #59 from MightyCreak/adapt-icons-to-scale-factor

Create icons using the window scale factor
This commit is contained in:
Creak 2020-07-18 18:06:44 -04:00 committed by GitHub
commit ac8f443758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -7404,12 +7404,15 @@ class Diffuse(Gtk.Window):
DIFFUSE_STOCK_LEFT_RIGHT = 'diffuse-left-right' DIFFUSE_STOCK_LEFT_RIGHT = 'diffuse-left-right'
DIFFUSE_STOCK_RIGHT_LEFT = 'diffuse-right-left' DIFFUSE_STOCK_RIGHT_LEFT = 'diffuse-right-left'
# get default theme and window scale factor
default_theme = Gtk.IconTheme.get_default() default_theme = Gtk.IconTheme.get_default()
scale_factor = self.get_scale_factor()
icon_size = Gtk.IconSize.lookup(Gtk.IconSize.LARGE_TOOLBAR).height icon_size = Gtk.IconSize.lookup(Gtk.IconSize.LARGE_TOOLBAR).height
factory = Gtk.IconFactory() factory = Gtk.IconFactory()
# render the base item used to indicate a new document # render the base item used to indicate a new document
p0 = default_theme.load_icon("document-new", icon_size, 0) p0 = default_theme.load_icon_for_scale("document-new", icon_size, scale_factor, 0)
w, h = p0.get_width(), p0.get_height() w, h = p0.get_width(), p0.get_height()
# render new 2-way merge icon # render new 2-way merge icon
@ -7435,8 +7438,8 @@ class Diffuse(Gtk.Window):
factory.add(DIFFUSE_STOCK_NEW_3WAY_MERGE, Gtk.IconSet.new_from_pixbuf(p)) factory.add(DIFFUSE_STOCK_NEW_3WAY_MERGE, Gtk.IconSet.new_from_pixbuf(p))
# render the left and right arrow we will use in our custom icons # render the left and right arrow we will use in our custom icons
p0 = default_theme.load_icon("go-next", icon_size, 0) p0 = default_theme.load_icon_for_scale("go-next", icon_size, scale_factor, 0)
p1 = default_theme.load_icon("go-previous", icon_size, 0) p1 = default_theme.load_icon_for_scale("go-previous", icon_size, scale_factor, 0)
w, h, s = p0.get_width(), p0.get_height(), 0.65 w, h, s = p0.get_width(), p0.get_height(), 0.65
sw, sh = int(s * w), int(s * h) sw, sh = int(s * w), int(s * h)
w1, h1 = w - sw, h - sh w1, h1 = w - sw, h - sh