コード例 #1
0
ファイル: viewer.py プロジェクト: juergh/jvncviewer
    def connect(self):
        logging.debug("Connecting to %s:%s", self.host, self.port)
        self.reconnect = True

        # Remove the previous VNC display from the window layout (in case of a
        # reconnect)
        self.vncbox.remove(self.vncdisplay)

        # Create the VNC display and add it to the window layout
        self.vncdisplay = GtkVnc.Display()
        self.vncbox.add(self.vncdisplay)
        self.vncdisplay.show()

        if self.password:
            self.vncdisplay.set_credential(GtkVnc.DisplayCredential.CLIENTNAME,
                                           "jvncviewer")
            self.vncdisplay.set_credential(GtkVnc.DisplayCredential.PASSWORD,
                                           self.password)

        self.vncdisplay.realize()

        self.vncdisplay.connect("size-allocate", self._size_allocate)
        self.vncdisplay.connect("vnc-auth-credential", self._auth_credential)
        self.vncdisplay.connect("vnc-auth-failure", self._auth_failure)
        self.vncdisplay.connect("vnc-connected", self._connected)
        self.vncdisplay.connect("vnc-disconnected", self._disconnected)
        self.vncdisplay.connect("vnc-error", self._error)
        self.vncdisplay.connect("vnc-initialized", self._initialized)

        self.vncdisplay.open_host(self.host, self.port)
コード例 #2
0
ファイル: main.py プロジェクト: okok3388/vncdesk
def main():
    number, arguments = read_cmd_line()

    ensure_display()

    vnc_server.start(number, arguments)

    window = Gtk.Window()
    vnc = GtkVnc.Display()

    window.add(vnc)
    window.connect("destroy", quit_all)
    window.set_title(settings['window']['title'])
    window.set_wmclass(settings['window']['name'], settings['window']['class'])

    vnc.realize()
    vnc.set_scaling(True)
    vnc.set_pointer_local(False)

    if gtk_vnc_allows_configuring_smoothing(vnc):
        vnc.set_smoothing(settings['window']['smoothing'])

    vnc.set_credential(GtkVnc.DisplayCredential.PASSWORD, vnc_server.password)

    vnc.open_host("localhost", str(vnc_server.port))

    vnc.connect("vnc-initialized", vnc_initialized, window)
    vnc.connect("vnc-disconnected", vnc_disconnected)

    Gtk.main()
コード例 #3
0
ファイル: viewer.py プロジェクト: juergh/jvncviewer
    def __init__(self, host, password, bmc=None):
        port = "5900"
        if ":" in host:
            host, port = host.split(':')

        self.host = host
        self.port = port
        self.password = password
        self.bmc = bmc

        self.reconnect = True
        self.connected = False
        self.power = None

        # Status icons
        self.connection_status = StatusIcon()
        self.connection_status.set_status(STATUS_ERROR)
        if bmc:
            self.power_status = StatusIcon()
            self.power_status.set_status(STATUS_UNKNOWN)

        # Menubar
        menubar = self._menubar(bmc)

        # VNC display
        self.vncdisplay = GtkVnc.Display()
        self.vncbox = Gtk.VBox()
        self.vncbox.set_size_request(720, 400)
        self.vncbox.add(self.vncdisplay)

        # Status bar
        statusbar = Gtk.HBox()
        statusbar.pack_start(Gtk.Label("Connection:"), False, False, 10)
        statusbar.pack_start(self.connection_status, False, False, 10)
        statusbar.pack_start(Gtk.Label("Power:"), False, False, 10)
        statusbar.pack_start(self.power_status, False, False, 10)

        # Layout
        layout = Gtk.VBox()
        layout.pack_start(menubar, False, False, 0)
        layout.pack_start(self.vncbox, True, True, 0)
        layout.pack_end(statusbar, False, False, 0)

        # Window
        self.window = Gtk.Window(title="jvncviewer - %s" % host)
        self.window.add(layout)
        self.window.connect("destroy", self.quit)
        self.window.show_all()
コード例 #4
0
    def _init_widget(self):
        self._display = GtkVnc.Display()

        # Make sure viewer doesn't force resize itself
        self._display.set_force_size(False)
        self._display.set_pointer_grab(True)

        self.emit("add-display-widget", self._display)
        self._display.realize()

        self._display.connect("vnc-pointer-grab",
            self._make_signal_proxy("pointer-grab"))
        self._display.connect("vnc-pointer-ungrab",
            self._make_signal_proxy("pointer-ungrab"))

        self._display.connect("vnc-auth-credential", self._auth_credential)
        self._display.connect("vnc-auth-failure", self._auth_failure_cb)
        self._display.connect("vnc-initialized", self._connected_cb)
        self._display.connect("vnc-disconnected", self._disconnected_cb)
        self._display.connect("vnc-desktop-resize", self._desktop_resize)

        self._display.show()
コード例 #5
0
    def __init__(self):
        css = b""".background { background-color: #000; }
                  .foreground { color: #fff; }"""
        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(css)
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        gladefile = "demo-client.glade"
        windowname = "MainWindow"
        self.builder = Gtk.Builder()
        self.builder.add_from_file(gladefile)
        dic = {
            "onDestroy": (self.quit),
            "onFullscreen": (self.fullscreen),
            "onAspectRatio": (self.aspect_ratio),
            "onWindowState": (self.window_event)
        }
        self.builder.connect_signals(dic)
        self.win = self.builder.get_object("MainWindow")
        self.frame = self.builder.get_object("Frame")
        host = self.get_server()
        port = "5999"
        self.ratio = 1.3
        self.maintain_aspect = True
        self.vnc = GtkVnc.Display()
        self.vnc.realize()
        self.vnc.set_pointer_grab(False)
        self.vnc.set_keyboard_grab(False)
        self.vnc.set_lossy_encoding(True)
        self.vnc.set_scaling(True)
        self.vnc.set_read_only(True)
        self.vnc.set_force_size(False)
        self.vnc.open_host(host, port)
        self.vnc.connect("vnc-connected", vnc_connected, self)
        self.vnc.connect("vnc-initialized", vnc_initialized, self)
        self.vnc.connect("vnc-disconnected", vnc_disconnected)
コード例 #6
0
ファイル: vnc_screenshot.py プロジェクト: wldmsjieun/badKarma
    with open("/tmp/badkarma-screenshot" + sys.argv[1] + "-" + sys.argv[2],
              "rb") as image:
        print(base64.b64encode(image.read()).decode())

    # quit
    Gtk.main_quit()
    quit()


def vnc_connected(dpy):

    # another workaround in order to get rid of black screenshots
    thread = threading.Thread(target=screenshot, args=[dpy])
    thread.start()


if __name__ == "__main__":

    dpy = GtkVnc.Display()
    dpy.open_host(sys.argv[1], sys.argv[2])

    dpy.connect("vnc-initialized", vnc_connected)

    # stupid workaround needed to suppress gdk warnings
    win = Gtk.Window()
    win.show()
    win.hide()
    win.add(dpy)

    Gtk.main()