aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-session.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-11-15 19:56:01 +0800
committerMilan Crha <mcrha@redhat.com>2011-11-15 19:56:42 +0800
commitd03f8dfccb680fd4d6595682def3a2b85b626f6f (patch)
tree19e55af514e1ae6b55a667a5d738771d74e0b9a2 /mail/e-mail-session.c
parent604948f1b5522c020128106eb4466af134648d83 (diff)
downloadgsoc2013-evolution-d03f8dfccb680fd4d6595682def3a2b85b626f6f.tar
gsoc2013-evolution-d03f8dfccb680fd4d6595682def3a2b85b626f6f.tar.gz
gsoc2013-evolution-d03f8dfccb680fd4d6595682def3a2b85b626f6f.tar.bz2
gsoc2013-evolution-d03f8dfccb680fd4d6595682def3a2b85b626f6f.tar.lz
gsoc2013-evolution-d03f8dfccb680fd4d6595682def3a2b85b626f6f.tar.xz
gsoc2013-evolution-d03f8dfccb680fd4d6595682def3a2b85b626f6f.tar.zst
gsoc2013-evolution-d03f8dfccb680fd4d6595682def3a2b85b626f6f.zip
Bug #440316 - Improve SSL Certificate check bad signature dialog
Diffstat (limited to 'mail/e-mail-session.c')
-rw-r--r--mail/e-mail-session.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c
index 39ccbbba80..7e9508cf93 100644
--- a/mail/e-mail-session.c
+++ b/mail/e-mail-session.c
@@ -125,10 +125,10 @@ struct _user_message_msg {
CamelSessionAlertType type;
gchar *prompt;
+ GSList *button_captions;
EFlag *done;
- guint allow_cancel : 1;
- guint result : 1;
+ gint result;
guint ismain : 1;
};
@@ -163,8 +163,8 @@ user_message_response (GtkDialog *dialog,
struct _user_message_msg *m)
{
/* if !allow_cancel, then we've already replied */
- if (m->allow_cancel) {
- m->result = button == GTK_RESPONSE_OK;
+ if (m->button_captions) {
+ m->result = button;
e_flag_set (m->done);
}
@@ -178,6 +178,8 @@ user_message_exec (struct _user_message_msg *m,
{
GtkWindow *parent;
const gchar *error_type;
+ gint index;
+ GSList *iter;
if (!m->ismain && user_message_dialog != NULL) {
g_queue_push_tail (&user_message_queue, mail_msg_ref (m));
@@ -186,19 +188,13 @@ user_message_exec (struct _user_message_msg *m,
switch (m->type) {
case CAMEL_SESSION_ALERT_INFO:
- error_type = m->allow_cancel ?
- "mail:session-message-info-cancel" :
- "mail:session-message-info";
+ error_type = "mail:session-message-info";
break;
case CAMEL_SESSION_ALERT_WARNING:
- error_type = m->allow_cancel ?
- "mail:session-message-warning-cancel" :
- "mail:session-message-warning";
+ error_type = "mail:session-message-warning";
break;
case CAMEL_SESSION_ALERT_ERROR:
- error_type = m->allow_cancel ?
- "mail:session-message-error-cancel" :
- "mail:session-message-error";
+ error_type = "mail:session-message-error";
break;
default:
error_type = NULL;
@@ -211,6 +207,25 @@ user_message_exec (struct _user_message_msg *m,
parent, error_type, m->prompt, NULL);
g_object_set (user_message_dialog, "resizable", TRUE, NULL);
+ if (m->button_captions) {
+ GtkWidget *action_area;
+ GList *children, *child;
+
+ /* remove all default buttons and keep only those requested */
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (user_message_dialog));
+
+ children = gtk_container_get_children (GTK_CONTAINER (action_area));
+ for (child = children; child != NULL; child = child->next) {
+ gtk_container_remove (GTK_CONTAINER (action_area), child->data);
+ }
+
+ g_list_free (children);
+ }
+
+ for (index = 0, iter = m->button_captions; iter; index++, iter = iter->next) {
+ gtk_dialog_add_button (GTK_DIALOG (user_message_dialog), iter->data, index);
+ }
+
/* XXX This is a case where we need to be able to construct
* custom EAlerts without a predefined XML definition. */
if (m->ismain) {
@@ -231,6 +246,7 @@ static void
user_message_free (struct _user_message_msg *m)
{
g_free (m->prompt);
+ g_slist_free_full (m->button_captions, g_free);
e_flag_free (m->done);
}
@@ -915,24 +931,28 @@ mail_session_forget_password (CamelSession *session,
return TRUE;
}
-static gboolean
+static gint
mail_session_alert_user (CamelSession *session,
CamelSessionAlertType type,
const gchar *prompt,
- gboolean cancel)
+ GSList *button_captions)
{
struct _user_message_msg *m;
GCancellable *cancellable;
- gboolean result = TRUE;
+ gint result = -1;
+ GSList *iter;
m = mail_msg_new (&user_message_info);
m->ismain = mail_in_main_thread ();
m->type = type;
m->prompt = g_strdup (prompt);
m->done = e_flag_new ();
- m->allow_cancel = cancel;
+ m->button_captions = g_slist_copy (button_captions);
+
+ for (iter = m->button_captions; iter; iter = iter->next)
+ iter->data = g_strdup (iter->data);
- if (cancel)
+ if (g_slist_length (button_captions) > 1)
mail_msg_ref (m);
cancellable = e_activity_get_cancellable (m->base.activity);
@@ -942,7 +962,7 @@ mail_session_alert_user (CamelSession *session,
else
mail_msg_main_loop_push (m);
- if (cancel) {
+ if (g_slist_length (button_captions) > 1) {
e_flag_wait (m->done);
result = m->result;
mail_msg_unref (m);