aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2002-06-11 05:26:18 +0800
committerRadek Doulik <rodo@src.gnome.org>2002-06-11 05:26:18 +0800
commit6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6 (patch)
tree92d62c2fdfae73eeb09382a7c852176f9d8c163d
parent524e3509c4a17958387308b3674548f7166610d6 (diff)
downloadgsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.tar.gz
gsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.tar.zst
gsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.zip
added "Set as default" menu item
2002-06-10 Radek Doulik <rodo@ximian.com> * e-msg-composer.c (signature_cb): added "Set as default" menu item * e-msg-composer-hdrs.c (e_msg_composer_hdrs_get_from_omenu): new method (e_msg_composer_hdrs_set_from_account): use e_msg_composer_hdrs_get_from_omenu svn path=/trunk/; revision=17160
-rw-r--r--composer/ChangeLog10
-rw-r--r--composer/e-msg-composer-hdrs.c11
-rw-r--r--composer/e-msg-composer-hdrs.h1
-rw-r--r--composer/e-msg-composer.c84
4 files changed, 92 insertions, 14 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 6f12747c2c..e5f946db29 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,13 @@
+2002-06-10 Radek Doulik <rodo@ximian.com>
+
+ * e-msg-composer.c (signature_cb): added "Set as default" menu
+ item
+
+ * e-msg-composer-hdrs.c (e_msg_composer_hdrs_get_from_omenu): new
+ method
+ (e_msg_composer_hdrs_set_from_account): use
+ e_msg_composer_hdrs_get_from_omenu
+
2002-06-07 Radek Doulik <rodo@ximian.com>
* e-msg-composer.c (get_signature_html): use new script signature
diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c
index 1db41d6d3d..a39fd806c6 100644
--- a/composer/e-msg-composer-hdrs.c
+++ b/composer/e-msg-composer-hdrs.c
@@ -810,7 +810,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 (gtk_object_get_data (GTK_OBJECT (hdrs->priv->from.entry), "from_menu"));
+ omenu = GTK_OPTION_MENU (e_msg_composer_hdrs_get_from_omenu (hdrs));
if (account_name)
default_account = -1;
@@ -1124,3 +1124,12 @@ e_msg_composer_hdrs_get_from_hbox (EMsgComposerHdrs *hdrs)
return hdrs->priv->from.entry;
}
+
+GtkWidget *
+e_msg_composer_hdrs_get_from_omenu (EMsgComposerHdrs *hdrs)
+{
+ g_return_val_if_fail (hdrs != NULL, NULL);
+ g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
+
+ return GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (hdrs->priv->from.entry), "from_menu"));
+}
diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h
index 9ea076687b..cd8d8fb579 100644
--- a/composer/e-msg-composer-hdrs.h
+++ b/composer/e-msg-composer-hdrs.h
@@ -115,6 +115,7 @@ 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);
GtkWidget *e_msg_composer_hdrs_get_from_hbox (EMsgComposerHdrs *hdrs);
+GtkWidget *e_msg_composer_hdrs_get_from_omenu (EMsgComposerHdrs *hdrs);
void e_msg_composer_set_hdrs_visible (EMsgComposerHdrs *hdrs,
gint flags);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index e551271f63..39997ce7e5 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -51,6 +51,7 @@
#include <sys/wait.h>
#include <unistd.h>
+#include <gtk/gtkoptionmenu.h>
#include <gal/unicode/gunicode.h>
#include <gal/util/e-unicode-i18n.h>
#include <gal/widgets/e-unicode.h>
@@ -1746,31 +1747,86 @@ static EPixmap pixcache [] = {
E_PIXMAP_END
};
+static void sig_select_item (EMsgComposer *composer);
+
static void
signature_cb (GtkWidget *w, EMsgComposer *composer)
{
MailConfigSignature *old_sig;
gboolean old_auto;
gint idx = g_list_index (GTK_MENU_SHELL (w)->children, gtk_menu_get_active (GTK_MENU (w)));
+ gint len = g_list_length (GTK_MENU_SHELL (w)->children);
/* printf ("signature_cb: %d\n", idx); */
old_sig = composer->signature;
old_auto = composer->auto_signature;
- if (idx == 0) { /* none */
- composer->signature = NULL;
- composer->auto_signature = FALSE;
- } else if (idx == 1) { /* auto */
- composer->signature = NULL;
- composer->auto_signature = TRUE;
- } else {
- composer->signature = g_list_nth_data (mail_config_get_signature_list (), idx - 2);
- composer->auto_signature = FALSE;
- }
- if (old_sig != composer->signature || old_auto != composer->auto_signature)
- e_msg_composer_show_sig_file (composer);
+ if (idx < len - 2) {
+ if (idx == 0) { /* none */
+ composer->signature = NULL;
+ composer->auto_signature = FALSE;
+ } else if (idx == 1) { /* auto */
+ composer->signature = NULL;
+ composer->auto_signature = TRUE;
+ } else {
+ composer->signature = g_list_nth_data (mail_config_get_signature_list (), idx - 2);
+ composer->auto_signature = FALSE;
+ }
+ if (old_sig != composer->signature || old_auto != composer->auto_signature)
+ e_msg_composer_show_sig_file (composer);
+ } else if (idx == len - 2) {
+ /* separator */
+ sig_select_item (composer);
+ } else if (idx == len - 1 && composer->hdrs && E_MSG_COMPOSER_HDRS (composer->hdrs)->account) {
+ const MailConfigAccount *account = E_MSG_COMPOSER_HDRS (composer->hdrs)->account;
+
+ if (account->id) {
+ GtkWidget *omenu, *menu;
+ MailConfigAccount *orig_acc;
+ gint i;
+
+ /*
+ * this is not exact, because the composer uses duplicates of accounts
+ * so I have to guess which account it is.
+ * in 1.4 we have to have account derived from gobject and composer should just
+ * ref it and not duplicate
+ */
+ omenu = e_msg_composer_hdrs_get_from_omenu (E_MSG_COMPOSER_HDRS (composer->hdrs));
+ menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
+ i = g_list_index (GTK_MENU_SHELL (menu)->children, gtk_menu_get_active (GTK_MENU (menu)));
+
+ orig_acc = g_slist_nth_data ((GSList *) mail_config_get_accounts (), i);
+ if (orig_acc) {
+ if (orig_acc->name && account->name && !strcmp (orig_acc->name, account->name)
+ && ((orig_acc->id->name == NULL && account->id->name == NULL)
+ || (orig_acc->id->name && account->id->name
+ && !strcmp (orig_acc->id->name, account->id->name)))
+ && ((orig_acc->id->address == NULL && account->id->address == NULL)
+ || (orig_acc->id->address && account->id->address
+ && !strcmp (orig_acc->id->address, account->id->address)))
+ && ((orig_acc->id->reply_to == NULL && account->id->reply_to == NULL)
+ || (orig_acc->id->reply_to && account->id->reply_to
+ && !strcmp (orig_acc->id->reply_to, account->id->reply_to)))
+ && ((orig_acc->id->reply_to == NULL && account->id->reply_to == NULL)
+ || (orig_acc->id->reply_to && account->id->reply_to
+ && !strcmp (orig_acc->id->reply_to, account->id->reply_to)))
+ && ((orig_acc->id->organization == NULL && account->id->organization == NULL)
+ || (orig_acc->id->organization && account->id->organization
+ && !strcmp (orig_acc->id->organization, account->id->organization)))) {
+
+ orig_acc->id->def_signature = composer->signature;
+ orig_acc->id->auto_signature = composer->auto_signature;
+ mail_config_write_account_sig (orig_acc, -1);
+ sig_select_item (composer);
+ return;
+ }
+ }
+ gnome_error_dialog (_("Can't set default signature for this account. "
+ "Maybe accounts were modified meanwhile?"));
+ }
+ }
/* printf ("signature_cb end\n"); */
}
@@ -1839,7 +1895,7 @@ setup_signatures_menu (EMsgComposer *composer)
GtkWidget *mi;
#define ADD(x) \
- mi = gtk_menu_item_new_with_label (x); \
+ mi = (x ? gtk_menu_item_new_with_label (x) : gtk_menu_item_new ()); \
gtk_widget_show (mi); \
gtk_menu_append (GTK_MENU (menu), mi);
@@ -1856,6 +1912,8 @@ setup_signatures_menu (EMsgComposer *composer)
ADD (gtk_str);
g_free (gtk_str);
}
+ ADD (NULL);
+ ADD (_("Set as default"));
#undef ADD
gtk_widget_show (menu);