Thanks Charles, this looks a lot better.
One small style thing - in the mail code we'd prefer you used function calls directly rather than the signal connection macro, and i'm not sure you really need mail_account_gui_signal_connect to be another function, since its only ever called from mail_account_gui_setup anyway.
Michael
On Wed, 2003-10-15 at 02:15, Charles Zhang wrote:
Thank you
Following your advices, this time I have created some functions on different object to complete encapsulating.
And avoid unnecessary passing of toplevel widget.
But I have to use connect serveral signals on some widget, because these handlers need different data, so different arguments.
Or should I alter the argement(i.e. pass a struct as argument) of the very existing function? I think that can I be able to merge the existing handler and the change signal handler together on the same widget?
Please spare some time to see if this patch meet us.
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2761.2.32
diff -u -p -r1.2761.2.32 ChangeLog
--- mail/ChangeLog 8 Oct 2003 16:06:08 -0000 1.2761.2.32
+++ mail/ChangeLog 14 Oct 2003 16:19:28 -0000
@@ -0,0 +0,18 @@
+2003-10-13 Charles Zhang <charles zhang sun com>
+
+ * mail-account-gui.c (mail_account_gui_changed): change signal
+ handler on gui object, callback func.
+ (mail_account_gui_signal_connect): connect widgets to change signal.
+ (mail_account_gui_setup): call func mail_account_gui_signal_connect.
+ (sig_changed): call change handler func.
+ (mail_account_gui_build_extra_conf): connect "changed" signal.
+ (default_folders_clicked): call change handler func.
+
+ * mail-account-editor.c (apply_changes): disable apply button.
+ (construct): disable apply button.
+ (mail_account_editor_changed): change signal handler on editor
+ object.
+
+ * mail_account_editor.h (mail_account_editor_changed): defination
+ of func above.
+
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 14 Oct 2003 16:19:32 -0000
@@ -105,7 +105,10 @@ apply_changes (MailAccountEditor *editor
if (mail_account_gui_save (editor->gui) == FALSE)
return FALSE;
-
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (editor),
+ GTK_RESPONSE_APPLY, FALSE);
+
/* save any changes we may have */
mail_config_write ();
@@ -151,7 +154,10 @@ construct (MailAccountEditor *editor, EA
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
-
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (editor),
+ GTK_RESPONSE_APPLY, FALSE);
+
g_signal_connect (editor, "response", G_CALLBACK (editor_response_cb), editor);
mail_account_gui_setup (editor->gui, GTK_WIDGET (editor));
@@ -172,3 +178,10 @@ mail_account_editor_new (EAccount *accou
return new;
}
+
+void
+mail_account_editor_changed (MailAccountEditor *editor)
+{
+ gtk_dialog_set_response_sensitive (GTK_WIDGET (editor),
+ GTK_RESPONSE_APPLY, TRUE);
+}
Index: mail/mail-account-editor.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-account-editor.h,v
retrieving revision 1.20
diff -u -p -r1.20 mail-account-editor.h
--- mail/mail-account-editor.h 17 Jan 2003 23:31:25 -0000 1.20
+++ mail/mail-account-editor.h 14 Oct 2003 16:19:32 -0000
@@ -59,6 +59,7 @@ typedef struct {
GtkType mail_account_editor_get_type (void);
MailAccountEditor *mail_account_editor_new (EAccount *account, GtkWindow *parent, MailAccountsTab *dialog);
+void mail_account_editor_changed (MailAccountEditor *editor);
#ifdef __cplusplus
}
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 14 Oct 2003 16:19:37 -0000
@@ -730,6 +730,14 @@ setup_toggle (GtkWidget *widget, const c
toggle_sensitivity (toggle, widget);
}
+static void
+mail_account_gui_changed (GtkWidget *widget, MailAccountGui *gui)
+{
+ MailAccountsTab *dialog = (MailAccountsTab *) gui->dialog;
+ MailAccountEditor *editor = (MailAccountEditor *) dialog->editor;
+ mail_account_editor_changed (editor);
+}
+
void
mail_account_gui_build_extra_conf (MailAccountGui *gui, const char *url_string)
{
@@ -876,6 +884,9 @@ mail_account_gui_build_extra_conf (MailA
g_hash_table_insert (gui->extra_config, entries[i].name, checkbox);
if (entries[i].depname)
setup_toggle (checkbox, entries[i].depname, gui);
+
+ g_signal_connect (checkbox, "toggled", G_CALLBACK (mail_account_gui_changed), gui);
+
break;
}
@@ -924,6 +935,8 @@ 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_account_gui_changed), gui);
+
break;
}
@@ -1088,6 +1101,8 @@ default_folders_clicked (GtkButton *butt
gui->sent_folder_uri = g_strdup (default_sent_folder_uri);
evolution_folder_selector_button_set_uri (EVOLUTION_FOLDER_SELECTOR_BUTTON (gui->sent_folder_button),
gui->sent_folder_uri);
+
+ mail_account_gui_changed (GTK_WIDGET (button), gui);
}
GtkWidget *mail_account_gui_folder_selector_button_new (char *widget_name, char *string1, char *string2, int int1, int int2);
@@ -1281,6 +1296,8 @@ sig_changed (GtkWidget *w, MailAccountGu
gui->def_signature = (MailConfigSignature *) g_object_get_data(G_OBJECT(active), "sig");
gui->auto_signature = index == 1 ? TRUE : FALSE;
+
+ mail_account_gui_changed (w, gui);
}
static void
@@ -1577,6 +1594,51 @@ mail_account_gui_new (EAccount *account,
return gui;
}
+static void
+mail_account_gui_signal_connect (MailAccountGui *gui)
+{
+#define CHANGE_CONNECT(w, s) g_signal_connect (w, s, G_CALLBACK (mail_account_gui_changed), gui);
+
+ CHANGE_CONNECT (gui->account_name, "changed");
+ CHANGE_CONNECT (gui->default_account, "toggled");
+ CHANGE_CONNECT (gui->full_name, "changed");
+ CHANGE_CONNECT (gui->email_address, "changed");
+ CHANGE_CONNECT (gui->reply_to, "changed");
+ CHANGE_CONNECT (gui->organization, "changed");
+
+ CHANGE_CONNECT (gui->source.type, "changed");
+ CHANGE_CONNECT (gui->source.hostname, "changed");
+ CHANGE_CONNECT (gui->source.username, "changed");
+ CHANGE_CONNECT (gui->source.path, "changed");
+ CHANGE_CONNECT (gui->source.use_ssl, "changed");
+ CHANGE_CONNECT (gui->source.authtype, "changed");
+ CHANGE_CONNECT (gui->source.remember, "toggled");
+
+ CHANGE_CONNECT (gui->source_auto_check, "toggled");
+ CHANGE_CONNECT (gui->source_auto_check_min, "value-changed");
+
+ CHANGE_CONNECT (gui->transport.type, "changed");
+ CHANGE_CONNECT (gui->transport.hostname, "changed");
+ CHANGE_CONNECT (gui->transport.username, "changed");
+ CHANGE_CONNECT (gui->transport_needs_auth, "toggled");
+ CHANGE_CONNECT (gui->transport.use_ssl, "changed");
+ CHANGE_CONNECT (gui->transport.authtype, "changed");
+ CHANGE_CONNECT (gui->transport.remember, "toggled");
+
+ CHANGE_CONNECT (gui->drafts_folder_button, "clicked");
+ CHANGE_CONNECT (gui->sent_folder_button, "clicked");
+ CHANGE_CONNECT (gui->always_cc, "toggled");
+ CHANGE_CONNECT (gui->cc_addrs, "changed");
+ CHANGE_CONNECT (gui->always_bcc, "toggled");
+ CHANGE_CONNECT (gui->bcc_addrs, "changed");
+
+ CHANGE_CONNECT (gui->pgp_key, "changed");
+ CHANGE_CONNECT (gui->pgp_encrypt_to_self, "toggled");
+ CHANGE_CONNECT (gui->pgp_always_sign, "toggled");
+ CHANGE_CONNECT (gui->pgp_no_imip_sign, "toggled");
+ CHANGE_CONNECT (gui->pgp_always_trust, "toggled");
+}
+
void
mail_account_gui_setup (MailAccountGui *gui, GtkWidget *top)
{
@@ -1760,6 +1822,8 @@ mail_account_gui_setup (MailAccountGui *
gui->transport.provider_type = CAMEL_PROVIDER_TRANSPORT;
g_free (transport_proto);
}
+
+ mail_account_gui_signal_connect (gui);
}
static void
|