def _new_tube_cb(self, tube_id, initiator, tube_type, service, params, state): self._logger.debug('New Tube') if ((tube_type == telepathy.TUBE_TYPE_STREAM) and (service == SERVICE) and (not self._connected)): tubes_chan = self._shared_activity.telepathy_tubes_chan iface = tubes_chan[telepathy.CHANNEL_TYPE_TUBES] addr = iface.AcceptStreamTube( tube_id, telepathy.SOCKET_ADDRESS_TYPE_IPV4, telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0) port = int(addr[1]) # additional properties are available from params ## Start a VNC viewer pointed at the appropriate port. #self._vncviewer = subprocess.Popen(['/usr/bin/vncviewer', # 'localhost::%d' % port, # '-ViewOnly', # '-Shared']) try: import gtkvnc vncwidget = gtkvnc.Display() self.set_canvas(vncwidget) vncwidget.realize() # I don't know what this does vncwidget.open_host('localhost', str(port)) self._connected = True self.show_all() except ImportError: self._label.set_text( "gtk-vnc-python is not properly installed. You must install gtk-vnc-python and restart this activity." )
def __init__(self): gladefile = "demo-client.glade" windowname = "MainWindow" self.wTree = gtk.glade.XML(gladefile) dic = { "on_MainWindow_destroy": (gtk.main_quit), "on_MenuQuit_activate": (gtk.main_quit), "on_MenuFullScreen_activate": (self.toggle_fs) } self.wTree.signal_autoconnect(dic) self.Layout = self.wTree.get_widget("Layout") host = self.get_server() port = "5999" self.vnc = gtkvnc.Display() self.Layout.add(self.vnc) 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.vnc.connect("vnc-initialized", vnc_initialized, self.wTree.get_widget("MainWindow")) self.vnc.connect("vnc-disconnected", vnc_disconnected)
def __init__(self, console): Viewer.__init__(self, console) self.display = gtkvnc.Display() self.sockfd = None # Last noticed desktop resolution self.desktop_resolution = None # VNC viewer needs a bit of help grabbing keyboard in a friendly way self.need_keygrab = True
def __init__(self, widget, host, port, read_only=False, share=False): View.__init__(self, widget) try: self.display = _gtkvnc.Display() except: LOG.error("ERROR IN init gtkvnc") self.read_only = read_only self.share = share self.sockfd = None self.host = host self.port = port
def vnc_disconnected(src, vnc, window, self): print _("Disconnected") dialog = gtk.MessageDialog (window, gtk.MESSAGE_INFO, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.BUTTONS_OK, _("You have been disconnected")) dialog.run() dialog.destroy() self.vnc.destroy() self.vnc=gtkvnc.Display() window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
def new_vnc_client(self): # We add any configuration here v = gtkvnc.Display() v.set_pointer_grab(True) v.set_keyboard_grab(True) v.set_read_only(self.view_only) v.set_depth(self.depth) v.connect("vnc-connected", self.vnc_connected) v.connect("vnc-disconnected", self.vnc_connected) v.connect("vnc-auth-credential", self.vnc_auth_cred) v.connect("vnc-auth-failure", self.vnc_auth_fail) return v
def __init__(self, max_mouse_rate=None): # Ensure silent import succeeded. If not, fail loudly this time. import gtkvnc _ViewerWidget.__init__(self, max_mouse_rate) aspect = AspectBin() self.add(aspect) self._vnc = gtkvnc.Display() aspect.add(self._vnc) self._vnc.connect('vnc-connected', self._reemit, 'viewer-connect') self._vnc.connect('vnc-disconnected', self._reemit, 'viewer-disconnect') self._vnc.connect('vnc-desktop-resize', self._resize) self._vnc.connect('vnc-keyboard-grab', self._grab, 'keyboard', True) self._vnc.connect('vnc-keyboard-ungrab', self._grab, 'keyboard', False) self._vnc.connect('vnc-pointer-grab', self._grab, 'mouse', True) self._vnc.connect('vnc-pointer-ungrab', self._grab, 'mouse', False) self._connect_display_signals(self._vnc) self._vnc.set_pointer_grab(True) self._vnc.set_keyboard_grab(True) self._vnc.set_scaling(True)
def __init__(self): self.parse_options() #build GUI self.gladefile = "data/gtkvncviewer.glade" self.wTree = gtk.glade.XML(self.gladefile) self.dialog = self.wTree.get_widget("connectDialog") self.about = self.wTree.get_widget("aboutDialog") self.about.set_version(version) self.window = self.wTree.get_widget("window") self.window_label = self.wTree.get_widget("window_label") self.window_toolbar_note = self.wTree.get_widget("toolbar_note") self.window_toolbar = self.wTree.get_widget("toolbar") self.layout = self.wTree.get_widget("viewport1") self.scrolledwindow = self.wTree.get_widget("scrolledwindow1") self.fullscreenButton = self.wTree.get_widget("fullscreenButton") self.fullscreenButton.set_active(False) self.iconview = self.wTree.get_widget("iconview1") self.keysButton = self.wTree.get_widget("keysButton") self.keysMenu = self.wTree.get_widget("keysMenu") self.keysMenu.attach_to_widget(self.keysButton, None) self.vnc=gtkvnc.Display() self.model = gtk.ListStore (str,str,str,gtk.gdk.Pixbuf) self.iconview.set_model(self.model) self.iconview.set_text_column(0) self.iconview.set_pixbuf_column(3) self.helpMenu = self.wTree.get_widget("helpMenu") self.helpButton = self.wTree.get_widget("helpButton") self.helpMenu.attach_to_widget(self.helpButton, None) if (launchpad): LaunchpadIntegration.set_sourcepackagename("gtkvncviewer") LaunchpadIntegration.add_items(self.helpMenu,0,False,False) else: self.helpButton.set_sensitive(False) if (self.dialog): self.window.connect("destroy", gtk.main_quit) #Create our dictionay and connect it dic = { "on_quitButton_clicked" : gtk.main_quit, "on_aboutButton_clicked" : self.show_about_dialog, "on_aboutDialog_response" : self.handle_about_dialog_answer, "on_aboutDialog_delete_event" : self.hide_about_dialog, "on_connectButton_clicked" : self.vncconnect, "on_window_delete_event" : self.close_window, "on_disconnectButton_clicked" : self.disconnect, "on_addButton_clicked" : self.add_server, "on_iconview1_selection_changed" : self.selected, "on_iconview1_item_activated" : self.activated, "on_delButton_clicked" : self.delete_clicked, "on_screenshotButton_clicked" : self.screenshot, "on_helpButton_clicked" : self.helpMenuPop, "on_togglebutton1_toggled" : self.fullscreen, "on_toolbar_note_entered" : self.show_hide_toolbar, "on_window_motion_notify_event" : self.mouse_moved_in_window, "on_desktopIconButton_clicked" : self.icon_on_desktop, "on_CtrlAltDelmenuitem_activate": self.send_cad, "on_CtrlAltBackmenuitem_activate": self.send_cab, "on_CtrlEscmenuitem_activate": self.send_ce, "on_CtrlAltF1menuitem_activate": self.send_caf1, "on_CtrlAltF2menuitem_activate": self.send_caf2, "on_CtrlAltF3menuitem_activate": self.send_caf3, "on_CtrlAltF4menuitem_activate": self.send_caf4, "on_CtrlAltF5menuitem_activate": self.send_caf5, "on_CtrlAltF6menuitem_activate": self.send_caf6, "on_CtrlAltF7menuitem_activate": self.send_caf7, "on_CtrlAltF8menuitem_activate": self.send_caf8, "on_CtrlAltF9menuitem_activate": self.send_caf9, "on_CtrlAltF10menuitem_activate": self.send_caf10, "on_CtrlAltF11menuitem_activate": self.send_caf11, "on_CtrlAltF12menuitem_activate": self.send_caf12, "on_AltRlessitem_activate": self.send_arless, "on_AltRqitem_activate": self.send_arq, "on_AltRszligitem_activate": self.send_arszlig, "on_AltRplusitem_activate": self.send_arplus, "on_AltR7item_activate": self.send_ar7, "on_AltR8item_activate": self.send_ar8, "on_AltR9item_activate": self.send_ar9, "on_AltR0item_activate": self.send_ar0, "on_keysButton_clicked" : self.keysMenuPop} self.wTree.signal_autoconnect(dic) self.dialog.show() #read stored credentials GCONF_AUTH_KEY = "/apps/gtkvncviewer" keyring = gnomekeyring.get_default_keyring_sync() gconfclient = gconf.client_get_default() gconfclient.add_dir (GCONF_AUTH_KEY, gconf.CLIENT_PRELOAD_RECURSIVE) entries = gconfclient.all_entries(GCONF_AUTH_KEY) if len(entries) == 0: return #found nothing for i in range(len(entries)): server = entries[i].get_key() server = server.replace (GCONF_AUTH_KEY+"/", "") auth_token = entries[i].get_value().get_int() if auth_token > 0: try: secret = gnomekeyring.item_get_info_sync(keyring, auth_token).get_secret() except gnomekeyring.DeniedError: username = None password = None auth_token = 0 print _("gnome-keyring access denied") else: username, password = secret.split('\n') else: username = None password = None pixbuf = self.iconview.render_icon(gtk.STOCK_NETWORK, gtk.ICON_SIZE_BUTTON) self.model.append([server, username, password, pixbuf]) #if a server was specified at startup, connect to it if self.startup_options.server: res = self.find_server(self.startup_options.server) if (res): #found, connect iter = res[3] self.iconview.select_path(iter) wait() self.vncconnect(self.window) else: #not found, just fill the server name in the dialog server_textbox = self.wTree.get_widget("serverEntry") user_textbox = self.wTree.get_widget("usernameEntry") server_textbox.set_text(self.startup_options.server) user_textbox.grab_focus()
# if not found, place the screen at the center of the image print("[-] can't found the screen position in the skin") x = (width - SCREEN_WIDTH) / 2 y = (height - SCREEN_HEIGHT) / 2 return x, y if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('-o', '--host', default='127.0.0.1', help='VNC host') parser.add_argument('-p', '--port', default='5902', help='VNC port') parser.add_argument('-s', '--skin', default=None, help='PNG image') args = parser.parse_args() window = gtk.Window(gtk.WINDOW_TOPLEVEL) vnc = gtkvnc.Display() if args.skin: image = Image.open(args.skin) IMG_PATH = args.skin IMG_WIDTH, IMG_HEIGHT = image.size x, y = find_screen_position(image) image.close() window.set_default_size(IMG_WIDTH, IMG_HEIGHT) fix = gtk.Fixed() fix.put(vnc, x, y) box = gtk.EventBox() window.add(box) box.add(fix) else: