def main(): import logging logging.basicConfig(format="%(asctime)s %(message)s") logging.root.setLevel(logging.DEBUG) appindicator = get_appindicator() if not appindicator: debug("appindicator not available") return if not can_use_appindicator(): debug("appindicator may not be shown...") from xpra.gtk_common.gobject_compat import import_gobject, import_gtk gobject = import_gobject() gtk = import_gtk() menu = gtk.Menu() item = gtk.MenuItem("Some Menu Item Here") menu.append(item) menu.show_all() a = AppindicatorTray(menu, "test", "xpra.png", None, None, None, gtk.main_quit) a.show() gobject.timeout_add(1000 * 10, gtk.main_quit) gtk.main()
def gtk_main_quit_really(): # We used to call gtk.main_quit() repeatedly, but this doesn't actually # work -- gtk.main_quit() always marks the *current* level of main loop # for destruction, so it's actually idempotent. We have to call # gtk.main_quit once, and then return to the main loop, and then call it # again, and then return to the main loop, etc. So we use a trick: We # register a function that gtk should call 'forever' (i.e., as long as the # main loop is running!) def gtk_main_quit_forever(): # We import gtk inside here, rather than at the top of the file, # because importing gtk has the side-effect of trying to connect to # the X server (and this process may block, may cause us to later be # killed if the X server goes away, etc.), and we don't want to impose # that on every user of this function. from xpra.gtk_common.gobject_compat import import_gtk gtk = import_gtk() gtk.main_quit() # So long as there are more nested main loops, re-register ourselves # to be called again: if gtk.main_level() > 1: return True else: # But when we've just quit the outermost main loop, then # unregister ourselves so that it's possible to start the # main-loop again if desired: return False from xpra.gtk_common.gobject_compat import import_gobject gobject = import_gobject() gobject.timeout_add(0, gtk_main_quit_forever)
def main(): log.enable_debug() from xpra.gtk_common.gobject_compat import import_gobject gobject = import_gobject() s = GTKStatusIconTray(None, "test", "xpra.png", None, None, None, gtk.main_quit) gobject.timeout_add(1000*2, s.set_blinking, True) gobject.timeout_add(1000*5, s.set_blinking, False) gobject.timeout_add(1000*10, gtk.main_quit) gtk.main()
def make_client(error_cb, opts): app = None if not opts.client_toolkit: from xpra.gtk_common.gobject_compat import import_gobject, is_gtk3 import_gobject() if is_gtk3(): opts.client_toolkit = "gtk3" else: opts.client_toolkit = "gtk2" ct = opts.client_toolkit.lower() toolkits = {} try: import gtk.gdk #@UnusedImport import xpra.client.gtk2 #@UnusedImport toolkits["gtk2"] = "xpra.client.gtk2.client" except Exception, e: print("cannot load gtk2: %s" % e)
def main(): import logging logging.basicConfig(format="%(asctime)s %(message)s") logging.root.setLevel(logging.DEBUG) from xpra.gtk_common.gobject_compat import import_gobject gobject = import_gobject() s = GTKStatusIconTray(None, "test", "xpra.png", None, None, None, gtk.main_quit) gobject.timeout_add(1000*2, s.set_blinking, True) gobject.timeout_add(1000*5, s.set_blinking, False) gobject.timeout_add(1000*10, gtk.main_quit) gtk.main()
def main(): log.enable_debug() appindicator = get_appindicator() if not appindicator: log("appindicator not available") return if not can_use_appindicator(): log("appindicator may not be shown...") from xpra.gtk_common.gobject_compat import import_gobject, import_gtk gobject = import_gobject() gtk = import_gtk() menu = gtk.Menu() item = gtk.MenuItem("Some Menu Item Here") menu.append(item) menu.show_all() a = AppindicatorTray(menu, "test", "xpra.png", None, None, None, gtk.main_quit) a.show() gobject.timeout_add(1000*10, gtk.main_quit) gtk.main()
def main(): from xpra.platform import init as platform_init platform_init("Xpra-Bug-Report", "Xpra Bug Report") from xpra.log import enable_color enable_color() from xpra.log import Logger, enable_debug_for log = Logger("util") #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.gtk_common.gobject_compat import import_gobject gobject = import_gobject() gobject.threads_init() from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.client.gtk_base.bug_report import BugReport app = BugReport() app.close = app.quit app.init(True) def app_signal(signum, frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: from xpra.platform.gui import ready as gui_ready gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): import sys if "-v" in sys.argv or "--verbose" in sys.argv: from xpra.log import add_debug_category add_debug_category("webcam") run = "-r" in sys.argv or "--run" in sys.argv if run: from xpra.gtk_common.gobject_compat import import_glib, import_gobject glib = import_glib() gobject = import_gobject() gobject.threads_init() from xpra.util import engs, print_nested_dict from xpra.platform import program_context with program_context("Webcam Info", "Webcam Info"): devices = get_virtual_video_devices() or {} log.info("Found %i virtual video device%s:", len(devices), engs(devices)) print_nested_dict(devices) all_devices = get_all_video_devices() or {} log.info("Found %i video device%s in total:", len(all_devices), engs(all_devices)) print_nested_dict(all_devices) if run: log.info("add watch for video device changes") def callback(added=None, device=None): if added is not None or device: log.info("video device %s: %s", ["removed", "added"][added], device) else: log.info("device change") log.info("starting main loop") main_loop = glib.MainLoop() glib.idle_add(add_video_device_change_callback, callback) try: main_loop.run() except KeyboardInterrupt: pass log.info("terminating, removing callback") remove_video_device_change_callback(callback)
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2011-2014 Antoine Martin <*****@*****.**> from xpra.gtk_common.gobject_compat import import_gtk, import_gdk, is_gtk3, import_pango, import_gobject from xpra.gtk_common.gtk_util import SHIFT_MASK, LOCK_MASK, CONTROL_MASK, MOD1_MASK, MOD2_MASK, MOD3_MASK, MOD4_MASK, MOD5_MASK import sys gtk = import_gtk() gdk = import_gdk() pango = import_pango() gobject = import_gobject() from xpra.deque import maxdeque from xpra.platform.paths import get_icon from xpra.gtk_common import gtk_util assert gtk_util, "cannot load compat class" modifier_names = { SHIFT_MASK : "Shift", LOCK_MASK : "Lock", CONTROL_MASK : "Control", MOD1_MASK : "mod1", MOD2_MASK : "mod2", MOD3_MASK : "mod3", MOD4_MASK : "mod4", MOD5_MASK : "mod5" } short_modifier_names = { SHIFT_MASK : "S",
# Copyright (C) 2009-2018 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. """ client_launcher.py This is a simple GUI for starting the xpra client. """ import os.path import sys import signal import traceback from xpra.gtk_common.gobject_compat import import_gtk, import_gdk, import_gobject, import_pango, import_glib gobject = import_gobject() gobject.threads_init() glib = import_glib() glib.threads_init() gtk = import_gtk() gdk = import_gdk() pango = import_pango() from xpra.platform.gui import init as gui_init gui_init() from xpra.scripts.config import read_config, make_defaults_struct, validate_config, save_config from xpra.codecs.codec_constants import PREFERED_ENCODING_ORDER from xpra.gtk_common.quit import gtk_main_quit_really from xpra.gtk_common.gtk_util import gtk_main, add_close_accel, scaled_image, pixbuf_new_from_file, color_parse, \ OptionMenu, choose_file, set_use_tray_workaround, window_defaults, imagebutton, \
# This file is part of Xpra. # Copyright (C) 2013-2015 Antoine Martin <*****@*****.**> # Copyright (C) 2008 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os from xpra.gtk_common.gobject_compat import import_glib, import_gobject glib = import_glib() try: glib.threads_init() except AttributeError: import_gobject().threads_init() from multiprocessing import Queue as MQueue, freeze_support freeze_support() from xpra.log import Logger log = Logger("proxy") from xpra.scripts.config import InitException from xpra.util import LOGIN_TIMEOUT, AUTHENTICATION_ERROR, SESSION_NOT_FOUND, DONE, repr_ellipsized from xpra.server.proxy.proxy_instance_process import ProxyInstanceProcess from xpra.server.server_core import ServerCore from xpra.server.control_command import ArgsControlCommand, ControlError from xpra.child_reaper import getChildReaper from xpra.scripts.config import make_defaults_struct from xpra.scripts.main import parse_display_name, connect_to from xpra.make_thread import make_thread
# This file is part of Xpra. # Copyright (C) 2013-2016 Antoine Martin <*****@*****.**> # Copyright (C) 2008 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os import sys from xpra.gtk_common.gobject_compat import import_glib, import_gobject glib = import_glib() try: glib.threads_init() except AttributeError: import_gobject().threads_init() from multiprocessing import Queue as MQueue, freeze_support freeze_support() from xpra.log import Logger log = Logger("proxy") authlog = Logger("proxy", "auth") from xpra.util import LOGIN_TIMEOUT, AUTHENTICATION_ERROR, PERMISSION_ERROR, SESSION_NOT_FOUND, SERVER_ERROR, repr_ellipsized, print_nested_dict, csv, typedict from xpra.os_util import get_username_for_uid, get_groups from xpra.server.proxy.proxy_instance_process import ProxyInstanceProcess from xpra.server.server_core import ServerCore from xpra.server.control_command import ArgsControlCommand, ControlError from xpra.child_reaper import getChildReaper from xpra.scripts.config import make_defaults_struct from xpra.scripts.main import parse_display_name, connect_to, start_server_subprocess