aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-session.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-11-17 22:55:48 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-11-17 22:55:48 +0800
commit900d019a0332b24d2bee7ea1407b149fca2c0598 (patch)
tree627edf5d63874be616d41c9a043571a80fc542f5 /mail/e-mail-session.c
parentcdb09641dc6be772931e5381cdf1e6a824a15684 (diff)
parentbadc11edcf5e73bc6148c7b5cdccee739eb9d7ae (diff)
downloadgsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.gz
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.bz2
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.lz
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.xz
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.zst
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.zip
Merge branch 'master' into wip/gsettings
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 af861f575f..f4fcbb26af 100644
--- a/mail/e-mail-session.c
+++ b/mail/e-mail-session.c
@@ -122,10 +122,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;
};
@@ -160,8 +160,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);
}
@@ -175,6 +175,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));
@@ -183,19 +185,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;
@@ -208,6 +204,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) {
@@ -228,6 +243,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);
}
@@ -889,24 +905,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);
@@ -916,7 +936,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);