def _render_prefs_icon(self): scale_factor = get_monitor_scale_factor() prefs_pixbuf = load_image(get_data_file('media', 'gear.svg'), 16 * scale_factor) surface = Gdk.cairo_surface_create_from_pixbuf(prefs_pixbuf, scale_factor, self.get_window()) prefs_image = Gtk.Image.new_from_surface(surface) self.prefs_btn.set_image(prefs_image)
def set_icon(self, icon): """ :param PixBuf icon: """ if not icon: return iconWgt = self.builder.get_object('item-icon') scale_factor = get_monitor_scale_factor() if scale_factor == 1: iconWgt.set_from_pixbuf(icon) return try: surface = Gdk.cairo_surface_create_from_pixbuf( icon, scale_factor, self.get_window()) iconWgt.set_from_surface(surface) except AttributeError: # Fallback for GTK+ older than 3.10 iconWgt.set_from_pixbuf(icon)
def get_icon_size(cls): return cls.ICON_SIZE * get_monitor_scale_factor()