Skip to content

Commit

Permalink
#2539 also show window icon as an option, avoid errors when workspace…
Browse files Browse the repository at this point in the history
… is not set (None value)

git-svn-id: https://xpra.org/svn/Xpra/trunk@26324 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 12, 2020
1 parent 744f9d4 commit f57c124
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 64 deletions.
33 changes: 26 additions & 7 deletions src/xpra/client/gtk3/gtk3_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

from gi.repository import Gdk, Gtk, Gio
from gi.repository import Gdk, Gtk, Gio, GdkPixbuf

from xpra.client.gtk_base.gtk_client_window_base import GTKClientWindowBase, HAS_X11_BINDINGS
from xpra.client.gtk3.window_menu import WindowMenuHelper
Expand Down Expand Up @@ -35,6 +35,7 @@


WINDOW_MENU = envbool("XPRA_WINDOW_MENU", False)
WINDOW_ICON = envbool("XPRA_WINDOW_ICON", False)


"""
Expand All @@ -47,20 +48,38 @@ class GTK3ClientWindow(GTKClientWindowBase):

def init_window(self, metadata):
super().init_window(metadata)
if WINDOW_MENU and self.get_decorated() and not self.is_OR():
if (WINDOW_MENU or WINDOW_ICON) and self.get_decorated() and not self.is_OR():
self.add_header_bar()

def set_icon(self, pixbuf):
super().set_icon(pixbuf)
if WINDOW_ICON:
tb = self.get_titlebar()
try:
h = tb.get_preferred_size()[-1]-8
except Exception:
h = 32
h = min(128, max(h, 24))
icon = pixbuf.scale_simple(h, h, GdkPixbuf.InterpType.HYPER)
self.header_bar_image.set_from_pixbuf(icon)

def add_header_bar(self):
self.menu_helper = WindowMenuHelper(self._client, self)
hb = Gtk.HeaderBar()
hb.set_show_close_button(True)
hb.props.title = self.get_title()
button = Gtk.Button()
icon = Gio.ThemedIcon(name="open-menu-symbolic")
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
button.add(image)
button.connect("clicked", self.show_window_menu)
hb.pack_end(button)
if WINDOW_ICON:
self.header_bar_image = Gtk.Image()
pixbuf = self._client.get_pixbuf("transparent.png")
self.header_bar_image.set_from_pixbuf(pixbuf)
hb.pack_start(self.header_bar_image)
if WINDOW_MENU:
icon = Gio.ThemedIcon(name="open-menu-symbolic")
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
button.add(image)
button.connect("clicked", self.show_window_menu)
hb.pack_end(button)
self.set_titlebar(hb)

def show_window_menu(self, *args):
Expand Down
58 changes: 1 addition & 57 deletions src/xpra/client/gtk_base/window_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_window_state():
def get_attributes():
attr = {}
workspace = w.get_desktop_workspace()
if workspace>0 and workspace!=WORKSPACE_UNSET:
if workspace not in (None, WORKSPACE_UNSET):
attr["workspace"] = workspace
opacity = w.get_opacity()
if opacity<1:
Expand Down Expand Up @@ -189,59 +189,3 @@ def bool_icon(self, image, on_off):
else:
icon = c.get_pixbuf("unticked-small.png")
image.set_from_pixbuf(icon)

def show_opengl_state(self):
if self.client.opengl_enabled:
glinfo = "%s / %s" % (
self.client.opengl_props.get("vendor", ""),
self.client.opengl_props.get("renderer", ""),
)
display_mode = self.client.opengl_props.get("display_mode", [])
bit_depth = self.client.opengl_props.get("depth", 0)
info = []
if bit_depth:
info.append("%i-bit" % bit_depth)
if "DOUBLE" in display_mode:
info.append("double buffering")
elif "SINGLE" in display_mode:
info.append("single buffering")
else:
info.append("unknown buffering")
if "ALPHA" in display_mode:
info.append("with transparency")
else:
info.append("without transparency")
else:
#info could be telling us that the gl bindings are missing:
glinfo = self.client.opengl_props.get("info", "disabled")
info = ["n/a"]
self.client_opengl_label.set_text(glinfo)
self.opengl_buffering.set_text(" ".join(info))

def show_window_renderers(self):
if not mixin_features.windows:
return
wr = []
renderers = {}
for wid, window in tuple(self.client._id_to_window.items()):
renderers.setdefault(window.get_backing_class(), []).append(wid)
for bclass, windows in renderers.items():
wr.append("%s (%i)" % (bclass.__name__.replace("Backing", ""), len(windows)))
self.window_rendering.set_text("GTK3: %s" % csv(wr))

self.bool_icon(self.client_opengl_icon, self.client.client_supports_opengl)

def get_window_encoder_stats(self):
window_encoder_stats = {}
#new-style server with namespace (easier):
window_dict = self.client.server_last_info.get("window")
if window_dict and isinstance(window_dict, dict):
for k,v in window_dict.items():
try:
wid = int(k)
encoder_stats = v.get("encoder")
if encoder_stats:
window_encoder_stats[wid] = encoder_stats
except Exception:
log.error("Error: cannot lookup window dict", exc_info=True)
return window_encoder_stats

0 comments on commit f57c124

Please sign in to comment.