diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-08-10 06:19:41 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-08-10 06:19:41 +0800 |
commit | eb23edd391e59e62a149446d0b0e8b1c345f1227 (patch) | |
tree | 044dc1d1cd765ae4925ecf6693518be3fbfe0968 | |
parent | ce31e66ee69196c0bd641c72097426ba99f2d7d0 (diff) | |
download | gsoc2013-evolution-eb23edd391e59e62a149446d0b0e8b1c345f1227.tar.gz gsoc2013-evolution-eb23edd391e59e62a149446d0b0e8b1c345f1227.tar.zst gsoc2013-evolution-eb23edd391e59e62a149446d0b0e8b1c345f1227.zip |
Modified to allow dropdown entry-boxes as well (for headers like From:)
2000-08-09 Jeffrey Stedfast <fejj@helixcode.com>
* e-msg-composer-hdrs.c (add_header): Modified to allow dropdown
entry-boxes as well (for headers like From:)
(setup_headers): Modified to use the correct enum type.
(create_dropdown_entry): New convenience function to add a
drop-down combo box and fill it in with identities
(init): Set from_entry to NULL
(e_msg_composer_hdrs_get_from): New convenience function to get
the text in the From widget in the composer
(e_msg_composer_hdrs_set_from): New convenience function to set
the From header in the composer
svn path=/trunk/; revision=4673
-rw-r--r-- | composer/ChangeLog | 13 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.c | 151 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.h | 3 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 18 |
4 files changed, 153 insertions, 32 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index ebed71a31a..606adb0c5f 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,16 @@ +2000-08-09 Jeffrey Stedfast <fejj@helixcode.com> + + * e-msg-composer-hdrs.c (add_header): Modified to allow dropdown + entry-boxes as well (for headers like From:) + (setup_headers): Modified to use the correct enum type. + (create_dropdown_entry): New convenience function to add a + drop-down combo box and fill it in with identities + (init): Set from_entry to NULL + (e_msg_composer_hdrs_get_from): New convenience function to get + the text in the From widget in the composer + (e_msg_composer_hdrs_set_from): New convenience function to set + the From header in the composer + 2000-08-08 JP Rosevear <jpr@helixcode.com> * Makefile.am: Fix build by allowing includes for e-table dir diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c index cffa8a763e..6f29ab94f6 100644 --- a/composer/e-msg-composer-hdrs.c +++ b/composer/e-msg-composer-hdrs.c @@ -37,6 +37,8 @@ #include "e-msg-composer-address-entry.h" #include "e-msg-composer-hdrs.h" +#include "mail/mail-config.h" + #define SELECT_NAMES_OAFID "OAFIID:addressbook:select-names:39301deb-174b-40d1-8a6e-5edc300f7b61" @@ -50,6 +52,7 @@ struct _EMsgComposerHdrsPrivate { GtkTooltips *tooltips; /* Standard headers. */ + GtkWidget *from_entry; GtkWidget *to_entry; GtkWidget *cc_entry; GtkWidget *bcc_entry; @@ -64,6 +67,12 @@ enum { LAST_SIGNAL }; +enum { + HEADER_ADDRBOOK, + HEADER_COMBOBOX, + HEADER_ENTRYBOX +}; + static gint signals[LAST_SIGNAL]; @@ -115,6 +124,68 @@ address_button_clicked_cb (GtkButton *button, } static GtkWidget * +create_dropdown_entry (EMsgComposerHdrs *hdrs, + const char *name) +{ + GtkWidget *combo; + GList *values = NULL; + + combo = gtk_combo_new (); + gtk_combo_set_use_arrows (GTK_COMBO (combo), TRUE); + gtk_combo_set_case_sensitive (GTK_COMBO (combo), FALSE); + + if (!strcmp (name, _("From:"))) { + CamelInternetAddress *ciaddr; + GSList *ids, *stmp; + GList *tmp; + MailConfigIdentity *id; + char *val; + + ids = mail_config_get_identities (); + stmp = ids; + while (stmp) { + char *string; + + id = stmp->data; + g_assert (id); + g_assert (id->name); + g_assert (id->address); + + ciaddr = camel_internet_address_new (); + camel_internet_address_add (ciaddr, id->name, id->address); + string = camel_address_encode (CAMEL_ADDRESS (ciaddr)); + + g_list_append (values, string); + stmp = stmp->next; + } + + if (values) + gtk_combo_set_popdown_strings (GTK_COMBO (combo), values); + + tmp = values; + while (tmp) { + g_free (tmp->data); + tmp = tmp->next; + } + g_list_free (values); + + id = mail_config_get_default_identity (); + g_assert (id); + g_assert (id->name); + g_assert (id->address); + + ciaddr = camel_internet_address_new (); + camel_internet_address_add (ciaddr, id->name, id->address); + val = camel_address_encode (CAMEL_ADDRESS (ciaddr)); + + gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), val); + g_free (val); + } + + return combo; +} + +static GtkWidget * create_addressbook_entry (EMsgComposerHdrs *hdrs, const char *name) { @@ -154,16 +225,16 @@ add_header (EMsgComposerHdrs *hdrs, const gchar *name, const gchar *tip, const gchar *tip_private, - gboolean is_addrbook) + int type) { EMsgComposerHdrsPrivate *priv; GtkWidget *label; GtkWidget *entry; guint pad; - + priv = hdrs->priv; - - if (is_addrbook) { + + if (type == HEADER_ADDRBOOK) { label = gtk_button_new_with_label (name); GTK_OBJECT_UNSET_FLAGS(label, GTK_CAN_FOCUS); gtk_signal_connect (GTK_OBJECT (label), "clicked", @@ -177,31 +248,37 @@ add_header (EMsgComposerHdrs *hdrs, label = gtk_label_new (name); pad = GNOME_PAD; } - + 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); - - if (is_addrbook) + + switch (type) { + case HEADER_ADDRBOOK: entry = create_addressbook_entry (hdrs, name); - else + break; + case HEADER_COMBOBOX: + entry = create_dropdown_entry (hdrs, name); + break; + default: entry = gtk_entry_new (); - + } + 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, GTK_FILL, 2, 2); - + gtk_tooltips_set_tip (hdrs->priv->tooltips, entry, tip, tip_private); } - + priv->num_hdrs++; - + return entry; } @@ -211,30 +288,35 @@ setup_headers (EMsgComposerHdrs *hdrs) EMsgComposerHdrsPrivate *priv; priv = hdrs->priv; - + + priv->from_entry = add_header + (hdrs, _("From:"), + _("Enter the identitiy you wish to send this message from"), + NULL, + HEADER_COMBOBOX); priv->to_entry = add_header (hdrs, _("To:"), _("Enter the recipients of the message"), NULL, - TRUE); + HEADER_ADDRBOOK); priv->cc_entry = add_header (hdrs, _("Cc:"), _("Enter the addresses that will receive a carbon copy of " "the message"), NULL, - TRUE); + 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, - TRUE); + HEADER_ADDRBOOK); priv->subject_entry = add_header (hdrs, _("Subject:"), _("Enter the subject of the mail"), NULL, - FALSE); + HEADER_ENTRYBOX); } @@ -295,6 +377,7 @@ init (EMsgComposerHdrs *hdrs) priv->corba_select_names = CORBA_OBJECT_NIL; + priv->from_entry = NULL; priv->to_entry = NULL; priv->cc_entry = NULL; priv->bcc_entry = NULL; @@ -336,15 +419,15 @@ e_msg_composer_hdrs_new (void) { EMsgComposerHdrs *new; EMsgComposerHdrsPrivate *priv; - + new = gtk_type_new (e_msg_composer_hdrs_get_type ()); priv = new->priv; - + if (! setup_corba (new)) { gtk_widget_destroy (GTK_WIDGET (new)); return NULL; } - + setup_headers (new); return GTK_WIDGET (new); @@ -438,10 +521,10 @@ e_msg_composer_hdrs_to_message (EMsgComposerHdrs *hdrs, g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); g_return_if_fail (msg != NULL); g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg)); - + s = gtk_entry_get_text (GTK_ENTRY (hdrs->priv->subject_entry)); camel_mime_message_set_subject (msg, g_strdup (s)); - + 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); @@ -468,6 +551,19 @@ set_entry (BonoboWidget *bonobo_widget, } void +e_msg_composer_hdrs_set_from (EMsgComposerHdrs *hdrs, + const char *from) +{ + GtkEntry *entry; + + g_return_if_fail (hdrs != NULL); + g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); + + entry = GTK_ENTRY (GTK_COMBO (hdrs->priv->from_entry)->entry); + gtk_entry_set_text (entry, from); +} + +void e_msg_composer_hdrs_set_to (EMsgComposerHdrs *hdrs, const GList *to_list) { @@ -512,6 +608,15 @@ e_msg_composer_hdrs_set_subject (EMsgComposerHdrs *hdrs, } +char * +e_msg_composer_hdrs_get_from (EMsgComposerHdrs *hdrs) +{ + g_return_val_if_fail (hdrs != NULL, NULL); + g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); + + return gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hdrs->priv->from_entry))); +} + /* FIXME this is currently unused and broken. */ GList * e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs) diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h index d9c27b9527..78a478dbfa 100644 --- a/composer/e-msg-composer-hdrs.h +++ b/composer/e-msg-composer-hdrs.h @@ -62,6 +62,8 @@ GtkWidget *e_msg_composer_hdrs_new (void); void e_msg_composer_hdrs_to_message (EMsgComposerHdrs *hdrs, CamelMimeMessage *msg); +void e_msg_composer_hdrs_set_from (EMsgComposerHdrs *hdrs, + const char *from); void e_msg_composer_hdrs_set_to (EMsgComposerHdrs *hdrs, const GList *to_list); void e_msg_composer_hdrs_set_cc (EMsgComposerHdrs *hdrs, @@ -71,6 +73,7 @@ void e_msg_composer_hdrs_set_bcc (EMsgComposerHdrs *hdrs, void e_msg_composer_hdrs_set_subject (EMsgComposerHdrs *hdrs, const char *subject); +char *e_msg_composer_hdrs_get_from (EMsgComposerHdrs *hdrs); GList *e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs); GList *e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs); GList *e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs); diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 2793535b51..bcb6aea723 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1181,26 +1181,26 @@ e_msg_composer_construct (EMsgComposer *composer) { GtkWidget *vbox; BonoboObject *editor_server; - + g_return_if_fail (gtk_main_level () > 0); - + gtk_window_set_default_size (GTK_WINDOW (composer), DEFAULT_WIDTH, DEFAULT_HEIGHT); - + gnome_app_construct (GNOME_APP (composer), "e-msg-composer", _("Compose a message")); - + composer->uih = bonobo_ui_handler_new (); bonobo_ui_handler_set_app (composer->uih, GNOME_APP (composer)); - + vbox = gtk_vbox_new (FALSE, 0); - + composer->hdrs = e_msg_composer_hdrs_new (); gtk_box_pack_start (GTK_BOX (vbox), composer->hdrs, FALSE, TRUE, 0); gtk_widget_show (composer->hdrs); - + /* Editor component. */ - + create_menubar (composer); create_toolbar (composer); composer->editor = create_editor (composer); @@ -1211,7 +1211,7 @@ e_msg_composer_construct (EMsgComposer *composer) = bonobo_object_query_interface (editor_server, "IDL:Bonobo/PersistFile:1.0"); composer->persist_stream_interface = bonobo_object_query_interface (editor_server, "IDL:Bonobo/PersistStream:1.0"); - + gtk_widget_show (composer->editor); gtk_box_pack_start (GTK_BOX (vbox), composer->editor, TRUE, TRUE, 0); gtk_widget_show (composer->editor); |