evolution r34972 - branches/mbarnes-composer/composer



Author: mbarnes
Date: Thu Feb  7 20:27:37 2008
New Revision: 34972
URL: http://svn.gnome.org/viewvc/evolution?rev=34972&view=rev

Log:
Implement the Security menu as GtkToggleActions.


Modified:
   branches/mbarnes-composer/composer/e-composer-actions.c
   branches/mbarnes-composer/composer/e-composer-actions.h
   branches/mbarnes-composer/composer/e-composer-private.h
   branches/mbarnes-composer/composer/e-msg-composer.c
   branches/mbarnes-composer/composer/e-msg-composer.h
   branches/mbarnes-composer/composer/evolution-composer.ui

Modified: branches/mbarnes-composer/composer/e-composer-actions.c
==============================================================================
--- branches/mbarnes-composer/composer/e-composer-actions.c	(original)
+++ branches/mbarnes-composer/composer/e-composer-actions.c	Thu Feb  7 20:27:37 2008
@@ -52,6 +52,20 @@
 }
 
 static void
+action_pgp_encrypt_cb (GtkToggleAction *action,
+                       EMsgComposer *composer)
+{
+	e_msg_composer_set_changed (composer);
+}
+
+static void
+action_pgp_sign_cb (GtkToggleAction *action,
+                    EMsgComposer *composer)
+{
+	e_msg_composer_set_changed (composer);
+}
+
+static void
 action_print_cb (GtkAction *action,
                  EMsgComposer *composer)
 {
@@ -100,6 +114,20 @@
 }
 
 static void
+action_smime_encrypt_cb (GtkToggleAction *action,
+                         EMsgComposer *composer)
+{
+	e_msg_composer_set_changed (composer);
+}
+
+static void
+action_smime_sign_cb (GtkToggleAction *action,
+                      EMsgComposer *composer)
+{
+	e_msg_composer_set_changed (composer);
+}
+
+static void
 action_view_bcc_cb (GtkToggleAction *action,
                     EMsgComposer *composer)
 {
@@ -244,6 +272,34 @@
 
 static GtkToggleActionEntry toggle_entries[] = {
 
+	{ "pgp-encrypt",
+	  NULL,
+	  N_("PGP _Encrypt"),
+	  NULL,
+	  NULL,
+	  G_CALLBACK (action_pgp_encrypt_cb) },
+
+	{ "pgp-sign",
+	  NULL,
+	  N_("PGP _Sign"),
+	  NULL,
+	  NULL,
+	  G_CALLBACK (action_pgp_sign_cb) },
+
+	{ "smime-encrypt",
+	  NULL,
+	  N_("S/MIME En_crypt"),
+	  NULL,
+	  NULL,
+	  G_CALLBACK (action_smime_encrypt_cb) },
+
+	{ "smime-sign",
+	  NULL,
+	  N_("S/MIME Sig_n"),
+	  NULL,
+	  NULL,
+	  G_CALLBACK (action_smime_sign_cb) },
+
 	{ "view-bcc",
 	  NULL,
 	  N_("_Bcc Field"),
@@ -298,6 +354,7 @@
 {
 	GtkActionGroup *action_group;
 	GtkUIManager *manager;
+	gboolean visible;
 
 	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
@@ -320,4 +377,13 @@
 	g_object_set (
 		G_OBJECT (ACTION (ATTACH)),
 		"short-label", _("Attach"), NULL);
+
+#if defined (HAVE_NSS) && defined (SMIME_SUPPORTED)
+	visible = TRUE;
+#else
+	visible = FALSE;
+#endif
+
+	gtk_action_set_visible (ACTION (SMIME_ENCRYPT), visible);
+	gtk_action_set_visible (ACTION (SMIME_SIGN), visible);
 }

Modified: branches/mbarnes-composer/composer/e-composer-actions.h
==============================================================================
--- branches/mbarnes-composer/composer/e-composer-actions.h	(original)
+++ branches/mbarnes-composer/composer/e-composer-actions.h	Thu Feb  7 20:27:37 2008
@@ -8,6 +8,10 @@
 	E_COMPOSER_ACTION ((composer), "attach")
 #define E_COMPOSER_ACTION_CLOSE(composer) \
 	E_COMPOSER_ACTION ((composer), "close")
+#define E_COMPOSER_ACTION_PGP_ENCRYPT(composer) \
+	E_COMPOSER_ACTION ((composer), "pgp-encrypt")
+#define E_COMPOSER_ACTION_PGP_SIGN(composer) \
+	E_COMPOSER_ACTION ((composer), "pgp-sign")
 #define E_COMPOSER_ACTION_PRINT(composer) \
 	E_COMPOSER_ACTION ((composer), "print")
 #define E_COMPOSER_ACTION_PRINT_PREVIEW(composer) \
@@ -18,8 +22,14 @@
 	E_COMPOSER_ACTION ((composer), "save-as")
 #define E_COMPOSER_ACTION_SAVE_DRAFT(composer) \
 	E_COMPOSER_ACTION ((composer), "save-draft")
+#define E_COMPOSER_ACTION_SECURITY_MENU(composer) \
+	E_COMPOSER_ACTION ((composer), "security-menu")
 #define E_COMPOSER_ACTION_SEND(composer) \
 	E_COMPOSER_ACTION ((composer), "send")
+#define E_COMPOSER_ACTION_SMIME_ENCRYPT(composer) \
+	E_COMPOSER_ACTION ((composer), "smime-encrypt")
+#define E_COMPOSER_ACTION_SMIME_SIGN(composer) \
+	E_COMPOSER_ACTION ((composer), "smime-sign")
 #define E_COMPOSER_ACTION_VIEW_BCC(composer) \
 	E_COMPOSER_ACTION ((composer), "view-bcc")
 #define E_COMPOSER_ACTION_VIEW_CC(composer) \

Modified: branches/mbarnes-composer/composer/e-composer-private.h
==============================================================================
--- branches/mbarnes-composer/composer/e-composer-private.h	(original)
+++ branches/mbarnes-composer/composer/e-composer-private.h	Thu Feb  7 20:27:37 2008
@@ -50,10 +50,6 @@
 	guint32 attachment_bar_visible : 1;
 	guint32 send_html              : 1;
 	guint32 is_alternative         : 1;
-	guint32 pgp_sign               : 1;
-	guint32 pgp_encrypt            : 1;
-	guint32 smime_sign             : 1;
-	guint32 smime_encrypt          : 1;
 	guint32 request_receipt        : 1;
 	guint32 set_priority	       : 1;
 	guint32 has_changed            : 1;

Modified: branches/mbarnes-composer/composer/e-msg-composer.c
==============================================================================
--- branches/mbarnes-composer/composer/e-msg-composer.c	(original)
+++ branches/mbarnes-composer/composer/e-msg-composer.c	Thu Feb  7 20:27:37 2008
@@ -586,6 +586,7 @@
 	EAttachmentBar *attachment_bar =
 		E_ATTACHMENT_BAR (p->attachment_bar);
 	EComposerHeaderTable *table;
+	GtkToggleAction *action;
 	CamelDataWrapper *plain, *html, *current;
 	CamelTransferEncoding plain_encoding;
 	const gchar *iconv_charset = NULL;
@@ -599,6 +600,10 @@
 	GByteArray *data;
 	EAccount *account;
 	gchar *charset;
+	gboolean pgp_sign;
+	gboolean pgp_encrypt;
+	gboolean smime_sign;
+	gboolean smime_encrypt;
 	gint i;
 
 	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
@@ -793,12 +798,25 @@
 
 	camel_exception_init (&ex);
 
-	/* Setup working recipient list if we're encrypting */
-	if (p->pgp_encrypt
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+	pgp_sign = gtk_toggle_action_get_active (action);
+
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
+	pgp_encrypt = gtk_toggle_action_get_active (action);
+
 #if defined (HAVE_NSS) && defined (SMIME_SUPPORTED)
-	    || p->smime_encrypt
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
+	smime_sign = gtk_toggle_action_get_active (action);
+
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
+	smime_encrypt = gtk_toggle_action_get_active (action);
+#else
+	smime_sign = FALSE;
+	smime_encrypt = FALSE;
 #endif
-		) {
+
+	/* Setup working recipient list if we're encrypting */
+	if (pgp_encrypt || smime_encrypt) {
 		gint j;
 		const gchar *types[] = { CAMEL_RECIPIENT_TYPE_TO, CAMEL_RECIPIENT_TYPE_CC, CAMEL_RECIPIENT_TYPE_BCC };
 
@@ -814,7 +832,7 @@
 		}
 	}
 
-	if (p->pgp_sign || p->pgp_encrypt) {
+	if (pgp_sign || pgp_encrypt) {
 		const gchar *pgp_userid;
 		CamelInternetAddress *from = NULL;
 		CamelCipherContext *cipher;
@@ -835,7 +853,7 @@
 			camel_internet_address_get (from, 0, NULL, &pgp_userid);
 		}
 
-		if (p->pgp_sign) {
+		if (pgp_sign) {
 			CamelMimePart *npart = camel_mime_part_new ();
 
 			cipher = mail_crypto_get_pgp_cipher_context (account);
@@ -851,7 +869,7 @@
 			part = npart;
 		}
 
-		if (p->pgp_encrypt) {
+		if (pgp_encrypt) {
 			CamelMimePart *npart = camel_mime_part_new ();
 
 			/* check to see if we should encrypt to self, NB gets removed immediately after use */
@@ -883,7 +901,7 @@
 	}
 
 #if defined (HAVE_NSS) && defined (SMIME_SUPPORTED)
-	if (p->smime_sign || p->smime_encrypt) {
+	if (smime_sign || smime_encrypt) {
 		CamelInternetAddress *from = NULL;
 		CamelCipherContext *cipher;
 
@@ -893,27 +911,27 @@
 			camel_mime_part_set_encoding (part, plain_encoding);
 		camel_object_unref (current);
 
-		if (p->smime_sign
+		if (smime_sign
 		    && (account == NULL || account->smime_sign_key == NULL || account->smime_sign_key[0] == 0)) {
 			camel_exception_set (&ex, CAMEL_EXCEPTION_SYSTEM,
 					     _("Cannot sign outgoing message: No signing certificate set for this account"));
 			goto exception;
 		}
 
-		if (p->smime_encrypt
+		if (smime_encrypt
 		    && (account == NULL || account->smime_sign_key == NULL || account->smime_sign_key[0] == 0)) {
 			camel_exception_set (&ex, CAMEL_EXCEPTION_SYSTEM,
 					     _("Cannot encrypt outgoing message: No encryption certificate set for this account"));
 			goto exception;
 		}
 
-		if (p->smime_sign) {
+		if (smime_sign) {
 			CamelMimePart *npart = camel_mime_part_new ();
 
 			cipher = camel_smime_context_new (session);
 
 			/* if we're also encrypting, envelope-sign rather than clear-sign */
-			if (p->smime_encrypt) {
+			if (smime_encrypt) {
 				camel_smime_context_set_sign_mode ((CamelSMIMEContext *)cipher, CAMEL_SMIME_SIGN_ENVELOPED);
 				camel_smime_context_set_encrypt_key ((CamelSMIMEContext *)cipher, TRUE, account->smime_encrypt_key);
 			} else if (account && account->smime_encrypt_key && *account->smime_encrypt_key) {
@@ -932,7 +950,7 @@
 			part = npart;
 		}
 
-		if (p->smime_encrypt) {
+		if (smime_encrypt) {
 			/* check to see if we should encrypt to self, NB removed after use */
 			if (account->smime_encrypt_to_self)
 				g_ptr_array_add (recipients, g_strdup (account->smime_encrypt_key));
@@ -954,7 +972,7 @@
 			camel_object_unref (from);
 
 		/* we replaced the message directly, we don't want to do reparenting foo */
-		if (p->smime_encrypt) {
+		if (smime_encrypt) {
 			camel_object_unref (part);
 			goto skip_content;
 		} else {
@@ -1707,63 +1725,6 @@
 }
 
 static void
-menu_security_pgp_sign_cb (BonoboUIComponent           *component,
-			   const char                  *path,
-			   Bonobo_UIComponent_EventType type,
-			   const char                  *state,
-			   gpointer                     composer)
-
-{
-	if (type != Bonobo_UIComponent_STATE_CHANGED)
-		return;
-
-	e_msg_composer_set_pgp_sign (E_MSG_COMPOSER (composer), atoi (state));
-}
-
-static void
-menu_security_pgp_encrypt_cb (BonoboUIComponent           *component,
-			      const char                  *path,
-			      Bonobo_UIComponent_EventType type,
-			      const char                  *state,
-			      gpointer                     composer)
-
-{
-	if (type != Bonobo_UIComponent_STATE_CHANGED)
-		return;
-
-	e_msg_composer_set_pgp_encrypt (E_MSG_COMPOSER (composer), atoi (state));
-}
-
-static void
-menu_security_smime_sign_cb (BonoboUIComponent           *component,
-			     const char                  *path,
-			     Bonobo_UIComponent_EventType type,
-			     const char                  *state,
-			     gpointer                     composer)
-
-{
-	if (type != Bonobo_UIComponent_STATE_CHANGED)
-		return;
-
-	e_msg_composer_set_smime_sign (E_MSG_COMPOSER (composer), atoi (state));
-}
-
-static void
-menu_security_smime_encrypt_cb (BonoboUIComponent           *component,
-				const char                  *path,
-				Bonobo_UIComponent_EventType type,
-				const char                  *state,
-				gpointer                     composer)
-
-{
-	if (type != Bonobo_UIComponent_STATE_CHANGED)
-		return;
-
-	e_msg_composer_set_smime_encrypt (E_MSG_COMPOSER (composer), atoi (state));
-}
-
-
-static void
 menu_insert_receipt_cb (BonoboUIComponent           *component,
 			const char                  *path,
 			Bonobo_UIComponent_EventType type,
@@ -1850,7 +1811,6 @@
 	EMMenuTargetWidget *target;
 	EMsgComposerPrivate *p = composer->priv;
 	BonoboUIContainer *container;
-	gboolean hide_smime;
 	char *charset;
 	char *xmlfile;
 
@@ -1913,54 +1873,6 @@
 		p->uic, "SetPriority",
 		menu_insert_priority_cb, composer);
 
-	/* Security -> PGP Sign */
-	bonobo_ui_component_set_prop (
-		p->uic, "/commands/SecurityPGPSign",
-		"state", p->pgp_sign ? "1" : "0", NULL);
-
-	bonobo_ui_component_add_listener (
-		p->uic, "SecurityPGPSign",
-		menu_security_pgp_sign_cb, composer);
-
-	/* Security -> PGP Encrypt */
-	bonobo_ui_component_set_prop (
-		p->uic, "/commands/SecurityPGPEncrypt",
-		"state", p->pgp_encrypt ? "1" : "0", NULL);
-
-	bonobo_ui_component_add_listener (
-		p->uic, "SecurityPGPEncrypt",
-		menu_security_pgp_encrypt_cb, composer);
-
-#if defined (HAVE_NSS) && defined (SMIME_SUPPORTED)
-	hide_smime = FALSE;
-#else
-	hide_smime = TRUE;
-#endif
-
-	/* Security -> S/MIME Sign */
-	bonobo_ui_component_set_prop (
-		p->uic, "/commands/SecuritySMimeSign",
-		"state", p->smime_sign ? "1" : "0", NULL);
-	bonobo_ui_component_set_prop (
-		p->uic, "/commands/SecuritySMimeSign",
-		"hidden", hide_smime ? "1" : "0", NULL);
-
-	bonobo_ui_component_add_listener (
-		p->uic, "SecuritySMimeSign",
-		menu_security_smime_sign_cb, composer);
-
-	/* Security -> S/MIME Encrypt */
-	bonobo_ui_component_set_prop (
-		p->uic, "/commands/SecuritySMimeEncrypt",
-		"state", p->smime_encrypt ? "1" : "0", NULL);
-	bonobo_ui_component_set_prop (
-		p->uic, "/commands/SecuritySMimeEncrypt",
-		"hidden", hide_smime ? "1" : "0", NULL);
-
-	bonobo_ui_component_add_listener (
-		p->uic, "SecuritySMimeEncrypt",
-		menu_security_smime_encrypt_cb, composer);
-
 	bonobo_ui_component_thaw (p->uic, NULL);
 
 	/* Setup main menu plugin mechanism */
@@ -2144,18 +2056,28 @@
 {
 	EMsgComposerPrivate *p = composer->priv;
 	EComposerHeaderTable *table;
+	GtkToggleAction *action;
 	EAccount *account;
+	gboolean active;
 
 	table = e_msg_composer_get_header_table (composer);
 	account = e_composer_header_table_get_account (table);
 
 	if (account) {
-		e_msg_composer_set_pgp_sign (composer,
-					     account->pgp_always_sign &&
-					     (!account->pgp_no_imip_sign || !p->mime_type ||
-					      g_ascii_strncasecmp (p->mime_type, "text/calendar", 13) != 0));
-		e_msg_composer_set_smime_sign (composer, account->smime_sign_default);
-		e_msg_composer_set_smime_encrypt (composer, account->smime_encrypt_default);
+		action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+		active = account->pgp_always_sign &&
+			(!account->pgp_no_imip_sign || !p->mime_type ||
+			g_ascii_strncasecmp (p->mime_type, "text/calendar", 13) != 0);
+		gtk_toggle_action (action, active);
+
+		action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
+		active = account->smime_sign_default;
+		gtk_toggle_action (action, active);
+
+		action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
+		active = account->smime_encrypt_default;
+		gtk_toggle_action (action, active);
+
 		update_auto_recipients (table, UPDATE_AUTO_CC, account->always_cc ? account->cc_addrs : NULL);
 		update_auto_recipients (table, UPDATE_AUTO_BCC, account->always_bcc ? account->bcc_addrs : NULL);
 	} else {
@@ -2672,7 +2594,7 @@
 }
 
 static void
-msg_composer_cut (GtkhtmlEditor *editor)
+msg_composer_cut_clipboard (GtkhtmlEditor *editor)
 {
 	EMsgComposer *composer;
 	GtkWidget *parent;
@@ -2682,15 +2604,17 @@
 	widget = gtk_window_get_focus (GTK_WINDOW (editor));
 	parent = gtk_widget_get_parent (widget);
 
-	if (parent == composer->priv->header_table)
+	if (parent == composer->priv->header_table) {
 		gtk_editable_cut_clipboard (GTK_EDITABLE (widget));
-	else
-		/* Chain up to the parent's cut() method. */
-		GTKHTML_EDITOR_CLASS (parent_class)->cut (editor);
+		return;
+	}
+
+	/* Chain up to parent's cut_clipboard() method. */
+	GTKHTML_EDITOR_CLASS (parent_class)->cut_clipboard (editor);
 }
 
 static void
-msg_composer_copy (GtkhtmlEditor *editor)
+msg_composer_copy_clipboard (GtkhtmlEditor *editor)
 {
 	EMsgComposer *composer;
 	GtkWidget *parent;
@@ -2700,15 +2624,17 @@
 	widget = gtk_window_get_focus (GTK_WINDOW (editor));
 	parent = gtk_widget_get_parent (widget);
 
-	if (parent == composer->priv->header_table)
+	if (parent == composer->priv->header_table) {
 		gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
-	else
-		/* Chain up to the parent's copy() method. */
-		GTKHTML_EDITOR_CLASS (parent_class)->copy (editor);
+		return;
+	}
+
+	/* Chain up to parent's copy_clipboard() method. */
+	GTKHTML_EDITOR_CLASS (parent_class)->copy_clipboard (editor);
 }
 
 static void
-msg_composer_paste (GtkhtmlEditor *editor)
+msg_composer_paste_clipboard (GtkhtmlEditor *editor)
 {
 	EMsgComposer *composer;
 	GtkWidget *parent;
@@ -2718,11 +2644,13 @@
 	widget = gtk_window_get_focus (GTK_WINDOW (editor));
 	parent = gtk_widget_get_parent (widget);
 
-	if (parent == composer->priv->header_table)
+	if (parent == composer->priv->header_table) {
 		gtk_editable_paste_clipboard (GTK_EDITABLE (widget));
-	else
-		/* Chain up to the parent's paste() method. */
-		GTKHTML_EDITOR_CLASS (parent_class)->paste (editor);
+		return;
+	}
+
+	/* Chain up to parent's paste_clipboard() method. */
+	GTKHTML_EDITOR_CLASS (parent_class)->paste_clipboard (editor);
 }
 
 static void
@@ -2771,9 +2699,9 @@
 	widget_class->delete_event = msg_composer_delete_event;
 
 	editor_class = GTKHTML_EDITOR_CLASS (class);
-	editor_class->cut = msg_composer_cut;
-	editor_class->copy = msg_composer_copy;
-	editor_class->paste = msg_composer_paste;
+	editor_class->cut_clipboard = msg_composer_cut_clipboard;
+	editor_class->copy_clipboard = msg_composer_copy_clipboard;
+	editor_class->paste_clipboard = msg_composer_paste_clipboard;
 	editor_class->select_all = msg_composer_select_all;
 
 	signals[SEND] =
@@ -3644,9 +3572,11 @@
 	CamelContentType *content_type;
 	CamelDataWrapper *content;
 	CamelMimePart *mime_part;
+	GtkToggleAction *action;
 
 	/* FIXME: make sure this isn't an s/mime signed part?? */
-	e_msg_composer_set_pgp_sign (composer, TRUE);
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+	gtk_toggle_action_set_active (action, TRUE);
 
 	mime_part = camel_multipart_get_part (multipart, CAMEL_MULTIPART_SIGNED_CONTENT);
 
@@ -3698,9 +3628,11 @@
 	CamelMimePart *mime_part;
 	CamelException ex;
 	CamelCipherValidity *valid;
+	GtkToggleAction *action;
 
 	/* FIXME: make sure this is a PGP/MIME encrypted part?? */
-	e_msg_composer_set_pgp_encrypt (composer, TRUE);
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
+	gtk_toggle_action_set_active (action, TRUE);
 
 	camel_exception_init (&ex);
 	cipher = mail_crypto_get_pgp_cipher_context (NULL);
@@ -3917,7 +3849,7 @@
 	CamelDataWrapper *content;
 	EAccount *account = NULL;
 	gchar *account_name;
-	EMsgComposer *new;
+	EMsgComposer *composer;
 	EComposerHeaderTable *table;
 	struct _camel_header_raw *xev;
 	gint len, i;
@@ -3928,16 +3860,16 @@
 			postto = g_list_append (postto, g_strstrip (g_strdup (headers->value)));
 	}
 
-	new = create_composer (postto ? E_MSG_COMPOSER_VISIBLE_MASK_POST : E_MSG_COMPOSER_VISIBLE_MASK_MAIL);
-	p = new->priv;
+	composer = create_composer (postto ? E_MSG_COMPOSER_VISIBLE_MASK_POST : E_MSG_COMPOSER_VISIBLE_MASK_MAIL);
+	p = composer->priv;
 
-	if (!new) {
+	if (!composer) {
 		g_list_foreach (postto, (GFunc)g_free, NULL);
 		g_list_free (postto);
 		return NULL;
 	}
 
-	table = e_msg_composer_get_header_table (new);
+	table = e_msg_composer_get_header_table (composer);
 
 	if (postto) {
 		e_composer_header_table_set_post_to_list (table, postto);
@@ -4094,20 +4026,27 @@
 
 		flags = g_strsplit (format, ", ", 0);
 		for (i=0;flags[i];i++) {
+			GtkToggleAction *action;
+
 			printf ("restoring draft flag '%s'\n", flags[i]);
 
 			if (g_ascii_strcasecmp (flags[i], "text/html") == 0)
-				e_msg_composer_set_send_html (new, TRUE);
+				e_msg_composer_set_send_html (composer, TRUE);
 			else if (g_ascii_strcasecmp (flags[i], "text/plain") == 0)
-				e_msg_composer_set_send_html (new, FALSE);
-			else if (g_ascii_strcasecmp (flags[i], "pgp-sign") == 0)
-				e_msg_composer_set_pgp_sign (new, TRUE);
-			else if (g_ascii_strcasecmp (flags[i], "pgp-encrypt") == 0)
-				e_msg_composer_set_pgp_encrypt (new, TRUE);
-			else if (g_ascii_strcasecmp (flags[i], "smime-sign") == 0)
-				e_msg_composer_set_smime_sign (new, TRUE);
-			else if (g_ascii_strcasecmp (flags[i], "smime-encrypt") == 0)
-				e_msg_composer_set_smime_encrypt (new, TRUE);
+				e_msg_composer_set_send_html (composer, FALSE);
+			else if (g_ascii_strcasecmp (flags[i], "pgp-sign") == 0) {
+				action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+				gtk_toggle_action_set_active (action, TRUE);
+			} else if (g_ascii_strcasecmp (flags[i], "pgp-encrypt") == 0) {
+				action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
+				gtk_toggle_action_set_active (action, TRUE);
+			} else if (g_ascii_strcasecmp (flags[i], "smime-sign") == 0) {
+				action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
+				gtk_toggle_action_set_active (action, TRUE);
+			} else if (g_ascii_strcasecmp (flags[i], "smime-encrypt") == 0) {
+				action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
+				gtk_toggle_action_set_active (action, TRUE);
+			}
 		}
 		g_strfreev (flags);
 	}
@@ -4118,12 +4057,12 @@
 	
 	/* Check for receipt request */
 	if (camel_medium_get_header (CAMEL_MEDIUM (message), "Disposition-Notification-To")) {
-		e_msg_composer_set_request_receipt (new, TRUE);
+		e_msg_composer_set_request_receipt (composer, TRUE);
 	}
 	
 	/* Check for mail priority */
 	if (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Priority")) {
-		e_msg_composer_set_priority (new, TRUE);
+		e_msg_composer_set_priority (composer, TRUE);
 	}
 
 	/* set extra headers */
@@ -4149,39 +4088,40 @@
 
 		if (CAMEL_IS_MULTIPART_SIGNED (content)) {
 			/* handle the signed content and configure the composer to sign outgoing messages */
-			handle_multipart_signed (new, multipart, 0);
+			handle_multipart_signed (composer, multipart, 0);
 		} else if (CAMEL_IS_MULTIPART_ENCRYPTED (content)) {
 			/* decrypt the encrypted content and configure the composer to encrypt outgoing messages */
-			handle_multipart_encrypted (new, CAMEL_MIME_PART (message), 0);
+			handle_multipart_encrypted (composer, CAMEL_MIME_PART (message), 0);
 		} else if (camel_content_type_is (content_type, "multipart", "alternative")) {
 			/* this contains the text/plain and text/html versions of the message body */
-			handle_multipart_alternative (new, multipart, 0);
+			handle_multipart_alternative (composer, multipart, 0);
 		} else {
 			/* there must be attachments... */
-			handle_multipart (new, multipart, 0);
+			handle_multipart (composer, multipart, 0);
 		}
 	} else {
 		ssize_t length;
 		gchar *html;
 
 		html = em_utils_part_to_html ((CamelMimePart *)message, &length, NULL);
-		e_msg_composer_set_pending_body (new, html, length);
+		e_msg_composer_set_pending_body (composer, html, length);
 	}
 
 	/* We wait until now to set the body text because we need to ensure that
 	 * the attachment bar has all the attachments, before we request them.
 	 */
-	e_msg_composer_flush_pending_body (new, TRUE);
+	e_msg_composer_flush_pending_body (composer, TRUE);
 
-	set_signature_gui (new);
+	set_signature_gui (composer);
 
-	return new;
+	return composer;
 }
 
 static void
 disable_editor (EMsgComposer *composer)
 {
 	GtkhtmlEditor *editor;
+	GtkAction *action;
 
 	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
@@ -4189,9 +4129,14 @@
 
 	gtkhtml_editor_run_command (editor, "editable-off");
 
-	gtk_action_set_sensitive (ACTION (EDIT_MENU), FALSE);
-	gtk_action_set_sensitive (ACTION (FORMAT_MENU), FALSE);
-	gtk_action_set_sensitive (ACTION (INSERT_MENU), FALSE);
+	action = GTKHTML_EDITOR_ACTION_EDIT_MENU (composer);
+	gtk_action_set_sensitive (action, FALSE);
+
+	action = GTKHTML_EDITOR_ACTION_FORMAT_MENU (composer);
+	gtk_action_set_sensitive (action, FALSE);
+
+	action = GTKHTML_EDITOR_ACTION_INSERT_MENU (composer);
+	gtk_action_set_sensitive (action, FALSE);
 
 	gtk_widget_set_sensitive (composer->priv->attachment_bar, FALSE);
 }
@@ -4503,8 +4448,12 @@
 		EAccount *account;
 
 		account = e_composer_header_table_get_account (table);
-		if (account && account->pgp_no_imip_sign)
-			e_msg_composer_set_pgp_sign (composer, FALSE);
+		if (account && account->pgp_no_imip_sign) {
+			GtkToggleAction *action;
+
+			action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+			gtk_toggle_action_set_active (action, FALSE);
+		}
 	}
 }
 
@@ -4726,12 +4675,49 @@
 	return build_message (composer, save_html_object_data);
 }
 
+static gchar *
+msg_composer_get_message_print_helper (EMsgComposer *composer)
+{
+	GtkToggleAction *action;
+	GString *string;
+
+	string = g_string_sized_new (128);
+
+	if (composer->priv->send_html)
+		g_string_append (string, "text/html");
+	else
+		g_string_append (string, "text/plain");
+	composer->priv->send_html = TRUE;
+
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+	if (gtk_toggle_action_get_active (action))
+		g_string_append (string, ", pgp-sign");
+	gtk_toggle_action_set_active (action, FALSE);
+
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
+	if (gtk_toggle_action_get_active (action))
+		g_string_append (string, ", pgp-encrypt");
+	gtk_toggle_action_set_active (action, FALSE);
+
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
+	if (gtk_toggle_action_get_active (action))
+		g_string_append (string, ", smime-sign");
+	gtk_toggle_action_set_active (action, FALSE);
+
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
+	if (gtk_toggle_action_get_active (action))
+		g_string_append (string, ", smime-encrypt");
+	gtk_toggle_action_set_active (action, FALSE);
+
+	return g_string_free (string, FALSE);
+}
+
 CamelMimeMessage *
 e_msg_composer_get_message_print (EMsgComposer *composer, gboolean save_html_object_data)
 {
 	EMsgComposer *temp_composer;
 	CamelMimeMessage *msg;
-	GString *flags;
+	gchar *flags;
 
 	msg = build_message (composer, save_html_object_data);
 	if (msg == NULL)
@@ -4740,36 +4726,16 @@
 	temp_composer = e_msg_composer_new_with_message (msg);
 	camel_object_unref (msg);
 
-	/* build flags string */
-	flags = g_string_sized_new (128);
-	if (temp_composer->priv->send_html)
-		g_string_append (flags, "text/html");
-	else
-		g_string_append (flags, "text/plain");
-	if (temp_composer->priv->pgp_sign)
-		g_string_append (flags, ", pgp-sign");
-	if (temp_composer->priv->pgp_encrypt)
-		g_string_append (flags, ", pgp-encrypt");
-	if (temp_composer->priv->smime_sign)
-		g_string_append (flags, ", smime-sign");
-	if (temp_composer->priv->smime_encrypt)
-		g_string_append (flags, ", smime-encrypt");
-
-	/* override composer flags */
-	temp_composer->priv->send_html = TRUE;
-	temp_composer->priv->pgp_sign = FALSE;
-	temp_composer->priv->pgp_encrypt = FALSE;
-	temp_composer->priv->smime_sign = FALSE;
-	temp_composer->priv->smime_encrypt = FALSE;
+	/* Override composer flags. */
+	flags = msg_composer_get_message_print_helper (temp_composer);
 
 	msg = build_message (temp_composer, save_html_object_data);
 	if (msg != NULL)
 		camel_medium_set_header (
-			CAMEL_MEDIUM (msg),
-			"X-Evolution-Format", flags->str);
+			CAMEL_MEDIUM (msg), "X-Evolution-Format", flags);
 
 	e_msg_composer_delete (temp_composer);
-	g_string_free (flags, TRUE);
+	g_free (flags);
 
 	return msg;
 }
@@ -4778,6 +4744,7 @@
 e_msg_composer_get_message_draft (EMsgComposer *composer)
 {
 	EComposerHeaderTable *table;
+	GtkToggleAction *action;
 	CamelMimeMessage *msg;
 	EAccount *account;
 	gboolean old_flags[4];
@@ -4791,24 +4758,43 @@
 	/* always save drafts as HTML to preserve formatting */
 	old_send_html = p->send_html;
 	p->send_html = TRUE;
-	old_flags[0] = p->pgp_sign;
-	p->pgp_sign = FALSE;
-	old_flags[1] = p->pgp_encrypt;
-	p->pgp_encrypt = FALSE;
-	old_flags[2] = p->smime_sign;
-	p->smime_sign = FALSE;
-	old_flags[3] = p->smime_encrypt;
-	p->smime_encrypt = FALSE;
+
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+	old_flags[0] = gtk_toggle_action_get_active (action);
+	gtk_toggle_action_set_active (action, FALSE);
+
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
+	old_flags[1] = gtk_toggle_action_get_active (action);
+	gtk_toggle_action_set_active (action, FALSE);
+
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
+	old_flags[2] = gtk_toggle_action_get_active (action);
+	gtk_toggle_action_set_active (action, FALSE);
+
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
+	old_flags[3] = gtk_toggle_action_get_active (action);
+	gtk_toggle_action_set_active (action, FALSE);
 
 	msg = build_message (composer, TRUE);
 	if (msg == NULL)
 		return NULL;
 
 	p->send_html = old_send_html;
-	p->pgp_sign = old_flags[0];
-	p->pgp_encrypt = old_flags[1];
-	p->smime_sign = old_flags[2];
-	p->smime_encrypt = old_flags[3];
+
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
+	gtk_toggle_action_set_active (action, old_flags[0]);
+
+	action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
+	gtk_toggle_action_set_active (action, old_flags[1]);
+
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
+	gtk_toggle_action_set_active (action, old_flags[2]);
+
+	action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
+	gtk_toggle_action_set_active (action, old_flags[3]);
+
+	if (msg == NULL)
+		return NULL;
 
 	/* Attach account info to the draft. */
 	account = e_composer_header_table_get_account (table);
@@ -4974,190 +4960,6 @@
 
 
 /**
- * e_msg_composer_set_pgp_sign:
- * @composer: A message composer widget
- * @send_html: Whether the composer should have the "PGP Sign" flag set
- *
- * Set the status of the "PGP Sign" toggle item.  The user can override it.
- **/
-void
-e_msg_composer_set_pgp_sign (EMsgComposer *composer, gboolean pgp_sign)
-{
-#if 0 /* GTKHTML-EDITOR */
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
-
-	if (p->pgp_sign && pgp_sign)
-		return;
-	if (!p->pgp_sign && !pgp_sign)
-		return;
-
-	p->pgp_sign = pgp_sign;
-	e_msg_composer_set_changed (composer);
-
-	bonobo_ui_component_set_prop (p->uic, "/commands/SecurityPGPSign",
-				      "state", p->pgp_sign ? "1" : "0", NULL);
-#endif /* GTKHTML-EDITOR */
-}
-
-
-/**
- * e_msg_composer_get_pgp_sign:
- * @composer: A message composer widget
- *
- * Get the status of the "PGP Sign" flag.
- *
- * Return value: The status of the "PGP Sign" flag.
- **/
-gboolean
-e_msg_composer_get_pgp_sign (EMsgComposer *composer)
-{
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
-
-	return p->pgp_sign;
-}
-
-
-/**
- * e_msg_composer_set_pgp_encrypt:
- * @composer: A message composer widget
- * @send_html: Whether the composer should have the "PGP Encrypt" flag set
- *
- * Set the status of the "PGP Encrypt" toggle item.  The user can override it.
- **/
-void
-e_msg_composer_set_pgp_encrypt (EMsgComposer *composer, gboolean pgp_encrypt)
-{
-#if 0 /* GTKHTML-EDITOR */
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
-
-	if (p->pgp_encrypt && pgp_encrypt)
-		return;
-	if (!p->pgp_encrypt && !pgp_encrypt)
-		return;
-
-	p->pgp_encrypt = pgp_encrypt;
-	e_msg_composer_set_changed (composer);
-
-	bonobo_ui_component_set_prop (p->uic, "/commands/SecurityPGPEncrypt",
-				      "state", p->pgp_encrypt ? "1" : "0", NULL);
-#endif /* GTKHTML-EDITOR */
-}
-
-
-/**
- * e_msg_composer_get_pgp_encrypt:
- * @composer: A message composer widget
- *
- * Get the status of the "PGP Encrypt" flag.
- *
- * Return value: The status of the "PGP Encrypt" flag.
- **/
-gboolean
-e_msg_composer_get_pgp_encrypt (EMsgComposer *composer)
-{
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
-
-	return p->pgp_encrypt;
-}
-
-
-/**
- * e_msg_composer_set_smime_sign:
- * @composer: A message composer widget
- * @send_html: Whether the composer should have the "S/MIME Sign" flag set
- *
- * Set the status of the "S/MIME Sign" toggle item.  The user can override it.
- **/
-void
-e_msg_composer_set_smime_sign (EMsgComposer *composer, gboolean smime_sign)
-{
-#if 0 /* GTKHTML-EDITOR */
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
-
-	if (p->smime_sign && smime_sign)
-		return;
-	if (!p->smime_sign && !smime_sign)
-		return;
-
-	p->smime_sign = smime_sign;
-	e_msg_composer_set_changed (composer);
-
-	bonobo_ui_component_set_prop (p->uic, "/commands/SecuritySMimeSign",
-				      "state", p->smime_sign ? "1" : "0", NULL);
-#endif /* GTKHTML-EDITOR */
-}
-
-
-/**
- * e_msg_composer_get_smime_sign:
- * @composer: A message composer widget
- *
- * Get the status of the "S/MIME Sign" flag.
- *
- * Return value: The status of the "S/MIME Sign" flag.
- **/
-gboolean
-e_msg_composer_get_smime_sign (EMsgComposer *composer)
-{
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
-
-	return p->smime_sign;
-}
-
-
-/**
- * e_msg_composer_set_smime_encrypt:
- * @composer: A message composer widget
- * @send_html: Whether the composer should have the "S/MIME Encrypt" flag set
- *
- * Set the status of the "S/MIME Encrypt" toggle item.  The user can override it.
- **/
-void
-e_msg_composer_set_smime_encrypt (EMsgComposer *composer, gboolean smime_encrypt)
-{
-#if 0 /* GTKHTML-EDITOR */
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
-
-	if (p->smime_encrypt && smime_encrypt)
-		return;
-	if (!p->smime_encrypt && !smime_encrypt)
-		return;
-
-	p->smime_encrypt = smime_encrypt;
-	e_msg_composer_set_changed (composer);
-
-	bonobo_ui_component_set_prop (p->uic, "/commands/SecuritySMimeEncrypt",
-				      "state", p->smime_encrypt ? "1" : "0", NULL);
-#endif /* GTKHTML-EDITOR */
-}
-
-
-/**
- * e_msg_composer_get_smime_encrypt:
- * @composer: A message composer widget
- *
- * Get the status of the "S/MIME Encrypt" flag.
- *
- * Return value: The status of the "S/MIME Encrypt" flag.
- **/
-gboolean
-e_msg_composer_get_smime_encrypt (EMsgComposer *composer)
-{
-	EMsgComposerPrivate *p = composer->priv;
-	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
-
-	return p->smime_encrypt;
-}
-
-
-/**
  * e_msg_composer_get_request_receipt
  * @composer: A message composer widget
  *
@@ -5670,7 +5472,7 @@
 
 	editor = GTKHTML_EDITOR (composer);
 
-	if (!gtkhtml_editor_is_paragraph_empty (composer))
+	if (!gtkhtml_editor_is_paragraph_empty (editor))
 		return;
 
 	data = gtkhtml_editor_get_paragraph_data (editor, "orig");

Modified: branches/mbarnes-composer/composer/e-msg-composer.h
==============================================================================
--- branches/mbarnes-composer/composer/e-msg-composer.h	(original)
+++ branches/mbarnes-composer/composer/e-msg-composer.h	Thu Feb  7 20:27:37 2008
@@ -144,21 +144,6 @@
 void                     e_msg_composer_set_enable_autosave              (EMsgComposer      *composer,
 									  gboolean           enabled);
 
-/* PGP */
-void                     e_msg_composer_set_pgp_sign                     (EMsgComposer      *composer,
-									  gboolean           pgp_sign);
-gboolean                 e_msg_composer_get_pgp_sign                     (EMsgComposer      *composer);
-void                     e_msg_composer_set_pgp_encrypt                  (EMsgComposer      *composer,
-									  gboolean           pgp_encrypt);
-gboolean                 e_msg_composer_get_pgp_encrypt                  (EMsgComposer      *composer);
-
-/* S/MIME */
-void                     e_msg_composer_set_smime_sign                   (EMsgComposer      *composer,
-									  gboolean           smime_sign);
-gboolean                 e_msg_composer_get_smime_sign                   (EMsgComposer      *composer);
-void                     e_msg_composer_set_smime_encrypt                (EMsgComposer      *composer,
-									  gboolean           smime_encrypt);
-gboolean                 e_msg_composer_get_smime_encrypt                (EMsgComposer      *composer);
 gchar                    *e_msg_composer_get_sig_file_content             (const gchar        *sigfile,
 									  gboolean           in_html);
 void                     e_msg_composer_add_message_attachments          (EMsgComposer      *composer,

Modified: branches/mbarnes-composer/composer/evolution-composer.ui
==============================================================================
--- branches/mbarnes-composer/composer/evolution-composer.ui	(original)
+++ branches/mbarnes-composer/composer/evolution-composer.ui	Thu Feb  7 20:27:37 2008
@@ -24,6 +24,12 @@
         <menuitem action='view-bcc'/>
       </menu>
     </placeholder>
+    <menu action='security-menu'>
+      <menuitem action='pgp-sign'/>
+      <menuitem action='pgp-encrypt'/>
+      <menuitem action='smime-sign'/>
+      <menuitem action='smime-encrypt'/>
+    </menu>
   </menubar>
   <toolbar name='main-toolbar'>
     <placeholder name='pre-main-toolbar'>



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