Skip to content

Commit

Permalink
#2762 resize all pixbufs to the same (guessed) size
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26385 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 17, 2020
1 parent 95de51e commit 4107c26
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/xpra/client/gtk3/gtk3_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from xpra.client.gtk_base.gtk_client_window_base import GTKClientWindowBase, HAS_X11_BINDINGS
from xpra.client.gtk3.window_menu import WindowMenuHelper
from xpra.gtk_common.gtk_util import WINDOW_NAME_TO_HINT
from xpra.gtk_common.gtk_util import WINDOW_NAME_TO_HINT, scaled_image
from xpra.util import envbool
from xpra.os_util import bytestostr, is_gnome, OSX
from xpra.log import Logger
Expand Down Expand Up @@ -53,20 +53,21 @@ def init_window(self, metadata):
if CUSTOM_TITLE_BAR and self.get_decorated() and not self.is_OR():
self.add_header_bar()

def _resize_pixbuf(self, pixbuf):
def _icon_size(self):
tb = self.get_titlebar()
try:
h = tb.get_preferred_size()[-1]-8
except Exception:
h = 32
h = min(128, max(h, 24))
return pixbuf.scale_simple(h, h, GdkPixbuf.InterpType.HYPER)
h = 24
return min(128, max(h, 24))

def set_icon(self, pixbuf):
super().set_icon(pixbuf)
hbi = self.header_bar_image
if hbi:
hbi.set_from_pixbuf(self._resize_pixbuf(pixbuf))
h = self._icon_size()
pixbuf = pixbuf.scale_simple(h, h, GdkPixbuf.InterpType.HYPER)
hbi.set_from_pixbuf(pixbuf)

def add_header_bar(self):
self.menu_helper = WindowMenuHelper(self._client, self)
Expand All @@ -75,9 +76,8 @@ def add_header_bar(self):
hb.set_show_close_button(True)
hb.props.title = self.get_title()
if WINDOW_ICON:
self.header_bar_image = Gtk.Image()
pixbuf = self._client.get_pixbuf("transparent.png")
self.header_bar_image.set_from_pixbuf(pixbuf)
self.header_bar_image = scaled_image(pixbuf, self._icon_size())
hb.pack_start(self.header_bar_image)
if WINDOW_MENU:
icon = Gio.ThemedIcon(name="open-menu-symbolic")
Expand All @@ -87,9 +87,8 @@ def add_header_bar(self):
button.connect("clicked", self.show_window_menu)
hb.pack_end(button)
if WINDOW_XPRA_MENU:
image = Gtk.Image()
pixbuf = self._client.get_pixbuf("xpra.png")
image.set_from_pixbuf(self._resize_pixbuf(pixbuf))
image = scaled_image(pixbuf, self._icon_size())
button = Gtk.Button()
button.add(image)
button.connect("clicked", self.show_xpra_menu)
Expand Down

0 comments on commit 4107c26

Please sign in to comment.