Skip to content

Commit

Permalink
Fix flags in HiDPI
Browse files Browse the repository at this point in the history
  • Loading branch information
clefebvre committed Aug 15, 2019
1 parent 5bda981 commit 4840ae4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions usr/lib/linuxmint/mintSources/mintSources.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def __init__(self, application, ui_builder):

r = Gtk.CellRendererPixbuf()
col = Gtk.TreeViewColumn(_("Country"), r, pixbuf = MirrorSelectionDialog.MIRROR_COUNTRY_FLAG_COLUMN)
col.set_cell_data_func(r, self.data_func_surface)
self._treeview.append_column(col)
col.set_sort_column_id(MirrorSelectionDialog.MIRROR_TOOLTIP_COLUMN)

Expand All @@ -538,6 +539,11 @@ def __init__(self, application, ui_builder):
with open('/usr/lib/linuxmint/mintSources/countries.json', encoding="utf-8", errors="ignore") as data_file:
self.countries = json.load(data_file)

def data_func_surface(self, column, cell, model, iter_, *args):
pixbuf = model.get_value(iter_, MirrorSelectionDialog.MIRROR_COUNTRY_FLAG_COLUMN)
surface = Gdk.cairo_surface_create_from_pixbuf(pixbuf, self._application.scale)
cell.set_property("surface", surface)

def _row_activated(self, treeview, path, view_column):
self._dialog.response(Gtk.ResponseType.APPLY)

Expand All @@ -561,10 +567,11 @@ def _update_list(self):
tooltip = country_name
if mirror.name != mirror.url:
tooltip = "%s: %s" % (country_name, mirror.name)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(flag, -1, FLAG_SIZE * self._application.scale)
self._mirrors_model.append((
mirror,
mirror.url,
GdkPixbuf.Pixbuf.new_from_file_at_size(flag, -1, FLAG_SIZE),
pixbuf,
0,
None,
tooltip,
Expand Down Expand Up @@ -810,6 +817,8 @@ def __init__(self):

self._main_window.set_icon_name("software-sources")

self.scale = self._main_window.get_scale_factor()

self._official_repositories_page = self.builder.get_object("official_repositories_page")

self.apt = mintcommon.aptdaemon.APT(self._main_window)
Expand Down Expand Up @@ -1845,11 +1854,13 @@ def update_flags(self):
base_flag_path = flag
break

pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(mint_flag_path, -1, FLAG_SIZE)
self.builder.get_object("image_mirror").set_from_pixbuf(pixbuf)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(mint_flag_path, -1, FLAG_SIZE * self.scale)
surface = Gdk.cairo_surface_create_from_pixbuf(pixbuf, self.scale)
self.builder.get_object("image_mirror").set_from_surface(surface)

pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(base_flag_path, -1, FLAG_SIZE)
self.builder.get_object("image_base_mirror").set_from_pixbuf(pixbuf)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(base_flag_path, -1, FLAG_SIZE * self.scale)
surface = Gdk.cairo_surface_create_from_pixbuf(pixbuf, self.scale)
self.builder.get_object("image_base_mirror").set_from_surface(surface)

def get_clipboard_text(self, source_type):
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
Expand Down

0 comments on commit 4840ae4

Please sign in to comment.