Re: [evolution-patches] patch for 48998



first, this should include a ChangeLog entry.

second, there are a few places that already hook onto some form of changed event, you should just call a function from there rather than hooking a signal onto every possible widget.

last, i'm not sure if this breaks abstraction somewhat - you're poking about the internals of the dialog->editor directly (i.e. by changing the button sensitivity), perhaps you should have a 'changed' method on it instead.

On Mon, 2003-10-13 at 00:44, Charles Zhang wrote:
Dear all
       I posted a patch for bug 48998 here.
       It fixes a bug of "apply button always leave active".
       Because this happens in a dialog, and all the button and 
optionmenu are all in this dialog, so I connect all their "changed" 
signal to a function.
       Please review.
       Thank you all.

Best Regards
Charles Zhang

Index: mail/mail-account-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-account-editor.c,v
retrieving revision 1.57
diff -u -p -r1.57 mail-account-editor.c
--- mail/mail-account-editor.c	25 Mar 2003 15:49:19 -0000	1.57
+++ mail/mail-account-editor.c	12 Oct 2003 14:33:11 -0000
@@ -109,6 +109,9 @@ apply_changes (MailAccountEditor *editor
 	/* save any changes we may have */
 	mail_config_write ();
 	
+	gtk_dialog_set_response_sensitive (GTK_DIALOG (editor),
+					   GTK_RESPONSE_APPLY, FALSE);
+	
 	/* FIXME: #1549: if the account was a remote store, delete it from the folder-tree and re-add it */
 	/* FIXME: preferably, we'd only do this if there were changes... oh well */
 	
@@ -159,6 +162,9 @@ construct (MailAccountEditor *editor, EA
 	mail_account_gui_build_extra_conf (editor->gui, source->url);
 	
 	gtk_widget_grab_focus (GTK_WIDGET (editor->gui->account_name));
+
+	gtk_dialog_set_response_sensitive (GTK_DIALOG (editor),
+					   GTK_RESPONSE_APPLY, FALSE);
 }
 
 MailAccountEditor *
Index: mail/mail-account-gui.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-account-gui.c,v
retrieving revision 1.133.4.3
diff -u -p -r1.133.4.3 mail-account-gui.c
--- mail/mail-account-gui.c	29 Sep 2003 15:43:30 -0000	1.133.4.3
+++ mail/mail-account-gui.c	12 Oct 2003 14:33:19 -0000
@@ -730,6 +730,15 @@ setup_toggle (GtkWidget *widget, const c
 	toggle_sensitivity (toggle, widget);
 }
 
+static void
+mail_config_changed (GtkWidget *widget, gpointer user_data)
+{
+	MailAccountsTab *dialog = (MailAccountsTab *) user_data;
+	
+	gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->editor),
+					   GTK_RESPONSE_APPLY, TRUE);
+}
+
 void
 mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string)
 {
@@ -742,6 +751,7 @@ mail_account_gui_build_extra_conf (MailA
 	GList *children, *child;
 	char *name;
 	int i, rows;
+	MailAccountsTab *dialog = (MailAccountsTab *) gui->dialog;
 	
 	if (url_string)
 		url = "" (url_string, NULL);
@@ -874,6 +884,9 @@ mail_account_gui_build_extra_conf (MailA
 					  GTK_EXPAND | GTK_FILL, 0, 0, 0);
 			rows++;
 			g_hash_table_insert (gui->extra_config, entries[i].name, checkbox);
+
+			g_signal_connect (checkbox, "toggled", G_CALLBACK (mail_config_changed), dialog);
+			
 			if (entries[i].depname)
 				setup_toggle (checkbox, entries[i].depname, gui);
 			break;
@@ -923,7 +936,9 @@ mail_account_gui_build_extra_conf (MailA
 			}
 
 			g_hash_table_insert (gui->extra_config, entries[i].name, entry);
-						
+
+			g_signal_connect (entry, "changed", G_CALLBACK (mail_config_changed), dialog);
+
 			break;
 		}
 		
@@ -1395,6 +1410,8 @@ prepare_signatures (MailAccountGui *gui)
 	g_signal_connect (gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)),
 			  "selection-done", G_CALLBACK(sig_changed), gui);
 	
+	g_signal_connect (gui->sig_option_menu, "changed", G_CALLBACK (mail_config_changed), gui->dialog);
+
 	glade_xml_signal_connect_data (gui->xml, "sigAddNewClicked",
 				       G_CALLBACK (sig_add_new_signature), gui);
 	
@@ -1430,6 +1447,9 @@ mail_account_gui_new (EAccount *account,
 	    || (account == mail_config_get_default_account ()))
 		gtk_toggle_button_set_active (gui->default_account, TRUE);
 	
+	g_signal_connect (gui->account_name, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->default_account, "toggled", G_CALLBACK (mail_config_changed), dialog);
+
 	/* Identity */
 	gui->full_name = GTK_ENTRY (glade_xml_get_widget (gui->xml, "identity_full_name"));
 	gui->email_address = GTK_ENTRY (glade_xml_get_widget (gui->xml, "identity_address"));
@@ -1437,7 +1457,7 @@ mail_account_gui_new (EAccount *account,
 	gui->organization = GTK_ENTRY (glade_xml_get_widget (gui->xml, "identity_organization"));
 	
 	prepare_signatures (gui);
-	
+
 	if (account->id->name)
 		gtk_entry_set_text (gui->full_name, account->id->name);
 	if (account->id->address)
@@ -1449,6 +1469,11 @@ mail_account_gui_new (EAccount *account,
 	
 	setup_signatures (gui);
 	
+	g_signal_connect (gui->full_name, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->email_address, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->reply_to, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->organization, "changed", G_CALLBACK (mail_config_changed), dialog);
+	
 	/* Source */
 	gui->source.provider_type = CAMEL_PROVIDER_STORE;
 	gui->source.type = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "source_type_omenu"));
@@ -1471,9 +1496,21 @@ mail_account_gui_new (EAccount *account,
 	gui->source.check_supported = GTK_BUTTON (glade_xml_get_widget (gui->xml, "source_check_supported"));
 	g_signal_connect (gui->source.check_supported, "clicked",
 			  G_CALLBACK (service_check_supported), &gui->source);
+
+	g_signal_connect (gui->source.type, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->source.hostname, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->source.username, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->source.path, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->source.use_ssl, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->source.authtype, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->source.remember, "toggled", G_CALLBACK (mail_config_changed), dialog);
+
 	gui->source_auto_check = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "extra_auto_check"));
 	gui->source_auto_check_min = GTK_SPIN_BUTTON (glade_xml_get_widget (gui->xml, "extra_auto_check_min"));
 	
+	g_signal_connect (gui->source_auto_check, "toggled", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->source_auto_check_min, "value-changed", G_CALLBACK (mail_config_changed), dialog);	
+
 	/* Transport */
 	gui->transport.provider_type = CAMEL_PROVIDER_TRANSPORT;
 	gui->transport.type = GTK_OPTION_MENU (glade_xml_get_widget (gui->xml, "transport_type_omenu"));
@@ -1497,6 +1534,14 @@ mail_account_gui_new (EAccount *account,
 	g_signal_connect (gui->transport.check_supported, "clicked",
 			  G_CALLBACK (service_check_supported), &gui->transport);
 	
+	g_signal_connect (gui->transport.type, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->transport.hostname, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->transport.username, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->transport_needs_auth, "toggled", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->transport.use_ssl, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->transport.authtype, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->transport.remember, "toggled", G_CALLBACK (mail_config_changed), dialog);
+	
 	/* Drafts folder */
 	gui->drafts_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "drafts_button"));
 	g_signal_connect (gui->drafts_folder_button, "selected",
@@ -1510,6 +1555,8 @@ mail_account_gui_new (EAccount *account,
 						    _("Select Folder"),
 						    gui->drafts_folder_uri,
 						    allowed_types);
+
+	g_signal_connect (gui->drafts_folder_button, "clicked", G_CALLBACK (mail_config_changed), dialog);
 	
 	/* Sent folder */
 	gui->sent_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "sent_button"));
@@ -1525,10 +1572,14 @@ mail_account_gui_new (EAccount *account,
 						    gui->sent_folder_uri,
 						    allowed_types);
 	
+	g_signal_connect (gui->sent_folder_button, "clicked", G_CALLBACK (mail_config_changed), dialog);
+	
 	/* Special Folders "Reset Defaults" button */
 	button = glade_xml_get_widget (gui->xml, "default_folders_button");
 	g_signal_connect (button, "clicked", G_CALLBACK (default_folders_clicked), gui);
 	
+	g_signal_connect (button, "clicked", G_CALLBACK (mail_config_changed), dialog);
+	
 	/* Always Cc */
 	gui->always_cc = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "always_cc"));
 	gtk_toggle_button_set_active (gui->always_cc, account->always_cc);
@@ -1536,6 +1587,9 @@ mail_account_gui_new (EAccount *account,
 	if (account->cc_addrs)
 		gtk_entry_set_text (gui->cc_addrs, account->cc_addrs);
 	
+	g_signal_connect (gui->always_cc, "toggled", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->cc_addrs, "changed", G_CALLBACK (mail_config_changed), dialog);
+	
 	/* Always Bcc */
 	gui->always_bcc = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "always_bcc"));
 	gtk_toggle_button_set_active (gui->always_bcc, account->always_bcc);
@@ -1543,6 +1597,9 @@ mail_account_gui_new (EAccount *account,
 	if (account->bcc_addrs)
 		gtk_entry_set_text (gui->bcc_addrs, account->bcc_addrs);
 	
+	g_signal_connect (gui->always_bcc, "toggled", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->bcc_addrs, "changed", G_CALLBACK (mail_config_changed), dialog);
+
 	/* Security */
 	gui->pgp_key = GTK_ENTRY (glade_xml_get_widget (gui->xml, "pgp_key"));
 	if (account->pgp_key)
@@ -1555,7 +1612,13 @@ mail_account_gui_new (EAccount *account,
 	gtk_toggle_button_set_active (gui->pgp_no_imip_sign, account->pgp_no_imip_sign);
 	gui->pgp_always_trust = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "pgp_always_trust"));
 	gtk_toggle_button_set_active (gui->pgp_always_trust, account->pgp_always_trust);
-	
+
+	g_signal_connect (gui->pgp_key, "changed", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->pgp_encrypt_to_self, "clicked", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->pgp_always_sign, "clicked", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->pgp_no_imip_sign, "clicked", G_CALLBACK (mail_config_changed), dialog);
+	g_signal_connect (gui->pgp_always_trust, "clicked", G_CALLBACK (mail_config_changed), dialog);
+		
 #if defined (HAVE_NSS) && defined (SMIME_SUPPORTED)
 	gui->smime_key = GTK_ENTRY (glade_xml_get_widget (gui->xml, "smime_key"));
 	if (account->smime_key)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]