From 931651f0426ddae240a8803c3c134de33312782f Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 2 Jul 2020 05:50:24 +0000 Subject: [PATCH] make code more readable git-svn-id: https://xpra.org/svn/Xpra/trunk@26859 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gtk3/gtk3_client_window.py | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/xpra/client/gtk3/gtk3_client_window.py b/src/xpra/client/gtk3/gtk3_client_window.py index 064d7d7108..540145a87b 100644 --- a/src/xpra/client/gtk3/gtk3_client_window.py +++ b/src/xpra/client/gtk3/gtk3_client_window.py @@ -10,8 +10,8 @@ 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, scaled_image -from xpra.scripts.config import TRUE_OPTIONS -from xpra.util import envbool +from xpra.scripts.config import TRUE_OPTIONS, FALSE_OPTIONS +from xpra.util import envbool, typedict from xpra.os_util import bytestostr, is_gnome, OSX from xpra.log import Logger @@ -50,11 +50,7 @@ class GTK3ClientWindow(GTKClientWindowBase): def init_window(self, metadata): super().init_window(metadata) self.header_bar_image = None - hbl = (self.headerbar or "").lower().strip() - if not self.is_OR() and self.get_decorated() and ( - ((hbl in TRUE_OPTIONS) and not metadata.rawget("size-constraints")) - or hbl=="force" - ): + if self.can_use_header_bar(metadata): self.add_header_bar() def _icon_size(self): @@ -73,6 +69,19 @@ def set_icon(self, pixbuf): pixbuf = pixbuf.scale_simple(h, h, GdkPixbuf.InterpType.HYPER) hbi.set_from_pixbuf(pixbuf) + def can_use_header_bar(self, metadata): + if self.is_OR() or not self.get_decorated(): + return False + hbl = (self.headerbar or "").lower().strip() + if hbl in FALSE_OPTIONS: + return False + if hbl in TRUE_OPTIONS: + sc = metadata.dictget("size-constraints") + return sc is None + if hbl=="force": + return True + return False + def add_header_bar(self): self.menu_helper = WindowMenuHelper(self._client, self) hb = Gtk.HeaderBar()