aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
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 /composer/e-msg-composer.c
parent524e3509c4a17958387308b3674548f7166610d6 (diff)
downloadgsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.tar
gsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.tar.gz
gsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.tar.bz2
gsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.tar.lz
gsoc2013-evolution-6e1b4aa52b51d584195ddf3d4b8f259ecefcc7e6.tar.xz
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
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c84
1 files changed, 71 insertions, 13 deletions
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);