[evolution/webkit] Fix alignment of extra widgets in EAlertDialogs.



commit aab19b4a1047db5cf7d799da9388108f7b522f4c
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Mar 24 16:47:53 2011 -0400

    Fix alignment of extra widgets in EAlertDialogs.
    
    Add e_alert_dialog_get_content_area(), which returns the GtkVBox
    containing the primary and secondary labels.  Use this instead of
    gtk_dialog_get_content_area() to maintain the dialog's left margin
    beneath the image.

 calendar/gui/dialogs/send-comp.c                   |    2 +-
 e-util/e-alert-dialog.c                            |   23 +++++-
 e-util/e-alert-dialog.h                            |    1 +
 mail/e-mail-reader-utils.c                         |   10 +--
 mail/e-mail-reader.c                               |   79 ++++++++++++--------
 mail/em-utils.c                                    |   18 +++--
 plugins/attachment-reminder/attachment-reminder.c  |   23 +++---
 .../org-gnome-attachment-reminder.error.xml        |    2 +-
 plugins/backup-restore/backup-restore.c            |   17 +++--
 9 files changed, 108 insertions(+), 67 deletions(-)
---
diff --git a/calendar/gui/dialogs/send-comp.c b/calendar/gui/dialogs/send-comp.c
index ab80844..eab2c2c 100644
--- a/calendar/gui/dialogs/send-comp.c
+++ b/calendar/gui/dialogs/send-comp.c
@@ -186,7 +186,7 @@ send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gbo
 	}
 
 	dialog = e_alert_dialog_new_for_args (parent, id, NULL);
-	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+	content_area = e_alert_dialog_get_content_area (E_ALERT_DIALOG (dialog));
 
 	if (strip_alarms)
 		sa_checkbox = add_checkbox (GTK_BOX (content_area), _("Send my alarms with this event"));
diff --git a/e-util/e-alert-dialog.c b/e-util/e-alert-dialog.c
index 6d24dcd..83ef05c 100644
--- a/e-util/e-alert-dialog.c
+++ b/e-util/e-alert-dialog.c
@@ -26,7 +26,7 @@
 #include "e-util.h"
 
 struct _EAlertDialogPrivate {
-	GtkWindow *parent;
+	GtkWidget *content_area;  /* not referenced */
 	EAlert *alert;
 };
 
@@ -184,6 +184,7 @@ alert_dialog_constructed (GObject *object)
 
 	widget = gtk_vbox_new (FALSE, 12);
 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+	dialog->priv->content_area = widget;
 	gtk_widget_show (widget);
 
 	container = widget;
@@ -334,7 +335,7 @@ e_alert_run_dialog_for_args (GtkWindow *parent,
 
 /**
  * e_alert_dialog_get_alert:
- * @dialog: a #EAlertDialog
+ * @dialog: an #EAlertDialog
  *
  * Returns the #EAlert associated with @dialog.
  *
@@ -347,3 +348,21 @@ e_alert_dialog_get_alert (EAlertDialog *dialog)
 
 	return dialog->priv->alert;
 }
+
+/**
+ * e_alert_dialog_get_content_area:
+ * @dialog: an #EAlertDialog
+ *
+ * Returns the vertical box containing the primary and secondary labels.
+ * Use this to pack additional widgets into the dialog with the proper
+ * horizontal alignment (maintaining the left margin below the image).
+ *
+ * Returns: the content area #GtkBox
+ **/
+GtkWidget *
+e_alert_dialog_get_content_area (EAlertDialog *dialog)
+{
+	g_return_val_if_fail (E_IS_ALERT_DIALOG (dialog), NULL);
+
+	return dialog->priv->content_area;
+}
diff --git a/e-util/e-alert-dialog.h b/e-util/e-alert-dialog.h
index 5a23d72..a8d1b1d 100644
--- a/e-util/e-alert-dialog.h
+++ b/e-util/e-alert-dialog.h
@@ -73,6 +73,7 @@ gint		e_alert_run_dialog_for_args	(GtkWindow *parent,
 						 const gchar *tag,
 						 ...) G_GNUC_NULL_TERMINATED;
 EAlert *	e_alert_dialog_get_alert	(EAlertDialog *dialog);
+GtkWidget *	e_alert_dialog_get_content_area	(EAlertDialog *dialog);
 
 G_END_DECLS
 
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index a049e6e..c7b651b 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -70,7 +70,7 @@ e_mail_reader_confirm_delete (EMailReader *reader)
 	CamelFolder *folder;
 	CamelStore *parent_store;
 	GtkWidget *check_button;
-	GtkWidget *content_area;
+	GtkWidget *container;
 	GtkWidget *dialog;
 	GtkWindow *window;
 	const gchar *label;
@@ -104,15 +104,11 @@ e_mail_reader_confirm_delete (EMailReader *reader)
 		window, "mail:ask-delete-vfolder-msg",
 		camel_folder_get_full_name (folder), NULL);
 
-	/* XXX e-error should provide a widget layout and API suitable
-	 *     for packing additional widgets to the right of the alert
-	 *     icon.  But for now, screw it. */
+	container = e_alert_dialog_get_content_area (E_ALERT_DIALOG (dialog));
 
 	label = _("Do not ask me again");
-	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 	check_button = gtk_check_button_new_with_label (label);
-	gtk_box_pack_start (
-		GTK_BOX (content_area), check_button, TRUE, TRUE, 6);
+	gtk_box_pack_start (GTK_BOX (container), check_button, TRUE, TRUE, 6);
 	gtk_widget_show (check_button);
 
 	response = gtk_dialog_run (GTK_DIALOG (dialog));
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index b70bebb..79439d3 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -658,7 +658,8 @@ check_close_browser_reader (EMailReader *reader)
 		if (!parent)
 			parent = e_mail_reader_get_window (reader);
 
-		dialog = e_alert_dialog_new_for_args (parent, "mail:ask-reply-close-browser", NULL);
+		dialog = e_alert_dialog_new_for_args (
+			parent, "mail:ask-reply-close-browser", NULL);
 		response = gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);
 
@@ -1254,18 +1255,22 @@ action_mail_reply_all_check (CamelFolder *folder,
 
 	if (recip_count >= 15) {
 		GtkWidget *dialog;
-		GtkWidget *content_area, *check;
+		GtkWidget *check;
+		GtkWidget *container;
 		gint response;
 
 		dialog = e_alert_dialog_new_for_args (
 			e_mail_reader_get_window (reader),
 			"mail:ask-reply-many-recips", NULL);
 
+		container = e_alert_dialog_get_content_area (
+			E_ALERT_DIALOG (dialog));
+
 		/* Check buttons */
-		check = gtk_check_button_new_with_mnemonic (_("_Do not ask me again."));
-		gtk_container_set_border_width (GTK_CONTAINER (check), 12);
-		content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-		gtk_box_pack_start (GTK_BOX (content_area), check, FALSE, FALSE, 0);
+		check = gtk_check_button_new_with_mnemonic (
+			_("_Do not ask me again."));
+		gtk_box_pack_start (
+			GTK_BOX (container), check, FALSE, FALSE, 0);
 		gtk_widget_show (check);
 
 		response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1282,11 +1287,16 @@ action_mail_reply_all_check (CamelFolder *folder,
 
 		gtk_widget_destroy (dialog);
 
-		if (response == GTK_RESPONSE_NO)
-			type = E_MAIL_REPLY_TO_SENDER;
-		else if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) {
-			g_object_unref (message);
-			return;
+		switch (response) {
+			case GTK_RESPONSE_NO:
+				type = E_MAIL_REPLY_TO_SENDER;
+				break;
+			case GTK_RESPONSE_CANCEL:
+			case GTK_RESPONSE_DELETE_EVENT:
+				g_object_unref (message);
+				return;
+			default:
+				break;
 		}
 	}
 
@@ -1411,20 +1421,22 @@ action_mail_reply_sender_check (CamelFolder *folder,
 	   it's a Reply-To: munged list message... unless we're ignoring munging */
 	if (ask_ignore_list_reply_to || !munged_list_message) {
 		GtkWidget *dialog;
-		GtkWidget *content_area, *check;
+		GtkWidget *check;
+		GtkWidget *container;
 		gint response;
 
 		dialog = e_alert_dialog_new_for_args (
 			e_mail_reader_get_window (reader),
 			"mail:ask-list-private-reply", NULL);
 
+		container = e_alert_dialog_get_content_area (
+			E_ALERT_DIALOG (dialog));
+
 		/* Check buttons */
 		check = gtk_check_button_new_with_mnemonic (
 			_("_Do not ask me again."));
-		gtk_container_set_border_width ((GtkContainer *)check, 12);
-		content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 		gtk_box_pack_start (
-			GTK_BOX (content_area), check, FALSE, FALSE, 0);
+			GTK_BOX (container), check, FALSE, FALSE, 0);
 		gtk_widget_show (check);
 
 		response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1446,8 +1458,7 @@ action_mail_reply_sender_check (CamelFolder *folder,
 
 	} else if (ask_list_reply_to) {
 		GtkWidget *dialog;
-		GtkWidget *content_area;
-		GtkWidget *vbox;
+		GtkWidget *container;
 		GtkWidget *check_again;
 		GtkWidget *check_always_ignore;
 		gint response;
@@ -1456,22 +1467,20 @@ action_mail_reply_sender_check (CamelFolder *folder,
 			e_mail_reader_get_window (reader),
 			"mail:ask-list-honour-reply-to", NULL);
 
-		/*Check buttons*/
-		vbox = gtk_vbox_new (FALSE, 0);
-		content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-		gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
-		gtk_box_pack_start (GTK_BOX (content_area), vbox, FALSE, FALSE, 0);
-		gtk_widget_show (vbox);
+		container = e_alert_dialog_get_content_area (
+			E_ALERT_DIALOG (dialog));
 
 		check_again = gtk_check_button_new_with_mnemonic (
 			_("_Do not ask me again."));
-		gtk_box_pack_start (GTK_BOX (vbox), check_again, FALSE, FALSE, 0);
+		gtk_box_pack_start (
+			GTK_BOX (container), check_again, FALSE, FALSE, 0);
 		gtk_widget_show (check_again);
 
 		check_always_ignore = gtk_check_button_new_with_mnemonic (
 			_("_Always ignore Reply-To: for mailing lists."));
 		gtk_box_pack_start (
-			GTK_BOX (vbox), check_always_ignore, FALSE, FALSE, 0);
+			GTK_BOX (container), check_always_ignore,
+			FALSE, FALSE, 0);
 		gtk_widget_show (check_always_ignore);
 
 		response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1487,13 +1496,19 @@ action_mail_reply_sender_check (CamelFolder *folder,
 
 		gtk_widget_destroy (dialog);
 
-		if (response == GTK_RESPONSE_NO)
-			type = E_MAIL_REPLY_TO_FROM;
-		else if (response == GTK_RESPONSE_OK)
-			type = E_MAIL_REPLY_TO_LIST;
-		else if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) {
-			g_object_unref (message);
-			goto exit;
+		switch (response) {
+			case GTK_RESPONSE_NO:
+				type = E_MAIL_REPLY_TO_FROM;
+				break;
+			case GTK_RESPONSE_OK:
+				type = E_MAIL_REPLY_TO_LIST;
+				break;
+			case GTK_RESPONSE_CANCEL:
+			case GTK_RESPONSE_DELETE_EVENT:
+				g_object_unref (message);
+				goto exit;
+			default:
+				break;
 		}
 	}
 
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 15008ab..e674c61 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -128,7 +128,8 @@ em_utils_prompt_user (GtkWindow *parent,
                       const gchar *tag,
                       ...)
 {
-	GtkWidget *mbox, *check = NULL;
+	GtkWidget *dialog;
+	GtkWidget *check = NULL;
 	GtkWidget *container;
 	va_list ap;
 	gint button;
@@ -146,24 +147,27 @@ em_utils_prompt_user (GtkWindow *parent,
 	alert = e_alert_new_valist (tag, ap);
 	va_end (ap);
 
-	mbox = e_alert_dialog_new (parent, alert);
+	dialog = e_alert_dialog_new (parent, alert);
 	g_object_unref (alert);
 
+	container = e_alert_dialog_get_content_area (E_ALERT_DIALOG (dialog));
+
 	if (promptkey) {
-		check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again"));
-		container = gtk_dialog_get_content_area (GTK_DIALOG (mbox));
-		gtk_box_pack_start (GTK_BOX (container), check, FALSE, FALSE, 0);
+		check = gtk_check_button_new_with_mnemonic (
+			_("_Do not show this message again"));
+		gtk_box_pack_start (
+			GTK_BOX (container), check, FALSE, FALSE, 0);
 		gtk_widget_show (check);
 	}
 
-	button = gtk_dialog_run ((GtkDialog *) mbox);
+	button = gtk_dialog_run (GTK_DIALOG (dialog));
 	if (promptkey)
 		gconf_client_set_bool (
 			client, promptkey,
 			!gtk_toggle_button_get_active (
 			GTK_TOGGLE_BUTTON (check)), NULL);
 
-	gtk_widget_destroy (mbox);
+	gtk_widget_destroy (dialog);
 
 	g_object_unref (client);
 
diff --git a/plugins/attachment-reminder/attachment-reminder.c b/plugins/attachment-reminder/attachment-reminder.c
index 723e8cf..113424b 100644
--- a/plugins/attachment-reminder/attachment-reminder.c
+++ b/plugins/attachment-reminder/attachment-reminder.c
@@ -105,26 +105,29 @@ org_gnome_evolution_attachment_reminder (EPlugin *ep, EMEventTargetComposer *t)
 static gboolean
 ask_for_missing_attachment (EPlugin *ep, GtkWindow *window)
 {
-	GtkWidget *check = NULL;
-	GtkDialog *dialog = NULL;
-	GtkWidget *content_area;
+	GtkWidget *check;
+	GtkWidget *dialog;
+	GtkWidget *container;
 	gint response;
 
-	dialog = (GtkDialog*) e_alert_dialog_new_for_args (
-		window, "org.gnome.evolution.plugins.attachment_reminder:attachment-reminder", NULL);
+	dialog = e_alert_dialog_new_for_args (
+		window, "org.gnome.evolution.plugins.attachment_reminder:"
+		"attachment-reminder", NULL);
+
+	container = e_alert_dialog_get_content_area (E_ALERT_DIALOG (dialog));
 
 	/*Check buttons*/
-	check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again."));
-	content_area = gtk_dialog_get_content_area (dialog);
-	gtk_box_pack_start (GTK_BOX (content_area), check, FALSE, FALSE, 0);
+	check = gtk_check_button_new_with_mnemonic (
+		_("_Do not show this message again."));
+	gtk_box_pack_start (GTK_BOX (container), check, FALSE, FALSE, 0);
 	gtk_widget_show (check);
 
-	response = gtk_dialog_run ((GtkDialog *) dialog);
+	response = gtk_dialog_run (GTK_DIALOG (dialog));
 
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
 		e_plugin_enable (ep, FALSE);
 
-	gtk_widget_destroy ((GtkWidget *)dialog);
+	gtk_widget_destroy (dialog);
 
 	if (response == GTK_RESPONSE_OK)
 		gtk_action_activate (E_COMPOSER_ACTION_ATTACH (window));
diff --git a/plugins/attachment-reminder/org-gnome-attachment-reminder.error.xml b/plugins/attachment-reminder/org-gnome-attachment-reminder.error.xml
index 4d77f44..8728c98 100644
--- a/plugins/attachment-reminder/org-gnome-attachment-reminder.error.xml
+++ b/plugins/attachment-reminder/org-gnome-attachment-reminder.error.xml
@@ -4,7 +4,7 @@
 	<error id="attachment-reminder" type="info">
 		<_primary>Message has no attachments</_primary>
 		<_secondary>Evolution has found some keywords that suggest that this message should contain an attachment, but cannot find one.</_secondary>
-		<button response="GTK_RESPONSE_OK" _label="_Add attachment..."/>
+		<button response="GTK_RESPONSE_OK" _label="_Add Attachment..."/>
 		<button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL" _label="_Edit Message"/>
 		<button response="GTK_RESPONSE_YES" _label="_Send"></button>
 	</error>
diff --git a/plugins/backup-restore/backup-restore.c b/plugins/backup-restore/backup-restore.c
index 2ff0ff1..aa0693e 100644
--- a/plugins/backup-restore/backup-restore.c
+++ b/plugins/backup-restore/backup-restore.c
@@ -113,7 +113,9 @@ sanity_check (const gchar *filename)
 static guint32
 dialog_prompt_user (GtkWindow *parent, const gchar *string, const gchar *tag, ...)
 {
-	GtkWidget *mbox, *check = NULL;
+	GtkWidget *dialog;
+	GtkWidget *check = NULL;
+	GtkWidget *container;
 	va_list ap;
 	gint button;
 	guint32 mask = 0;
@@ -123,24 +125,25 @@ dialog_prompt_user (GtkWindow *parent, const gchar *string, const gchar *tag, ..
 	alert = e_alert_new_valist (tag, ap);
 	va_end (ap);
 
-	mbox = e_alert_dialog_new (parent, alert);
+	dialog = e_alert_dialog_new (parent, alert);
 	g_object_unref (alert);
 
+	container = e_alert_dialog_get_content_area (E_ALERT_DIALOG (dialog));
+
 	check = gtk_check_button_new_with_mnemonic (string);
 	/* We should hardcode this to true */
-	gtk_toggle_button_set_active ((GtkToggleButton *)check, TRUE);
-	gtk_container_set_border_width ((GtkContainer *)check, 12);
-	gtk_box_pack_start ((GtkBox *)gtk_dialog_get_content_area ((GtkDialog *) mbox), check, TRUE, TRUE, 0);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
+	gtk_box_pack_start (GTK_BOX (container), check, FALSE, FALSE, 0);
 	gtk_widget_show (check);
 
-	button = gtk_dialog_run ((GtkDialog *) mbox);
+	button = gtk_dialog_run (GTK_DIALOG (dialog));
 
 	if (button == GTK_RESPONSE_YES)
 		mask |= BR_OK;
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
 		mask |= BR_START;
 
-	gtk_widget_destroy (mbox);
+	gtk_widget_destroy (dialog);
 
 	return mask;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]