def create_window(self): self.window = gtk.Window() self.window.connect("destroy", self.destroy) self.window.set_default_size(400, 300) self.window.set_border_width(20) self.window.set_title("Xpra Launcher") self.window.modify_bg(STATE_NORMAL, gdk.Color(red=65535, green=65535, blue=65535)) icon_pixbuf = self.get_icon("xpra.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) if icon_pixbuf: 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) icon_pixbuf = self.get_icon("bugs.png") self.bug_tool = None if icon_pixbuf: bug_button = gtk.Button("") settings = bug_button.get_settings() settings.set_property('gtk-button-images', True) def bug(*args): if self.bug_tool == None: from xpra.client.gtk_base.bug_report import BugReport self.bug_tool = BugReport() self.bug_tool.init(show_about=False) self.bug_tool.show() bug_button.connect("clicked", bug) bug_button.set_tooltip_text("Bug Report") image = gtk.Image() image.set_from_pixbuf(icon_pixbuf) bug_button.set_image(image) hbox.pack_start(bug_button, expand=False, fill=False) label = gtk.Label("Connect to xpra server") label.modify_font(pango.FontDescription("sans 14")) hbox.pack_start(label, expand=True, fill=True) vbox.pack_start(hbox) # Mode: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Mode: ")) self.mode_combo = gtk.combo_box_new_text() #self.mode_combo.get_model().clear() self.mode_combo.append_text("TCP") if "AES" in ENCRYPTION_CIPHERS: self.mode_combo.append_text("TCP + AES") self.mode_combo.append_text("SSH") self.mode_combo.connect("changed", self.mode_changed) hbox.pack_start(self.mode_combo) vbox.pack_start(hbox) self.encoding_combo = None if not PYTHON3: #not implemented for gtk3, where we can't use set_menu()... # Encoding: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Encoding: ")) self.encoding_combo = OptionMenu() def get_current_encoding(): return self.config.encoding def set_new_encoding(e): self.config.encoding = e encodings = [ x for x in PREFERED_ENCODING_ORDER if x in self.client.get_encodings() ] server_encodings = encodings es = make_encodingsmenu(get_current_encoding, set_new_encoding, encodings, server_encodings) self.encoding_combo.set_menu(es) set_history_from_active(self.encoding_combo) hbox.pack_start(self.encoding_combo) vbox.pack_start(hbox) self.encoding_combo.connect("changed", self.encoding_changed) # Quality hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.quality_label = gtk.Label("Quality: ") hbox.pack_start(self.quality_label) self.quality_combo = OptionMenu() def set_min_quality(q): self.config.min_quality = q def set_quality(q): self.config.quality = q def get_min_quality(): return self.config.min_quality def get_quality(): return self.config.quality sq = make_min_auto_menu("Quality", MIN_QUALITY_OPTIONS, QUALITY_OPTIONS, get_min_quality, get_quality, set_min_quality, set_quality) self.quality_combo.set_menu(sq) set_history_from_active(self.quality_combo) hbox.pack_start(self.quality_combo) vbox.pack_start(hbox) # Speed hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.speed_label = gtk.Label("Speed: ") hbox.pack_start(self.speed_label) self.speed_combo = OptionMenu() def set_min_speed(s): self.config.min_speed = s def set_speed(s): self.config.speed = s def get_min_speed(): return self.config.min_speed def get_speed(): return self.config.speed ss = make_min_auto_menu("Speed", MIN_SPEED_OPTIONS, SPEED_OPTIONS, get_min_speed, get_speed, set_min_speed, set_speed) self.speed_combo.set_menu(ss) set_history_from_active(self.speed_combo) hbox.pack_start(self.speed_combo) vbox.pack_start(hbox) # Username@Host:Port hbox = gtk.HBox(False, 0) hbox.set_spacing(5) self.username_entry = gtk.Entry() self.username_entry.set_max_length(128) self.username_entry.set_width_chars(16) self.username_entry.connect("changed", self.validate) self.username_entry.set_tooltip_text("SSH username") self.username_label = gtk.Label("@") self.host_entry = gtk.Entry() self.host_entry.set_max_length(128) self.host_entry.set_width_chars(24) self.host_entry.connect("changed", self.validate) self.host_entry.set_tooltip_text("hostname") self.ssh_port_entry = gtk.Entry() self.ssh_port_entry.set_max_length(5) self.ssh_port_entry.set_width_chars(5) self.ssh_port_entry.connect("changed", self.validate) self.ssh_port_entry.set_tooltip_text("SSH port") self.port_entry = gtk.Entry() self.port_entry.set_max_length(5) self.port_entry.set_width_chars(5) self.port_entry.connect("changed", self.validate) self.port_entry.set_tooltip_text("port/display") hbox.pack_start(self.username_entry) hbox.pack_start(self.username_label) hbox.pack_start(self.host_entry) hbox.pack_start(self.ssh_port_entry) hbox.pack_start(gtk.Label(":")) hbox.pack_start(self.port_entry) vbox.pack_start(hbox) # Password hbox = gtk.HBox(False, 0) hbox.set_spacing(20) self.password_entry = gtk.Entry() self.password_entry.set_max_length(128) self.password_entry.set_width_chars(30) self.password_entry.set_text("") self.password_entry.set_visibility(False) self.password_entry.connect("changed", self.password_ok) self.password_entry.connect("changed", self.validate) self.password_label = gtk.Label("Password: "******"Save") self.save_btn.set_tooltip_text("Save settings to a session file") self.save_btn.connect("clicked", self.save_clicked) hbox.pack_start(self.save_btn) #Load: self.load_btn = gtk.Button("Load") self.load_btn.set_tooltip_text("Load settings from a session file") self.load_btn.connect("clicked", self.load_clicked) hbox.pack_start(self.load_btn) # Connect button: self.button = gtk.Button("Connect") self.button.connect("clicked", self.connect_clicked) connect_icon = self.get_icon("retry.png") if connect_icon: self.button.set_image(scaled_image(connect_icon, 24)) hbox.pack_start(self.button) def accel_close(*args): gtk.main_quit() add_close_accel(self.window, accel_close) vbox.show_all() self.window.vbox = vbox self.window.add(vbox)
def create_window(self): self.window = gtk.Window() self.window.connect("destroy", self.destroy) self.window.set_default_size(400, 260) self.window.set_border_width(20) self.window.set_title("Xpra Launcher") self.window.modify_bg(STATE_NORMAL, gdk.Color(red=65535, green=65535, blue=65535)) self.window.set_position(WIN_POS_CENTER) vbox = gtk.VBox(False, 0) vbox.set_spacing(15) #top row: hbox = gtk.HBox(False, 0) # About dialog (and window icon): icon_pixbuf = self.get_icon("xpra.png") if icon_pixbuf: self.window.set_icon(icon_pixbuf) logo_button = self.image_button("", "About", icon_pixbuf, about) hbox.pack_start(logo_button, expand=False, fill=False) # Bug report tool link: icon_pixbuf = self.get_icon("bugs.png") self.bug_tool = None if icon_pixbuf: def bug(*_args): if self.bug_tool==None: from xpra.client.gtk_base.bug_report import BugReport self.bug_tool = BugReport() self.bug_tool.init(show_about=False) self.bug_tool.show() bug_button = self.image_button("", "Bug Report", icon_pixbuf, bug) hbox.pack_start(bug_button, expand=False, fill=False) # Session browser link: icon_pixbuf = self.get_icon("mdns.png") self.mdns_gui = None if icon_pixbuf and self.has_mdns(): def mdns(*_args): if self.mdns_gui==None: from xpra.client.gtk_base.mdns_gui import mdns_sessions self.mdns_gui = mdns_sessions(self.config) def close_mdns(): self.mdns_gui.destroy() self.mdns_gui = None self.mdns_gui.do_quit = close_mdns else: self.mdns_gui.present() mdns_button = self.image_button("", "Browse Sessions", icon_pixbuf, mdns) hbox.pack_start(mdns_button, expand=False, fill=False) # Title label = gtk.Label("Connect to xpra server") label.modify_font(pango.FontDescription("sans 14")) hbox.pack_start(label, expand=True, fill=True) vbox.pack_start(hbox) # Mode: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Mode: ")) self.mode_combo = gtk.combo_box_new_text() for x in self.get_connection_modes(): self.mode_combo.append_text(x.upper()) self.mode_combo.connect("changed", self.mode_changed) hbox.pack_start(self.mode_combo) vbox.pack_start(hbox) # Username@Host:Port hbox = gtk.HBox(False, 0) hbox.set_spacing(5) self.username_entry = gtk.Entry() self.username_entry.set_max_length(128) self.username_entry.set_width_chars(16) self.username_entry.connect("changed", self.validate) self.username_entry.set_tooltip_text("username") self.username_label = gtk.Label("@") self.host_entry = gtk.Entry() self.host_entry.set_max_length(128) self.host_entry.set_width_chars(24) self.host_entry.connect("changed", self.validate) self.host_entry.set_tooltip_text("hostname") self.ssh_port_entry = gtk.Entry() self.ssh_port_entry.set_max_length(5) self.ssh_port_entry.set_width_chars(5) self.ssh_port_entry.connect("changed", self.validate) self.ssh_port_entry.set_tooltip_text("SSH port") self.port_entry = gtk.Entry() self.port_entry.set_max_length(5) self.port_entry.set_width_chars(5) self.port_entry.connect("changed", self.validate) self.port_entry.set_tooltip_text("port/display") hbox.pack_start(self.username_entry) hbox.pack_start(self.username_label) hbox.pack_start(self.host_entry) hbox.pack_start(self.ssh_port_entry) hbox.pack_start(gtk.Label(":")) hbox.pack_start(self.port_entry) vbox.pack_start(hbox) # Password hbox = gtk.HBox(False, 0) hbox.set_spacing(20) self.password_entry = gtk.Entry() self.password_entry.set_max_length(128) self.password_entry.set_width_chars(30) self.password_entry.set_text("") self.password_entry.set_visibility(False) self.password_entry.connect("changed", self.password_ok) self.password_entry.connect("changed", self.validate) self.password_label = gtk.Label("Password: "******"Disable Strict Host Key Check") self.nostrict_host_check.set_active(False) al = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0) al.add(self.nostrict_host_check) hbox.pack_start(al) vbox.pack_start(hbox) # Info Label self.info = gtk.Label() self.info.set_line_wrap(True) self.info.set_size_request(360, -1) self.info.modify_fg(STATE_NORMAL, red) vbox.pack_start(self.info) #hide encoding options by default self.encoding_combo = None self.encoding_options_check = None self.encoding_box = None if not PYTHON3: #not implemented for gtk3, where we can't use set_menu()... hbox = gtk.HBox(False, 0) hbox.set_spacing(20) self.encoding_options_check = gtk.CheckButton("Advanced Encoding Options") self.encoding_options_check.connect("toggled", self.encoding_options_toggled) self.encoding_options_check.set_active(False) al = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0) al.add(self.encoding_options_check) hbox.pack_start(al) vbox.pack_start(hbox) self.encoding_box = gtk.VBox() vbox.pack_start(self.encoding_box) # Encoding: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Encoding: ")) self.encoding_combo = OptionMenu() def get_current_encoding(): return self.config.encoding def set_new_encoding(e): self.config.encoding = e encodings = ["auto"]+[x for x in PREFERED_ENCODING_ORDER if x in self.client.get_encodings()] server_encodings = encodings es = make_encodingsmenu(get_current_encoding, set_new_encoding, encodings, server_encodings) self.encoding_combo.set_menu(es) set_history_from_active(self.encoding_combo) hbox.pack_start(self.encoding_combo) self.encoding_box.pack_start(hbox) self.encoding_combo.connect("changed", self.encoding_changed) # Quality hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.quality_label = gtk.Label("Quality: ") hbox.pack_start(self.quality_label) self.quality_combo = OptionMenu() def set_min_quality(q): self.config.min_quality = q def set_quality(q): self.config.quality = q def get_min_quality(): return self.config.min_quality def get_quality(): return self.config.quality sq = make_min_auto_menu("Quality", MIN_QUALITY_OPTIONS, QUALITY_OPTIONS, get_min_quality, get_quality, set_min_quality, set_quality) self.quality_combo.set_menu(sq) set_history_from_active(self.quality_combo) hbox.pack_start(self.quality_combo) self.encoding_box.pack_start(hbox) # Speed hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.speed_label = gtk.Label("Speed: ") hbox.pack_start(self.speed_label) self.speed_combo = OptionMenu() def set_min_speed(s): self.config.min_speed = s def set_speed(s): self.config.speed = s def get_min_speed(): return self.config.min_speed def get_speed(): return self.config.speed ss = make_min_auto_menu("Speed", MIN_SPEED_OPTIONS, SPEED_OPTIONS, get_min_speed, get_speed, set_min_speed, set_speed) self.speed_combo.set_menu(ss) set_history_from_active(self.speed_combo) hbox.pack_start(self.speed_combo) self.encoding_box.pack_start(hbox) self.encoding_box.hide() # Buttons: hbox = gtk.HBox(False, 20) vbox.pack_start(hbox) #Save: self.save_btn = gtk.Button("Save") self.save_btn.set_tooltip_text("Save settings to a session file") self.save_btn.connect("clicked", self.save_clicked) hbox.pack_start(self.save_btn) #Load: self.load_btn = gtk.Button("Load") self.load_btn.set_tooltip_text("Load settings from a session file") self.load_btn.connect("clicked", self.load_clicked) hbox.pack_start(self.load_btn) # Connect button: self.button = gtk.Button("Connect") self.button.connect("clicked", self.connect_clicked) connect_icon = self.get_icon("retry.png") if connect_icon: self.button.set_image(scaled_image(connect_icon, 24)) hbox.pack_start(self.button) def accel_close(*_args): gtk.main_quit() add_close_accel(self.window, accel_close) vbox.show_all() self.encoding_options_toggled() self.window.vbox = vbox self.window.add(vbox)
def create_window(self): self.window = gtk.Window() self.window.connect("destroy", self.destroy) self.window.set_default_size(400, 300) self.window.set_border_width(20) self.window.set_title("Xpra Launcher") self.window.modify_bg(STATE_NORMAL, gdk.Color(red=65535, green=65535, blue=65535)) icon_pixbuf = self.get_icon("xpra.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) if icon_pixbuf: 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) icon_pixbuf = self.get_icon("bugs.png") self.bug_tool = None if icon_pixbuf: bug_button = gtk.Button("") settings = bug_button.get_settings() settings.set_property('gtk-button-images', True) def bug(*args): if self.bug_tool==None: from xpra.client.gtk_base.bug_report import BugReport self.bug_tool = BugReport() self.bug_tool.init(show_about=False) self.bug_tool.show() bug_button.connect("clicked", bug) bug_button.set_tooltip_text("Bug Report") image = gtk.Image() image.set_from_pixbuf(icon_pixbuf) bug_button.set_image(image) hbox.pack_start(bug_button, expand=False, fill=False) label = gtk.Label("Connect to xpra server") label.modify_font(pango.FontDescription("sans 14")) hbox.pack_start(label, expand=True, fill=True) vbox.pack_start(hbox) # Mode: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Mode: ")) self.mode_combo = gtk.combo_box_new_text() #self.mode_combo.get_model().clear() self.mode_combo.append_text("TCP") if "AES" in ENCRYPTION_CIPHERS: self.mode_combo.append_text("TCP + AES") self.mode_combo.append_text("SSH") self.mode_combo.connect("changed", self.mode_changed) hbox.pack_start(self.mode_combo) vbox.pack_start(hbox) self.encoding_combo = None if not PYTHON3: #not implemented for gtk3, where we can't use set_menu()... # Encoding: hbox = gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(gtk.Label("Encoding: ")) self.encoding_combo = OptionMenu() def get_current_encoding(): return self.config.encoding def set_new_encoding(e): self.config.encoding = e encodings = [x for x in PREFERED_ENCODING_ORDER if x in self.client.get_encodings()] server_encodings = encodings es = make_encodingsmenu(get_current_encoding, set_new_encoding, encodings, server_encodings) self.encoding_combo.set_menu(es) set_history_from_active(self.encoding_combo) hbox.pack_start(self.encoding_combo) vbox.pack_start(hbox) self.encoding_combo.connect("changed", self.encoding_changed) # Quality hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.quality_label = gtk.Label("Quality: ") hbox.pack_start(self.quality_label) self.quality_combo = OptionMenu() def set_min_quality(q): self.config.min_quality = q def set_quality(q): self.config.quality = q def get_min_quality(): return self.config.min_quality def get_quality(): return self.config.quality sq = make_min_auto_menu("Quality", MIN_QUALITY_OPTIONS, QUALITY_OPTIONS, get_min_quality, get_quality, set_min_quality, set_quality) self.quality_combo.set_menu(sq) set_history_from_active(self.quality_combo) hbox.pack_start(self.quality_combo) vbox.pack_start(hbox) # Speed hbox = gtk.HBox(False, 20) hbox.set_spacing(20) self.speed_label = gtk.Label("Speed: ") hbox.pack_start(self.speed_label) self.speed_combo = OptionMenu() def set_min_speed(s): self.config.min_speed = s def set_speed(s): self.config.speed = s def get_min_speed(): return self.config.min_speed def get_speed(): return self.config.speed ss = make_min_auto_menu("Speed", MIN_SPEED_OPTIONS, SPEED_OPTIONS, get_min_speed, get_speed, set_min_speed, set_speed) self.speed_combo.set_menu(ss) set_history_from_active(self.speed_combo) hbox.pack_start(self.speed_combo) vbox.pack_start(hbox) # Username@Host:Port hbox = gtk.HBox(False, 0) hbox.set_spacing(5) self.username_entry = gtk.Entry() self.username_entry.set_max_length(128) self.username_entry.set_width_chars(16) self.username_entry.connect("changed", self.validate) self.username_entry.set_tooltip_text("SSH username") self.username_label = gtk.Label("@") self.host_entry = gtk.Entry() self.host_entry.set_max_length(128) self.host_entry.set_width_chars(24) self.host_entry.connect("changed", self.validate) self.host_entry.set_tooltip_text("hostname") self.ssh_port_entry = gtk.Entry() self.ssh_port_entry.set_max_length(5) self.ssh_port_entry.set_width_chars(5) self.ssh_port_entry.connect("changed", self.validate) self.ssh_port_entry.set_tooltip_text("SSH port") self.port_entry = gtk.Entry() self.port_entry.set_max_length(5) self.port_entry.set_width_chars(5) self.port_entry.connect("changed", self.validate) self.port_entry.set_tooltip_text("port/display") hbox.pack_start(self.username_entry) hbox.pack_start(self.username_label) hbox.pack_start(self.host_entry) hbox.pack_start(self.ssh_port_entry) hbox.pack_start(gtk.Label(":")) hbox.pack_start(self.port_entry) vbox.pack_start(hbox) # Password hbox = gtk.HBox(False, 0) hbox.set_spacing(20) self.password_entry = gtk.Entry() self.password_entry.set_max_length(128) self.password_entry.set_width_chars(30) self.password_entry.set_text("") self.password_entry.set_visibility(False) self.password_entry.connect("changed", self.password_ok) self.password_entry.connect("changed", self.validate) self.password_label = gtk.Label("Password: "******"Save") self.save_btn.set_tooltip_text("Save settings to a session file") self.save_btn.connect("clicked", self.save_clicked) hbox.pack_start(self.save_btn) #Load: self.load_btn = gtk.Button("Load") self.load_btn.set_tooltip_text("Load settings from a session file") self.load_btn.connect("clicked", self.load_clicked) hbox.pack_start(self.load_btn) # Connect button: self.button = gtk.Button("Connect") self.button.connect("clicked", self.connect_clicked) connect_icon = self.get_icon("retry.png") if connect_icon: self.button.set_image(scaled_image(connect_icon, 24)) hbox.pack_start(self.button) def accel_close(*args): gtk.main_quit() add_close_accel(self.window, accel_close) vbox.show_all() self.window.vbox = vbox self.window.add(vbox)