Пример #1
0
def do_main(opts):
    from xpra.platform import program_context
    from xpra.log import enable_color
    with program_context("Xpra-Session-Browser", "Xpra Session Browser"):
        enable_color()
        gui = SessionsGUI(opts)
        gtk_main()
        log.info("do_main() gui.exit_code=%i", gui.exit_code)
        return gui.exit_code
Пример #2
0
def exception_dialog(title):
    md = gtk.MessageDialog(None, DIALOG_DESTROY_WITH_PARENT, MESSAGE_INFO,  BUTTONS_CLOSE, title)
    md.format_secondary_text(traceback.format_exc())
    md.show_all()
    def close_dialog(*_args):
        md.destroy()
        gtk.main_quit()
    md.connect("response", close_dialog)
    md.connect("close", close_dialog)
    gtk_main()
Пример #3
0
def exception_dialog(title):
    md = gtk.MessageDialog(None, DIALOG_DESTROY_WITH_PARENT, MESSAGE_INFO,  BUTTONS_CLOSE, title)
    md.format_secondary_text(traceback.format_exc())
    md.show_all()
    def close_dialog(*args):
        md.destroy()
        gtk.main_quit()
    md.connect("response", close_dialog)
    md.connect("close", close_dialog)
    gtk_main()
Пример #4
0
def do_main(opts):
    from xpra.platform import program_context, command_error
    from xpra.log import enable_color
    with program_context("Xpra-Session-Browser", "Xpra Session Browser"):
        enable_color()
        if not get_listener_class():
            command_error("no mDNS support in this build")
            return 1
        gui = mdns_sessions(opts)
        gtk_main()
        return gui.exit_code
Пример #5
0
def do_main(opts):
    from xpra.platform import program_context
    from xpra.log import enable_color
    with program_context("Xpra-Session-Browser", "Xpra Session Browser"):
        enable_color()
        gui = SessionsGUI(opts)
        import signal
        signal.signal(signal.SIGINT, gui.app_signal)
        signal.signal(signal.SIGTERM, gui.app_signal)
        gtk_main()
        log("do_main() gui.exit_code=%i", gui.exit_code)
        return gui.exit_code
Пример #6
0
def main():
    from xpra.platform import program_context
    with program_context("Session Access"):
        from xpra.platform.gui import init as gui_init
        gui_init()
        if len(sys.argv)<2:
            sys.stderr.write("usage: %s 'message' [timeout-in-seconds]\n" % sys.argv[0])
            sys.exit(4)
        info = sys.argv[1]
        if len(sys.argv)>=3:
            timeout = int(sys.argv[2])
        else:
            timeout = 600
        w = AuthDialog(info=info, timeout=timeout)
        gtk_main()
        return w.exit_code
Пример #7
0
 def do_run(self):
     if UI_THREAD_WATCHER:
         from xpra.platform.ui_thread_watcher import get_UI_watcher
         self.ui_watcher = get_UI_watcher(glib.timeout_add,
                                          glib.source_remove)
         self.ui_watcher.start()
     if server_features.windows:
         display = display_get_default()
         i = 0
         while i < display.get_n_screens():
             screen = display.get_screen(i)
             screen.connect("size-changed", self._screen_size_changed)
             screen.connect("monitors-changed", self._monitors_changed)
             i += 1
     gtk_main_quit_on_fatal_exceptions_enable()
     log("do_run() calling %s", gtk_main)
     gtk_main()
     log("do_run() end of gtk.main()")
Пример #8
0
def do_main(opts):
    from xpra.platform import program_context, command_error
    from xpra.log import enable_color
    from xpra.platform.gui import init, set_default_icon
    with program_context("Xpra-Session-Browser", "Xpra Session Browser"):
        enable_color()

        set_default_icon("bugs.png")
        init()

        if not get_listener_class():
            command_error("no mDNS support in this build")
            return 1
        mdns = opts.mdns
        if mdns:
            gui = mdns_sessions(opts)
        else:
            gui = SessionsGUI(opts)
        gtk_main()
        return gui.exit_code
Пример #9
0
def main():
    from xpra.platform import program_context
    from xpra.log import enable_color
    from xpra.platform.gui import init, ready
    from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable
    gtk_main_quit_on_fatal_exceptions_enable()
    with program_context("Xpra-GUI", "Xpra GUI"):
        enable_color()
        init()
        gui = GUI()
        register_os_signals(gui.app_signal)
        ready()
        if OSX:
            from xpra.platform.darwin.gui import wait_for_open_handlers
            wait_for_open_handlers(gui.show, gui.open_file, gui.open_url)
        else:
            gui.show()
        gtk_main()
        log("do_main() gui.exit_code=%i", gui.exit_code)
        return 0
Пример #10
0
 def run(self):
     gtk_main()
Пример #11
0
 def gtk_main(self):
     gtk_main()
Пример #12
0
 def run(self):
     log("run()")
     gtk_main()
     log("run() gtk_main done")
     return self.exit_code
Пример #13
0
 def do_run(self):
     gtk_main_quit_on_fatal_exceptions_enable()
     log("do_run() calling %s", gtk_main)
     gtk_main()
     log("do_run() end of gtk.main()")
Пример #14
0
def main():
    window = gtk.Window(WINDOW_TOPLEVEL)
    window.set_size_request(600, 200)
    window.connect("delete_event", gtk.main_quit)
    window.add_events(WINDOW_EVENT_MASK)
    vbox = gtk.VBox(False, 0)
    hbox = gtk.HBox(False, 0)
    vbox.pack_start(hbox, expand=False, fill=False, padding=10)

    def keyevent_info(event):
        keyval = event.keyval
        keycode = event.hardware_keycode
        keyname = gdk.keyval_name(keyval)
        return "%i:%s" % (keycode, keyname)

    def key_pressed(_window, event):
        event_label.set_text("key_pressed: %s" % keyevent_info(event))

    window.connect("key-press-event", key_pressed)

    def key_released(_window, event):
        event_label.set_text("key_released: %s" % keyevent_info(event))

    window.connect("key-press-event", key_pressed)
    window.connect("key-release-event", key_pressed)

    def motion_notify(_window, event):
        event_label.set_text("motion: %i,%i" % (event.x_root, event.y_root))

    window.connect("motion-notify-event", motion_notify)

    grab_pointer_btn = gtk.Button("grab pointer")

    def grab_pointer(*args):
        action_label.set_text("grab_pointer%s" % str(args))

        def do_grab():
            event_mask = BUTTON_RELEASE_MASK
            v = gdk.pointer_grab(window.get_window(), False, event_mask, None,
                                 None, 0)
            #gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.KEY_PRESS_MASK \
            #gdk.KEY_RELEASE_MASK | gdk.ENTER_NOTIFY_MASK)
            # | gdk.ENTER_NOTIFY_MASK
            #gdk.ALL_EVENTS_MASK
            action_label.set_text("pointer_grab() returned %s" %
                                  GRAB_STATUS_STRING.get(v, v))
            glib.timeout_add(10 * 1000, gdk.pointer_ungrab, 0)

        print("will grab in 5 seconds!")
        glib.timeout_add(5 * 1000, do_grab)

    grab_pointer_btn.connect('clicked', grab_pointer)
    hbox.pack_start(grab_pointer_btn, expand=False, fill=False, padding=10)

    ungrab_pointer_btn = gtk.Button("ungrab pointer")

    def ungrab_pointer(*_args):
        v = gdk.pointer_ungrab(0)
        action_label.set_text("pointer_ungrab(0)=%s" %
                              GRAB_STATUS_STRING.get(v, v))
        window.unmaximize()

    ungrab_pointer_btn.connect('clicked', ungrab_pointer)
    hbox.pack_start(ungrab_pointer_btn, expand=False, fill=False, padding=10)

    grab_keyboard_btn = gtk.Button("grab keyboard")

    def grab_keyboard(*_args):
        v = gdk.keyboard_grab(window.get_window(), True, 0)
        action_label.set_text("keyboard_grab(..)=%s" %
                              GRAB_STATUS_STRING.get(v, v))
        glib.timeout_add(10 * 1000, gdk.keyboard_ungrab, 0)

    grab_keyboard_btn.connect('clicked', grab_keyboard)
    hbox.pack_start(grab_keyboard_btn, expand=False, fill=False, padding=10)

    ungrab_keyboard_btn = gtk.Button("ungrab keyboard")

    def ungrab_keyboard(*_args):
        v = gdk.keyboard_ungrab(0)
        action_label.set_text("keyboard_ungrab(0)=%s" %
                              GRAB_STATUS_STRING.get(v, v))

    ungrab_keyboard_btn.connect('clicked', ungrab_keyboard)
    hbox.pack_start(ungrab_keyboard_btn, expand=False, fill=False, padding=10)

    vbox.add(gtk.Label("Last action:"))
    action_label = gtk.Label("")
    vbox.add(action_label)

    vbox.add(gtk.Label("Last event:"))
    event_label = gtk.Label("")
    vbox.add(event_label)

    window.add(vbox)
    window.show_all()
    gtk_main()
    return 0
Пример #15
0
 def run(self):
     log("run()")
     gtk_main()
     log("run() gtk_main done")
Пример #16
0
 def do_run(self):
     gtk_main_quit_on_fatal_exceptions_enable()
     log("do_run() calling %s", gtk_main)
     gtk_main()
     log("do_run() end of gtk.main()")
Пример #17
0
 def run(self):
     log("run()")
     gtk_main()
     log("run() gtk_main done")
Пример #18
0
    def acquire(self, when):
        old_owner = self._owner()
        if when is self.IF_UNOWNED and old_owner != XNone:
            raise AlreadyOwned

        if is_gtk3():
            set_clipboard_data(self.clipboard, "VERSION")
        else:
            self.clipboard.set_with_data([("VERSION", 0, 0)],
	                                     self._get,
	                                     self._clear,
	                                     None)

        # Having acquired the selection, we have to announce our existence
        # (ICCCM 2.8, still).  The details here probably don't matter too
        # much; I've never heard of an app that cares about these messages,
        # and metacity actually gets the format wrong in several ways (no
        # MANAGER or owner_window atoms).  But might as well get it as right
        # as possible.

        # To announce our existence, we need:
        #   -- the timestamp we arrived at
        #   -- the manager selection atom
        #   -- the window that registered the selection
        # Of course, because Gtk is doing so much magic for us, we have to do
        # some weird tricks to get at these.

        # Ask ourselves when we acquired the selection:
        contents = wait_for_contents(self.clipboard, "TIMESTAMP")
        ts_data = selectiondata_get_data(contents)

        #data is a timestamp, X11 datatype is Time which is CARD32,
        #(which is 64 bits on 64-bit systems!)
        Lsize = calcsize("@L")
        if len(ts_data)==Lsize:
            ts_num = unpack("@L", ts_data[:Lsize])[0]
        else:
            ts_num = 0      #CurrentTime
            log.warn("invalid data for 'TIMESTAMP': %s", ([hex(ord(x)) for x in ts_data]))
        # Calculate the X atom for this selection:
        selection_xatom = get_xatom(self.atom)
        # Ask X what window we used:
        self._xwindow = X11WindowBindings().XGetSelectionOwner(self.atom)

        root = self.clipboard.get_display().get_default_screen().get_root_window()
        xid = get_xwindow(root)
        X11WindowBindings().sendClientMessage(xid, xid, False, StructureNotifyMask,
                          "MANAGER",
                          ts_num, selection_xatom, self._xwindow)

        if old_owner != XNone and when is self.FORCE:
            # Block in a recursive mainloop until the previous owner has
            # cleared out.
            try:
                with xsync:
                    window = get_pywindow(self.clipboard, old_owner)
                    window.set_events(window.get_events() | STRUCTURE_MASK)
                log("got window")
            except XError:
                log("Previous owner is already gone, not blocking")
            else:
                log("Waiting for previous owner to exit...")
                add_event_receiver(window, self)
                gtk_main()
                log("...they did.")
        window = get_pywindow(self.clipboard, self._xwindow)
        window.set_title("Xpra-ManagerSelection")
        if is_gtk3():
            #we can't use set_with_data(..),
            #so we have to listen for owner-change:
            self.clipboard.connect("owner-change", self._owner_change)
Пример #19
0
 def gtk_main(self):
     gtk_main()
Пример #20
0
 def run(self):
     gtk_main()