Index: Makefile
===================================================================
RCS file: /usr/cvsroot/gastman/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile	25 Mar 2003 19:45:15 -0000	1.2
+++ Makefile	17 Oct 2003 21:16:15 -0000
@@ -7,12 +7,32 @@
 #
 # For GTK 1.2
 #
-GTKFLAGS=$(shell if [ -z "$(GTK2FLAGS)" ]; then echo `gtk12-config --cflags`; else echo $(GTK2FLAGS); fi)
-GTKLIBS=$(shell if [ -z "$(GTK2LIBS)" ]; then echo `gtk12-config --libs`; else echo $(GTK2LIBS); fi)
-#GTKFLAGS=$(shell gtk-config --cflags)
-#GTKLIBS=$(shell gtk-config --libs)
-
-GLIBFLAGS=$(shell echo `glib12-config --cflags`)
+GTKFLAGS=$(shell \
+	if [ -z $(GTK2FLAGS) ]; then \
+		if [ `which gtk12-config 2>/dev/null`="" ]; then \
+			echo `gtk-config --cflags`; \
+		else \
+			echo `gtk12-config --cflags`; \
+		fi \
+	else \
+		echo $(GTK2FLAGS); \
+	fi)
+GTKLIBS=$(shell \
+	if [ -z "$(GTK2LIBS)" ]; then \
+		if [ `which gtk12-config 2>/dev/null`="" ]; then \
+			echo `gtk-config --cflags`; \
+		else \
+			echo `gtk12-config --libs`; \
+		fi \
+	else \
+		echo $(GTK2LIBS); \
+	fi)
+GLIBFLAGS=$(shell \
+	if [ `which glib12-config`="" ]; then \
+		echo `glib-config --cflags`; \
+	else \
+		echo `glib12-config --cflags`; \
+	fi)
 
 CFLAGS=-Wall -g $(GTKFLAGS) $(GLIBFLAGS) -Iinclude -DGTK_ENABLE_BROKEN
 LIBS=$(GTKLIBS) $(shell if [ -f /etc/master.passwd ]; then echo ""; else echo "-ldb "; fi)
Index: gastman.c
===================================================================
RCS file: /usr/cvsroot/gastman/gastman.c,v
retrieving revision 1.5
diff -u -r1.5 gastman.c
--- gastman.c	4 Jul 2003 16:24:07 -0000	1.5
+++ gastman.c	17 Oct 2003 21:16:16 -0000
@@ -1782,7 +1782,7 @@
 		strncpy(host, *argv, sizeof(host) - 1);
 
 	if (strlen(host) || 
-		(!gui_get_user_input("Enter hostname", "Enter the hostname you wish to connect to:", host, sizeof(host) - 1) &&
+		(!gui_get_hostname(host, sizeof(host) - 1) &&
 			strlen(host))) {
 		if (!login(host)) {
 			manage_calls(host);
Index: gastman.h
===================================================================
RCS file: /usr/cvsroot/gastman/gastman.h,v
retrieving revision 1.4
diff -u -r1.4 gastman.h
--- gastman.h	4 Jul 2003 16:24:07 -0000	1.4
+++ gastman.h	17 Oct 2003 21:16:16 -0000
@@ -52,6 +52,7 @@
 int gui_set_icon(int nformat);
 int gui_status(char *str);
 int gui_get_user_input(char *title, char *msg, char *buf, int buflen);
+int gui_get_hostname(char *buf, int buflen);
 int gui_link(struct gui_object *obj1, struct gui_object *obj2);
 int gui_unlink(struct gui_object *obj1, struct gui_object *obj2);
 int gui_show_chan_menu(void);
Index: gui.c
===================================================================
RCS file: /usr/cvsroot/gastman/gui.c,v
retrieving revision 1.6
diff -u -r1.6 gui.c
--- gui.c	4 Jul 2003 16:24:07 -0000	1.6
+++ gui.c	17 Oct 2003 21:16:19 -0000
@@ -28,6 +28,10 @@
 #include <gtk/gtk.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
 #include <db.h>
 #include <math.h>
 #include <time.h>
@@ -934,7 +938,7 @@
 int gui_init(int *argc, char **argv[])
 {
 	char *fn = loc_file();
-	int res;
+	int res = 0;
 	if (fn) {
 #ifdef __FreeBSD__
 		if (!(db = dbopen(fn, O_CREAT | O_RDWR, 0664, DB_BTREE, NULL))) {
@@ -952,7 +956,7 @@
 	}
 	gtk_init(argc, argv);
 	srand(time(NULL));
-	return 0;
+	return res;
 }
 
 void dialog_answer(GtkWidget *widget, gpointer data)
@@ -966,6 +970,7 @@
 }
 
 static GtkWidget *entry;
+static GtkWidget *combo;
 static char *outmsg;
 static int outmsglen;
 void entry_answer(GtkWidget *widget, gpointer data)
@@ -979,6 +984,21 @@
 	dialog = NULL;
 }
 
+void combo_answer(GtkWidget *widget, gpointer data)
+{
+	GtkCombo *combo2 = GTK_COMBO(combo);
+	choice = (int)(long)data;
+	if (!choice) {
+		char *extra;
+		strncpy(outmsg, gtk_entry_get_text(GTK_ENTRY(combo2->entry)), outmsglen - 1);
+		if ((extra = strstr(outmsg, " (")))
+			extra[0] = '\0';
+	} else
+		strcpy(outmsg, "");
+	gtk_widget_destroy(dialog);
+	dialog = NULL;
+}
+
 static char lastcmd[512];
 
 void command_ready(GtkWidget *widget, gpointer data)
@@ -1042,6 +1062,108 @@
 		gtk_main_iteration_do(1);
 	if (window)
 		gtk_widget_set_sensitive(window, TRUE);
+	return choice;
+}
+
+int gui_get_hostname(char *buf, int buflen)
+{
+	GtkWidget *button;
+	GtkWidget *tw;
+	GtkWidget *vbox, *hbox;
+	GtkWidget *icon;
+	GList *list = NULL;
+	char *rtext = "GAstman: Select hostname";
+	int x;
+	int choices = 2;
+	DIR *gastman_dir;
+	struct dirent *gastman_dirent;
+	static char fn[256];
+
+	snprintf(fn, sizeof(fn), "%s" G_DIR_SEPARATOR_S ".gastman", gui_get_home_dir());
+	gastman_dir = opendir(fn);
+	while (( gastman_dirent = readdir(gastman_dir) )) {
+		char *thedot;
+		if ( gastman_dirent->d_name[0] == '.' )
+			continue;
+		if (( thedot = strstr(gastman_dirent->d_name, ".extens") )) {
+			char *copy;
+			struct hostent *hostent;
+
+			thedot[0] = '\0';
+			if ((hostent = gethostbyname(gastman_dirent->d_name))) {
+				struct in_addr addr;
+				memcpy(&addr, hostent->h_addr_list[0], sizeof(addr));
+				if (strcmp(inet_ntoa(addr), gastman_dirent->d_name)) {
+					copy = alloca(strlen(gastman_dirent->d_name) + strlen(inet_ntoa(addr)) + 4);
+					if (copy) {
+						sprintf(copy, "%s (%s)", gastman_dirent->d_name, inet_ntoa(addr));
+						list = g_list_append(list, copy);
+					}
+				} else {
+					copy = alloca(strlen(gastman_dirent->d_name) + 1);
+					if (copy) {
+						strcpy(copy, gastman_dirent->d_name);
+						list = g_list_append(list, copy);
+					}
+				}
+			} else {
+				copy = alloca(strlen(gastman_dirent->d_name) + 1);
+				if (copy) {
+					strcpy(copy, gastman_dirent->d_name);
+					list = g_list_append(list, copy);
+				}
+			}
+		}
+	}
+	closedir(gastman_dir);
+
+	dialog = gtk_dialog_new();
+	tw = gtk_label_new("Select or enter the hostname you wish to connect to:");
+	gtk_window_set_title(GTK_WINDOW(dialog), rtext);
+	gtk_widget_realize(dialog);
+	fix_icon(dialog->window);
+	gtk_widget_show(tw);
+	vbox = gtk_vbox_new(FALSE, 0);
+	hbox = gtk_hbox_new(FALSE, 0);
+	icon = make_pixmap_from_data(dialog, inkwell_xpm);
+	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 10);
+	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 10);
+	gtk_box_pack_start(GTK_BOX(vbox), tw, TRUE, TRUE, 15);
+	gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 10);
+	combo = gtk_combo_new();
+	gtk_combo_set_case_sensitive(GTK_COMBO(combo), FALSE);
+	gtk_combo_set_value_in_list(GTK_COMBO(combo), FALSE, FALSE);
+	gtk_combo_set_use_arrows(GTK_COMBO(combo), TRUE);
+	gtk_combo_set_use_arrows_always(GTK_COMBO(combo), TRUE);
+	gtk_combo_set_popdown_strings(GTK_COMBO(combo), list);
+	gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 5);
+	/* gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)), "activate", GTK_SIGNAL_FUNC(combo_answer), (gpointer)(long)0); */
+	choice = -1;
+	
+	for (x=0;x<choices;x++) {
+		button = gtk_button_new_with_label(okcancel[x]);
+		gtk_widget_set_usize(button, 80, 30);
+		gtk_widget_show(button);
+		gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(combo_answer), (gpointer)(long)x);
+		gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, FALSE, FALSE, 10);
+	}
+	gtk_widget_grab_focus(combo);
+	if (window)
+		gtk_widget_set_sensitive(window, FALSE);
+	outmsg = buf;
+	outmsglen = buflen;
+	gtk_window_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+	gtk_widget_show_all(dialog);
+	/* Block as long as dialog is here */
+	while(dialog) 
+		gtk_main_iteration_do(1);
+	if (window)
+		gtk_widget_set_sensitive(window, TRUE);
+
+	/* Clean up associated memory */
+	g_list_free(list);
+
 	return choice;
 }
 
