diff options
author | Miguel de Icaza <miguel@ximian.com> | 2001-03-08 10:06:26 +0800 |
---|---|---|
committer | Miguel de Icaza <miguel@src.gnome.org> | 2001-03-08 10:06:26 +0800 |
commit | 6145f688cc4154f580c4443f999fd14a027a14d8 (patch) | |
tree | b9be6d5401b7c17610310581f561ba3cfffcbf63 | |
parent | 3f72523dfa9fcbea86538b37130b863fc805e7ec (diff) | |
download | gsoc2013-evolution-6145f688cc4154f580c4443f999fd14a027a14d8.tar gsoc2013-evolution-6145f688cc4154f580c4443f999fd14a027a14d8.tar.gz gsoc2013-evolution-6145f688cc4154f580c4443f999fd14a027a14d8.tar.bz2 gsoc2013-evolution-6145f688cc4154f580c4443f999fd14a027a14d8.tar.lz gsoc2013-evolution-6145f688cc4154f580c4443f999fd14a027a14d8.tar.xz gsoc2013-evolution-6145f688cc4154f580c4443f999fd14a027a14d8.tar.zst gsoc2013-evolution-6145f688cc4154f580c4443f999fd14a027a14d8.zip |
New function. Used to store integer values into the configuration engine.
2001-03-06 Miguel de Icaza <miguel@ximian.com>
* e-msg-composer.c (set_config): New function. Used to store
integer values into the configuration engine. Handles the case of
Bonobo-conf being installed, or falls back to gnome_config.
* e-msg-composer-hdrs.c (add_header): Renamed to be
header_new_recipient(). Now we take care of the other cases in
create_headers, which is a lot nicer now.
(create_optionmenu): Removed extra "name" argument which was not
being used anyways (the only arg passed was From:).
(init): Removed all the redundant NULL initialization by using
nice g_new0
(create_headers): New function, much cleaner.
Use of Pair structure everywhere instead of individual widgets to
keep track of which ones are visible and which ones are not.
* e-msg-composer.c (setup_ui): Handle ViewFrom and ViewBCC
commands.
(menu_view_bcc_cb, menu_view_from_cb): New functions that
implement the features described.
(menu_format_html_cb): Removed unrequired test, as
e_msg_composer_set_send_html already optimizes the case of the
state being the same.
(menu_security_pgp_encrypt_cb): Remove redundant code.
(menu_security_pgp_sign_cb): ditto.
2001-03-06 Miguel de Icaza <miguel@ximian.com>
* evolution-message-composer.xml: Reorder menus to be File, Edit,
View, Insert, Format (instead of File, Edit, Format, View, Insert).
Add View/From Field and View/From BCC
Add Insert/File.
Add File/Send menu item.
Change the look to follow the "mailer" look (thiner display).
svn path=/trunk/; revision=8590
-rw-r--r-- | composer/ChangeLog | 31 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.c | 425 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.h | 13 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 361 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 24 | ||||
-rw-r--r-- | ui/ChangeLog | 13 | ||||
-rw-r--r-- | ui/evolution-message-composer.xml | 53 |
7 files changed, 645 insertions, 275 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 0c4683df8a..d900bee606 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,34 @@ +2001-03-06 Miguel de Icaza <miguel@ximian.com> + + * e-msg-composer.c (set_config): New function. Used to store + integer values into the configuration engine. Handles the case of + Bonobo-conf being installed, or falls back to gnome_config. + + * e-msg-composer-hdrs.c (add_header): Renamed to be + header_new_recipient(). Now we take care of the other cases in + create_headers, which is a lot nicer now. + + (create_optionmenu): Removed extra "name" argument which was not + being used anyways (the only arg passed was From:). + (init): Removed all the redundant NULL initialization by using + nice g_new0 + + (create_headers): New function, much cleaner. + + Use of Pair structure everywhere instead of individual widgets to + keep track of which ones are visible and which ones are not. + + * e-msg-composer.c (setup_ui): Handle ViewFrom and ViewBCC + commands. + (menu_view_bcc_cb, menu_view_from_cb): New functions that + implement the features described. + + (menu_format_html_cb): Removed unrequired test, as + e_msg_composer_set_send_html already optimizes the case of the + state being the same. + (menu_security_pgp_encrypt_cb): Remove redundant code. + (menu_security_pgp_sign_cb): ditto. + 2001-03-02 Jeffrey Stedfast <fejj@ximian.com> * e-icon-list.c (icon_new_from_pixbuf): Added a comment reminding diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c index 3fa0634e52..57ae25a5f8 100644 --- a/composer/e-msg-composer-hdrs.c +++ b/composer/e-msg-composer-hdrs.c @@ -43,23 +43,29 @@ #define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames" +/* Indexes in the GtkTable assigned to various items */ + +#define LINE_FROM 0 +#define LINE_TO 1 +#define LINE_CC 2 +#define LINE_BCC 3 +#define LINE_SUBJECT 4 + +typedef struct { + GtkWidget *label; + GtkWidget *entry; +} Pair; + struct _EMsgComposerHdrsPrivate { GNOME_Evolution_Addressbook_SelectNames corba_select_names; - /* Total number of headers that we have. */ - guint num_hdrs; - /* The tooltips. */ GtkTooltips *tooltips; GSList *from_options; /* Standard headers. */ - GtkWidget *from_entry; - GtkWidget *to_entry; - GtkWidget *cc_entry; - GtkWidget *bcc_entry; - GtkWidget *subject_entry; + Pair from, to, cc, bcc, subject; }; @@ -72,12 +78,6 @@ enum { LAST_SIGNAL }; -enum { - HEADER_ADDRBOOK, - HEADER_OPTIONMENU, - HEADER_ENTRYBOX -}; - static gint signals[LAST_SIGNAL]; @@ -150,7 +150,8 @@ address_button_clicked_cb (GtkButton *button, CORBA_exception_init (&ev); - GNOME_Evolution_Addressbook_SelectNames_activateDialog (priv->corba_select_names, emchas->string, &ev); + GNOME_Evolution_Addressbook_SelectNames_activateDialog ( + priv->corba_select_names, emchas->string, &ev); CORBA_exception_free (&ev); } @@ -164,67 +165,65 @@ from_changed (GtkWidget *item, gpointer data) } static GtkWidget * -create_optionmenu (EMsgComposerHdrs *hdrs, - const char *name) +create_from_optionmenu (EMsgComposerHdrs *hdrs) { GtkWidget *omenu, *menu, *first = NULL; + const GSList *accounts; + GtkWidget *item; int i = 0, history = 0; omenu = gtk_option_menu_new (); menu = gtk_menu_new (); - if (!strcmp (name, _("From:"))) { - const GSList *accounts; - GtkWidget *item; - accounts = mail_config_get_accounts (); - while (accounts) { - const MailConfigAccount *account; - char *label; - char *native_label; - - account = accounts->data; - - /* this should never ever fail */ - if (!account || !account->name || !account->id) { - g_assert_not_reached (); - continue; - } - - if (strcmp (account->name, account->id->address)) - label = g_strdup_printf ("%s <%s> (%s)", account->id->name, - account->id->address, account->name); - else - label = g_strdup_printf ("%s <%s>", account->id->name, account->id->address); - - - native_label = e_utf8_to_gtk_string (GTK_WIDGET (menu), label); - item = gtk_menu_item_new_with_label (native_label); - g_free (native_label); - g_free (label); - - gtk_object_set_data (GTK_OBJECT (item), "account", account_copy (account)); - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (from_changed), hdrs); - - if (account->default_account) { - first = item; - history = i; - } - - /* this is so we can later set which one we want */ - hdrs->priv->from_options = g_slist_append (hdrs->priv->from_options, item); - - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - - accounts = accounts->next; - i++; + accounts = mail_config_get_accounts (); + while (accounts) { + const MailConfigAccount *account; + char *label; + char *native_label; + + account = accounts->data; + + /* this should never ever fail */ + if (!account || !account->name || !account->id) { + g_assert_not_reached (); + continue; } + + if (strcmp (account->name, account->id->address)) + label = g_strdup_printf ("%s <%s> (%s)", account->id->name, + account->id->address, account->name); + else + label = g_strdup_printf ("%s <%s>", account->id->name, account->id->address); + + + native_label = e_utf8_to_gtk_string (GTK_WIDGET (menu), label); + item = gtk_menu_item_new_with_label (native_label); + g_free (native_label); + g_free (label); + + gtk_object_set_data (GTK_OBJECT (item), "account", account_copy (account)); + gtk_signal_connect (GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (from_changed), hdrs); + + if (account->default_account) { + first = item; + history = i; + } + + /* this is so we can later set which one we want */ + hdrs->priv->from_options = g_slist_append (hdrs->priv->from_options, item); + + gtk_menu_append (GTK_MENU (menu), item); + gtk_widget_show (item); + + accounts = accounts->next; + i++; } gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); - if (first) { + + if (first){ gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), history); gtk_signal_emit_by_name (GTK_OBJECT (first), "activate", hdrs); } @@ -261,13 +260,16 @@ create_addressbook_entry (EMsgComposerHdrs *hdrs, CORBA_exception_init (&ev); - GNOME_Evolution_Addressbook_SelectNames_addSection (corba_select_names, name, name, &ev); + GNOME_Evolution_Addressbook_SelectNames_addSection ( + corba_select_names, name, name, &ev); if (ev._major != CORBA_NO_EXCEPTION) { CORBA_exception_free (&ev); return NULL; } - corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (corba_select_names, name, &ev); + corba_control = + GNOME_Evolution_Addressbook_SelectNames_getEntryBySection ( + corba_select_names, name, &ev); if (ev._major != CORBA_NO_EXCEPTION) { CORBA_exception_free (&ev); @@ -276,18 +278,47 @@ create_addressbook_entry (EMsgComposerHdrs *hdrs, CORBA_exception_free (&ev); - control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + control_widget = bonobo_widget_new_control_from_objref ( + corba_control, CORBA_OBJECT_NIL); cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (control_widget)); pb = bonobo_control_frame_get_control_property_bag (cf, NULL); - bonobo_event_source_client_add_listener (pb, addressbook_entry_changed, - "Bonobo/Property:change:entry_changed", - NULL, hdrs); + bonobo_event_source_client_add_listener ( + pb, addressbook_entry_changed, + "Bonobo/Property:change:entry_changed", + NULL, hdrs); return control_widget; } +static Pair +header_new_recipient (EMsgComposerHdrs *hdrs, const gchar *name, const gchar *tip) +{ + EMsgComposerHdrsPrivate *priv; + Pair ret; + + priv = hdrs->priv; + + ret.label = gtk_button_new_with_label (name); + GTK_OBJECT_UNSET_FLAGS (ret.label, GTK_CAN_FOCUS); + gtk_signal_connect_full ( + GTK_OBJECT (ret.label), "clicked", + GTK_SIGNAL_FUNC (address_button_clicked_cb), NULL, + e_msg_composer_hdrs_and_string_create(hdrs, name), + (GtkDestroyNotify) e_msg_composer_hdrs_and_string_free, + FALSE, FALSE); + + gtk_tooltips_set_tip ( + hdrs->priv->tooltips, ret.label, + _("Click here for the address book"), + NULL); + + ret.entry = create_addressbook_entry (hdrs, name); + + return ret; +} + static void entry_changed (GtkWidget *entry, EMsgComposerHdrs *hdrs) { @@ -303,115 +334,131 @@ entry_changed (GtkWidget *entry, EMsgComposerHdrs *hdrs) gtk_signal_emit (GTK_OBJECT (hdrs), signals[HDRS_CHANGED]); } -static GtkWidget * -add_header (EMsgComposerHdrs *hdrs, - const gchar *name, - const gchar *tip, - const gchar *tip_private, - int type) +static void +create_headers (EMsgComposerHdrs *hdrs) +{ + EMsgComposerHdrsPrivate *priv = hdrs->priv; + + /* + * From: + */ + priv->from.label = gtk_label_new (_("From:")); + priv->from.entry = create_from_optionmenu (hdrs); + + /* + * Subject: + */ + priv->subject.label = gtk_label_new (_("Subject:")); + priv->subject.entry = e_entry_new (); + gtk_object_set (GTK_OBJECT (priv->subject.entry), + "editable", TRUE, + "use_ellipsis", TRUE, + "allow_newlines", FALSE, + NULL); + gtk_signal_connect (GTK_OBJECT (priv->subject.entry), "changed", + GTK_SIGNAL_FUNC (entry_changed), hdrs); + + /* + * To: CC: and Bcc: + */ + priv->to = header_new_recipient ( + hdrs, _("To:"), + _("Enter the recipients of the message")); + + priv->cc = header_new_recipient ( + hdrs, _("Cc:"), + _("Enter the addresses that will receive a carbon copy of the message")); + + priv->bcc = header_new_recipient ( + hdrs, _("Bcc:"), + _("Enter the addresses that will receive a carbon copy of " + "the message without appearing in the recipient list of " + "the message.")); +} + +static void +attach_couple (EMsgComposerHdrs *hdrs, Pair *pair, int line) { - EMsgComposerHdrsPrivate *priv; - GtkWidget *label; - GtkWidget *entry; - guint pad; + int pad; - priv = hdrs->priv; - - if (type == HEADER_ADDRBOOK) { - label = gtk_button_new_with_label (name); - GTK_OBJECT_UNSET_FLAGS (label, GTK_CAN_FOCUS); - gtk_signal_connect_full (GTK_OBJECT (label), "clicked", - GTK_SIGNAL_FUNC (address_button_clicked_cb), NULL, - e_msg_composer_hdrs_and_string_create(hdrs, name), - (GtkDestroyNotify) e_msg_composer_hdrs_and_string_free, - FALSE, FALSE); - pad = 2; - gtk_tooltips_set_tip (hdrs->priv->tooltips, label, - _("Click here for the address book"), - NULL); - } else { - label = gtk_label_new (name); + if (GTK_IS_LABEL (pair->label)) pad = GNOME_PAD; - } + else + pad = 2; - gtk_table_attach (GTK_TABLE (hdrs), label, - 0, 1, priv->num_hdrs, priv->num_hdrs + 1, - GTK_FILL, GTK_FILL, - pad, pad); - gtk_widget_show (label); - - switch (type) { - case HEADER_ADDRBOOK: - entry = create_addressbook_entry (hdrs, name); - break; - case HEADER_OPTIONMENU: - entry = create_optionmenu (hdrs, name); - break; - case HEADER_ENTRYBOX: - default: - entry = e_entry_new (); - gtk_object_set (GTK_OBJECT(entry), - "editable", TRUE, - "use_ellipsis", TRUE, - "allow_newlines", FALSE, - NULL); - gtk_signal_connect (GTK_OBJECT (entry), "changed", - GTK_SIGNAL_FUNC (entry_changed), hdrs); - } + gtk_table_attach ( + GTK_TABLE (hdrs), + pair->label, 0, 1, + line, line + 1, + GTK_FILL, GTK_FILL, pad, pad); - if (entry != NULL) { - gtk_widget_show (entry); - - gtk_table_attach (GTK_TABLE (hdrs), entry, - 1, 2, priv->num_hdrs, priv->num_hdrs + 1, - GTK_FILL | GTK_EXPAND, 0, - 2, 2); - - gtk_tooltips_set_tip (hdrs->priv->tooltips, entry, tip, tip_private); + gtk_table_attach ( + GTK_TABLE (hdrs), + pair->entry, 1, 2, + line, line + 1, + GTK_FILL | GTK_EXPAND, 0, 2, 2); +} + +static void +attach_headers (EMsgComposerHdrs *hdrs) +{ + EMsgComposerHdrsPrivate *p = hdrs->priv; + + attach_couple (hdrs, &p->from, LINE_FROM); + attach_couple (hdrs, &p->to, LINE_TO); + attach_couple (hdrs, &p->cc, LINE_CC); + attach_couple (hdrs, &p->bcc, LINE_BCC); + attach_couple (hdrs, &p->subject, LINE_SUBJECT); +} + +static void +set_pair_visibility (EMsgComposerHdrs *h, Pair *pair, gboolean visible) +{ + if (visible){ + gtk_widget_show (pair->label); + gtk_widget_show (pair->entry); + } else { + gtk_widget_hide (pair->label); + gtk_widget_hide (pair->entry); } - - priv->num_hdrs++; - - return entry; } static void -setup_headers (EMsgComposerHdrs *hdrs) +headers_set_visibility (EMsgComposerHdrs *h, gint visible_flags) { - EMsgComposerHdrsPrivate *priv; + EMsgComposerHdrsPrivate *p = h->priv; - priv = hdrs->priv; - - priv->from_entry = add_header - (hdrs, _("From:"), - _("Enter the identity you wish to send this message from"), - NULL, - HEADER_OPTIONMENU); - priv->to_entry = add_header - (hdrs, _("To:"), - _("Enter the recipients of the message"), - NULL, - HEADER_ADDRBOOK); - priv->cc_entry = add_header - (hdrs, _("Cc:"), - _("Enter the addresses that will receive a carbon copy of " - "the message"), - NULL, - HEADER_ADDRBOOK); - priv->bcc_entry = add_header - (hdrs, _("Bcc:"), - _("Enter the addresses that will receive a carbon copy of " - "the message without appearing in the recipient list of " - "the message."), - NULL, - HEADER_ADDRBOOK); - priv->subject_entry = add_header - (hdrs, _("Subject:"), - _("Enter the subject of the mail"), - NULL, - HEADER_ENTRYBOX); + set_pair_visibility (h, &p->from, visible_flags & E_MSG_COMPOSER_VISIBLE_FROM); + set_pair_visibility (h, &p->cc, visible_flags & E_MSG_COMPOSER_VISIBLE_CC); + set_pair_visibility (h, &p->bcc, visible_flags & E_MSG_COMPOSER_VISIBLE_BCC); + set_pair_visibility (h, &p->subject, visible_flags & E_MSG_COMPOSER_VISIBLE_SUBJECT); +} + +void +e_msg_composer_set_hdrs_visible (EMsgComposerHdrs *hdrs, gint visible_flags) +{ + g_return_if_fail (hdrs != NULL); + g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); + + headers_set_visibility (hdrs, visible_flags); + gtk_widget_queue_resize (GTK_WIDGET (hdrs)); } +static void +setup_headers (EMsgComposerHdrs *hdrs, gint visible_flags) +{ + create_headers (hdrs); + attach_headers (hdrs); + + /* + * To: is always visible + */ + gtk_widget_show (hdrs->priv->to.label); + gtk_widget_show (hdrs->priv->to.entry); + + headers_set_visibility (hdrs, visible_flags); +} + /* GtkObject methods. */ @@ -498,25 +545,11 @@ init (EMsgComposerHdrs *hdrs) { EMsgComposerHdrsPrivate *priv; - priv = g_new (EMsgComposerHdrsPrivate, 1); + priv = g_new0 (EMsgComposerHdrsPrivate, 1); - priv->corba_select_names = CORBA_OBJECT_NIL; - - priv->from_options = NULL; - - priv->from_entry = NULL; - priv->to_entry = NULL; - priv->cc_entry = NULL; - priv->bcc_entry = NULL; - priv->subject_entry = NULL; - priv->tooltips = gtk_tooltips_new (); - priv->num_hdrs = 0; - hdrs->priv = priv; - - hdrs->account = NULL; } @@ -544,7 +577,7 @@ e_msg_composer_hdrs_get_type (void) } GtkWidget * -e_msg_composer_hdrs_new (void) +e_msg_composer_hdrs_new (gint visible_flags) { EMsgComposerHdrs *new; EMsgComposerHdrsPrivate *priv; @@ -557,7 +590,7 @@ e_msg_composer_hdrs_new (void) return NULL; } - setup_headers (new); + setup_headers (new, visible_flags); return GTK_WIDGET (new); } @@ -603,9 +636,9 @@ e_msg_composer_hdrs_to_message (EMsgComposerHdrs *hdrs, camel_mime_message_set_from (msg, from); camel_object_unref (CAMEL_OBJECT (from)); - set_recipients (msg, hdrs->priv->to_entry, CAMEL_RECIPIENT_TYPE_TO); - set_recipients (msg, hdrs->priv->cc_entry, CAMEL_RECIPIENT_TYPE_CC); - set_recipients (msg, hdrs->priv->bcc_entry, CAMEL_RECIPIENT_TYPE_BCC); + set_recipients (msg, hdrs->priv->to.entry, CAMEL_RECIPIENT_TYPE_TO); + set_recipients (msg, hdrs->priv->cc.entry, CAMEL_RECIPIENT_TYPE_CC); + set_recipients (msg, hdrs->priv->bcc.entry, CAMEL_RECIPIENT_TYPE_BCC); } @@ -642,7 +675,7 @@ e_msg_composer_hdrs_set_from_account (EMsgComposerHdrs *hdrs, g_return_if_fail (hdrs != NULL); g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - omenu = GTK_OPTION_MENU (hdrs->priv->from_entry); + omenu = GTK_OPTION_MENU (hdrs->priv->from.entry); /* find the item that represents the account and activate it */ l = hdrs->priv->from_options; @@ -670,7 +703,7 @@ e_msg_composer_hdrs_set_to (EMsgComposerHdrs *hdrs, g_return_if_fail (hdrs != NULL); g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - set_entry (BONOBO_WIDGET (hdrs->priv->to_entry), to_list); + set_entry (BONOBO_WIDGET (hdrs->priv->to.entry), to_list); } void @@ -680,7 +713,7 @@ e_msg_composer_hdrs_set_cc (EMsgComposerHdrs *hdrs, g_return_if_fail (hdrs != NULL); g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - set_entry (BONOBO_WIDGET (hdrs->priv->cc_entry), cc_list); + set_entry (BONOBO_WIDGET (hdrs->priv->cc.entry), cc_list); } void @@ -690,7 +723,7 @@ e_msg_composer_hdrs_set_bcc (EMsgComposerHdrs *hdrs, g_return_if_fail (hdrs != NULL); g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); - set_entry (BONOBO_WIDGET (hdrs->priv->bcc_entry), bcc_list); + set_entry (BONOBO_WIDGET (hdrs->priv->bcc.entry), bcc_list); } void @@ -701,7 +734,7 @@ e_msg_composer_hdrs_set_subject (EMsgComposerHdrs *hdrs, g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); g_return_if_fail (subject != NULL); - gtk_object_set (GTK_OBJECT (hdrs->priv->subject_entry), + gtk_object_set (GTK_OBJECT (hdrs->priv->subject.entry), "text", subject, NULL); } @@ -772,7 +805,7 @@ e_msg_composer_hdrs_get_subject (EMsgComposerHdrs *hdrs) g_return_val_if_fail (hdrs != NULL, NULL); g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - gtk_object_get (GTK_OBJECT (hdrs->priv->subject_entry), + gtk_object_get (GTK_OBJECT (hdrs->priv->subject.entry), "text", &subject, NULL); return subject; @@ -785,7 +818,7 @@ e_msg_composer_hdrs_get_to_entry (EMsgComposerHdrs *hdrs) g_return_val_if_fail (hdrs != NULL, NULL); g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - return hdrs->priv->to_entry; + return hdrs->priv->to.entry; } GtkWidget * @@ -794,7 +827,7 @@ e_msg_composer_hdrs_get_cc_entry (EMsgComposerHdrs *hdrs) g_return_val_if_fail (hdrs != NULL, NULL); g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - return hdrs->priv->cc_entry; + return hdrs->priv->cc.entry; } GtkWidget * @@ -803,7 +836,7 @@ e_msg_composer_hdrs_get_bcc_entry (EMsgComposerHdrs *hdrs) g_return_val_if_fail (hdrs != NULL, NULL); g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - return hdrs->priv->bcc_entry; + return hdrs->priv->bcc.entry; } GtkWidget * @@ -812,5 +845,5 @@ e_msg_composer_hdrs_get_subject_entry (EMsgComposerHdrs *hdrs) g_return_val_if_fail (hdrs != NULL, NULL); g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - return hdrs->priv->subject_entry; + return hdrs->priv->subject.entry; } diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h index 9b1c5c4c84..9a32aee0fc 100644 --- a/composer/e-msg-composer-hdrs.h +++ b/composer/e-msg-composer-hdrs.h @@ -64,9 +64,16 @@ struct _EMsgComposerHdrsClass { void (* hdrs_changed) (EMsgComposerHdrs *hdrs); }; +typedef enum { + E_MSG_COMPOSER_VISIBLE_FROM = 1, + E_MSG_COMPOSER_VISIBLE_CC = 2, + E_MSG_COMPOSER_VISIBLE_BCC = 4, + E_MSG_COMPOSER_VISIBLE_SUBJECT = 8 +} EMsgComposerHeaderVisibleFlags; + GtkType e_msg_composer_hdrs_get_type (void); -GtkWidget *e_msg_composer_hdrs_new (void); +GtkWidget *e_msg_composer_hdrs_new (gint visible_flags); void e_msg_composer_hdrs_to_message (EMsgComposerHdrs *hdrs, CamelMimeMessage *msg); @@ -93,6 +100,10 @@ GtkWidget *e_msg_composer_hdrs_get_cc_entry (EMsgComposerHdrs *hdrs); GtkWidget *e_msg_composer_hdrs_get_bcc_entry (EMsgComposerHdrs *hdrs); GtkWidget *e_msg_composer_hdrs_get_subject_entry (EMsgComposerHdrs *hdrs); +gint e_msg_composer_get_hdrs_visible (EMsgComposerHdrs *hdrs); +void e_msg_composer_set_hdrs_visible (EMsgComposerHdrs *hdrs, + gint flags); + #ifdef _cplusplus } #endif /* _cplusplus */ diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 03e747c481..088161a1fe 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -18,7 +18,11 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Authors: Ettore Perazzoli, Jeffrey Stedfast + * Authors: + * Ettore Perazzoli (ettore@ximian.com) + * Jeffrey Stedfast (fejj@ximian.com) + * Miguel de Icaza (miguel@ximian.com) + * */ /* @@ -28,6 +32,8 @@ - Somehow users should be able to see if any file(s) are attached even when the attachment bar is not shown. + Should use EventSources to keep track of global changes made to configuration + values. Right now it ignores the problem olympically. Miguel. */ #ifdef HAVE_CONFIG_H @@ -636,6 +642,26 @@ set_editor_text (EMsgComposer *composer, const char *sig_file, const char *text) bonobo_object_unref (BONOBO_OBJECT(stream)); } +void +set_config (EMsgComposer *composer, char *key, int val) +{ + if (composer->property_bag){ + CORBA_Environment ev; + CORBA_exception_init (&ev); + + bonobo_property_bag_client_set_value_gint ( + composer->property_bag, key, val, &ev); + CORBA_exception_free (&ev); + return; + } else { + char *full_key; + + full_key = g_strconcat ("Evolution/Composer/", key, NULL); + gnome_config_set_int (full_key, val); + g_free (full_key); + } +} + /* Commands. */ @@ -1098,21 +1124,10 @@ menu_format_html_cb (BonoboUIComponent *component, gpointer user_data) { - EMsgComposer *composer; - gboolean new_state; - if (type != Bonobo_UIComponent_STATE_CHANGED) return; - composer = E_MSG_COMPOSER (user_data); - - new_state = atoi (state); - - if ((new_state && composer->send_html) || - (! new_state && ! composer->send_html)) - return; - - e_msg_composer_set_send_html (composer, new_state); + e_msg_composer_set_send_html (E_MSG_COMPOSER (user_data), atoi (state)); } static void @@ -1120,24 +1135,13 @@ menu_security_pgp_sign_cb (BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, const char *state, - gpointer user_data) + gpointer composer) { - EMsgComposer *composer; - gboolean new_state; - if (type != Bonobo_UIComponent_STATE_CHANGED) return; - - composer = E_MSG_COMPOSER (user_data); - - new_state = atoi (state); - - if ((new_state && composer->pgp_sign) || - (!new_state && ! composer->pgp_sign)) - return; - - e_msg_composer_set_pgp_sign (composer, new_state); + + e_msg_composer_set_pgp_sign (E_MSG_COMPOSER (composer), atoi (state)); } static void @@ -1145,24 +1149,52 @@ menu_security_pgp_encrypt_cb (BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, const char *state, - gpointer user_data) + gpointer composer) { - EMsgComposer *composer; - gboolean new_state; - if (type != Bonobo_UIComponent_STATE_CHANGED) return; - composer = E_MSG_COMPOSER (user_data); - - new_state = atoi (state); - - if ((new_state && composer->pgp_encrypt) || - (!new_state && ! composer->pgp_encrypt)) + e_msg_composer_set_pgp_encrypt (E_MSG_COMPOSER (composer), atoi (state)); +} + +static void +menu_view_from_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + if (type != Bonobo_UIComponent_STATE_CHANGED) return; - - e_msg_composer_set_pgp_encrypt (composer, new_state); + + e_msg_composer_set_view_from (E_MSG_COMPOSER (user_data), atoi (state)); +} + +static void +menu_view_bcc_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + e_msg_composer_set_view_bcc (E_MSG_COMPOSER (user_data), atoi (state)); +} + +static void +menu_view_cc_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + e_msg_composer_set_view_cc (E_MSG_COMPOSER (user_data), atoi (state)); } @@ -1203,29 +1235,60 @@ setup_ui (EMsgComposer *composer) "evolution-message-composer"); /* Format -> HTML */ - bonobo_ui_component_set_prop (composer->uic, "/commands/FormatHtml", - "state", composer->send_html ? "1" : "0", NULL); - - bonobo_ui_component_add_listener (composer->uic, "FormatHtml", - menu_format_html_cb, composer); + bonobo_ui_component_set_prop ( + composer->uic, "/commands/FormatHtml", + "state", composer->send_html ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + composer->uic, "FormatHtml", + menu_format_html_cb, composer); + + /* View/From */ + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewFrom", + "state", composer->view_from ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + composer->uic, "ViewFrom", + menu_view_from_cb, composer); + + /* View/BCC */ + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewBCC", + "state", composer->view_bcc ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + composer->uic, "ViewBCC", + menu_view_bcc_cb, composer); + + /* View/CC */ + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewCC", + "state", composer->view_cc ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + composer->uic, "ViewCC", + menu_view_cc_cb, composer); + /* Security -> PGP Sign */ - bonobo_ui_component_set_prop (composer->uic, "/commands/SecurityPGPSign", - "state", composer->pgp_sign ? "1" : "0", NULL); + bonobo_ui_component_set_prop ( + composer->uic, "/commands/SecurityPGPSign", + "state", composer->pgp_sign ? "1" : "0", NULL); - bonobo_ui_component_add_listener (composer->uic, "SecurityPGPSign", - menu_security_pgp_sign_cb, composer); + bonobo_ui_component_add_listener ( + composer->uic, "SecurityPGPSign", + menu_security_pgp_sign_cb, composer); /* Security -> PGP Encrypt */ - bonobo_ui_component_set_prop (composer->uic, "/commands/SecurityPGPEncrypt", - "state", composer->pgp_encrypt ? "1" : "0", NULL); + bonobo_ui_component_set_prop ( + composer->uic, "/commands/SecurityPGPEncrypt", + "state", composer->pgp_encrypt ? "1" : "0", NULL); - bonobo_ui_component_add_listener (composer->uic, "SecurityPGPEncrypt", - menu_security_pgp_encrypt_cb, composer); + bonobo_ui_component_add_listener ( + composer->uic, "SecurityPGPEncrypt", + menu_security_pgp_encrypt_cb, composer); /* View -> Attachments */ - bonobo_ui_component_add_listener (composer->uic, "ViewAttach", - menu_view_attachments_activate_cb, composer); + bonobo_ui_component_add_listener ( + composer->uic, "ViewAttach", + menu_view_attachments_activate_cb, composer); } @@ -1287,6 +1350,8 @@ destroy (GtkObject *object) CORBA_Environment ev; composer = E_MSG_COMPOSER (object); + + gnome_config_sync (); if (composer->uic) bonobo_object_unref (BONOBO_OBJECT (composer->uic)); @@ -1474,6 +1539,96 @@ e_msg_composer_get_type (void) return type; } +static int +get_config_value (const char *key) +{ + char *full_key = g_strconcat ("/Evolution/Composer/", key, NULL); + int v; + + v = gnome_config_get_int (full_key); + g_free (full_key); + return v; +} + +static gint +load_with_failue_control (Bonobo_PropertyBag bag, char *key, gint default_if_fails) +{ + CORBA_Environment ev; + gint v; + + CORBA_exception_init (&ev); + v = bonobo_property_bag_client_get_value_gint (bag, key, &ev); + if (ev._major == CORBA_NO_EXCEPTION) + return v; + CORBA_exception_free (&ev); + + return default_if_fails; +} + +static void +load_from_property_bag (EMsgComposer *composer) +{ + Bonobo_PropertyBag bag = composer->property_bag; + + composer->view_from = load_with_failue_control (bag, "ViewFrom", 1); + composer->view_bcc = load_with_failue_control (bag, "ViewBCC", 0); + composer->view_cc = load_with_failue_control (bag, "ViewCC", 1); + composer->view_subject = load_with_failue_control (bag, "ViewSubject", 1); +} + +static void +load_from_gnome_config (EMsgComposer *composer) +{ + composer->view_from = get_config_value ("ViewFrom=1"); + composer->view_bcc = get_config_value ("ViewBCC=0"); + composer->view_cc = get_config_value ("ViewCC=1"); + composer->view_subject = get_config_value ("ViewSubject=1"); +} + +static void +e_msg_composer_load_config (EMsgComposer *composer) +{ + Bonobo_PropertyBag pbag; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + pbag = bonobo_get_object ( + "config:/Evolution/Mail/Composer", "IDL:Bonobo/PropertyBag:1.0", + &ev); + if (ev._major == CORBA_NO_EXCEPTION && pbag != CORBA_OBJECT_NIL){ + composer->property_bag = pbag; + load_from_property_bag (composer); + } else { + composer->property_bag = CORBA_OBJECT_NIL; + load_from_gnome_config (composer); + } + CORBA_exception_free (&ev); +} + +static gint +e_msg_composer_get_visible_flags (EMsgComposer *composer) +{ + int flags = 0; + + if (composer->view_from) + flags |= E_MSG_COMPOSER_VISIBLE_FROM; + if (composer->view_cc) + flags |= E_MSG_COMPOSER_VISIBLE_CC; + if (composer->view_bcc) + flags |= E_MSG_COMPOSER_VISIBLE_BCC; + if (composer->view_subject) + flags |= E_MSG_COMPOSER_VISIBLE_SUBJECT; + + /* + * Until we have a GUI way, lets make sure that + * even if the user screws up, we will do the right + * thing (screws up == edit the config file manually + * and screw up). + */ + flags |= E_MSG_COMPOSER_VISIBLE_SUBJECT; + return flags; +} + /** * e_msg_composer_construct: * @composer: A message composer widget @@ -1485,7 +1640,8 @@ e_msg_composer_construct (EMsgComposer *composer) { GtkWidget *vbox; BonoboObject *editor_server; - + gint vis; + static GtkTargetEntry drop_types[] = { {"text/uri-list", 0, 1} }; @@ -1503,12 +1659,15 @@ e_msg_composer_construct (EMsgComposer *composer) drop_types, 1, GDK_ACTION_COPY); gtk_signal_connect (GTK_OBJECT (composer), "drag_data_received", GTK_SIGNAL_FUNC (drag_data_received), NULL); + e_msg_composer_load_config (composer); setup_ui (composer); vbox = gtk_vbox_new (FALSE, 0); + + vis = e_msg_composer_get_visible_flags (composer); + composer->hdrs = e_msg_composer_hdrs_new (vis); - composer->hdrs = e_msg_composer_hdrs_new (); gtk_box_pack_start (GTK_BOX (vbox), composer->hdrs, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (composer->hdrs), "subject_changed", GTK_SIGNAL_FUNC (subject_changed_cb), composer); @@ -2183,8 +2342,11 @@ e_msg_composer_set_send_html (EMsgComposer *composer, composer->send_html = send_html; - bonobo_ui_component_set_prop (composer->uic, "/commands/FormatHtml", - "state", composer->send_html ? "1" : "0", NULL); + bonobo_ui_component_set_prop ( + composer->uic, "/commands/FormatHtml", + "state", composer->send_html ? "1" : "0", NULL); + + set_config (composer, "FormatHTML", composer->send_html); } /** @@ -2249,7 +2411,6 @@ e_msg_composer_set_pgp_sign (EMsgComposer *composer, gboolean pgp_sign) "state", composer->pgp_sign ? "1" : "0", NULL); } - /** * e_msg_composer_get_pgp_sign: * @composer: A message composer widget @@ -2312,6 +2473,88 @@ e_msg_composer_get_pgp_encrypt (EMsgComposer *composer) /** + * e_msg_composer_set_view_bcc: + * @composer: A message composer widget + * @state: whether to show or hide the bcc view + * + * Controls the state of the BCC display + */ +void +e_msg_composer_set_view_bcc (EMsgComposer *composer, gboolean view_bcc) +{ + g_return_if_fail (composer != NULL); + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + if ((composer->view_bcc && view_bcc) || + (!composer->view_bcc && !view_bcc)) + return; + + composer->view_bcc = view_bcc; + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewBCC", + "state", composer->view_bcc ? "1" : "0", NULL); + set_config (composer, "ViewBCC", composer->view_bcc); + e_msg_composer_set_hdrs_visible + (E_MSG_COMPOSER_HDRS (composer->hdrs), + e_msg_composer_get_visible_flags (composer)); + +} + +/** + * e_msg_composer_set_view_cc: + * @composer: A message composer widget + * @state: whether to show or hide the cc view + * + * Controls the state of the CC display + */ +void +e_msg_composer_set_view_cc (EMsgComposer *composer, gboolean view_cc) +{ + g_return_if_fail (composer != NULL); + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + if ((composer->view_cc && view_cc) || + (!composer->view_cc && !view_cc)) + return; + + composer->view_cc = view_cc; + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewCC", + "state", composer->view_cc ? "1" : "0", NULL); + set_config (composer, "ViewCC", composer->view_cc); + e_msg_composer_set_hdrs_visible + (E_MSG_COMPOSER_HDRS (composer->hdrs), + e_msg_composer_get_visible_flags (composer)); +} + +/** + * e_msg_composer_set_view_from: + * @composer: A message composer widget + * @state: whether to show or hide the From selector + * + * Controls the state of the From selector + */ +void +e_msg_composer_set_view_from (EMsgComposer *composer, gboolean view_from) +{ + g_return_if_fail (composer != NULL); + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + if ((composer->view_from && view_from) || + (!composer->view_from && !view_from)) + return; + + composer->view_from = view_from; + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewFrom", + "state", composer->view_from ? "1" : "0", NULL); + set_config (composer, "ViewFrom", composer->view_from); + e_msg_composer_set_hdrs_visible + (E_MSG_COMPOSER_HDRS (composer->hdrs), + e_msg_composer_get_visible_flags (composer)); +} + +/** * e_msg_composer_guess_mime_type: * @file_name: filename * diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 485ca6f9f1..e03a89bfa6 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* e-msg-composer.h * - * Copyright (C) 1999 Helix Code, Inc. + * Copyright (C) 1999, 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -70,14 +70,19 @@ struct _EMsgComposer { GNOME_GtkHTML_Editor_Engine editor_engine; BonoboObject *editor_listener; GHashTable *inline_images; + + Bonobo_PropertyBag property_bag; char *sig_file; gboolean attachment_bar_visible : 1; - gboolean send_html : 1; - gboolean pgp_sign : 1; + gboolean send_html : 1; + gboolean pgp_sign : 1; gboolean pgp_encrypt : 1; - + gboolean view_from : 1; + gboolean view_bcc : 1; + gboolean view_cc : 1; + gboolean view_subject: 1; gboolean has_changed : 1; }; @@ -116,9 +121,18 @@ CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *compose void e_msg_composer_set_sig_file (EMsgComposer *composer, const char *sig_file); const char *e_msg_composer_get_sig_file (EMsgComposer *composer); +gboolean e_msg_composer_get_send_html (EMsgComposer *composer); void e_msg_composer_set_send_html (EMsgComposer *composer, gboolean send_html); -gboolean e_msg_composer_get_send_html (EMsgComposer *composer); +gboolean e_msg_composer_get_view_from (EMsgComposer *composer); +void e_msg_composer_set_view_from (EMsgComposer *composer, + gboolean view_from); +gboolean e_msg_composer_get_view_bcc (EMsgComposer *composer); +void e_msg_composer_set_view_bcc (EMsgComposer *composer, + gboolean view_bcc); +gboolean e_msg_composer_get_view_cc (EMsgComposer *composer); +void e_msg_composer_set_view_cc (EMsgComposer *composer, + gboolean view_cc); void e_msg_composer_set_pgp_sign (EMsgComposer *composer, gboolean pgp_sign); diff --git a/ui/ChangeLog b/ui/ChangeLog index d1216c94ff..2851194612 100644 --- a/ui/ChangeLog +++ b/ui/ChangeLog @@ -1,5 +1,18 @@ 2001-03-06 Miguel de Icaza <miguel@ximian.com> + * evolution-message-composer.xml: Reorder menus to be File, Edit, + View, Insert, Format (instead of File, Edit, Format, View, Insert). + + Add View/From Field and View/From BCC + + Add Insert/File. + + Add File/Send menu item. + + Change the look to follow the "mailer" look (thiner display). + + + * evolution-tasks.xml: Added "File/New/Task" as well. * evolution-mail.xml: Added "File/New/Mail Message" at the top diff --git a/ui/evolution-message-composer.xml b/ui/evolution-message-composer.xml index 06152658fc..1d2707780a 100644 --- a/ui/evolution-message-composer.xml +++ b/ui/evolution-message-composer.xml @@ -30,11 +30,22 @@ pixtype="stock" pixname="Send Mail"/> <cmd name="FileAttach" _label="Attach" _tip="Attach a file" - pixtype="stock" pixname="Attach" accel="*Ctrl**Alt*A"/> + pixtype="stock" pixname="Attach"/> <cmd name="FormatHtml" _label="HTML" _tip="Send the mail in HTML format" type="toggle" state="0"/> + <cmd name="ViewFrom" _label="_From Field" + _tip="Toggles whether the From chooser is displayed" type="toggle" state="0"/> + + <cmd name="ViewCC" _label="_Cc Field" + _tip="Toggles whether the CC field is displayed" + type="toggle" state="0"/> + + <cmd name="ViewBCC" _label="_Bcc Field" + _tip="Toggles whether the BCC field is displayed" + type="toggle" state="0"/> + <cmd name="ViewAttach" _label="Show attachments" _tip="Show / hide attachments" type="toggle" state="0"/> @@ -59,6 +70,12 @@ <placeholder name="FileOps"/> + <menuitem name="FileSend" verb="" _label="Send"/> + + <menuitem name="FileSendLater" verb="" _label="Send _Later"/> + + <separator/> + <menuitem name="FileSave" verb="" _label="_Save"/> <menuitem name="FileSaveAs" verb="" _label="Save _As..."/> @@ -74,11 +91,6 @@ <separator/> - <menuitem name="FileSend" verb="" _label="Send"/> - - <menuitem name="FileSendLater" verb="" _label="Send _Later"/> - - <separator/> <menuitem name="FileClose" verb="" _label="_Close"/> @@ -87,16 +99,29 @@ <submenu name="Edit" _label="_Edit"/> + <submenu name="View" _label="_View"> - <submenu name="Format" _label="F_ormat"> - - <menuitem name="FormatHtml" verb=""/> - + <menuitem name="ViewAttach" verb="" + _label="Show _attachments"/> + + <separator/> + + <menuitem name="ViewFrom" verb=""/> + <menuitem name="ViewCC" verb=""/> + <menuitem name="ViewBCC" verb=""/> </submenu> - <submenu name="View" _label="_View"> + <submenu name="Insert" _label="_Insert"> + <menuitem name="FileAttach" verb="" + _label="_File"/> + + <placeholder name="Component"> + </placeholder> + </submenu> + + <submenu name="Format" _label="F_ormat"> - <menuitem name="ViewAttach" verb="" _label="Show _attachments"/> + <menuitem name="FormatHtml" verb=""/> </submenu> @@ -126,9 +151,9 @@ </menu> - <dockitem name="Toolbar" behavior="exclusive"> + <dockitem name="Toolbar" behavior="exclusive" hlook="text" vlook="icon"> - <toolitem name="FileSend" verb="" _tip="Send this message now"/> + <toolitem name="FileSend" verb="" _tip="Send this message now" priority="1"/> <toolitem name="FileAttach" verb=""/> |