changeset 5876:8d6e5f804325

[gaim-migrate @ 6308] The Save button is now insensitive if the buddy entry is blank. Maybe it's because it doesn't have any friends. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 15 Jun 2003 02:19:54 +0000
parents 448f2f4ca3ec
children f336fc0a7b8b
files src/gtkpounce.c
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkpounce.c	Sun Jun 15 02:03:23 2003 +0000
+++ b/src/gtkpounce.c	Sun Jun 15 02:19:54 2003 +0000
@@ -74,6 +74,9 @@
 	
 	GtkWidget *save_pounce;
 
+	/* Buttons */
+	GtkWidget *save_button;
+
 } GaimGtkPounceDialog;
 
 /**************************************************************************
@@ -319,6 +322,16 @@
 	return opt_menu;
 }
 
+static void
+buddy_changed_cb(GtkEntry *entry, GaimGtkPounceDialog *dialog)
+{
+	if (dialog->save_button == NULL)
+		return;
+
+	gtk_widget_set_sensitive(dialog->save_button,
+			*gtk_entry_get_text(entry) != '\0');
+}
+
 void
 gaim_gtkpounce_dialog_show(struct buddy *buddy,
 						   GaimPounce *cur_pounce)
@@ -411,6 +424,9 @@
 	gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_entry, TRUE, TRUE, 0);
 	gtk_widget_show(dialog->buddy_entry);
 
+	g_signal_connect(G_OBJECT(dialog->buddy_entry), "changed",
+			 G_CALLBACK(buddy_changed_cb), dialog);
+
 	if (cur_pounce != NULL) {
 		gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry),
 						   gaim_pounce_get_pouncee(cur_pounce));
@@ -605,13 +621,16 @@
 					 G_CALLBACK(cancel_cb), dialog);
 
 	/* Save button */
-	button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
+	dialog->save_button = button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
 	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 	gtk_widget_show(button);
 	
 	g_signal_connect(G_OBJECT(button), "clicked",
 					 G_CALLBACK(save_pounce_cb), dialog);
 
+	if (*gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)) == '\0')
+		gtk_widget_set_sensitive(button, FALSE);
+
 	/* Set the values of stuff. */
 	if (cur_pounce != NULL) {
 		GaimPounceEvent events = gaim_pounce_get_events(cur_pounce);