Exemplo n.º 1
0
 def get_property(self, prop):
     if prop == "xid":
         return self.client_window.xid
     elif prop == "depth":
         return self._depth
     elif prop == "title":
         return get_wm_name() or "xpra desktop"
     elif prop == "client-machine":
         return socket.gethostname()
     elif prop == "window-type":
         return ["NORMAL"]
     elif prop == "shadow":
         return True
     elif prop == "class-instance":
         return ("xpra-desktop", "Xpra-Desktop")
     elif prop == "icon":
         try:
             icon_name = get_wm_name() + ".png"
             icon = get_icon(icon_name)
             log("get_icon(%s)=%s", icon_name, icon)
             return icon
         except:
             log("failed to return window icon")
             return None
     else:
         return gobject.GObject.get_property(self, prop)
Exemplo n.º 2
0
def do_init():
    osxapp = get_OSXApplication()
    icon = get_icon("xpra.png")
    if icon:
        osxapp.set_dock_icon_pixbuf(icon)
    mh = getOSXMenuHelper(None)
    osxapp.set_dock_menu(mh.build_dock_menu())
    osxapp.set_menu_bar(mh.rebuild())
Exemplo n.º 3
0
def do_init():
    osxapp = get_OSXApplication()
    icon = get_icon("xpra.png")
    if icon:
        osxapp.set_dock_icon_pixbuf(icon)
    mh = getOSXMenuHelper(None)
    osxapp.set_dock_menu(mh.build_dock_menu())
    osxapp.set_menu_bar(mh.rebuild())
Exemplo n.º 4
0
 def update_icon(self):
     icon = None
     try:
         icon_name = (get_wm_name() or "").lower() + ".png"
         icon = get_icon(icon_name)
         iconlog("get_icon(%s)=%s", icon_name, icon)
     except:
         iconlog("failed to return window icon")
     return self._updateprop("icon", icon)
Exemplo n.º 5
0
    def __init__(self):
        self.window = gtk.Window()
        self.window.connect("destroy", self.destroy)
        self.window.set_default_size(640, 300)
        self.window.set_border_width(20)
        self.window.set_title("Clipboard Test Tool")

        vbox = gtk.VBox(False, 0)
        vbox.set_spacing(15)

        self.log = deque(maxlen=25)
        for x in range(25):
            self.log.append("")
        self.events = gtk.Label()
        fixed = pango.FontDescription('monospace 9')
        self.events.modify_font(fixed)

        #how many clipboards to show:
        self.clipboards = CLIPBOARDS

        tb = TableBuilder()
        table = tb.get_table()
        labels = [label("Selection")]
        labels += [
            label("Value"),
            label("Clear"),
            label("Targets"),
            label("Actions")
        ]
        tb.add_row(*labels)
        for selection in self.clipboards:
            cs = ClipboardInstance(selection, self.add_event)
            get_actions = gtk.HBox()
            for x in (cs.get_get_targets_btn, cs.get_target_btn,
                      cs.get_string_btn):
                get_actions.pack_start(x)
            tb.add_row(label(selection), cs.value_label, cs.clear_label_btn,
                       cs.get_targets, get_actions)
            set_actions = gtk.HBox()
            for x in (cs.set_target_btn, cs.set_string_btn):
                set_actions.pack_start(x)
            tb.add_row(None, cs.value_entry, cs.clear_entry_btn,
                       cs.set_targets, set_actions)
        vbox.pack_start(table)
        vbox.add(self.events)

        self.window.add(vbox)
        self.window.show_all()
        icon = get_icon("clipboard.png")
        if icon:
            self.window.set_icon(icon)
        try:
            self.add_event(
                "ALL", "window=%s, xid=%#x" %
                (self.window, get_xwindow(self.window.get_window())))
        except Exception:
            self.add_event("ALL", "window=%s" % self.window)
Exemplo n.º 6
0
 def get_image(self, icon_name, size=None):
     try:
         pixbuf = get_icon(icon_name)
         debug("get_image(%s, %s) pixbuf=%s", icon_name, size, pixbuf)
         if not pixbuf:
             return  None
         if size:
             return scaled_image(pixbuf, size)
         return  gtk.image_new_from_pixbuf(pixbuf)
     except:
         log.error("get_image(%s, %s)", icon_name, size, exc_info=True)
         return  None
Exemplo n.º 7
0
 def get_image(self, icon_name, size=None):
     try:
         pixbuf = get_icon(icon_name)
         debug("get_image(%s, %s) pixbuf=%s", icon_name, size, pixbuf)
         if not pixbuf:
             return None
         if size:
             return scaled_image(pixbuf, size)
         return gtk.image_new_from_pixbuf(pixbuf)
     except:
         log.error("get_image(%s, %s)", icon_name, size, exc_info=True)
         return None
Exemplo n.º 8
0
def about(on_close=None):
    global about_dialog
    if about_dialog:
        about_dialog.show()
        about_dialog.present()
        return
    from xpra.platform.paths import get_icon
    xpra_icon = get_icon("xpra.png")
    dialog = gtk.AboutDialog()
    if not is_gtk3():
        import webbrowser

        def on_website_hook(*_args):
            ''' called when the website item is selected '''
            webbrowser.open(SITE_URL)

        def on_email_hook(*_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(XPRA_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()
Exemplo n.º 9
0
def do_init():
    osxapp = get_OSXApplication()
    log("do_init() osxapp=%s", osxapp)
    from xpra.platform.paths import get_icon
    icon = get_icon("xpra.png")
    log("do_init() icon=%s", icon)
    if icon:
        osxapp.set_dock_icon_pixbuf(icon)
    from xpra.platform.darwin.osx_menu import getOSXMenuHelper
    mh = getOSXMenuHelper(None)
    log("do_init() menu helper=%s", mh)
    osxapp.set_dock_menu(mh.build_dock_menu())
    osxapp.set_menu_bar(mh.rebuild())
Exemplo n.º 10
0
def do_init():
    osxapp = get_OSXApplication()
    log("do_init() osxapp=%s", osxapp)
    from xpra.platform.paths import get_icon
    icon = get_icon("xpra.png")
    log("do_init() icon=%s", icon)
    if icon:
        osxapp.set_dock_icon_pixbuf(icon)
    from xpra.platform.darwin.osx_menu import getOSXMenuHelper
    mh = getOSXMenuHelper(None)
    log("do_init() menu helper=%s", mh)
    osxapp.set_dock_menu(mh.build_dock_menu())
    osxapp.set_menu_bar(mh.rebuild())
Exemplo n.º 11
0
 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 = self.get_generic_os_name()
         return ("xpra-%s" % osn, "Xpra-%s" % osn.upper())
     elif prop == "icon":
         #convert it to a cairo surface..
         #because that's what the property is expected to be
         try:
             import gtk.gdk
             from xpra.platform.paths import get_icon
             icon_name = self.get_generic_os_name() + ".png"
             icon = get_icon(icon_name)
             log("icon(%s)=%s", icon_name, icon)
             if not icon:
                 return None
             import cairo
             surf = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                       icon.get_width(), icon.get_height())
             gc = gtk.gdk.CairoContext(cairo.Context(surf))
             gc.set_source_pixbuf(icon, 0, 0)
             gc.paint()
             log("icon=%s", surf)
             return surf
         except:
             log("failed to return window icon")
             return None
     else:
         raise Exception("invalid property: %s" % prop)
     return None
Exemplo n.º 12
0
	def	__init__(self):
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.window.connect("destroy", self.destroy)
		self.window.set_default_size(640, 300)
		self.window.set_border_width(20)

		vbox = gtk.VBox(False, 0)
		vbox.set_spacing(15)

		self.log = maxdeque(maxlen=25)
		for x in range(25):
			self.log.append("")
		self.events = gtk.Label()
		fixed = pango.FontDescription('monospace 9')
		self.events.modify_font(fixed)

		#how many clipboards to show:
		self.clipboards = ["CLIPBOARD", "PRIMARY", "SECONDARY"]
		if sys.platform.startswith("win"):
			self.clipboards = ["CLIPBOARD"]

		tb = TableBuilder()
		table = tb.get_table()
		labels = [label("Selection")]
		labels += [label("Value"), label("Clear"), label("Targets"), label("Actions")]
		tb.add_row(*labels)
		for selection in self.clipboards:
			cs = ClipboardInstance(selection, self.add_event)
			get_actions = gtk.HBox()
			for x in (cs.get_get_targets_btn, cs.get_target_btn, cs.get_string_btn):
				get_actions.pack_start(x)
			tb.add_row(label(selection), cs.value_label, cs.clear_label_btn, cs.get_targets, get_actions)
			set_actions = gtk.HBox()
			for x in (cs.set_target_btn, cs.set_string_btn):
				set_actions.pack_start(x)
			tb.add_row(None, cs.value_entry, cs.clear_entry_btn, cs.set_targets, set_actions)
		vbox.pack_start(table)
		vbox.add(self.events)

		self.window.add(vbox)
		self.window.show_all()
		icon = get_icon("clipboard.png")
		if icon:
			self.window.set_icon(icon)
		try:
			self.add_event("ALL", "window=%s, xid=%s" % (self.window, hex(self.window.get_window().xid)))
		except:
			self.add_event("ALL", "window=%s" % self.window)
Exemplo n.º 13
0
 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 = self.get_generic_os_name()
         return ("xpra-%s" % osn, "Xpra-%s" % osn.upper())
     elif prop=="icon":
         #convert it to a cairo surface..
         #because that's what the property is expected to be
         try:
             import gtk.gdk
             from xpra.platform.paths import get_icon
             icon_name = self.get_generic_os_name()+".png"
             icon = get_icon(icon_name)
             log("icon(%s)=%s", icon_name, icon)
             if not icon:
                 return None
             import cairo
             surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, icon.get_width(), icon.get_height())
             gc = gtk.gdk.CairoContext(cairo.Context(surf))
             gc.set_source_pixbuf(icon, 0, 0)
             gc.paint()
             log("icon=%s", surf)
             return surf
         except:
             log("failed to return window icon")
             return None
     else:
         raise ValueError("invalid property: %s" % prop)
     return None
Exemplo n.º 14
0
 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
Exemplo n.º 15
0
def do_init():
    osxapp = get_OSXApplication()
    log("do_init() osxapp=%s", osxapp)
    if not osxapp:
        return  #not much else we can do here
    from xpra.platform.paths import get_icon
    from xpra.platform.gui import get_default_icon
    filename = get_default_icon()
    icon = get_icon(filename)
    log("do_init() icon=%s", icon)
    if icon:
        osxapp.set_dock_icon_pixbuf(icon)
    from xpra.platform.darwin.osx_menu import getOSXMenuHelper
    mh = getOSXMenuHelper(None)
    log("do_init() menu helper=%s", mh)
    osxapp.set_dock_menu(mh.build_dock_menu())
    osxapp.set_menu_bar(mh.rebuild())
Exemplo n.º 16
0
def about(on_close=None):
	global about_dialog
	if about_dialog:
		about_dialog.show()
		about_dialog.present()
		return
	from xpra.platform.paths 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()
Exemplo n.º 17
0
    def __init__(self):
        self.init_constants()
        self.window = gtk.Window()
        self.window.connect("destroy", self.destroy)
        self.window.set_default_size(540, 800)
        self.window.set_border_width(20)
        self.window.set_title("Keyboard State Tool")

        # Title
        vbox = gtk.VBox(False, 0)
        vbox.set_spacing(15)
        label = gtk.Label("Keyboard State")
        label.modify_font(pango.FontDescription("sans 13"))
        vbox.pack_start(label)

        self.modifiers = gtk.Label()
        vbox.add(self.modifiers)

        self.mouse = gtk.Label()
        vbox.add(self.mouse)

        self.keys = gtk.Label()
        fixed = pango.FontDescription('monospace 9')
        self.keys.modify_font(fixed)
        vbox.add(self.keys)

        self.window.add(vbox)
        self.window.show_all()
        glib.timeout_add(100, self.populate_modifiers)

        self.key_events = deque(maxlen=35)
        display = Gdk.Display.get_default()
        keymap = Gdk.Keymap.get_for_display(display)
        self.keymap_change_timer = 0
        keymap.connect("keys-changed", self.keymap_changed)
        self.show_keymap("current keymap")
        self.window.connect("key-press-event", self.key_press)
        self.window.connect("key-release-event", self.key_release)
        if not is_gtk3():
            self.window.window.set_cursor(gdk.Cursor(gdk.HAND2))

        icon = get_icon("keyboard.png")
        if icon:
            self.window.set_icon(icon)
Exemplo n.º 18
0
    def    __init__(self):
        self.init_constants()
        self.window = Gtk.Window()
        self.window.connect("destroy", self.destroy)
        self.window.set_default_size(540, 800)
        self.window.set_border_width(20)
        self.window.set_title("Keyboard State Tool")

        # Title
        vbox = Gtk.VBox(False, 0)
        vbox.set_spacing(15)
        label = Gtk.Label("Keyboard State")
        label.modify_font(Pango.FontDescription("sans 13"))
        #patch pack_start:
        from xpra.gtk_common.gtk_util import pack_start
        assert pack_start
        vbox.pack_start(label)

        self.modifiers = Gtk.Label()
        vbox.add(self.modifiers)

        self.mouse = Gtk.Label()
        vbox.add(self.mouse)

        self.keys = Gtk.Label()
        fixed = Pango.FontDescription('monospace 9')
        self.keys.modify_font(fixed)
        vbox.add(self.keys)

        self.window.add(vbox)
        GLib.timeout_add(100, self.populate_modifiers)

        self.key_events = deque(maxlen=35)
        self.window.connect("key-press-event", self.key_press)
        self.window.connect("key-release-event", self.key_release)
        display = Gdk.Display.get_default()
        keymap = Gdk.Keymap.get_for_display(display)
        self.keymap_change_timer = 0
        keymap.connect("keys-changed", self.keymap_changed)
        self.show_keymap("current keymap")

        icon = get_icon("keyboard.png")
        if icon:
            self.window.set_icon(icon)
Exemplo n.º 19
0
Arquivo: gui.py Projeto: dochench/xpra
def do_init():
    osxapp = get_OSXApplication()
    log("do_init() osxapp=%s", osxapp)
    if not osxapp:
        return  #not much else we can do here
    from xpra.platform.paths import get_icon
    from xpra.platform.gui import get_default_icon
    filename = get_default_icon()
    icon = get_icon(filename)
    log("do_init() icon=%s", icon)
    if icon:
        osxapp.set_dock_icon_pixbuf(icon)
    from xpra.platform.darwin.osx_menu import getOSXMenuHelper
    mh = getOSXMenuHelper(None)
    log("do_init() menu helper=%s", mh)
    osxapp.set_dock_menu(mh.build_dock_menu())
    import warnings
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore", message=".*invalid cast from 'GtkMenuBar'")
        osxapp.set_menu_bar(mh.rebuild())
Exemplo n.º 20
0
 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
Exemplo n.º 21
0
    def    __init__(self):
        self.window = gtk.Window()
        self.window.connect("destroy", self.destroy)
        self.window.set_default_size(540, 800)
        self.window.set_border_width(20)
        self.window.set_title("Keyboard State Tool")

        # Title
        vbox = gtk.VBox(False, 0)
        vbox.set_spacing(15)
        label = gtk.Label("Keyboard State")
        label.modify_font(pango.FontDescription("sans 13"))
        vbox.pack_start(label)

        self.modifiers = gtk.Label()
        vbox.add(self.modifiers)

        self.mouse = gtk.Label()
        vbox.add(self.mouse)

        self.keys = gtk.Label()
        fixed = pango.FontDescription('monospace 9')
        self.keys.modify_font(fixed)
        vbox.add(self.keys)

        self.window.add(vbox)
        self.window.show_all()
        gobject.timeout_add(100, self.populate_modifiers)

        self.key_events = maxdeque(maxlen=35)
        self.window.connect("key-press-event", self.key_press)
        self.window.connect("key-release-event", self.key_release)
        if not is_gtk3():
            self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))

        icon = get_icon("keyboard.png")
        if icon:
            self.window.set_icon(icon)
Exemplo n.º 22
0
    def    __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.destroy)
        self.window.set_default_size(540, 800)
        self.window.set_border_width(20)

        # Title
        vbox = gtk.VBox(False, 0)
        vbox.set_spacing(15)
        label = gtk.Label("Keyboard State")
        label.modify_font(pango.FontDescription("sans 13"))
        vbox.pack_start(label)

        self.modifiers = gtk.Label()
        vbox.add(self.modifiers)

        self.mouse = gtk.Label()
        vbox.add(self.mouse)

        self.keys = gtk.Label()
        fixed = pango.FontDescription('monospace 9')
        self.keys.modify_font(fixed)
        vbox.add(self.keys)

        self.window.add(vbox)
        self.window.show_all()
        gobject.timeout_add(100, self.populate_modifiers)

        self.key_events = maxdeque(maxlen=35)
        self.window.connect("key-press-event", self.key_press)
        self.window.connect("key-release-event", self.key_release)
        self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))

        icon = get_icon("keyboard.png")
        if icon:
            self.window.set_icon(icon)
Exemplo n.º 23
0
 def get_default_window_icon(self):
     icon_name = get_generic_os_name() + ".png"
     return get_icon(icon_name)
Exemplo n.º 24
0
 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()