Ejemplo n.º 1
0
def new_backing(wid, w, h, old_backing, mmap_enabled, mmap):
    if is_gtk3() or PREFER_CAIRO:
        b = CairoBacking(wid, w, h, old_backing, mmap_enabled, mmap)
    else:
        b = PixmapBacking(wid, w, h, old_backing, mmap_enabled, mmap)
    if old_backing:
        old_backing.close()
    return b
Ejemplo n.º 2
0
def new_backing(wid, w, h, backing, mmap_enabled, mmap):
    if USE_FAKE_BACKING:
        return FakeBacking(wid)
    if is_gtk3() or USE_CAIRO:
        backing_class = CairoBacking
    else:
        backing_class = PixmapBacking
    return make_new_backing(backing_class, wid, w, h, backing, mmap_enabled, mmap)
Ejemplo n.º 3
0
def new_backing(wid, w, h, old_backing, mmap_enabled, mmap):
    if is_gtk3() or PREFER_CAIRO:
        b = CairoBacking(wid, w, h, old_backing, mmap_enabled, mmap)
    else:
        b = PixmapBacking(wid, w, h, old_backing, mmap_enabled, mmap)
    if old_backing:
        old_backing.close()
    return b
Ejemplo n.º 4
0
def new_backing(wid, w, h, backing, mmap_enabled, mmap):
    if USE_FAKE_BACKING:
        return FakeBacking(wid)
    if is_gtk3() or USE_CAIRO:
        backing_class = CairoBacking
    else:
        backing_class = PixmapBacking
    return make_new_backing(backing_class, wid, w, h, backing, mmap_enabled,
                            mmap)
Ejemplo n.º 5
0
def add_close_accel(window, callback):
    if is_gtk3():
        return      #TODO: implement accel for gtk3
    # key accelerators
    accel_group = gtk.AccelGroup()
    accel_group.connect_group(ord('w'), gdk.CONTROL_MASK, gtk.ACCEL_LOCKED, callback)
    window.add_accel_group(accel_group)
    accel_group = gtk.AccelGroup()
    escape_key, modifier = gtk.accelerator_parse('Escape')
    accel_group.connect_group(escape_key, modifier, gtk.ACCEL_LOCKED |  gtk.ACCEL_VISIBLE, callback)
    window.add_accel_group(accel_group)
Ejemplo n.º 6
0
def add_close_accel(window, callback):
    if is_gtk3():
        return  #TODO: implement accel for gtk3
    # key accelerators
    accel_group = gtk.AccelGroup()
    accel_group.connect_group(ord('w'), gdk.CONTROL_MASK, gtk.ACCEL_LOCKED,
                              callback)
    window.add_accel_group(accel_group)
    accel_group = gtk.AccelGroup()
    escape_key, modifier = gtk.accelerator_parse('Escape')
    accel_group.connect_group(escape_key, modifier,
                              gtk.ACCEL_LOCKED | gtk.ACCEL_VISIBLE, callback)
    window.add_accel_group(accel_group)
Ejemplo n.º 7
0
def new_backing(wid, w, h, old_backing, mmap_enabled, mmap):
    w = max(1, w)
    h = max(1, h)
    try:
        if old_backing:
            old_backing._video_decoder_lock.acquire()
        if is_gtk3() or PREFER_CAIRO:
            b = CairoBacking(wid, w, h, old_backing, mmap_enabled, mmap)
        else:
            b = PixmapBacking(wid, w, h, old_backing, mmap_enabled, mmap)
    finally:
        if old_backing:
            old_backing.close()
            old_backing._video_decoder_lock.release()        
    return b
Ejemplo n.º 8
0
def about(*args):
    global about_dialog, GPL2
    if about_dialog:
        about_dialog.show()
        about_dialog.present()
        return
    xpra_icon = get_icon("xpra.png")
    dialog = gtk.AboutDialog()
    if not is_gtk3():

        def on_website_hook(dialog, web, *args):
            ''' called when the website item is selected '''
            webbrowser.open(SITE_URL)

        def on_email_hook(dialog, mail, *args):
            webbrowser.open("mailto://[email protected]")

        gtk.about_dialog_set_url_hook(on_website_hook)
        gtk.about_dialog_set_email_hook(on_email_hook)
        if xpra_icon:
            dialog.set_icon(xpra_icon)
    dialog.set_name("Xpra")
    from xpra import __version__
    dialog.set_version(__version__)
    dialog.set_authors(('Antoine Martin <*****@*****.**>',
                        'Nathaniel Smith <*****@*****.**>',
                        'Serviware - Arthur Huillet <*****@*****.**>'))
    dialog.set_license(
        GPL2 or
        "Your installation may be corrupted, the license text for GPL version 2 could not be found,\nplease refer to:\nhttp://www.gnu.org/licenses/gpl-2.0.txt"
    )
    dialog.set_comments("\n".join(get_build_info()))
    dialog.set_website(SITE_URL)
    dialog.set_website_label(SITE_DOMAIN)
    if xpra_icon:
        dialog.set_logo(xpra_icon)
    if hasattr(dialog, "set_program_name"):
        dialog.set_program_name(APPLICATION_NAME)

    def response(*args):
        dialog.destroy()
        global about_dialog
        about_dialog = None

    dialog.connect("response", response)
    about_dialog = dialog
    dialog.show()
Ejemplo n.º 9
0
def about(on_close=None):
	global about_dialog
	if about_dialog:
		about_dialog.show()
		about_dialog.present()
		return
	from xpra.platform import get_icon
	xpra_icon = get_icon("xpra.png")
	dialog = gtk.AboutDialog()
	if not is_gtk3():
		def on_website_hook(dialog, web, *args):
			''' called when the website item is selected '''
			webbrowser.open(SITE_URL)
		def on_email_hook(dialog, mail, *args):
			webbrowser.open("mailto://[email protected]")
		gtk.about_dialog_set_url_hook(on_website_hook)
		gtk.about_dialog_set_email_hook(on_email_hook)
		if xpra_icon:
			dialog.set_icon(xpra_icon)
	dialog.set_name("Xpra")
	dialog.set_version(__version__)
	dialog.set_authors(('Antoine Martin <*****@*****.**>',
						'Nathaniel Smith <*****@*****.**>',
						'Serviware - Arthur Huillet <*****@*****.**>'))
	_license = load_license()
	dialog.set_license(_license or "Your installation may be corrupted,"
					+ " the license text for GPL version 2 could not be found,"
					+ "\nplease refer to:\nhttp://www.gnu.org/licenses/gpl-2.0.txt")
	dialog.set_comments("\n".join(get_build_info()))
	dialog.set_website(SITE_URL)
	dialog.set_website_label(SITE_DOMAIN)
	if xpra_icon:
		dialog.set_logo(xpra_icon)
	if hasattr(dialog, "set_program_name"):
		dialog.set_program_name(APPLICATION_NAME)
	def close(*args):
		close_about()
		#the about function may be called as a widget callback
		#so avoid calling the widget as if it was a function!
		if on_close and hasattr(on_close, '__call__'):
			on_close()
	dialog.connect("response", close)
	add_close_accel(dialog, close)
	about_dialog = dialog
	dialog.show()
Ejemplo n.º 10
0
def xget_u32_property(target, name):
    try:
        if not has_wimpiggy_prop:
            if is_gtk3():
                name_atom = gdk.Atom.intern(name, False)
                type_atom = gdk.Atom.intern("CARDINAL", False)
                gdk.property_get(target, name_atom, type_atom, 0, 9999, False)
            else:
                prop = target.property_get(name)
            if not prop or len(prop) != 3 or len(prop[2]) != 1:
                return None
            log("xget_u32_property(%s, %s)=%s", target, name, prop[2][0])
            return prop[2][0]
        v = prop_get(target, name, "u32", ignore_errors=True)
        log("xget_u32_property(%s, %s)=%s", target, name, v)
        if type(v) == int:
            return v
    except Exception, e:
        log.error("xget_u32_property error on %s / %s: %s", target, name, e)
Ejemplo n.º 11
0
def xget_u32_property(target, name):
    try:
        if not has_wimpiggy_prop:
            if is_gtk3():
                name_atom = gdk.Atom.intern(name, False)
                type_atom = gdk.Atom.intern("CARDINAL", False)
                gdk.property_get(target, name_atom, type_atom, 0, 9999, False)
            else:
                prop = target.property_get(name)
            if not prop or len(prop) != 3 or len(prop[2]) != 1:
                return None
            log("xget_u32_property(%s, %s)=%s", target, name, prop[2][0])
            return prop[2][0]
        v = prop_get(target, name, "u32", ignore_errors=True)
        log("xget_u32_property(%s, %s)=%s", target, name, v)
        if type(v) == int:
            return v
    except Exception, e:
        log.error("xget_u32_property error on %s / %s: %s", target, name, e)
Ejemplo n.º 12
0
def new_backing(wid, w, h, backing, mmap_enabled, mmap):
    w = max(1, w)
    h = max(1, h)
    lock = None
    if backing:
        lock = backing._video_decoder_lock
    try:
        if lock:
            lock.acquire()
        if backing is None:
            if is_gtk3() or PREFER_CAIRO:
                backing = CairoBacking(wid, w, h, mmap_enabled, mmap)
            else:
                backing = PixmapBacking(wid, w, h, mmap_enabled, mmap)
        backing.init(w, h)
    finally:
        if lock:
            lock.release()
    return backing
Ejemplo n.º 13
0
    def about(self, *args):
        if self.about_dialog:
            self.about_dialog.present()
            return
        dialog = gtk.AboutDialog()
        if not is_gtk3():

            def on_website_hook(dialog, web, *args):
                webbrowser.open("http://xpra.org/")

            def on_email_hook(dialog, mail, *args):
                webbrowser.open("mailto://" + mail)

            gtk.about_dialog_set_url_hook(on_website_hook)
            gtk.about_dialog_set_email_hook(on_email_hook)
            xpra_icon = self.get_pixbuf("xpra.png")
            if xpra_icon:
                dialog.set_icon(xpra_icon)
        dialog.set_name("Xpra")
        from xpra import __version__
        dialog.set_version(__version__)
        dialog.set_copyright('Copyright (c) 2009-2012')
        dialog.set_authors(
            ('Antoine Martin <*****@*****.**>',
             'Nathaniel Smith <*****@*****.**>',
             'Serviware - Arthur Huillet <*****@*****.**>'))
        #dialog.set_artists ([""])
        dialog.set_license(self.get_license_text())
        dialog.set_website("http://xpra.org/")
        dialog.set_website_label("xpra.org")
        pixbuf = self.get_pixbuf("xpra.png")
        if pixbuf:
            dialog.set_logo(pixbuf)
        dialog.set_program_name("Xpra")
        dialog.set_comments("\n".join(self.get_build_info()))
        dialog.connect("response", self.close_about)
        self.about_dialog = dialog
        dialog.show()
        dialog.present()
Ejemplo n.º 14
0
def about(*args):
	global about_dialog, GPL2
	if about_dialog:
		about_dialog.show()
		about_dialog.present()
		return
	xpra_icon = get_icon("xpra.png")
	dialog = gtk.AboutDialog()
	if not is_gtk3():
		def on_website_hook(dialog, web, *args):
			''' called when the website item is selected '''
			webbrowser.open(SITE_URL)
		def on_email_hook(dialog, mail, *args):
			webbrowser.open("mailto://[email protected]")
		gtk.about_dialog_set_url_hook(on_website_hook)
		gtk.about_dialog_set_email_hook(on_email_hook)
		if xpra_icon:
			dialog.set_icon(xpra_icon)
	dialog.set_name("Xpra")
	from xpra import __version__
	dialog.set_version(__version__)
	dialog.set_authors(('Antoine Martin <*****@*****.**>',
						'Nathaniel Smith <*****@*****.**>',
						'Serviware - Arthur Huillet <*****@*****.**>'))
	dialog.set_license(GPL2 or "Your installation may be corrupted, the license text for GPL version 2 could not be found,\nplease refer to:\nhttp://www.gnu.org/licenses/gpl-2.0.txt")
	dialog.set_comments("\n".join(get_build_info()))
	dialog.set_website(SITE_URL)
	dialog.set_website_label(SITE_DOMAIN)
	if xpra_icon:
		dialog.set_logo(xpra_icon)
	if hasattr(dialog, "set_program_name"):
		dialog.set_program_name(APPLICATION_NAME)
	def response(*args):
		dialog.destroy()
		global about_dialog
		about_dialog = None
	dialog.connect("response", response)
	about_dialog = dialog
	dialog.show()
Ejemplo n.º 15
0
# This file is part of Parti.
# Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>)
# Copyright (C) 2010-2012 Antoine Martin <*****@*****.**>
# Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

#pygtk3 vs pygtk2 (sigh)
from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3

gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()
if is_gtk3():

    def get_root_size():
        return gdk.get_default_root_window().get_geometry()[2:]

    def set_windows_cursor(gtkwindows, new_cursor):
        pass
        #window.override_cursor(cursor, None)
else:

    def get_root_size():
        return gdk.get_default_root_window().get_size()

    def set_windows_cursor(gtkwindows, new_cursor):
        cursor = None
        if len(new_cursor) > 0:
            (_, _, w, h, xhot, yhot, serial, pixels) = new_cursor
            log.debug(
Ejemplo n.º 16
0
# This file is part of Parti.
# Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>)
# Copyright (C) 2010-2012 Antoine Martin <*****@*****.**>
# Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

#pygtk3 vs pygtk2 (sigh)
from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3
gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()
if is_gtk3():
    def get_root_size():
        return gdk.get_default_root_window().get_geometry()[2:]
    def set_windows_cursor(gtkwindows, new_cursor):
        pass
        #window.override_cursor(cursor, None)
else:
    def get_root_size():
        return gdk.get_default_root_window().get_size()
    def set_windows_cursor(gtkwindows, new_cursor):
        cursor = None
        if len(new_cursor)>0:
            (_, _, w, h, xhot, yhot, serial, pixels) = new_cursor
            log.debug("new cursor at %s,%s with serial=%s, dimensions: %sx%s, len(pixels)=%s" % (xhot,yhot, serial, w,h, len(pixels)))
            pixbuf = gdk.pixbuf_new_from_data(pixels, gdk.COLORSPACE_RGB, True, 8, w, h, w * 4)
            x = max(0, min(xhot, w-1))
            y = max(0, min(yhot, h-1))
            size = gdk.display_get_default().get_default_cursor_size()
            if size>0 and (size<w or size<h):
Ejemplo n.º 17
0
from xpra.dotxpra import DotXpra
from xpra.platform import (XPRA_LOCAL_SERVERS_SUPPORTED, DEFAULT_SSH_CMD,
                           GOT_PASSWORD_PROMPT_SUGGESTION, add_client_options)
from xpra.protocol import TwoFileConnection, SocketConnection

from wimpiggy.gobject_compat import import_gobject, is_gtk3

import_gobject()
try:
    import Image
    assert Image
    _has_PIL = True
except:
    _has_PIL = False
ENCODINGS = []
if is_gtk3():
    """ with gtk3, we get png via cairo out of the box
        but we need PIL for the others:
    """
    ENCODINGS.append("png")
    if _has_PIL:
        ENCODINGS.append("jpeg")
        ENCODINGS.append("rgb24")
else:
    """ with gtk2, we get rgb24 via gdk pixbuf out of the box
        but we need PIL for the others:
    """
    if _has_PIL:
        ENCODINGS.append("png")
        ENCODINGS.append("jpeg")
    ENCODINGS.append("rgb24")
Ejemplo n.º 18
0
from xpra.platform import (XPRA_LOCAL_SERVERS_SUPPORTED,
                           DEFAULT_SSH_CMD,
                           GOT_PASSWORD_PROMPT_SUGGESTION,
                           add_client_options)
from xpra.bytestreams import TwoFileConnection, SocketConnection

from wimpiggy.gobject_compat import import_gobject, is_gtk3
import_gobject()
try:
    import Image
    assert Image
    _has_PIL = True
except:
    _has_PIL = False
ENCODINGS = []
if is_gtk3():
    """ with gtk3, we get png via cairo out of the box
        but we need PIL for the others:
    """
    ENCODINGS.append("png")
    if _has_PIL:
        ENCODINGS.append("jpeg")
        ENCODINGS.append("rgb24")
else:
    """ with gtk2, we get rgb24 via gdk pixbuf out of the box
        but we need PIL for the others:
    """
    if _has_PIL:
        ENCODINGS.append("png")
        ENCODINGS.append("jpeg")
    ENCODINGS.append("rgb24")
Ejemplo n.º 19
0
# This file is part of Parti.
# Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>)
# Copyright (C) 2010-2012 Antoine Martin <*****@*****.**>
# Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

#pygtk3 vs pygtk2 (sigh)
from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3
gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()
if is_gtk3():
    def get_modifiers_mask():
        return gdk.get_default_root_window().get_pointer()[-1]
    def get_root_size():
        return gdk.get_default_root_window().get_geometry()[2:]
    def init_window(win, wintype):
        #TODO: no idea how to do this with gtk3
        #maybe not even possible..
        gtk.Window.__init__(win)
    def get_window_geometry(gtkwindow):
        x, y = gtkwindow.get_position()
        w, h = gtkwindow.get_size()
        return (x, y, w, h)
    def set_geometry_hints(window, hints):
        """ we convert the hints as a dict into a gdk.Geometry + gdk.WindowHints """
        wh = gdk.WindowHints
        name_to_hint = {"maximum-size"  : wh.MAX_SIZE,
                        "max_width"     : wh.MAX_SIZE,
                        "max_height"    : wh.MAX_SIZE,
Ejemplo n.º 20
0
# This file is part of Parti.
# Copyright (C) 2010-2013 Antoine Martin <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

from wimpiggy.gobject_compat import import_gtk, is_gtk3
gtk = import_gtk()

from wimpiggy.log import Logger
log = Logger()

from xpra.window_backing import make_new_backing, PixmapBacking

ORIENTATION = {}
if not is_gtk3():
    #where was this moved to??
    HORIZONTAL = gtk.ORIENTATION_HORIZONTAL
    VERTICAL = gtk.ORIENTATION_VERTICAL
else:
    VERTICAL = "VERTICAL"
    HORIZONTAL = "HORIZONTAL"
ORIENTATION = {HORIZONTAL: "HORIZONTAL", VERTICAL: "VERTICAL"}


class ClientTray(object):
    def __init__(self, client, wid, w, h):
        self._client = client
        self._id = wid
        self._geometry = None
        self._screen = -1
        self._orientation = VERTICAL
Ejemplo n.º 21
0
# This file is part of Parti.
# Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>)
# Copyright (C) 2010-2012 Antoine Martin <*****@*****.**>
# Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

#pygtk3 vs pygtk2 (sigh)
from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3
gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()
if is_gtk3():
    def get_modifiers_mask():
        return gdk.get_default_root_window().get_pointer()[-1]
    def get_root_size():
        return gdk.get_default_root_window().get_geometry()[2:]
    def init_window(win, wintype):
        #TODO: no idea how to do this with gtk3
        #maybe not even possible..
        gtk.Window.__init__(win)
    def get_window_geometry(gtkwindow):
        x, y = gtkwindow.get_position()
        w, h = gtkwindow.get_size()
        return (x, y, w, h)
    def set_geometry_hints(window, hints):
        """ we convert the hints as a dict into a gdk.Geometry + gdk.WindowHints """
        wh = gdk.WindowHints
        name_to_hint = {"maximum-size"  : wh.MAX_SIZE,
                        "max_width"     : wh.MAX_SIZE,
                        "max_height"    : wh.MAX_SIZE,
Ejemplo n.º 22
0
    def __init__(self, client, session_name, window_icon_pixbuf, conn,
                 get_pixbuf):
        gtk.Window.__init__(self)
        self.client = client
        self.session_name = session_name
        self.connection = conn
        self.last_populate_time = 0
        self.last_populate_statistics = 0
        self.is_closed = False
        self.get_pixbuf = get_pixbuf
        self.set_title(self.session_name or "Session Info")
        self.set_destroy_with_parent(True)
        self.set_resizable(True)
        self.set_decorated(True)
        if window_icon_pixbuf:
            self.set_icon(window_icon_pixbuf)
        if is_gtk3():
            self.set_position(gtk.WindowPosition.CENTER)
        else:
            self.set_position(gtk.WIN_POS_CENTER)

        #tables on the left in a vbox with buttons at the top:
        self.tab_box = gtk.VBox(False, 0)
        self.tab_button_box = gtk.HBox(True, 0)
        self.tabs = []  #pairs of button, table
        self.populate_cb = None
        self.tab_box.pack_start(self.tab_button_box,
                                expand=False,
                                fill=True,
                                padding=0)

        #Package Table:
        tb = self.table_tab("package.png", "Software", self.populate_package)
        #title row:
        tb.attach(title_box(""), 0, xoptions=gtk.EXPAND | gtk.FILL, xpadding=0)
        tb.attach(title_box("Client"),
                  1,
                  xoptions=gtk.EXPAND | gtk.FILL,
                  xpadding=0)
        tb.attach(title_box("Server"),
                  2,
                  xoptions=gtk.EXPAND | gtk.FILL,
                  xpadding=0)
        tb.inc()

        scaps = self.client.server_capabilities
        from xpra.__init__ import __version__
        tb.new_row("Xpra", label(__version__),
                   label(self.client._remote_version or "unknown"))
        cl_rev, cl_ch, cl_date = "unknown", "", ""
        try:
            from xpra.build_info import BUILD_DATE as cl_date, REVISION as cl_rev, LOCAL_MODIFICATIONS as cl_ch
        except:
            pass
        tb.new_row("Revision", label(cl_rev),
                   label(self.client._remote_revision or "unknown"))
        tb.new_row("Local Changes", label(cl_ch),
                   label(scaps.get("local_modifications", "unknown")))
        tb.new_row("Build date", label(cl_date),
                   label(scaps.get("build_date", "unknown")))

        def make_version_str(version):
            if version and type(version) in (tuple, list):
                version = ".".join([str(x) for x in version])
            return version or "unknown"

        def server_version_info(prop_name):
            return make_version_str(scaps.get(prop_name))

        def client_version_info(prop_name):
            info = "unknown"
            if hasattr(gtk, prop_name):
                info = make_version_str(getattr(gtk, prop_name))
            return info

        if is_gtk3():
            tb.new_row("PyGobject", label(gobject._version))
            tb.new_row("Client GDK", label(gdk._version))
            tb.new_row("GTK", label(gtk._version),
                       label(server_version_info("gtk_version")))
        else:
            tb.new_row("PyGTK", label(client_version_info("pygtk_version")),
                       label(server_version_info("pygtk_version")))
            tb.new_row("GTK", label(client_version_info("gtk_version")),
                       label(server_version_info("gtk_version")))
        tb.new_row("Python", label(platform.python_version()),
                   label(server_version_info("python_version")))
        cl_gst_v, cl_pygst_v = "", ""
        from xpra.scripts.main import HAS_SOUND
        if HAS_SOUND:
            try:
                from xpra.sound.gstreamer_util import gst_version as cl_gst_v, pygst_version as cl_pygst_v
            except:
                pass
        tb.new_row("GStreamer", label(make_version_str(cl_gst_v)),
                   label(server_version_info("gst_version")))
        tb.new_row("pygst", label(make_version_str(cl_pygst_v)),
                   label(server_version_info("pygst_version")))
        tb.new_row(
            "OpenGL",
            label(
                make_version_str(self.client.opengl_props.get("opengl",
                                                              "n/a"))),
            label("n/a"))
        tb.new_row(
            "OpenGL Vendor",
            label(make_version_str(self.client.opengl_props.get("vendor",
                                                                ""))),
            label("n/a"))
        tb.new_row(
            "PyOpenGL",
            label(
                make_version_str(
                    self.client.opengl_props.get("pyopengl", "n/a"))),
            label("n/a"))

        # Features Table:
        tb = self.table_tab("features.png", "Features", self.populate_features)
        randr_box = gtk.HBox(False, 20)
        self.server_randr_label = label()
        self.server_randr_icon = gtk.Image()
        randr_box.add(self.server_randr_icon)
        randr_box.add(self.server_randr_label)
        tb.new_row("RandR Support", randr_box)
        self.server_encodings_label = label()
        tb.new_row("Server Encodings", self.server_encodings_label)
        self.client_encodings_label = label()
        tb.new_row("Client Encodings", self.client_encodings_label)
        self.server_mmap_icon = gtk.Image()
        tb.new_row("Memory Mapped Transfers", self.server_mmap_icon)
        self.server_clipboard_icon = gtk.Image()
        tb.new_row("Clipboard", self.server_clipboard_icon)
        self.server_notifications_icon = gtk.Image()
        tb.new_row("Notification Forwarding", self.server_notifications_icon)
        self.server_bell_icon = gtk.Image()
        tb.new_row("Bell Forwarding", self.server_bell_icon)
        self.server_cursors_icon = gtk.Image()
        tb.new_row("Cursor Forwarding", self.server_cursors_icon)
        speaker_box = gtk.HBox(False, 20)
        self.server_speaker_icon = gtk.Image()
        speaker_box.add(self.server_speaker_icon)
        self.speaker_codec_label = label()
        speaker_box.add(self.speaker_codec_label)
        tb.new_row("Speaker Forwarding", speaker_box)
        self.server_speaker_codecs_label = label()
        tb.new_row("Server Codecs", self.server_speaker_codecs_label)
        self.client_speaker_codecs_label = label()
        tb.new_row("Client Codecs", self.client_speaker_codecs_label)
        microphone_box = gtk.HBox(False, 20)
        self.server_microphone_icon = gtk.Image()
        microphone_box.add(self.server_microphone_icon)
        self.microphone_codec_label = label()
        microphone_box.add(self.microphone_codec_label)
        tb.new_row("Microphone Forwarding", microphone_box)
        self.server_microphone_codecs_label = label()
        tb.new_row("Server Codecs", self.server_microphone_codecs_label)
        self.client_microphone_codecs_label = label()
        tb.new_row("Client Codecs", self.client_microphone_codecs_label)

        # Connection Table:
        tb = self.table_tab("connect.png", "Connection",
                            self.populate_connection)
        tb.new_row("Server Endpoint", label(self.connection.target))
        if self.client.server_display:
            tb.new_row("Server Display", label(self.client.server_display))
        if "hostname" in scaps:
            tb.new_row("Server Hostname", label(scaps.get("hostname")))
        if self.client.server_platform:
            tb.new_row("Server Platform", label(self.client.server_platform))
        self.server_load_label = label()
        tb.new_row("Server Load",
                   self.server_load_label,
                   label_text="Average over 1, 5 and 15 minutes")
        self.session_started_label = label()
        tb.new_row("Session Started", self.session_started_label)
        self.session_connected_label = label()
        tb.new_row("Session Connected", self.session_connected_label)
        self.input_packets_label = label()
        tb.new_row("Packets Received", self.input_packets_label)
        self.input_bytes_label = label()
        tb.new_row("Bytes Received", self.input_bytes_label)
        self.output_packets_label = label()
        tb.new_row("Packets Sent", self.output_packets_label)
        self.output_bytes_label = label()
        tb.new_row("Bytes Sent", self.output_bytes_label)
        self.compression_label = label()
        tb.new_row("Compression Level", self.compression_label)
        self.connection_type_label = label()
        tb.new_row("Connection Type", self.connection_type_label)
        self.input_encryption_label = label()
        tb.new_row("Input Encryption", self.input_encryption_label)
        self.output_encryption_label = label()
        tb.new_row("Output Encryption", self.output_encryption_label)

        # Details:
        tb = self.table_tab("browse.png", "Statistics",
                            self.populate_statistics)
        tb.widget_xalign = 1.0
        tb.attach(title_box(""), 0, xoptions=gtk.EXPAND | gtk.FILL, xpadding=0)
        tb.attach(title_box("Latest"),
                  1,
                  xoptions=gtk.EXPAND | gtk.FILL,
                  xpadding=0)
        tb.attach(title_box("Minimum"),
                  2,
                  xoptions=gtk.EXPAND | gtk.FILL,
                  xpadding=0)
        tb.attach(title_box("Average"),
                  3,
                  xoptions=gtk.EXPAND | gtk.FILL,
                  xpadding=0)
        tb.attach(title_box("90 percentile"),
                  4,
                  xoptions=gtk.EXPAND | gtk.FILL,
                  xpadding=0)
        tb.attach(title_box("Maximum"),
                  5,
                  xoptions=gtk.EXPAND | gtk.FILL,
                  xpadding=0)
        tb.inc()

        def maths_labels():
            return label(), label(), label(), label(), label()

        self.server_latency_labels = maths_labels()
        tb.add_row(label("Server Latency (ms)"), *self.server_latency_labels)
        self.client_latency_labels = maths_labels()
        tb.add_row(label("Client Latency (ms)"), *self.client_latency_labels)
        if self.client.windows_enabled:
            if self.client.server_info_request:
                self.batch_labels = maths_labels()
                tb.add_row(label("Batch Delay (ms)"), *self.batch_labels)
                self.damage_labels = maths_labels()
                tb.add_row(label("Damage Latency (ms)"), *self.damage_labels)

            self.regions_per_second_labels = maths_labels()
            tb.add_row(label("Regions/s"), *self.regions_per_second_labels)
            self.regions_sizes_labels = maths_labels()
            tb.add_row(label("Pixels/region"), *self.regions_sizes_labels)
            self.pixels_per_second_labels = maths_labels()
            tb.add_row(label("Pixels/s"), *self.pixels_per_second_labels)

            self.windows_managed_label = label()
            tb.new_row("Regular Windows", self.windows_managed_label),
            self.transient_managed_label = label()
            tb.new_row("Transient Windows", self.transient_managed_label),
            self.trays_managed_label = label()
            tb.new_row("Trays Managed", self.trays_managed_label),
            if self.client.opengl_enabled:
                self.opengl_label = label()
                tb.new_row("OpenGL Windows", self.opengl_label),

        self.graph_box = gtk.VBox(False, 10)
        self.add_tab("statistics.png", "Graphs", self.populate_graphs,
                     self.graph_box)
        bandwidth_label = "Number of bytes measured by the networks sockets"
        if SHOW_PIXEL_STATS:
            bandwidth_label += ",\nand number of pixels rendered"
        self.bandwidth_graph = self.add_graph_button(bandwidth_label,
                                                     self.save_graphs)
        self.latency_graph = self.add_graph_button(
            "The time it takes to send an echo packet and get the reply",
            self.save_graphs)
        self.pixel_in_data = maxdeque(N_SAMPLES + 4)
        self.net_in_data = maxdeque(N_SAMPLES + 4)
        self.net_out_data = maxdeque(N_SAMPLES + 4)

        self.set_border_width(15)
        self.add(self.tab_box)
        if not is_gtk3():
            self.set_geometry_hints(self.tab_box)

        def window_deleted(*args):
            self.is_closed = True

        self.connect('delete_event', window_deleted)
        self.show_tab(self.tabs[0][1])
        self.set_size_request(-1, 480)
        self.populate()
        self.populate_all()
        gobject.timeout_add(1000, self.populate)
        gobject.timeout_add(100, self.populate_tab)
        self.connect("realize", self.populate_graphs)
        add_close_accel(self, self.destroy)
Ejemplo n.º 23
0
    def __init__(self, client, session_name, window_icon_pixbuf, conn, get_pixbuf):
        gtk.Window.__init__(self)
        self.client = client
        self.session_name = session_name
        self.connection = conn
        self.last_populate_time = 0
        self.last_populate_statistics = 0
        self.is_closed = False
        self.get_pixbuf = get_pixbuf
        self.set_title(self.session_name or "Session Info")
        self.set_destroy_with_parent(True)
        self.set_resizable(True)
        self.set_decorated(True)
        if window_icon_pixbuf:
            self.set_icon(window_icon_pixbuf)
        if is_gtk3():
            self.set_position(gtk.WindowPosition.CENTER)
        else:
            self.set_position(gtk.WIN_POS_CENTER)

        #tables on the left in a vbox with buttons at the top:
        self.tab_box = gtk.VBox(False, 0)
        self.tab_button_box = gtk.HBox(True, 0)
        self.tabs = []          #pairs of button, table
        self.populate_cb = None
        self.tab_box.pack_start(self.tab_button_box, expand=False, fill=True, padding=0)

        #Package Table:
        tb = self.table_tab("package.png", "Software", self.populate_package)
        #title row:
        tb.attach(title_box(""), 0, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.attach(title_box("Client"), 1, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.attach(title_box("Server"), 2, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.inc()

        scaps = self.client.server_capabilities
        from xpra.__init__ import __version__
        tb.new_row("Xpra", label(__version__), label(self.client._remote_version or "unknown"))
        cl_rev, cl_ch, cl_date = "unknown", "", ""
        try:
            from xpra.build_info import BUILD_DATE as cl_date, REVISION as cl_rev, LOCAL_MODIFICATIONS as cl_ch
        except:
            pass
        tb.new_row("Revision", label(cl_rev), label(self.client._remote_revision or "unknown"))
        tb.new_row("Local Changes", label(cl_ch), label(scaps.get("local_modifications", "unknown")))
        tb.new_row("Build date", label(cl_date), label(scaps.get("build_date", "unknown")))
        def make_version_str(version):
            if version and type(version) in (tuple, list):
                version = ".".join([str(x) for x in version])
            return version or "unknown"
        def server_version_info(prop_name):
            return make_version_str(scaps.get(prop_name))
        def client_version_info(prop_name):
            info = "unknown"
            if hasattr(gtk, prop_name):
                info = make_version_str(getattr(gtk, prop_name))
            return info
        if is_gtk3():
            tb.new_row("PyGobject", label(gobject._version))
            tb.new_row("Client GDK", label(gdk._version))
            tb.new_row("GTK", label(gtk._version), label(server_version_info("gtk_version")))
        else:
            tb.new_row("PyGTK", label(client_version_info("pygtk_version")), label(server_version_info("pygtk_version")))
            tb.new_row("GTK", label(client_version_info("gtk_version")), label(server_version_info("gtk_version")))
        tb.new_row("Python", label(platform.python_version()), label(server_version_info("python_version")))
        cl_gst_v, cl_pygst_v = "", ""
        from xpra.scripts.main import HAS_SOUND
        if HAS_SOUND:
            try:
                from xpra.sound.gstreamer_util import gst_version as cl_gst_v, pygst_version as cl_pygst_v
            except:
                pass
        tb.new_row("GStreamer", label(make_version_str(cl_gst_v)), label(server_version_info("gst_version")))
        tb.new_row("pygst", label(make_version_str(cl_pygst_v)), label(server_version_info("pygst_version")))
        tb.new_row("OpenGL", label(make_version_str(self.client.opengl_props.get("opengl", "n/a"))), label("n/a"))
        tb.new_row("OpenGL Vendor", label(make_version_str(self.client.opengl_props.get("vendor", ""))), label("n/a"))
        tb.new_row("PyOpenGL", label(make_version_str(self.client.opengl_props.get("pyopengl", "n/a"))), label("n/a"))

        # Features Table:
        tb = self.table_tab("features.png", "Features", self.populate_features)
        randr_box = gtk.HBox(False, 20)
        self.server_randr_label = label()
        self.server_randr_icon = gtk.Image()
        randr_box.add(self.server_randr_icon)
        randr_box.add(self.server_randr_label)
        tb.new_row("RandR Support", randr_box)
        self.server_encodings_label = label()
        tb.new_row("Server Encodings", self.server_encodings_label)
        self.client_encodings_label = label()
        tb.new_row("Client Encodings", self.client_encodings_label)
        self.server_mmap_icon = gtk.Image()
        tb.new_row("Memory Mapped Transfers", self.server_mmap_icon)
        self.server_clipboard_icon = gtk.Image()
        tb.new_row("Clipboard", self.server_clipboard_icon)
        self.server_notifications_icon = gtk.Image()
        tb.new_row("Notification Forwarding", self.server_notifications_icon)
        self.server_bell_icon = gtk.Image()
        tb.new_row("Bell Forwarding", self.server_bell_icon)
        self.server_cursors_icon = gtk.Image()
        tb.new_row("Cursor Forwarding", self.server_cursors_icon)
        speaker_box = gtk.HBox(False, 20)
        self.server_speaker_icon = gtk.Image()
        speaker_box.add(self.server_speaker_icon)
        self.speaker_codec_label = label()
        speaker_box.add(self.speaker_codec_label)
        tb.new_row("Speaker Forwarding", speaker_box)
        self.server_speaker_codecs_label = label()
        tb.new_row("Server Codecs", self.server_speaker_codecs_label)
        self.client_speaker_codecs_label = label()
        tb.new_row("Client Codecs", self.client_speaker_codecs_label)
        microphone_box = gtk.HBox(False, 20)
        self.server_microphone_icon = gtk.Image()
        microphone_box.add(self.server_microphone_icon)
        self.microphone_codec_label = label()
        microphone_box.add(self.microphone_codec_label)
        tb.new_row("Microphone Forwarding", microphone_box)
        self.server_microphone_codecs_label = label()
        tb.new_row("Server Codecs", self.server_microphone_codecs_label)
        self.client_microphone_codecs_label = label()
        tb.new_row("Client Codecs", self.client_microphone_codecs_label)

        # Connection Table:
        tb = self.table_tab("connect.png", "Connection", self.populate_connection)
        tb.new_row("Server Endpoint", label(self.connection.target))
        if self.client.server_display:
            tb.new_row("Server Display", label(self.client.server_display))
        if "hostname" in scaps:
            tb.new_row("Server Hostname", label(scaps.get("hostname")))
        if self.client.server_platform:
            tb.new_row("Server Platform", label(self.client.server_platform))
        self.server_load_label = label()
        tb.new_row("Server Load", self.server_load_label, label_text="Average over 1, 5 and 15 minutes")
        self.session_started_label = label()
        tb.new_row("Session Started", self.session_started_label)
        self.session_connected_label = label()
        tb.new_row("Session Connected", self.session_connected_label)
        self.input_packets_label = label()
        tb.new_row("Packets Received", self.input_packets_label)
        self.input_bytes_label = label()
        tb.new_row("Bytes Received", self.input_bytes_label)
        self.output_packets_label = label()
        tb.new_row("Packets Sent", self.output_packets_label)
        self.output_bytes_label = label()
        tb.new_row("Bytes Sent", self.output_bytes_label)
        self.compression_label = label()
        tb.new_row("Compression Level", self.compression_label)
        self.connection_type_label = label()
        tb.new_row("Connection Type", self.connection_type_label)
        self.input_encryption_label = label()
        tb.new_row("Input Encryption", self.input_encryption_label)
        self.output_encryption_label = label()
        tb.new_row("Output Encryption", self.output_encryption_label)

        # Details:
        tb = self.table_tab("browse.png", "Statistics", self.populate_statistics)
        tb.widget_xalign = 1.0
        tb.attach(title_box(""), 0, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.attach(title_box("Latest"), 1, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.attach(title_box("Minimum"), 2, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.attach(title_box("Average"), 3, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.attach(title_box("90 percentile"), 4, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.attach(title_box("Maximum"), 5, xoptions=gtk.EXPAND|gtk.FILL, xpadding=0)
        tb.inc()

        def maths_labels():
            return label(), label(), label(), label(), label()
        self.server_latency_labels = maths_labels()
        tb.add_row(label("Server Latency (ms)"), *self.server_latency_labels)
        self.client_latency_labels = maths_labels()
        tb.add_row(label("Client Latency (ms)"), *self.client_latency_labels)
        if self.client.windows_enabled:
            if self.client.server_info_request:
                self.batch_labels = maths_labels()
                tb.add_row(label("Batch Delay (ms)"), *self.batch_labels)
                self.damage_labels = maths_labels()
                tb.add_row(label("Damage Latency (ms)"), *self.damage_labels)

            self.regions_per_second_labels = maths_labels()
            tb.add_row(label("Regions/s"), *self.regions_per_second_labels)
            self.regions_sizes_labels = maths_labels()
            tb.add_row(label("Pixels/region"), *self.regions_sizes_labels)
            self.pixels_per_second_labels = maths_labels()
            tb.add_row(label("Pixels/s"), *self.pixels_per_second_labels)

            self.windows_managed_label = label()
            tb.new_row("Regular Windows", self.windows_managed_label),
            self.transient_managed_label = label()
            tb.new_row("Transient Windows", self.transient_managed_label),
            self.trays_managed_label = label()
            tb.new_row("Trays Managed", self.trays_managed_label),
            if self.client.opengl_enabled:
                self.opengl_label = label()
                tb.new_row("OpenGL Windows", self.opengl_label),

        self.graph_box = gtk.VBox(False, 10)
        self.add_tab("statistics.png", "Graphs", self.populate_graphs, self.graph_box)
        bandwidth_label = "Number of bytes measured by the networks sockets"
        if SHOW_PIXEL_STATS:
            bandwidth_label += ",\nand number of pixels rendered"
        self.bandwidth_graph = self.add_graph_button(bandwidth_label, self.save_graphs)
        self.latency_graph = self.add_graph_button("The time it takes to send an echo packet and get the reply", self.save_graphs)
        self.pixel_in_data = maxdeque(N_SAMPLES+4)
        self.net_in_data = maxdeque(N_SAMPLES+4)
        self.net_out_data = maxdeque(N_SAMPLES+4)

        self.set_border_width(15)
        self.add(self.tab_box)
        if not is_gtk3():
            self.set_geometry_hints(self.tab_box)
        def window_deleted(*args):
            self.is_closed = True
        self.connect('delete_event', window_deleted)
        self.show_tab(self.tabs[0][1])
        self.set_size_request(-1, 480)
        self.populate()
        self.populate_all()
        gobject.timeout_add(1000, self.populate)
        gobject.timeout_add(100, self.populate_tab)
        self.connect("realize", self.populate_graphs)
        add_close_accel(self, self.destroy)
Ejemplo n.º 24
0
# This file is part of Parti.
# Copyright (C) 2012-2013 Antoine Martin <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

cursor_names = {}
from wimpiggy.gobject_compat import import_gdk, is_gtk3
gdk = import_gdk()
#we could also directly lookup the attribute name
#on the gtk.gdk class, but this could cause problems
#as there are other non-cursor functions and attributes
#defined in that class. This is quick and easy.
if not is_gtk3():
    cursor_names["X_CURSOR"] = gdk.X_CURSOR
    cursor_names["ARROW"] = gdk.ARROW
    cursor_names["BASED_ARROW_DOWN"] = gdk.BASED_ARROW_DOWN
    cursor_names["BASED_ARROW_UP"] = gdk.BASED_ARROW_UP
    cursor_names["BOAT"] = gdk.BOAT
    cursor_names["BOGOSITY"] = gdk.BOGOSITY
    cursor_names["BOTTOM_LEFT_CORNER"] = gdk.BOTTOM_LEFT_CORNER
    cursor_names["BOTTOM_RIGHT_CORNER"] = gdk.BOTTOM_RIGHT_CORNER
    cursor_names["BOTTOM_SIDE"] = gdk.BOTTOM_SIDE
    cursor_names["BOTTOM_TEE"] = gdk.BOTTOM_TEE
    cursor_names["BOX_SPIRAL"] = gdk.BOX_SPIRAL
    cursor_names["CENTER_PTR"] = gdk.CENTER_PTR
    cursor_names["CIRCLE"] = gdk.CIRCLE
    cursor_names["CLOCK"] = gdk.CLOCK
    cursor_names["COFFEE_MUG"] = gdk.COFFEE_MUG
    cursor_names["CROSS"] = gdk.CROSS
    cursor_names["CROSS_REVERSE"] = gdk.CROSS_REVERSE
    cursor_names["CROSSHAIR"] = gdk.CROSSHAIR