addconn: Simplify remote connection choices

Remove vs. local is a boolean choice, so wrap it in a checkbox. Keep the
connection combo for simply choosing the auth method, and have it default
to SSH which is far and away the common case.
This commit is contained in:
Cole Robinson 2010-08-24 14:56:03 -04:00
parent 12c1b07819
commit e398b0e791
2 changed files with 135 additions and 95 deletions

View File

@ -30,10 +30,9 @@ from virtManager.error import vmmErrorDialog
HV_XEN = 0
HV_QEMU = 1
CONN_LOCAL = 0
CONN_SSH = 0
CONN_TCP = 1
CONN_TLS = 2
CONN_SSH = 3
class vmmConnect(gobject.GObject):
__gsignals__ = {
@ -59,6 +58,7 @@ class vmmConnect(gobject.GObject):
"on_hypervisor_changed": self.hypervisor_changed,
"on_connection_changed": self.connection_changed,
"on_hostname_combo_changed": self.hostname_combo_changed,
"on_connect_remote_toggled": self.connect_remote_toggled,
"on_cancel_clicked": self.cancel,
"on_connect_clicked": self.open_connection,
@ -75,20 +75,7 @@ class vmmConnect(gobject.GObject):
# Plain hostname resolve failed, means we should just use IP addr
self.can_resolve_hostname = None
stock_img = gtk.image_new_from_stock(gtk.STOCK_CONNECT,
gtk.ICON_SIZE_BUTTON)
self.window.get_widget("connect").set_image(stock_img)
self.window.get_widget("connection").set_active(0)
self.window.get_widget("connect").grab_default()
self.window.get_widget("autoconnect").set_active(True)
self.window.get_widget("hostname").child.connect("changed",
self.hostname_changed)
connListModel = gtk.ListStore(str, str, str)
host = self.window.get_widget("hostname")
host.set_model(connListModel)
host.set_text_column(2)
connListModel.set_sort_column_id(2, gtk.SORT_ASCENDING)
self.set_initial_state()
self.bus = None
self.server = None
@ -104,7 +91,6 @@ class vmmConnect(gobject.GObject):
self.reset_state()
def cancel(self,ignore1=None,ignore2=None):
self.close()
self.emit("cancelled")
@ -119,15 +105,37 @@ class vmmConnect(gobject.GObject):
win.present()
self.reset_state()
def set_initial_state(self):
stock_img = gtk.image_new_from_stock(gtk.STOCK_CONNECT,
gtk.ICON_SIZE_BUTTON)
self.window.get_widget("connect").set_image(stock_img)
self.window.get_widget("connect").grab_default()
# Hostname combo box entry
hostListModel = gtk.ListStore(str, str, str)
host = self.window.get_widget("hostname")
host.set_model(hostListModel)
host.set_text_column(2)
hostListModel.set_sort_column_id(2, gtk.SORT_ASCENDING)
self.window.get_widget("hostname").child.connect("changed",
self.hostname_changed)
def reset_state(self):
self.set_default_hypervisor()
self.window.get_widget("connection").set_active(0)
self.window.get_widget("autoconnect").set_sensitive(True)
self.window.get_widget("autoconnect").set_active(True)
self.window.get_widget("hostname").get_model().clear()
self.window.get_widget("hostname").child.set_text("")
self.window.get_widget("connect-remote").set_active(False)
self.stop_browse()
self.connect_remote_toggled(self.window.get_widget("connect-remote"))
self.populate_uri()
def is_remote(self):
# Whether user is requesting a remote connection
return self.window.get_widget("connect-remote").get_active()
def set_default_hypervisor(self):
default = virtinst.util.default_connection()
if default is None:
@ -228,11 +236,11 @@ class vmmConnect(gobject.GObject):
def hypervisor_changed(self, src):
self.populate_uri()
def connection_changed(self, src):
is_remote = (self.window.get_widget("connection").get_active() > 0)
def connect_remote_toggled(self, src):
is_remote = self.is_remote()
self.window.get_widget("hostname").set_sensitive(is_remote)
self.window.get_widget("connection").set_sensitive(is_remote)
self.window.get_widget("autoconnect").set_active(not is_remote)
if is_remote and self.can_browse:
self.start_browse()
else:
@ -240,6 +248,9 @@ class vmmConnect(gobject.GObject):
self.populate_uri()
def connection_changed(self, src):
self.populate_uri()
def populate_uri(self):
uri = self.generate_uri()
self.window.get_widget("uri-entry").set_text(uri)
@ -248,6 +259,7 @@ class vmmConnect(gobject.GObject):
hv = self.window.get_widget("hypervisor").get_active()
conn = self.window.get_widget("connection").get_active()
host = self.window.get_widget("hostname").child.get_text()
is_remote = self.is_remote()
user = "root"
if conn == CONN_SSH and '@' in host:
@ -260,7 +272,7 @@ class vmmConnect(gobject.GObject):
hvstr = "qemu"
hoststr = ""
if conn == CONN_LOCAL:
if not is_remote:
hoststr = ":///"
elif conn == CONN_TLS:
hoststr = "+tls://" + host + "/"
@ -276,10 +288,10 @@ class vmmConnect(gobject.GObject):
return uri
def validate(self):
conn = self.window.get_widget("connection").get_active()
is_remote = self.is_remote()
host = self.window.get_widget("hostname").child.get_text()
if conn != CONN_LOCAL and not host:
if is_remote and not host:
return self.err.val_err(_("A hostname is required for "
"remote connections."))

View File

@ -18,56 +18,10 @@
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="n_rows">6</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkCheckButton" id="autoconnect">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label90">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">A_utoconnect:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">autoconnect</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label91">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">H_ostname:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="hypervisor">
<property name="visible">True</property>
@ -98,28 +52,12 @@ QEMU/KVM</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label88">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Connec_tion:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">connection</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="connection">
<property name="visible">True</property>
<property name="items" translatable="yes">Local
Remote Password or Kerberos
Remote SSL/TLS with x509 certificate
Remote tunnel over SSH</property>
<property name="items" translatable="yes">SSH
TCP (SASL, Kerberos, ...)
SSL/TLS with certificates</property>
<accessibility>
<atkproperty name="AtkObject::accessible-name" translatable="yes">Connection Select</atkproperty>
</accessibility>
@ -128,8 +66,8 @@ Remote tunnel over SSH</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@ -142,8 +80,8 @@ Remote tunnel over SSH</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@ -164,20 +102,110 @@ Remote tunnel over SSH</property>
<property name="label" translatable="yes">Generated URI:</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="uri-entry">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label">uri</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="connect-remote">
<property name="label" translatable="yes">Connect to _remote host</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_connect_remote_toggled"/>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">22</property>
<child>
<widget class="GtkLabel" id="label88">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Connec_tion:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">connection</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">22</property>
<child>
<widget class="GtkLabel" id="label91">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">H_ostname:</property>
<property name="use_underline">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label90">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">A_utoconnect:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">autoconnect</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="autoconnect">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
</widget>