changeset 4613:5385b3625a72

[gaim-migrate @ 4902] this fixes it for real ;-) committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 25 Feb 2003 17:11:01 +0000
parents c05e6ecdc902
children 9f92925b6507
files src/dialogs.c
diffstat 1 files changed, 25 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Tue Feb 25 01:48:36 2003 +0000
+++ b/src/dialogs.c	Tue Feb 25 17:11:01 2003 +0000
@@ -566,11 +566,8 @@
 	if (resp == GTK_RESPONSE_OK) {
 		who = gtk_entry_get_text(GTK_ENTRY(info->entry));
 
-		if (!g_strcasecmp(who, "")) {
-/*
-SOMEONE FIX THIS CORRECTLY
-			g_free(info);
-*/
+		if (!who || !*who) {
+			/* this shouldn't ever happen */
 			return;
 		}
 
@@ -679,6 +676,12 @@
 	info->gc = gc;
 }
 
+static void im_dialog_set_ok_sensitive(GtkWidget *entry, gpointer data) {
+	const char *txt = gtk_entry_get_text(GTK_ENTRY(entry));
+	gtk_dialog_set_response_sensitive(GTK_DIALOG(imdialog), GTK_RESPONSE_OK,
+			(*txt != '\0'));
+}
+
 void show_im_dialog()
 {
 	GtkWidget *hbox, *vbox;
@@ -696,7 +699,7 @@
 	if (!imdialog) {
 		info = g_new0(struct getuserinfo, 1);
 		info->gc = connections->data;
-		imdialog = gtk_dialog_new_with_buttons(_("Gaim - New Message"), blist ? GTK_WINDOW(blist) : NULL, GTK_DIALOG_MODAL, 
+		imdialog = gtk_dialog_new_with_buttons(_("Gaim - New Message"), blist ? GTK_WINDOW(blist) : NULL, GTK_DIALOG_MODAL,
 						       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
 		gtk_dialog_set_default_response (GTK_DIALOG(imdialog), GTK_RESPONSE_OK);
 		gtk_container_set_border_width (GTK_CONTAINER(imdialog), 6);
@@ -704,7 +707,8 @@
 		gtk_dialog_set_has_separator(GTK_DIALOG(imdialog), FALSE);
 		gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(imdialog)->vbox), 12);
 		gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), 6);
-		
+		gtk_dialog_set_response_sensitive(GTK_DIALOG(imdialog), GTK_RESPONSE_OK, FALSE);
+
 		hbox = gtk_hbox_new(FALSE, 12);
 		gtk_container_add(GTK_CONTAINER(GTK_DIALOG(imdialog)->vbox), hbox);
 		gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
@@ -712,22 +716,22 @@
 
 		vbox = gtk_vbox_new(FALSE, 0);
 		gtk_container_add(GTK_CONTAINER(hbox), vbox);
-		
+
 		label = gtk_label_new(_("Please enter the screenname of the person you would like to IM.\n"));
 		gtk_widget_set_size_request(GTK_WIDGET(label), 350, -1);
 		gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
 		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
 		gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
-		
+
 		hbox = gtk_hbox_new(FALSE, 6);
 		gtk_container_add(GTK_CONTAINER(vbox), hbox);
-		
+
 		table = gtk_table_new(2, 2, FALSE);
 		gtk_table_set_row_spacings(GTK_TABLE(table), 6);
 		gtk_table_set_col_spacings(GTK_TABLE(table), 6);
 		gtk_container_set_border_width(GTK_CONTAINER(table), 12);
 		gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
-	
+
 		label = gtk_label_new(NULL);
 		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Screenname:"));
 		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
@@ -737,6 +741,8 @@
 		gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1);
 		gtk_entry_set_activates_default (GTK_ENTRY(info->entry), TRUE);
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->entry));
+		g_signal_connect(G_OBJECT(info->entry), "changed",
+				G_CALLBACK(im_dialog_set_ok_sensitive), NULL);
 
 		if (connections->next) {
 
@@ -744,13 +750,13 @@
 			gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
 			gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:"));
 			gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-			
+
 			info->account = gtk_option_menu_new();
 			gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2);
 			gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account));
-			
+
 			menu = gtk_menu_new();
-			
+
 			while (g) {
 				c = (struct gaim_connection *)g->data;
 				if (!c->prpl->send_im) {
@@ -760,20 +766,20 @@
 				g_snprintf(buf, sizeof(buf), "%s (%s)", c->username, c->prpl->name);
 				opt = gtk_menu_item_new_with_label(buf);
 				gtk_object_set_user_data(GTK_OBJECT(opt), info);
-				
+
 				g_signal_connect(GTK_OBJECT(opt), "activate",
 						   G_CALLBACK(show_info_select_account), c);
-				
+
 				gtk_menu_append(GTK_MENU(menu), opt);
 				g = g->next;
 			}
-			
+
 			gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu);
 		}
-		
+
 		g_signal_connect(G_OBJECT(imdialog), "response", G_CALLBACK(do_im), info);
 	}
-	
+
 	gtk_widget_show_all(imdialog);
 	if (info)
 		gtk_widget_grab_focus(GTK_WIDGET(info->entry));