示例#1
0
 def show(self):
     log("show()")
     if not self.window:
         self.setup_window()
     force_focus()
     self.window.show_all()
     self.window.present()
示例#2
0
def show_confirm_dialog(argv):
    from xpra.platform.gui import ready as gui_ready
    from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable
    from xpra.platform.gui import init as gui_init

    gui_init()
    gtk_main_quit_on_fatal_exceptions_enable()

    log("show_confirm_dialog(%s)", argv)
    def arg(n):
        if len(argv)<=n:
            return ""
        return argv[n].replace("\\n\\r", "\\n").replace("\\n", "\n")
    title = arg(0) or "Confirm Key"
    prompt = arg(1)
    info = arg(2)
    icon = arg(3)
    buttons = []
    n = 4
    while len(argv)>(n+1):
        label = arg(n)
        try:
            code = int(arg(n+1))
        except ValueError as e:
            log.error("Error: confirm dialog cannot parse code '%s': %s", arg(n+1), e)
            return 1
        buttons.append((label, code))
        n += 2
    app = ConfirmDialogWindow(title, prompt, info, icon, buttons)
    register_os_signals(app.quit)
    gui_ready()
    force_focus()
    app.show()
    return app.run()
示例#3
0
 def run(self):
     self.show_all()
     force_focus()
     self.present()
     if Gtk.main_level() == 0:
         Gtk.main()
     return self.exit_code or 0
示例#4
0
 def run(self):
     from xpra.make_thread import start_thread
     start_thread(self.read_stdin, "read-stdin", True)
     self.show_all()
     force_focus()
     self.present()
     self.timeout_timer = GLib.timeout_add(TIMEOUT*1000, self.timeout)
     self.pulse_timer = GLib.timeout_add(100, self.pulse)
     Gtk.main()
     return self.exit_code or 0
示例#5
0
    def run(self):
        from xpra.make_thread import start_thread
        start_thread(self.read_stdin, "read-stdin", True)
        self.show_all()
        force_focus()
        self.present()
        self.timeout_timer = GLib.timeout_add(TIMEOUT * 1000, self.timeout)
        self.pulse_timer = GLib.timeout_add(100, self.pulse)
        scrash = envint("XPRA_SPLASH_CRASH", -1)
        if scrash >= 0:

            def crash():
                import ctypes  #pylint: disable=import-outside-toplevel
                ctypes.string_at(0)

            GLib.timeout_add(scrash, crash)
        Gtk.main()
        return self.exit_code or 0
示例#6
0
 def show_with_focus():
     force_focus()
     w.show_all()
     w.present()
示例#7
0
 def show_with_focus(self):
     force_focus()
     self.window.show_all()
     self.window.present()
示例#8
0
文件: bell.py 项目: qmutz/xpra
 def show_with_focus(self):
     force_focus()
     self.show_all()
     super().present()
示例#9
0
 def show():
     force_focus()
     self.present()
示例#10
0
 def show():
     force_focus()
     self.present()
     self.password_input.grab_focus()
示例#11
0
    def setup_window(self):
        self.window = gtk.Window()
        window_defaults(self.window)
        self.window.connect("delete-event", self.close)
        self.window.set_default_size(400, 300)
        self.window.set_title("Xpra Bug Report")

        icon_pixbuf = self.get_icon("bugs.png")
        if icon_pixbuf:
            self.window.set_icon(icon_pixbuf)
        self.window.set_position(WIN_POS_CENTER)

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

        # Title
        hbox = gtk.HBox(False, 0)
        icon_pixbuf = self.get_icon("xpra.png")
        if icon_pixbuf and self.show_about:
            from xpra.gtk_common.about import about
            logo_button = gtk.Button("")
            settings = logo_button.get_settings()
            settings.set_property('gtk-button-images', True)
            logo_button.connect("clicked", about)
            logo_button.set_tooltip_text("About")
            image = gtk.Image()
            image.set_from_pixbuf(icon_pixbuf)
            logo_button.set_image(image)
            hbox.pack_start(logo_button, expand=False, fill=False)

        label = gtk.Label("Xpra Bug Report Tool")
        label.modify_font(pango.FontDescription("sans 14"))
        hbox.pack_start(label, expand=True, fill=True)
        vbox.pack_start(hbox)

        #the box containing all the input:
        ibox = gtk.VBox(False, 0)
        ibox.set_spacing(3)
        vbox.pack_start(ibox)

        # Description
        al = gtk.Alignment(xalign=0, yalign=0.5, xscale=0.0, yscale=0)
        al.add(gtk.Label("Please describe the problem:"))
        ibox.pack_start(al)
        #self.description = gtk.Entry(max=128)
        #self.description.set_width_chars(40)
        self.description = gtk.TextView()
        self.description.set_accepts_tab(True)
        self.description.set_justification(JUSTIFY_LEFT)
        self.description.set_border_width(2)
        self.description.set_size_request(300, 80)
        #self.description.modify_bg(STATE_NORMAL, gdk.Color(red=32768, green=32768, blue=32768))
        ibox.pack_start(self.description, expand=False, fill=False)

        # Toggles:
        al = gtk.Alignment(xalign=0, yalign=0.5, xscale=0.0, yscale=0)
        al.add(gtk.Label("Include:"))
        ibox.pack_start(al)
        #generic toggles:
        from xpra.gtk_common.keymap import get_gtk_keymap
        from xpra.codecs.loader import codec_versions, load_codecs
        load_codecs()
        try:
            from xpra.sound.wrapper import query_sound

            def get_sound_info():
                return query_sound()
        except ImportError:
            get_sound_info = None

        def get_gl_info():
            if self.opengl_info:
                return self.opengl_info
            try:
                from xpra.client.gl.gtk_base.gtkgl_check import check_support
                return check_support(force_enable=True)
            except Exception as e:
                return {"error": str(e)}

        from xpra.net.net_util import get_info as get_net_info
        from xpra.platform.paths import get_info as get_path_info
        from xpra.platform.gui import get_info as get_gui_info
        from xpra.version_util import get_version_info, get_platform_info, get_host_info

        def get_sys_info():
            from xpra.platform.info import get_user_info
            from xpra.scripts.config import read_xpra_defaults
            return {
                "argv": sys.argv,
                "path": sys.path,
                "exec_prefix": sys.exec_prefix,
                "executable": sys.executable,
                "version": get_version_info(),
                "platform": get_platform_info(),
                "host": get_host_info(),
                "paths": get_path_info(),
                "gtk": get_gtk_version_info(),
                "gui": get_gui_info(),
                "display": get_display_info(),
                "user": get_user_info(),
                "env": os.environ,
                "config": read_xpra_defaults(),
            }

        get_screenshot, take_screenshot_fn = None, None
        #screenshot: may have OS-specific code
        try:
            from xpra.platform.gui import take_screenshot
            take_screenshot_fn = take_screenshot
        except ImportError:
            log("failed to load platfrom specific screenshot code",
                exc_info=True)
        if not take_screenshot_fn:
            #try with Pillow:
            try:
                from PIL import ImageGrab  #@UnresolvedImport
                from io import BytesIO

                def pillow_imagegrab_screenshot():
                    img = ImageGrab.grab()
                    out = BytesIO()
                    img.save(out, format="PNG")
                    v = out.getvalue()
                    out.close()
                    return (img.width, img.height, "png", img.width * 3, v)

                take_screenshot_fn = pillow_imagegrab_screenshot
            except Exception as e:
                log("cannot use Pillow's ImageGrab: %s", e)
        if not take_screenshot_fn:
            #default: gtk screen capture
            try:
                from xpra.server.shadow.gtk_root_window_model import GTKImageCapture
                rwm = GTKImageCapture(get_default_root_window())
                take_screenshot_fn = rwm.take_screenshot
            except Exception:
                log.warn("Warning: failed to load gtk screenshot code",
                         exc_info=True)
        log("take_screenshot_fn=%s", take_screenshot_fn)
        if take_screenshot_fn:

            def _get_screenshot():
                #take_screenshot() returns: w, h, "png", rowstride, data
                return take_screenshot_fn()[4]

            get_screenshot = _get_screenshot
        self.toggles = (
            ("system", "txt", "System", get_sys_info,
             "Xpra version, platform and host information"),
            ("network", "txt", "Network", get_net_info,
             "Compression, packet encoding and encryption"),
            ("encoding", "txt", "Encodings", codec_versions,
             "Picture encodings supported"),
            ("opengl", "txt", "OpenGL", get_gl_info,
             "OpenGL driver and features"),
            ("sound", "txt", "Sound", get_sound_info,
             "Sound codecs and GStreamer version information"),
            ("keyboard", "txt", "Keyboard Mapping", get_gtk_keymap,
             "Keyboard layout and key mapping"),
            ("xpra-info", "txt", "Server Info", self.get_server_info,
             "Full server information from 'xpra info'"),
            ("screenshot", "png", "Screenshot", get_screenshot, ""),
        )
        for name, _, title, value_cb, tooltip in self.toggles:
            cb = gtk.CheckButton(title +
                                 [" (not available)", ""][bool(value_cb)])
            cb.set_active(self.includes.get(name, True))
            cb.set_sensitive(bool(value_cb))
            cb.set_tooltip_text(tooltip)
            ibox.pack_start(cb)
            setattr(self, name, cb)

        # Buttons:
        hbox = gtk.HBox(False, 20)
        vbox.pack_start(hbox)

        def btn(label, tooltip, callback, icon_name=None):
            btn = gtk.Button(label)
            btn.set_tooltip_text(tooltip)
            btn.connect("clicked", callback)
            if icon_name:
                icon = self.get_icon(icon_name)
                if icon:
                    btn.set_image(scaled_image(icon, 24))
            hbox.pack_start(btn)
            return btn

        force_focus()
        btn("Copy to clipboard", "Copy all data to clipboard",
            self.copy_clicked, "clipboard.png")
        btn("Save", "Save Bug Report", self.save_clicked, "download.png")
        btn("Cancel", "", self.close, "quit.png")

        def accel_close(*_args):
            self.close()

        add_close_accel(self.window, accel_close)
        vbox.show_all()
        self.window.vbox = vbox
        self.window.add(vbox)
示例#12
0
 def show():
     force_focus()
     self.window.show()
     self.window.present()
示例#13
0
 def show_with_focus():
     from xpra.platform.gui import force_focus
     force_focus()
     w.show_all()
     w.present()