def get_property(self, prop): #subclasses can define properties as attributes: attr_name = prop.replace("-", "_") if hasattr(self, attr_name): return getattr(self, attr_name) #otherwise fallback to default behaviour: if prop == "title": return prettify_plug_name( self.window.get_screen().get_display().get_name()) if prop == "client-machine": return socket.gethostname() if prop == "window-type": return ["NORMAL"] if prop == "fullscreen": return False if prop == "shadow": return True if prop == "depth": return 24 if prop == "scaling": return None if prop == "opacity": return None if prop == "size-hints": size = self.get_dimensions() return { "maximum-size": size, "minimum-size": size, "base-size": size, } if prop == "class-instance": osn = get_generic_os_name() return ("xpra-%s" % osn, "Xpra-%s" % osn.upper()) if prop == "icons": try: icon_name = get_icon_filename( (get_generic_os_name() or "").lower() + ".png") from PIL import Image img = Image.open(icon_name) log("Image(%s)=%s", icon_name, img) if img: icon_data = load_binary_file(icon_name) assert icon_data w, h = img.size icon = (w, h, "png", icon_data) icons = (icon, ) return icons except: log("failed to return window icon") return () if prop == "content-type": return "desktop" raise ValueError("invalid property: %s" % prop)
def get_property(self, prop): #subclasses can define properties as attributes: attr_name = prop.replace("-", "_") if hasattr(self, attr_name): return getattr(self, attr_name) #otherwise fallback to default behaviour: if prop == "title": return prettify_plug_name( self.window.get_screen().get_display().get_name()) elif prop == "client-machine": return socket.gethostname() elif prop == "window-type": return ["NORMAL"] elif prop == "fullscreen": return False elif prop == "shadow": return True elif prop == "scaling": return None elif prop == "opacity": return None elif prop == "size-hints": size = self.get_dimensions() return { "maximum-size": size, "minimum-size": size, "base-size": size } elif prop == "class-instance": osn = get_generic_os_name() return ("xpra-%s" % osn, "Xpra-%s" % osn.upper()) elif prop == "icon": try: from xpra.platform.paths import get_icon icon_name = get_generic_os_name() + ".png" icon = get_icon(icon_name) log("icon(%s)=%s", icon_name, icon) return icon except: log("failed to return window icon") return None elif prop == "content-type": return "desktop" else: raise ValueError("invalid property: %s" % prop) return None
def get_property(self, prop): if prop == "title": return prettify_plug_name( self.window.get_screen().get_display().get_name()) elif prop == "client-machine": return socket.gethostname() elif prop == "window-type": return ["NORMAL"] elif prop == "fullscreen": return False elif prop == "shadow": return True elif prop == "scaling": return None elif prop == "opacity": return None elif prop == "size-hints": size = self.window.get_size() return { "maximum-size": size, "minimum-size": size, "base-size": size } elif prop == "class-instance": osn = get_generic_os_name() return ("xpra-%s" % osn, "Xpra-%s" % osn.upper()) elif prop == "icon": try: from xpra.platform.paths import get_icon icon_name = get_generic_os_name() + ".png" icon = get_icon(icon_name) log("icon(%s)=%s", icon_name, icon) return icon except: log("failed to return window icon") return None else: raise ValueError("invalid property: %s" % prop) return None
def get_default_window_icon(self, _size): icon_name = get_generic_os_name()+".png" icon = get_icon(icon_name) if not icon: return None return icon.get_width(), icon.get_height(), "RGBA", icon.get_pixels()
def get_default_window_icon(self): icon_name = get_generic_os_name() + ".png" return get_icon(icon_name)