From 0e4c54eddced72c9639001849148fe1813c5dc4e Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 29 Sep 2010 21:11:44 -0400 Subject: Messin around with EAlerts. Trying out a new interface called EAlertSink. The idea is to centralize how errors are shown to the user. A GtkWindow subclass would implement the EAlertSink interface, which consists of a single method: void (*submit_alert) (EAlertSink *alert_sink, EAlert *alert); The subclass has complete control over what to do with the EAlert, although I imagine we'll wind up implementing various alert-handling policies as standalone widgets such as EAlertDialog. I'd like to try an EAlertInfoBar. Code that would otherwise display an error dialog itself would instead pass the EAlert to an appropriate EAlertSink and be done with it. Nothing is final yet. Still hacking on EAlert trying to find an API that feels right for these use cases. --- widgets/misc/e-signature-editor.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'widgets') diff --git a/widgets/misc/e-signature-editor.c b/widgets/misc/e-signature-editor.c index 28c5819865..effbf8bc30 100644 --- a/widgets/misc/e-signature-editor.c +++ b/widgets/misc/e-signature-editor.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -64,10 +65,11 @@ static const gchar *ui = " \n" ""; -G_DEFINE_TYPE ( +G_DEFINE_TYPE_WITH_CODE ( ESignatureEditor, e_signature_editor, - GTKHTML_TYPE_EDITOR) + GTKHTML_TYPE_EDITOR, + G_IMPLEMENT_INTERFACE (E_TYPE_ALERT_SINK, NULL)) static void handle_error (GError **error) @@ -150,8 +152,8 @@ action_save_and_close_cb (GtkAction *action, gtkhtml_editor_save (GTKHTML_EDITOR (editor), filename, html, &error); if (error != NULL) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (editor), + e_alert_submit ( + GTK_WIDGET (editor), "mail:no-save-signature", error->message, NULL); g_clear_error (&error); @@ -165,8 +167,8 @@ action_save_and_close_cb (GtkAction *action, /* Make sure the signature name is not blank. */ if (*signature_name == '\0') { - e_alert_run_dialog_for_args ( - GTK_WINDOW (editor), + e_alert_submit ( + GTK_WIDGET (editor), "mail:blank-signature", NULL); gtk_widget_grab_focus (entry); g_free (signature_name); @@ -178,8 +180,8 @@ action_save_and_close_cb (GtkAction *action, same_name = (ESignature *) e_signature_list_find ( signature_list, E_SIGNATURE_FIND_NAME, signature_name); if (same_name != NULL && !e_signature_is_equal (signature, same_name)) { - e_alert_run_dialog_for_args ( - GTK_WINDOW (editor), + e_alert_submit ( + GTK_WIDGET (editor), "mail:signature-already-exists", signature_name, NULL); gtk_widget_grab_focus (entry); -- cgit