diff options
author | Radek Doulik <rodo@src.gnome.org> | 2002-06-05 23:43:50 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2002-06-05 23:43:50 +0800 |
commit | ee96e3762905713b1785d24f6de278608060d6c3 (patch) | |
tree | 3a789f264c3bf3d039d2f6733e1693b2bf2a137b /mail/mail-account-gui.c | |
parent | 4ea52e5e61cbd750f37b07f4aad0c92ede66556c (diff) | |
download | gsoc2013-evolution-ee96e3762905713b1785d24f6de278608060d6c3.tar.gz gsoc2013-evolution-ee96e3762905713b1785d24f6de278608060d6c3.tar.zst gsoc2013-evolution-ee96e3762905713b1785d24f6de278608060d6c3.zip |
signature editor reworked, WIP
svn path=/trunk/; revision=17117
Diffstat (limited to 'mail/mail-account-gui.c')
-rw-r--r-- | mail/mail-account-gui.c | 295 |
1 files changed, 53 insertions, 242 deletions
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 71f72e4269..80b27b0ff0 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -1179,78 +1179,51 @@ clear_menu (GtkWidget *menu) static inline int sig_get_index (MailConfigSignature *sig) { - return sig->id + (mail_config_get_signatures_random () ? 2 : 1); + return sig ? sig->id + 2 : 0; } -static gint -sig_get_gui_index (MailAccountGui *gui, gboolean text) +static inline int +sig_gui_get_index (MailAccountGui *gui) { - MailConfigSignature *sig = text ? gui->text_signature : gui->html_signature; - gboolean random = text ? gui->text_random : gui->html_random; - - if (random) + if (gui->auto_signature) return 1; - else if (!sig) - return 0; - else - return sig_get_index (sig); + return sig_get_index (gui->def_signature); } static void sig_fill_options (MailAccountGui *gui) { - GtkWidget *menu_text, *menu_html; + GtkWidget *menu; GtkWidget *mi; GList *l; MailConfigSignature *sig; - menu_text = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_text)); - menu_html = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_html)); - - if (menu_text) - clear_menu (menu_text); - else - menu_text = gtk_menu_new (); + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)); - if (menu_html) - clear_menu (menu_html); + if (menu) + clear_menu (menu); else - menu_html = gtk_menu_new (); - - gtk_menu_append (GTK_MENU (menu_text), gtk_menu_item_new_with_label (_("None"))); - gtk_menu_append (GTK_MENU (menu_html), gtk_menu_item_new_with_label (_("None"))); - - if (mail_config_get_signatures_random ()) { - gtk_menu_append (GTK_MENU (menu_text), gtk_menu_item_new_with_label (_("Random"))); - gtk_menu_append (GTK_MENU (menu_html), gtk_menu_item_new_with_label (_("Random"))); - } + menu = gtk_menu_new (); + + gtk_menu_append (GTK_MENU (menu), gtk_menu_item_new_with_label (_("None"))); + gtk_menu_append (GTK_MENU (menu), gtk_menu_item_new_with_label (_("Autogenerated"))); + /* gtk_menu_append (GTK_MENU (menu), gtk_menu_item_new_with_label (_("Random"))); */ for (l = mail_config_get_signature_list (); l; l = l->next) { + gchar *utf8; + sig = l->data; - mi = gtk_menu_item_new_with_label (sig->name); - gtk_object_set_data (GTK_OBJECT (mi), "sig", sig); - gtk_menu_append (GTK_MENU (menu_text), mi); - - mi = gtk_menu_item_new_with_label (sig->name); + utf8 = e_utf8_to_gtk_string (menu, sig->name); + mi = gtk_menu_item_new_with_label (utf8); + g_free (utf8); gtk_object_set_data (GTK_OBJECT (mi), "sig", sig); - gtk_menu_append (GTK_MENU (menu_html), mi); + gtk_widget_show (mi); + gtk_menu_append (GTK_MENU (menu), mi); } } static void -sig_select_text_sig (MailAccountGui *gui) -{ - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_text), sig_get_gui_index (gui, TRUE)); -} - -static void -sig_select_html_sig (MailAccountGui *gui) -{ - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), sig_get_gui_index (gui, FALSE)); -} - -static void -sig_changed_text (GtkWidget *w, MailAccountGui *gui) +sig_changed (GtkWidget *w, MailAccountGui *gui) { GtkWidget *active; int index; @@ -1258,55 +1231,8 @@ sig_changed_text (GtkWidget *w, MailAccountGui *gui) active = gtk_menu_get_active (GTK_MENU (w)); index = g_list_index (GTK_MENU_SHELL (w)->children, active); - gui->text_signature = (MailConfigSignature *) gtk_object_get_data (GTK_OBJECT (active), "sig"); - gui->text_random = index == 1; - - gtk_widget_set_sensitive (GTK_WIDGET (gui->sig_edit_text), gui->text_signature != NULL); -} - -static void -sig_changed_html (GtkWidget *w, MailAccountGui *gui) -{ - GtkWidget *active; - int index; - - active = gtk_menu_get_active (GTK_MENU (w)); - index = g_list_index (GTK_MENU_SHELL (w)->children, active); - - gui->html_signature = (MailConfigSignature *) gtk_object_get_data (GTK_OBJECT (active), "sig"); - gui->html_random = index == 1; - - gtk_widget_set_sensitive (GTK_WIDGET (gui->sig_edit_html), gui->html_signature != NULL); -} - -static void -sig_edit_text (GtkWidget *w, MailAccountGui *gui) -{ - MailConfigSignature *sig = gui->text_signature; - - if (!sig) - return; - - if (sig->filename && *sig->filename) - mail_signature_editor (sig); - else - e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, - _("Please specify signature filename\nin Andvanced section of signature settings.")); -} - -static void -sig_edit_html (GtkWidget *w, MailAccountGui *gui) -{ - MailConfigSignature *sig = gui->html_signature; - - if (!sig) - return; - - if (sig->filename && *sig->filename) - mail_signature_editor (sig); - else - e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, - _("Please specify signature filename\nin Andvanced section of signature settings.")); + gui->def_signature = (MailConfigSignature *) gtk_object_get_data (GTK_OBJECT (active), "sig"); + gui->auto_signature = index == 1 ? TRUE : FALSE; } static void @@ -1318,50 +1244,25 @@ sig_switch_to_list (GtkWidget *w, MailAccountGui *gui) } static void -sig_new_text (GtkWidget *w, MailAccountGui *gui) +sig_add_new_signature (GtkWidget *w, MailAccountGui *gui) { if (!gui->dialog) return; sig_switch_to_list (w, gui); - gui->text_signature = mail_composer_prefs_new_signature (NULL, FALSE); - gui->text_random = FALSE; - - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_text), sig_get_index (gui->text_signature)); + gui->def_signature = mail_composer_prefs_new_signature (NULL, FALSE); + gui->auto_signature = FALSE; - gtk_widget_set_sensitive (gui->sig_edit_text, TRUE); -} - -static void -sig_new_html (GtkWidget *w, MailAccountGui *gui) -{ - if (!gui->dialog) - return; - - sig_switch_to_list (w, gui); - - gui->html_signature = mail_composer_prefs_new_signature (NULL, TRUE); - gui->html_random = FALSE; - - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), sig_get_index (gui->html_signature)); - - gtk_widget_set_sensitive (gui->sig_edit_html, TRUE); + gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); } static void setup_signatures (MailAccountGui *gui) { - gui->text_signature = gui->account->id->text_signature; - gui->text_random = gui->account->id->text_random; - gui->html_signature = gui->account->id->html_signature; - gui->html_random = gui->account->id->html_random; - - sig_select_text_sig (gui); - sig_select_html_sig (gui); - - gtk_widget_set_sensitive (GTK_WIDGET (gui->sig_edit_text), gui->text_signature != NULL); - gtk_widget_set_sensitive (GTK_WIDGET (gui->sig_edit_html), gui->html_signature != NULL); + gui->def_signature = gui->account->id->def_signature; + gui->auto_signature = gui->account->id->auto_signature; + gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); } static void @@ -1376,15 +1277,9 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccoun mi = gtk_menu_item_new_with_label (sig->name); gtk_object_set_data (GTK_OBJECT (mi), "sig", sig); gtk_widget_show (mi); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_text)); + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)); gtk_menu_append (GTK_MENU (menu), mi); - - mi = gtk_menu_item_new_with_label (sig->name); - gtk_object_set_data (GTK_OBJECT (mi), "sig", sig); - gtk_widget_show (mi); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_html)); - gtk_menu_append (GTK_MENU (GTK_MENU (menu)), mi); - + break; } case MAIL_CONFIG_SIG_EVENT_NAME_CHANGED: { @@ -1392,24 +1287,15 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccoun GtkWidget *mi; d(printf ("gui NAME CHANGED\n")); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_text)); - gtk_widget_ref (menu); - gtk_option_menu_remove_menu (GTK_OPTION_MENU (gui->sig_option_text)); - mi = g_list_nth_data (GTK_MENU_SHELL (menu)->children, sig_get_index (sig)); - gtk_label_set_text (GTK_LABEL (GTK_BIN (mi)->child), sig->name); - gtk_option_menu_set_menu (GTK_OPTION_MENU (gui->sig_option_text), menu); - gtk_widget_unref (menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_text), sig_get_gui_index (gui, TRUE)); - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_html)); + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)); gtk_widget_ref (menu); - gtk_option_menu_remove_menu (GTK_OPTION_MENU (gui->sig_option_html)); + gtk_option_menu_remove_menu (GTK_OPTION_MENU (gui->sig_option_menu)); mi = g_list_nth_data (GTK_MENU_SHELL (menu)->children, sig_get_index (sig)); gtk_label_set_text (GTK_LABEL (GTK_BIN (mi)->child), sig->name); - gtk_option_menu_set_menu (GTK_OPTION_MENU (gui->sig_option_html), menu); + gtk_option_menu_set_menu (GTK_OPTION_MENU (gui->sig_option_menu), menu); gtk_widget_unref (menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), sig_get_gui_index (gui, FALSE)); - + gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); + break; } case MAIL_CONFIG_SIG_EVENT_DELETED: { @@ -1418,74 +1304,18 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccoun d(printf ("gui DELETED\n")); - if (sig == gui->text_signature) { - gui->text_signature = NULL; - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_text), - sig_get_gui_index (gui, TRUE)); + if (sig == gui->def_signature) { + gui->def_signature = NULL; + gui->auto_signature = TRUE; + gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_menu), sig_gui_get_index (gui)); } - - if (sig == gui->html_signature) { - gui->html_signature = NULL; - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), - sig_get_gui_index (gui, FALSE)); - } - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_text)); - mi = g_list_nth_data (GTK_MENU_SHELL (menu)->children, sig_get_index (sig)); - gtk_container_remove (GTK_CONTAINER (menu), mi); - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_html)); + + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu)); mi = g_list_nth_data (GTK_MENU_SHELL (menu)->children, sig_get_index (sig)); gtk_container_remove (GTK_CONTAINER (menu), mi); break; } - case MAIL_CONFIG_SIG_EVENT_RANDOM_ON: { - GtkWidget *menu; - GtkWidget *mi; - - d(printf ("gui RANDOM ON\n")); - - mi = gtk_menu_item_new_with_label (_("Random")); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_text)); - gtk_menu_insert (GTK_MENU (menu), mi, 1); - gtk_widget_show (mi); - - mi = gtk_menu_item_new_with_label (_("Random")); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_html)); - gtk_menu_insert (GTK_MENU (menu), mi, 1); - gtk_widget_show (mi); - - break; - } - case MAIL_CONFIG_SIG_EVENT_RANDOM_OFF: { - GtkWidget *menu; - GtkWidget *mi; - - d(printf ("gui RANDOM OFF\n")); - - if (gui->text_random) { - gui->text_random = FALSE; - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_text), - sig_get_gui_index (gui, TRUE)); - } - - if (gui->html_random) { - gui->html_random = FALSE; - gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), - sig_get_gui_index (gui, FALSE)); - } - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_text)); - mi = g_list_nth_data (GTK_MENU_SHELL (menu)->children, 1); - gtk_container_remove (GTK_CONTAINER (menu), mi); - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_html)); - mi = g_list_nth_data (GTK_MENU_SHELL (menu)->children, 1); - gtk_container_remove (GTK_CONTAINER (menu), mi); - - break; - } default: ; } @@ -1494,34 +1324,17 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccoun static void prepare_signatures (MailAccountGui *gui) { - gui->sig_option_text = glade_xml_get_widget (gui->xml, "option-sig-text"); - gui->sig_option_html = glade_xml_get_widget (gui->xml, "option-sig-html"); - + gui->sig_option_menu = glade_xml_get_widget (gui->xml, "sigOption"); sig_fill_options (gui); + gtk_signal_connect (GTK_OBJECT (gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_menu))), + "selection-done", sig_changed, gui); - gtk_signal_connect (GTK_OBJECT (gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_text))), - "selection-done", sig_changed_text, gui); - gtk_signal_connect (GTK_OBJECT (gtk_option_menu_get_menu (GTK_OPTION_MENU (gui->sig_option_html))), - "selection-done", sig_changed_html, gui); - - gui->sig_new_text = glade_xml_get_widget (gui->xml, "button-sig-new-text"); - gtk_signal_connect (GTK_OBJECT (gui->sig_new_text), "clicked", GTK_SIGNAL_FUNC (sig_new_text), gui); - gui->sig_new_html = glade_xml_get_widget (gui->xml, "button-sig-new-html"); - gtk_signal_connect (GTK_OBJECT (gui->sig_new_html), "clicked", GTK_SIGNAL_FUNC (sig_new_html), gui); - gui->sig_edit_text = glade_xml_get_widget (gui->xml, "button-sig-edit-text"); - gtk_signal_connect (GTK_OBJECT (gui->sig_edit_text), "clicked", GTK_SIGNAL_FUNC (sig_edit_text), gui); - gui->sig_edit_html = glade_xml_get_widget (gui->xml, "button-sig-edit-html"); - gtk_signal_connect (GTK_OBJECT (gui->sig_edit_html), "clicked", GTK_SIGNAL_FUNC (sig_edit_html), gui); + glade_xml_signal_connect_data (gui->xml, "sigAddNewClicked", GTK_SIGNAL_FUNC (sig_add_new_signature), gui); if (!gui->dialog) { - gtk_widget_hide (glade_xml_get_widget (gui->xml, "label-sig-text")); - gtk_widget_hide (glade_xml_get_widget (gui->xml, "label-sig-html")); - gtk_widget_hide (gui->sig_option_text); - gtk_widget_hide (gui->sig_option_html); - gtk_widget_hide (gui->sig_new_text); - gtk_widget_hide (gui->sig_new_html); - gtk_widget_hide (gui->sig_edit_text); - gtk_widget_hide (gui->sig_edit_html); + gtk_widget_hide (glade_xml_get_widget (gui->xml, "sigLabel")); + gtk_widget_hide (glade_xml_get_widget (gui->xml, "sigOption")); + gtk_widget_hide (glade_xml_get_widget (gui->xml, "sigAddNew")); } else { mail_config_signature_register_client ((MailConfigSignatureClient) sig_event_client, gui); } @@ -1993,10 +1806,8 @@ mail_account_gui_save (MailAccountGui *gui) account->id->organization = e_utf8_gtk_entry_get_text (gui->organization); /* signatures */ - account->id->text_signature = gui->text_signature; - account->id->text_random = gui->text_random; - account->id->html_signature = gui->html_signature; - account->id->html_random = gui->html_random; + account->id->def_signature = gui->def_signature; + account->id->auto_signature = gui->auto_signature; old_enabled = account->source && account->source->enabled; service_destroy (account->source); |