diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-10-01 00:28:29 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-10-01 00:28:29 +0800 |
commit | 75be8d77019b08759864d4405dbdbcbfef98ced5 (patch) | |
tree | 1afb0410e183cd5c1ec18458aa1cb7e3e66e101e | |
parent | 4674fb54872a093b9e116de91e7122c42be735fa (diff) | |
download | gsoc2013-evolution-75be8d77019b08759864d4405dbdbcbfef98ced5.tar gsoc2013-evolution-75be8d77019b08759864d4405dbdbcbfef98ced5.tar.gz gsoc2013-evolution-75be8d77019b08759864d4405dbdbcbfef98ced5.tar.bz2 gsoc2013-evolution-75be8d77019b08759864d4405dbdbcbfef98ced5.tar.lz gsoc2013-evolution-75be8d77019b08759864d4405dbdbcbfef98ced5.tar.xz gsoc2013-evolution-75be8d77019b08759864d4405dbdbcbfef98ced5.tar.zst gsoc2013-evolution-75be8d77019b08759864d4405dbdbcbfef98ced5.zip |
Bug 659486 - EAlert default response is ignored by EAlertDialog
-rw-r--r-- | composer/mail-composer.error.xml | 2 | ||||
-rw-r--r-- | e-util/e-alert-dialog.c | 28 |
2 files changed, 23 insertions, 7 deletions
diff --git a/composer/mail-composer.error.xml b/composer/mail-composer.error.xml index 7398f17442..0f6f11d429 100644 --- a/composer/mail-composer.error.xml +++ b/composer/mail-composer.error.xml @@ -35,7 +35,7 @@ <button _label="_Send" response="GTK_RESPONSE_YES"/> </error> - <error id="exit-unsaved" type="warning" default="GTK_RESPONSE_YES"> + <error id="exit-unsaved" type="warning" default="GTK_RESPONSE_CANCEL"> <_primary>Are you sure you want to discard the message, titled '{0}', you are composing?</_primary> <_secondary>Closing this composer window will discard the message permanently, unless you choose to save the message in your Drafts folder. This will allow you to continue the message at a later date.</_secondary> <button _label="_Discard Changes" response="GTK_RESPONSE_NO"/> diff --git a/e-util/e-alert-dialog.c b/e-util/e-alert-dialog.c index 8696588ab2..70e53432f3 100644 --- a/e-util/e-alert-dialog.c +++ b/e-util/e-alert-dialog.c @@ -120,6 +120,7 @@ alert_dialog_constructed (GObject *object) PangoAttrList *list; GList *actions; const gchar *primary, *secondary; + gint default_response; gint min_width = -1, prefer_width = -1; gint height; @@ -129,6 +130,8 @@ alert_dialog_constructed (GObject *object) dialog = E_ALERT_DIALOG (object); alert = e_alert_dialog_get_alert (dialog); + default_response = e_alert_get_default_response (alert); + gtk_window_set_title (GTK_WINDOW (dialog), " "); action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); @@ -149,15 +152,19 @@ alert_dialog_constructed (GObject *object) actions = e_alert_peek_actions (alert); while (actions != NULL) { GtkWidget *button; + gpointer data; /* These actions are already wired to trigger an * EAlert::response signal when activated, which * will in turn call to gtk_dialog_response(), * so we can add buttons directly to the action - * area without knowing their response IDs. */ + * area without knowing their response IDs. + * (XXX Well, kind of. See below.) */ button = gtk_button_new (); + gtk_widget_set_can_default (button, TRUE); + gtk_activatable_set_related_action ( GTK_ACTIVATABLE (button), GTK_ACTION (actions->data)); @@ -166,14 +173,23 @@ alert_dialog_constructed (GObject *object) GTK_BOX (action_area), button, FALSE, FALSE, 0); + /* This is set in e_alert_add_action(). */ + data = g_object_get_data ( + actions->data, "e-alert-response-id"); + + /* Normally GtkDialog sets the initial focus widget to + * the button corresponding to the default response, but + * because the buttons are not directly tied to response + * IDs, we have set both the default widget and the + * initial focus widget ourselves. */ + if (GPOINTER_TO_INT (data) == default_response) { + gtk_widget_grab_default (button); + gtk_widget_grab_focus (button); + } + actions = g_list_next (actions); } - if (e_alert_get_default_response (alert)) - gtk_dialog_set_default_response ( - GTK_DIALOG (dialog), - e_alert_get_default_response (alert)); - widget = gtk_hbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (widget), 12); gtk_box_pack_start (GTK_BOX (content_area), widget, FALSE, FALSE, 0); |