evolution r35301 - branches/mbarnes-composer/composer



Author: mbarnes
Date: Tue Apr  1 18:59:58 2008
New Revision: 35301
URL: http://svn.gnome.org/viewvc/evolution?rev=35301&view=rev

Log:
Initialization cleanup and and some code rearrangement.


Modified:
   branches/mbarnes-composer/composer/e-msg-composer.c

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	Tue Apr  1 18:59:58 2008
@@ -982,6 +982,109 @@
 	return NULL;
 }
 
+/* Attachment Bar */
+
+static void
+emcab_add (EPopup *ep, EPopupItem *item, gpointer data)
+{
+	GtkWidget *widget = data;
+	GtkWidget *composer;
+
+	composer = gtk_widget_get_toplevel (widget);
+	gtk_action_activate (ACTION (ATTACH));
+}
+
+static void
+emcab_properties (EPopup *ep, EPopupItem *item, gpointer data)
+{
+	EAttachmentBar *attachment_bar = data;
+
+	e_attachment_bar_edit_selected (attachment_bar);
+}
+
+static void
+emcab_remove (EPopup *ep, EPopupItem *item, gpointer data)
+{
+	EAttachmentBar *attachment_bar = data;
+
+	e_attachment_bar_remove_selected (attachment_bar);
+}
+
+static void
+emcab_popup_position (GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data)
+{
+	GtkWidget *widget = user_data;
+	GnomeIconList *icon_list = user_data;
+	GList *selection;
+	GnomeCanvasPixbuf *image;
+
+	gdk_window_get_origin (widget->window, x, y);
+
+	selection = gnome_icon_list_get_selection (icon_list);
+	if (selection == NULL)
+		return;
+
+	image = gnome_icon_list_get_icon_pixbuf_item (
+		icon_list, GPOINTER_TO_INT(selection->data));
+	if (image == NULL)
+		return;
+
+	/* Put menu to the center of icon. */
+	*x += (int)(image->item.x1 + image->item.x2) / 2;
+	*y += (int)(image->item.y1 + image->item.y2) / 2;
+}
+
+static void
+emcab_popups_free (EPopup *ep, GSList *list, gpointer data)
+{
+	g_slist_free (list);
+}
+
+/* Popup menu handling.  */
+static EPopupItem emcab_popups[] = {
+	{ E_POPUP_ITEM, "10.attach", N_("_Remove"), emcab_remove, NULL, GTK_STOCK_REMOVE, EM_POPUP_ATTACHMENTS_MANY },
+	{ E_POPUP_ITEM, "20.attach", N_("_Properties"), emcab_properties, NULL, GTK_STOCK_PROPERTIES, EM_POPUP_ATTACHMENTS_ONE },
+	{ E_POPUP_BAR, "30.attach.00", NULL, NULL, NULL, NULL, EM_POPUP_ATTACHMENTS_MANY|EM_POPUP_ATTACHMENTS_ONE },
+	{ E_POPUP_ITEM, "30.attach.01", N_("_Add attachment..."), emcab_add, NULL, GTK_STOCK_ADD, 0 },
+};
+
+/* if id != -1, then use it as an index for target of the popup */
+
+static void
+emcab_popup (EAttachmentBar *bar, GdkEventButton *event, int id)
+{
+	GSList *attachments = NULL, *menus = NULL;
+	int i;
+	EMPopup *emp;
+	EMPopupTargetAttachments *t;
+	GtkMenu *menu;
+
+	attachments = e_attachment_bar_get_attachment (bar, id);
+
+	for (i=0;i<sizeof (emcab_popups)/sizeof (emcab_popups[0]);i++)
+		menus = g_slist_prepend (menus, &emcab_popups[i]);
+
+	/** @HookPoint-EMPopup: Composer Attachment Bar Context Menu
+	 * @Id: org.gnome.evolution.mail.composer.attachmentbar.popup
+	 * @Class: org.gnome.evolution.mail.popup:1.0
+	 * @Target: EMPopupTargetAttachments
+	 *
+	 * This is the context menu on the composer attachment bar.
+	 */
+	emp = em_popup_new ("org.gnome.evolution.mail.composer.attachmentbar.popup");
+	e_popup_add_items ((EPopup *)emp, menus, NULL, emcab_popups_free, bar);
+	t = em_popup_target_new_attachments (emp, attachments);
+	t->target.widget = (GtkWidget *)bar;
+	menu = e_popup_create_menu_once ((EPopup *)emp, (EPopupTarget *)t, 0);
+
+	if (event == NULL)
+		gtk_menu_popup (menu, NULL, NULL, emcab_popup_position, bar, 0, gtk_get_current_event_time ());
+	else
+		gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
+}
+
+/* Signatures */
+
 static gchar *
 get_file_content (EMsgComposer *composer,
                   const gchar *filename,
@@ -1355,8 +1458,31 @@
 
 /* Miscellaneous callbacks.  */
 
+static gint
+attachment_bar_button_press_event_cb (EAttachmentBar *attachment_bar,
+                                      GdkEventButton *event)
+{
+	GnomeIconList *icon_list;
+	gint icon_number;
+
+	if (event->button != 3)
+		return FALSE;
+
+	icon_list = GNOME_ICON_LIST (attachment_bar);
+	icon_number = gnome_icon_list_get_icon_at (
+		icon_list, event->x, event->y);
+	if (icon_number >= 0) {
+		gnome_icon_list_unselect_all (icon_list);
+		gnome_icon_list_select_icon (icon_list, icon_number);
+	}
+
+	emcab_popup (attachment_bar, event, icon_number);
+
+	return TRUE;
+}
+
 static void
-attachment_bar_changed_cb (EAttachmentBar *bar,
+attachment_bar_changed_cb (EAttachmentBar *attachment_bar,
                            EMsgComposer *composer)
 {
 	GtkhtmlEditor *editor;
@@ -1364,7 +1490,7 @@
 	guint attachment_num;
 
 	editor = GTKHTML_EDITOR (composer);
-	attachment_num = e_attachment_bar_get_num_attachments (bar);
+	attachment_num = e_attachment_bar_get_num_attachments (attachment_bar);
 
 	if (attachment_num > 0) {
 		gchar *markup;
@@ -1395,6 +1521,26 @@
 	gtkhtml_editor_set_changed (editor, TRUE);
 }
 
+static gint
+attachment_bar_key_press_event_cb (EAttachmentBar *attachment_bar,
+                                   GdkEventKey *event)
+{
+	if (event->keyval == GDK_Delete) {
+		e_attachment_bar_remove_selected (attachment_bar);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static gboolean
+attachment_bar_popup_menu_cb (EAttachmentBar *attachment_bar)
+{
+	emcab_popup (attachment_bar, NULL, -1);
+
+	return TRUE;
+}
+
 static void
 attachment_expander_notify_cb (GtkExpander *expander,
                                GParamSpec *pspec,
@@ -1591,6 +1737,46 @@
 	camel_object_unref (mime_part);
 }
 
+static void
+msg_composer_update_preferences (GConfClient *client,
+                                 guint cnxn_id,
+                                 GConfEntry *entry,
+                                 EMsgComposer *composer)
+{
+	GtkhtmlEditor *editor;
+	gboolean enable;
+	GError *error = NULL;
+
+	editor = GTKHTML_EDITOR (composer);
+
+	enable = gconf_client_get_bool (
+		client, COMPOSER_GCONF_INLINE_SPELLING_KEY, &error);
+	if (error == NULL)
+		gtkhtml_editor_set_inline_spelling (editor, enable);
+	else {
+		g_warning ("%s", error->message);
+		g_clear_error (&error);
+	}
+
+	enable = gconf_client_get_bool (
+		client, COMPOSER_GCONF_MAGIC_LINKS_KEY, &error);
+	if (error == NULL)
+		gtkhtml_editor_set_magic_links (editor, enable);
+	else {
+		g_warning ("%s", error->message);
+		g_clear_error (&error);
+	}
+
+	enable = gconf_client_get_bool (
+		client, COMPOSER_GCONF_MAGIC_SMILEYS_KEY, &error);
+	if (error == NULL)
+		gtkhtml_editor_set_magic_smileys (editor, enable);
+	else {
+		g_warning ("%s", error->message);
+		g_clear_error (&error);
+	}
+}
+
 struct _drop_data {
 	EMsgComposer *composer;
 
@@ -1842,6 +2028,15 @@
 }
 
 static void
+msg_composer_notify_header_cb (EMsgComposer *composer)
+{
+	GtkhtmlEditor *editor;
+
+	editor = GTKHTML_EDITOR (composer);
+	gtkhtml_editor_set_changed (editor, TRUE);
+}
+
+static void
 msg_composer_dispose (GObject *object)
 {
 	EMsgComposer *composer = E_MSG_COMPOSER (object);
@@ -2411,17 +2606,32 @@
 static void
 msg_composer_init (EMsgComposer *composer)
 {
+	EMsgComposerPrivate *p;
+	EComposerHeaderTable *table;
+#if 0 /* GTKHTML-EDITOR */
+	EMMenuTargetWidget *target;
+#endif
+	GtkToggleAction *action;
+	GConfClient *client;
 	GArray *array;
+	GtkHTML *html;
 	guint binding_id;
+	gboolean active;
 
 	composer->priv = E_MSG_COMPOSER_GET_PRIVATE (composer);
+
 	all_composers = g_slist_prepend (all_composers, composer);
+	html = gtkhtml_editor_get_html (GTKHTML_EDITOR (composer));
+	table = E_COMPOSER_HEADER_TABLE (composer->priv->header_table);
+	client = gconf_client_get_default ();
 
 	e_composer_private_init (composer);
 
 	gtk_window_set_title (GTK_WINDOW (composer), _("Compose Message"));
 	gtk_window_set_icon_name (GTK_WINDOW (composer), "mail-message-new");
 
+	/* Persistent State */
+
 	array = composer->priv->gconf_bridge_binding_ids;
 
 	binding_id = gconf_bridge_bind_property (
@@ -2466,6 +2676,19 @@
 		GTK_WINDOW (composer), TRUE, FALSE);
 	g_array_append_val (array, binding_id);
 
+	/* Drag-and-Drop Support */
+
+	gtk_drag_dest_set (
+		GTK_WIDGET (composer), GTK_DEST_DEFAULT_ALL,
+		drop_types, G_N_ELEMENTS (drop_types),
+		GDK_ACTION_COPY | GDK_ACTION_ASK | GDK_ACTION_MOVE);
+
+	g_signal_connect (
+		html, "drag-data-received",
+		G_CALLBACK (msg_composer_drag_data_received), NULL);
+
+	/* Plugin Support */
+
 #if 0 /* GTKHTML-EDITOR */
 	/** @HookPoint-EMMenu: Main Mail Menu
 	 * @Id: org.gnome.evolution.mail.composer
@@ -2476,292 +2699,19 @@
 	 * target will point to the EMsgComposer object.
 	 */
 	composer->priv->menu = em_menu_new ("org.gnome.evolution.mail.composer");
-#endif
-}
-
-GType
-e_msg_composer_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0)) {
-		static const GTypeInfo type_info = {
-			sizeof (EMsgComposerClass),
-			(GBaseInitFunc) NULL,
-			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) msg_composer_class_init,
-			(GClassFinalizeFunc) NULL,
-			NULL,  /* class_data */
-			sizeof (EMsgComposer),
-			0,     /* n_preallocs */
-			(GInstanceInitFunc) msg_composer_init,
-			NULL   /* value_table */
-		};
-
-		type = g_type_register_static (
-			GTKHTML_TYPE_EDITOR, "EMsgComposer", &type_info, 0);
-	}
-
-	return type;
-}
-
-static void
-msg_composer_update_preferences (GConfClient *client,
-                                 guint cnxn_id,
-                                 GConfEntry *entry,
-                                 EMsgComposer *composer)
-{
-	GtkhtmlEditor *editor;
-	gboolean enable;
-	GError *error = NULL;
-
-	editor = GTKHTML_EDITOR (composer);
-
-	enable = gconf_client_get_bool (
-		client, COMPOSER_GCONF_INLINE_SPELLING_KEY, &error);
-	if (error == NULL)
-		gtkhtml_editor_set_inline_spelling (editor, enable);
-	else {
-		g_warning ("%s", error->message);
-		g_clear_error (&error);
-	}
-
-	enable = gconf_client_get_bool (
-		client, COMPOSER_GCONF_MAGIC_LINKS_KEY, &error);
-	if (error == NULL)
-		gtkhtml_editor_set_magic_links (editor, enable);
-	else {
-		g_warning ("%s", error->message);
-		g_clear_error (&error);
-	}
-
-	enable = gconf_client_get_bool (
-		client, COMPOSER_GCONF_MAGIC_SMILEYS_KEY, &error);
-	if (error == NULL)
-		gtkhtml_editor_set_magic_smileys (editor, enable);
-	else {
-		g_warning ("%s", error->message);
-		g_clear_error (&error);
-	}
-}
-
-/* Callbacks.  */
-
-static void
-emcab_add (EPopup *ep, EPopupItem *item, gpointer data)
-{
-	EAttachmentBar *bar = data;
-	GtkWidget *composer;
-
-	composer = gtk_widget_get_toplevel (GTK_WIDGET (bar));
-	gtk_action_activate (ACTION (ATTACH));
-}
-
-static void
-emcab_properties (EPopup *ep, EPopupItem *item, gpointer data)
-{
-	EAttachmentBar *bar = data;
-
-	e_attachment_bar_edit_selected (bar);
-}
-
-static void
-emcab_remove (EPopup *ep, EPopupItem *item, gpointer data)
-{
-	EAttachmentBar *bar = data;
-
-	e_attachment_bar_remove_selected (bar);
-}
-
-/* Popup menu handling.  */
-static EPopupItem emcab_popups[] = {
-	{ E_POPUP_ITEM, "10.attach", N_("_Remove"), emcab_remove, NULL, GTK_STOCK_REMOVE, EM_POPUP_ATTACHMENTS_MANY },
-	{ E_POPUP_ITEM, "20.attach", N_("_Properties"), emcab_properties, NULL, GTK_STOCK_PROPERTIES, EM_POPUP_ATTACHMENTS_ONE },
-	{ E_POPUP_BAR, "30.attach.00", NULL, NULL, NULL, NULL, EM_POPUP_ATTACHMENTS_MANY|EM_POPUP_ATTACHMENTS_ONE },
-	{ E_POPUP_ITEM, "30.attach.01", N_("_Add attachment..."), emcab_add, NULL, GTK_STOCK_ADD, 0 },
-};
-
-static void
-emcab_popup_position (GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data)
-{
-	EAttachmentBar *bar = user_data;
-	GnomeIconList *icon_list = user_data;
-	GList *selection;
-	GnomeCanvasPixbuf *image;
-
-	gdk_window_get_origin (((GtkWidget*) bar)->window, x, y);
-
-	selection = gnome_icon_list_get_selection (icon_list);
-	if (selection == NULL)
-		return;
-
-	image = gnome_icon_list_get_icon_pixbuf_item (icon_list, GPOINTER_TO_INT(selection->data));
-	if (image == NULL)
-		return;
-
-	/* Put menu to the center of icon. */
-	*x += (int)(image->item.x1 + image->item.x2) / 2;
-	*y += (int)(image->item.y1 + image->item.y2) / 2;
-}
-
-static void
-emcab_popups_free (EPopup *ep, GSList *l, gpointer data)
-{
-	g_slist_free (l);
-}
-
-/* if id != -1, then use it as an index for target of the popup */
-
-static void
-emcab_popup (EAttachmentBar *bar, GdkEventButton *event, int id)
-{
-	GSList *attachments = NULL, *menus = NULL;
-	int i;
-	EMPopup *emp;
-	EMPopupTargetAttachments *t;
-	GtkMenu *menu;
-
-	attachments = e_attachment_bar_get_attachment (bar, id);
-
-	for (i=0;i<sizeof (emcab_popups)/sizeof (emcab_popups[0]);i++)
-		menus = g_slist_prepend (menus, &emcab_popups[i]);
-
-	/** @HookPoint-EMPopup: Composer Attachment Bar Context Menu
-	 * @Id: org.gnome.evolution.mail.composer.attachmentbar.popup
-	 * @Class: org.gnome.evolution.mail.popup:1.0
-	 * @Target: EMPopupTargetAttachments
-	 *
-	 * This is the context menu on the composer attachment bar.
-	 */
-	emp = em_popup_new ("org.gnome.evolution.mail.composer.attachmentbar.popup");
-	e_popup_add_items ((EPopup *)emp, menus, NULL,emcab_popups_free, bar);
-	t = em_popup_target_new_attachments (emp, attachments);
-	t->target.widget = (GtkWidget *)bar;
-	menu = e_popup_create_menu_once ((EPopup *)emp, (EPopupTarget *)t, 0);
-
-	if (event == NULL)
-		gtk_menu_popup (menu, NULL, NULL, emcab_popup_position, bar, 0, gtk_get_current_event_time ());
-	else
-		gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
-}
-
-static gboolean
-popup_menu_event (GtkWidget *widget)
-{
-	emcab_popup ((EAttachmentBar *)widget, NULL, -1);
-	return TRUE;
-}
-
-static int
-button_press_event (GtkWidget *widget, GdkEventButton *event)
-{
-	EAttachmentBar *bar = (EAttachmentBar *)widget;
-	GnomeIconList *icon_list = GNOME_ICON_LIST(widget);
-	int icon_number;
-
-	if (event->button != 3)
-		return FALSE;
-
-	icon_number = gnome_icon_list_get_icon_at (icon_list, event->x, event->y);
-	if (icon_number >= 0) {
-		gnome_icon_list_unselect_all (icon_list);
-		gnome_icon_list_select_icon (icon_list, icon_number);
-	}
-
-	emcab_popup (bar, event, icon_number);
-
-	return TRUE;
-}
-
-static gint
-key_press_event (GtkWidget *widget, GdkEventKey *event)
-{
-	EAttachmentBar *bar = E_ATTACHMENT_BAR(widget);
-
-	if (event->keyval == GDK_Delete) {
-		e_attachment_bar_remove_selected (bar);
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-static void
-msg_composer_notify_header_cb (EMsgComposer *composer)
-{
-	GtkhtmlEditor *editor;
-
-	editor = GTKHTML_EDITOR (composer);
-	gtkhtml_editor_set_changed (editor, TRUE);
-}
-
-static EMsgComposer *
-create_composer (gint visible_mask)
-{
-	EMsgComposer *composer;
-	EComposerHeaderTable *table;
-#if 0 /* GTKHTML-EDITOR */
-	EMMenuTargetWidget *target;
-#endif
-	GConfClient *client;
-	GtkToggleAction *action;
-	EMsgComposerPrivate *p;
-	gboolean active;
-
-	composer = g_object_new (E_TYPE_MSG_COMPOSER, NULL);
-	p = composer->priv;
-
-	client = gconf_client_get_default ();
-
-	/* DND support */
-	gtk_drag_dest_set (
-		GTK_WIDGET (composer), GTK_DEST_DEFAULT_ALL,
-		drop_types, G_N_ELEMENTS (drop_types),
-		GDK_ACTION_COPY | GDK_ACTION_ASK | GDK_ACTION_MOVE);
-
-#if 0 /* GTKHTML-EDITOR */
-	/* Setup main menu plugin mechanism. */
 	target = em_menu_target_new_widget (p->menu, (GtkWidget *)composer);
 	e_menu_update_target ((EMenu *)p->menu, target);
 	e_menu_activate ((EMenu *)p->menu, p->uic, TRUE);
+
 #endif
 
 	/* Configure Headers */
 
-	table = E_COMPOSER_HEADER_TABLE (p->header_table);
-
 	e_composer_header_table_set_account_list (
 		table, mail_config_get_accounts ());
 	e_composer_header_table_set_signature_list (
 		table, mail_config_get_signatures ());
 
-	/* If we're mailing, you cannot disable "To". */
-	action = GTK_TOGGLE_ACTION (ACTION (VIEW_TO));
-	active = visible_mask & E_MSG_COMPOSER_VISIBLE_TO;
-	gtk_action_set_sensitive (ACTION (VIEW_TO), active);
-	gtk_toggle_action_set_active (action, active);
-
-	/* Ditto for "Post-To". */
-	action = GTK_TOGGLE_ACTION (ACTION (VIEW_POST_TO));
-	active = visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO;
-	gtk_action_set_sensitive (ACTION (VIEW_POST_TO), active);
-	gtk_toggle_action_set_active (action, active);
-
-	/* Disable "Cc" if we're posting. */
-	if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_CC)) {
-		action = GTK_TOGGLE_ACTION (ACTION (VIEW_CC));
-		gtk_toggle_action_set_active (action, FALSE);
-	}
-
-	/* Disable "Bcc" if we're posting. */
-	if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_BCC)) {
-		action = GTK_TOGGLE_ACTION (ACTION (VIEW_BCC));
-		gtk_toggle_action_set_active (action, FALSE);
-	}
-
-	action = GTK_TOGGLE_ACTION (ACTION (VIEW_SUBJECT));
-	gtk_toggle_action_set_active (action, TRUE);
-
 	g_signal_connect_swapped (
 		table, "notify::account",
 		G_CALLBACK (msg_composer_account_changed_cb), composer);
@@ -2800,7 +2750,6 @@
 		client, COMPOSER_GCONF_REQUEST_RECEIPT_KEY, NULL);
 	gtk_toggle_action_set_active (action, active);
 
-	/* Listen for user preference updates. */
 	gconf_client_add_dir (
 		client, COMPOSER_GCONF_PREFIX,
 		GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
@@ -2813,13 +2762,13 @@
 
 	g_signal_connect (
 		p->attachment_bar, "button_press_event",
-		G_CALLBACK (button_press_event), NULL);
+		G_CALLBACK (attachment_bar_button_press_event_cb), NULL);
 	g_signal_connect (
 		p->attachment_bar, "key_press_event",
-		G_CALLBACK (key_press_event), NULL);
+		G_CALLBACK (attachment_bar_key_press_event_cb), NULL);
 	g_signal_connect (
 		p->attachment_bar, "popup-menu",
-		G_CALLBACK (popup_menu_event), NULL);
+		G_CALLBACK (attachment_bar_popup_menu_cb), NULL);
 	g_signal_connect (
 		p->attachment_bar, "changed",
 		G_CALLBACK (attachment_bar_changed_cb), composer);
@@ -2827,17 +2776,83 @@
 		p->attachment_expander, "notify::expanded",
 		G_CALLBACK (attachment_expander_notify_cb), composer);
 
-	g_signal_connect (
-		gtkhtml_editor_get_html (GTKHTML_EDITOR (composer)),
-		"drag_data_received",
-		G_CALLBACK (msg_composer_drag_data_received), NULL);
-
 	e_composer_autosave_register (composer);
 
 	/* Initialization may have tripped the "changed" state. */
 	gtkhtml_editor_set_changed (GTKHTML_EDITOR (composer), FALSE);
 
 	g_object_unref (client);
+}
+
+GType
+e_msg_composer_get_type (void)
+{
+	static GType type = 0;
+
+	if (G_UNLIKELY (type == 0)) {
+		static const GTypeInfo type_info = {
+			sizeof (EMsgComposerClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) msg_composer_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,  /* class_data */
+			sizeof (EMsgComposer),
+			0,     /* n_preallocs */
+			(GInstanceInitFunc) msg_composer_init,
+			NULL   /* value_table */
+		};
+
+		type = g_type_register_static (
+			GTKHTML_TYPE_EDITOR, "EMsgComposer", &type_info, 0);
+	}
+
+	return type;
+}
+
+/* Callbacks.  */
+
+static EMsgComposer *
+create_composer (gint visible_mask)
+{
+	EMsgComposer *composer;
+	EMsgComposerPrivate *p;
+	EComposerHeaderTable *table;
+	GtkToggleAction *action;
+	gboolean active;
+
+	composer = g_object_new (E_TYPE_MSG_COMPOSER, NULL);
+	table = E_COMPOSER_HEADER_TABLE (composer->priv->header_table);
+	p = composer->priv;
+
+	/* Configure View Menu */
+
+	/* If we're mailing, you cannot disable "To". */
+	action = GTK_TOGGLE_ACTION (ACTION (VIEW_TO));
+	active = visible_mask & E_MSG_COMPOSER_VISIBLE_TO;
+	gtk_action_set_sensitive (ACTION (VIEW_TO), active);
+	gtk_toggle_action_set_active (action, active);
+
+	/* Ditto for "Post-To". */
+	action = GTK_TOGGLE_ACTION (ACTION (VIEW_POST_TO));
+	active = visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO;
+	gtk_action_set_sensitive (ACTION (VIEW_POST_TO), active);
+	gtk_toggle_action_set_active (action, active);
+
+	/* Disable "Cc" if we're posting. */
+	if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_CC)) {
+		action = GTK_TOGGLE_ACTION (ACTION (VIEW_CC));
+		gtk_toggle_action_set_active (action, FALSE);
+	}
+
+	/* Disable "Bcc" if we're posting. */
+	if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_BCC)) {
+		action = GTK_TOGGLE_ACTION (ACTION (VIEW_BCC));
+		gtk_toggle_action_set_active (action, FALSE);
+	}
+
+	action = GTK_TOGGLE_ACTION (ACTION (VIEW_SUBJECT));
+	gtk_toggle_action_set_active (action, TRUE);
 
 	return composer;
 }



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