+struct connection_widgets
+{
+ GtkWidget *hentry;
+ GtkWidget *combo;
+ GtkWidget *button;
+};
+
+static void hostname_cb(GtkEntry *entry, gpointer data)
+{
+ struct connection_widgets *cw = data;
+ int uses_net = 0, is_localhost = 0;
+ const gchar *text;
+ gchar *ctext;
+
+ /*
+ * Check whether to display the 'auto start backend' box
+ * or not. Show it if we are a localhost and using network,
+ * or using a socket.
+ */
+ ctext = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cw->combo));
+ if (!ctext || !strncmp(ctext, "IPv4", 4) || !strncmp(ctext, "IPv6", 4))
+ uses_net = 1;
+ g_free(ctext);
+
+ if (uses_net) {
+ text = gtk_entry_get_text(GTK_ENTRY(cw->hentry));
+ if (!strcmp(text, "127.0.0.1") || !strcmp(text, "localhost") ||
+ !strcmp(text, "::1") || !strcmp(text, "ip6-localhost") ||
+ !strcmp(text, "ip6-loopback"))
+ is_localhost = 1;
+ }
+
+ if (!uses_net || is_localhost) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cw->button), 1);
+ gtk_widget_set_sensitive(cw->button, 1);
+ } else {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cw->button), 0);
+ gtk_widget_set_sensitive(cw->button, 0);
+ }
+}
+