aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-account-gui.c
diff options
context:
space:
mode:
authorRadek Doulik <rodo@src.gnome.org>2002-03-07 08:21:59 +0800
committerRadek Doulik <rodo@src.gnome.org>2002-03-07 08:21:59 +0800
commita1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0 (patch)
tree2b0704091ffc986a0bcfdc4af18ad8c08ea3a136 /mail/mail-account-gui.c
parentfb1819e374f6d663e7b1044e5beb280f56ddb6e6 (diff)
downloadgsoc2013-evolution-a1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0.tar
gsoc2013-evolution-a1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0.tar.gz
gsoc2013-evolution-a1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0.tar.bz2
gsoc2013-evolution-a1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0.tar.lz
gsoc2013-evolution-a1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0.tar.xz
gsoc2013-evolution-a1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0.tar.zst
gsoc2013-evolution-a1bb1ba0fe60989c4e1ebf2798db8c2f5973d8c0.zip
merge new signature handling
svn path=/trunk/; revision=15960
Diffstat (limited to 'mail/mail-account-gui.c')
-rw-r--r--mail/mail-account-gui.c623
1 files changed, 334 insertions, 289 deletions
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index f6ca76846a..981a1b98e9 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -29,8 +29,6 @@
#include <string.h>
#include <stdarg.h>
-#include <bonobo.h>
-#include <bonobo/bonobo-stream-memory.h>
#include <gal/widgets/e-unicode.h>
#include <gal/widgets/e-gui-utils.h>
@@ -38,7 +36,7 @@
#include "mail-account-gui.h"
#include "mail-session.h"
#include "mail-send-recv.h"
-#include "e-msg-composer.h"
+#include "mail-signature-editor.h"
#define d(x)
@@ -961,342 +959,409 @@ provider_compare (const CamelProvider *p1, const CamelProvider *p2)
}
}
-/*
- * Signature editor
- *
- */
-
-struct _ESignatureEditor {
- MailAccountGui *gui;
- GtkWidget *win;
- GtkWidget *control;
+static void
+ssl_option_activate (GtkWidget *widget, gpointer user_data)
+{
+ MailAccountGuiService *service = user_data;
- gchar *filename;
- gboolean html;
- gboolean has_changed;
-};
-typedef struct _ESignatureEditor ESignatureEditor;
-
-#define E_SIGNATURE_EDITOR(o) ((ESignatureEditor *) o)
+ service->ssl_selected = widget;
+}
-#define DEFAULT_WIDTH 600
-#define DEFAULT_HEIGHT 500
+static void
+construct_ssl_menu (MailAccountGuiService *service)
+{
+ GtkWidget *menu, *item = NULL;
+ int i;
+
+ menu = gtk_menu_new ();
+
+ for (i = 0; i < num_ssl_options; i++) {
+ item = gtk_menu_item_new_with_label (_(ssl_options[i].label));
+ gtk_object_set_data (GTK_OBJECT (item), "use_ssl", ssl_options[i].value);
+ gtk_signal_connect (GTK_OBJECT (item), "activate",
+ ssl_option_activate, service);
+ gtk_widget_show (item);
+ gtk_menu_append (GTK_MENU (menu), item);
+ }
+
+ gtk_option_menu_remove_menu (service->use_ssl);
+ gtk_option_menu_set_menu (service->use_ssl, menu);
+
+ gtk_option_menu_set_history (service->use_ssl, i - 1);
+ gtk_signal_emit_by_name (GTK_OBJECT (item), "activate", service);
+}
-enum { REPLY_YES = 0, REPLY_NO, REPLY_CANCEL };
+ static void
+clear_menu (GtkWidget *menu)
+{
+ while (GTK_MENU_SHELL (menu)->children)
+ gtk_container_remove (GTK_CONTAINER (menu), GTK_MENU_SHELL (menu)->children->data);
+}
-static void
-destroy_editor (ESignatureEditor *editor)
+static inline gint
+sig_get_index (MailConfigSignature *sig)
{
- gtk_widget_destroy (editor->win);
- g_free (editor->filename);
- g_free (editor);
+ return sig->id + (mail_config_get_signatures_random () ? 2 : 1);
}
-static void
-menu_file_save_error (BonoboUIComponent *uic, CORBA_Environment *ev) {
- e_notice (GTK_WINDOW (uic), GNOME_MESSAGE_BOX_ERROR,
- _("Could not save signature file."));
-
- g_warning ("Exception while saving signature (%s)",
- bonobo_exception_get_text (ev));
+static gint
+sig_get_gui_index (MailAccountGui *gui, gboolean text)
+{
+ MailConfigSignature *sig = text ? gui->text_signature : gui->html_signature;
+ gboolean random = text ? gui->text_random : gui->html_random;
+
+ if (random)
+ return 1;
+ else if (!sig)
+ return 0;
+ else
+ return sig_get_index (sig);
}
static void
-menu_file_save_cb (BonoboUIComponent *uic,
- void *data,
- const char *path)
+sig_fill_options (MailAccountGui *gui)
{
- ESignatureEditor *editor;
- Bonobo_PersistFile pfile_iface;
- CORBA_Environment ev;
-
- editor = E_SIGNATURE_EDITOR (data);
- if (editor->html) {
- CORBA_exception_init (&ev);
-
- pfile_iface = bonobo_object_client_query_interface (bonobo_widget_get_server (BONOBO_WIDGET (editor->control)),
- "IDL:Bonobo/PersistFile:1.0", NULL);
- Bonobo_PersistFile_save (pfile_iface, editor->filename, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- menu_file_save_error (uic, &ev);
+ GtkWidget *menu_text, *menu_html;
+ GtkWidget *mi;
+ GList *l;
+ MailConfigSignature *sig;
- CORBA_exception_free (&ev);
- } else {
- BonoboStream *stream;
- CORBA_Environment ev;
- Bonobo_PersistStream pstream_iface;
-
- CORBA_exception_init (&ev);
-
- stream = bonobo_stream_open (BONOBO_IO_DRIVER_FS, editor->filename,
- Bonobo_Storage_WRITE | Bonobo_Storage_CREATE, 0);
+ 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));
- pstream_iface = bonobo_object_client_query_interface
- (bonobo_widget_get_server (BONOBO_WIDGET (editor->control)),
- "IDL:Bonobo/PersistStream:1.0", NULL);
+ clear_menu (menu_text);
+ clear_menu (menu_html);
- Bonobo_PersistStream_save (pstream_iface,
- (Bonobo_Stream) bonobo_object_corba_objref (BONOBO_OBJECT (stream)),
- "text/plain", &ev);
+ 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 (ev._major != CORBA_NO_EXCEPTION)
- menu_file_save_error (uic, &ev);
-
- CORBA_exception_free (&ev);
- bonobo_object_unref (BONOBO_OBJECT (stream));
+ 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")));
}
-}
-static void
-exit_dialog_cb (int reply, ESignatureEditor *editor)
-{
- switch (reply) {
- case REPLY_YES:
- menu_file_save_cb (NULL, editor, NULL);
- destroy_editor (editor);
- break;
- case REPLY_NO:
- destroy_editor (editor);
- break;
- case REPLY_CANCEL:
- default:
+ for (l = mail_config_get_signature_list (); l; l = l->next) {
+ 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);
+ gtk_object_set_data (GTK_OBJECT (mi), "sig", sig);
+ gtk_menu_append (GTK_MENU (menu_html), mi);
}
}
static void
-do_exit (ESignatureEditor *editor)
+sig_select_text_sig (MailAccountGui *gui)
{
- if (editor->has_changed) {
- GtkWidget *dialog;
- GtkWidget *label;
- gint button;
-
- dialog = gnome_dialog_new (_("Save signature"),
- GNOME_STOCK_BUTTON_YES, /* Save */
- GNOME_STOCK_BUTTON_NO, /* Don't save */
- GNOME_STOCK_BUTTON_CANCEL, /* Cancel */
- NULL);
-
- label = gtk_label_new (_("This signature has been changed, but hasn't been saved.\n"
- "\nDo you wish to save your changes?"));
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (editor->win));
- gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
- button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
-
- exit_dialog_cb (button, editor);
- } else
- destroy_editor (editor);
+ gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_text), sig_get_gui_index (gui, TRUE));
}
-static int
-delete_event_cb (GtkWidget *w, GdkEvent *event, ESignatureEditor *editor)
+static void
+sig_select_html_sig (MailAccountGui *gui)
{
- do_exit (editor);
-
- return FALSE;
+ gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), sig_get_gui_index (gui, FALSE));
}
static void
-menu_file_close_cb (BonoboUIComponent *uic, gpointer data, const gchar *path)
+sig_changed_text (GtkWidget *w, MailAccountGui *gui)
{
- ESignatureEditor *editor;
-
- editor = E_SIGNATURE_EDITOR (data);
- do_exit (editor);
+ GtkWidget *active;
+ gint index;
+
+ 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
-menu_file_save_close_cb (BonoboUIComponent *uic, gpointer data, const gchar *path)
+sig_changed_html (GtkWidget *w, MailAccountGui *gui)
{
- ESignatureEditor *editor;
-
- editor = E_SIGNATURE_EDITOR (data);
+ GtkWidget *active;
+ gint index;
- menu_file_save_cb (uic, editor, path);
- destroy_editor (editor);
-}
-
-static BonoboUIVerb verbs [] = {
+ active = gtk_menu_get_active (GTK_MENU (w));
+ index = g_list_index (GTK_MENU_SHELL (w)->children, active);
- BONOBO_UI_VERB ("FileSave", menu_file_save_cb),
- BONOBO_UI_VERB ("FileClose", menu_file_close_cb),
- BONOBO_UI_VERB ("FileSaveClose", menu_file_save_close_cb),
+ gui->html_signature = (MailConfigSignature *) gtk_object_get_data (GTK_OBJECT (active), "sig");
+ gui->html_random = index == 1;
- BONOBO_UI_VERB_END
-};
+ gtk_widget_set_sensitive (GTK_WIDGET (gui->sig_edit_html), gui->html_signature != NULL);
+}
static void
-load_signature (ESignatureEditor *editor)
+sig_edit_text (GtkWidget *w, MailAccountGui *gui)
{
- CORBA_Environment ev;
-
- if (editor->html) {
- Bonobo_PersistFile pfile_iface;
-
- pfile_iface = bonobo_object_client_query_interface (bonobo_widget_get_server (BONOBO_WIDGET (editor->control)),
- "IDL:Bonobo/PersistFile:1.0", NULL);
- CORBA_exception_init (&ev);
- Bonobo_PersistFile_load (pfile_iface, editor->filename, &ev);
- CORBA_exception_free (&ev);
- } else {
- Bonobo_PersistStream pstream_iface;
- BonoboStream *stream;
- gchar *data, *html;
-
- data = e_msg_composer_get_sig_file_content (editor->filename, FALSE);
- html = g_strdup_printf ("<PRE>\n%s", data);
- g_free (data);
-
- pstream_iface = bonobo_object_client_query_interface
- (bonobo_widget_get_server (BONOBO_WIDGET (editor->control)),
- "IDL:Bonobo/PersistStream:1.0", NULL);
- CORBA_exception_init (&ev);
- stream = bonobo_stream_mem_create (html, strlen (html), TRUE, FALSE);
-
- if (stream == NULL) {
- g_warning ("Couldn't create memory stream\n");
- } else {
- BonoboObject *stream_object;
- Bonobo_Stream corba_stream;
-
- stream_object = BONOBO_OBJECT (stream);
- corba_stream = bonobo_object_corba_objref (stream_object);
- Bonobo_PersistStream_load (pstream_iface, corba_stream,
- "text/html", &ev);
- }
-
- Bonobo_Unknown_unref (pstream_iface, &ev);
- CORBA_Object_release (pstream_iface, &ev);
- CORBA_exception_free (&ev);
- bonobo_object_unref (BONOBO_OBJECT (stream));
-
- g_free (html);
- }
+ MailConfigSignature *sig = gui->text_signature;
+
+ if (!sig)
+ return;
+
+ if (sig->filename && *sig->filename)
+ mail_signature_editor (sig->filename, sig->html);
+ else
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Please specify signature filename\nin Andvanced section of signature settings."));
}
static void
-launch_signature_editor (MailAccountGui *gui, const gchar *filename, gboolean html)
+sig_edit_html (GtkWidget *w, MailAccountGui *gui)
{
- ESignatureEditor *editor;
- BonoboUIComponent *component;
- BonoboUIContainer *container;
- gchar *title;
-
- if (!filename || !*filename)
- return;
-
- editor = g_new0 (ESignatureEditor, 1);
-
- editor->html = html;
- editor->filename = g_strdup (filename);
- editor->has_changed = TRUE;
+ MailConfigSignature *sig = gui->html_signature;
- title = g_strdup_printf ("Edit %ssignature (%s)", html ? "HTML " : "", filename);
- editor->win = bonobo_window_new ("e-sig-editor", title);
- editor->gui = gui;
- gtk_window_set_default_size (GTK_WINDOW (editor->win), DEFAULT_WIDTH, DEFAULT_HEIGHT);
- gtk_window_set_policy (GTK_WINDOW (editor->win), FALSE, TRUE, FALSE);
- gtk_window_set_modal (GTK_WINDOW (editor->win), TRUE);
- g_free (title);
-
- container = bonobo_ui_container_new ();
- bonobo_ui_container_set_win (container, BONOBO_WINDOW (editor->win));
-
- component = bonobo_ui_component_new_default ();
- bonobo_ui_component_set_container (component, bonobo_object_corba_objref (BONOBO_OBJECT (container)));
- bonobo_ui_component_add_verb_list_with_data (component, verbs, editor);
- bonobo_ui_util_set_ui (component, EVOLUTION_DATADIR, "evolution-signature-editor.xml", "evolution-signature-editor");
-
- editor->control = bonobo_widget_new_control ("OAFIID:GNOME_GtkHTML_Editor",
- bonobo_ui_component_get_container (component));
-
- if (editor->control == NULL) {
- g_warning ("Cannot get 'OAFIID:GNOME_GtkHTML_Editor'.");
-
- destroy_editor (editor);
+ if (!sig)
return;
- }
-
- load_signature (editor);
- gtk_signal_connect (GTK_OBJECT (editor->win), "delete_event",
- GTK_SIGNAL_FUNC (delete_event_cb), editor);
+ if (sig->filename && *sig->filename)
+ mail_signature_editor (sig->filename, sig->html);
+ else
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Please specify signature filename\nin Andvanced section of signature settings."));
+}
- bonobo_window_set_contents (BONOBO_WINDOW (editor->win), editor->control);
- bonobo_widget_set_property (BONOBO_WIDGET (editor->control), "FormatHTML", html, NULL);
- gtk_widget_show (GTK_WIDGET (editor->win));
- gtk_widget_show (GTK_WIDGET (editor->control));
- gtk_widget_grab_focus (editor->control);
+static void
+sig_switch_to_list (GtkWidget *w, MailAccountGui *gui)
+{
+ gtk_window_set_transient_for (GTK_WINDOW (gtk_widget_get_toplevel (w)), NULL);
+ gdk_window_raise (GTK_WIDGET (gui->dialog)->window);
+ gtk_notebook_set_page (GTK_NOTEBOOK (glade_xml_get_widget (gui->dialog->gui, "notebook")), 3);
}
static void
-edit_signature (GtkWidget *w, MailAccountGui *gui)
+sig_set_and_write (MailAccountGui *gui)
{
- launch_signature_editor (gui, gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (gui->signature))), FALSE);
+ gui->account->id->text_signature = gui->text_signature;
+ gui->account->id->text_random = gui->text_random;
+ gui->account->id->html_signature = gui->html_signature;
+ gui->account->id->html_random = gui->html_random;
+
+ mail_config_write_account_sig (gui->account, -1);
}
static void
-edit_html_signature (GtkWidget *w, MailAccountGui *gui)
+sig_new_text (GtkWidget *w, MailAccountGui *gui)
{
- launch_signature_editor (gui, gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (gui->html_signature))), TRUE);
+ if (!gui->dialog)
+ return;
+
+ sig_switch_to_list (w, gui);
+
+ gui->text_signature = mail_accounts_dialog_new_signature (gui->dialog, FALSE);
+ gui->text_random = FALSE;
+
+ gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_text), sig_get_index (gui->text_signature));
+
+ sig_set_and_write (gui);
}
static void
-signature_changed (GtkWidget *entry, MailAccountGui *gui)
+sig_new_html (GtkWidget *w, MailAccountGui *gui)
{
- gtk_widget_set_sensitive (GTK_WIDGET (gui->edit_signature),
- *gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (gui->signature))) != 0);
+ if (!gui->dialog)
+ return;
+
+ sig_switch_to_list (w, gui);
+
+ gui->html_signature = mail_accounts_dialog_new_signature (gui->dialog, TRUE);
+ gui->html_random = FALSE;
+
+ gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), sig_get_index (gui->html_signature));
+
+ sig_set_and_write (gui);
}
static void
-html_signature_changed (GtkWidget *entry, MailAccountGui *gui)
+setup_signatures (MailAccountGui *gui)
{
- gtk_widget_set_sensitive (GTK_WIDGET (gui->edit_html_signature),
- *gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (gui->html_signature))) != 0);
+ 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);
}
static void
-ssl_option_activate (GtkWidget *widget, gpointer user_data)
+sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailAccountGui *gui)
{
- MailAccountGuiService *service = user_data;
-
- service->ssl_selected = widget;
+ switch (event) {
+ case MAIL_CONFIG_SIG_EVENT_ADDED: {
+
+ GtkWidget *menu;
+ GtkWidget *mi;
+
+ printf ("accounts ADDED\n");
+ 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));
+ 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: {
+
+ GtkWidget *menu;
+ GtkWidget *mi;
+
+ 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));
+ gtk_widget_ref (menu);
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU (gui->sig_option_html));
+ 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_widget_unref (menu);
+ gtk_option_menu_set_history (GTK_OPTION_MENU (gui->sig_option_html), sig_get_gui_index (gui, FALSE));
+
+ break;
+ }
+ case MAIL_CONFIG_SIG_EVENT_DELETED: {
+
+ GtkWidget *menu;
+ GtkWidget *mi;
+
+ 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->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));
+ 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;
+
+ 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;
+
+ 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:
+ ;
+ }
}
static void
-construct_ssl_menu (MailAccountGuiService *service)
+prepare_signatures (MailAccountGui *gui)
{
- GtkWidget *menu, *item = NULL;
- int i;
-
- menu = gtk_menu_new ();
-
- for (i = 0; i < num_ssl_options; i++) {
- item = gtk_menu_item_new_with_label (_(ssl_options[i].label));
- gtk_object_set_data (GTK_OBJECT (item), "use_ssl", ssl_options[i].value);
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- ssl_option_activate, service);
- gtk_widget_show (item);
- gtk_menu_append (GTK_MENU (menu), item);
+ 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");
+
+ sig_fill_options (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);
+
+ 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);
+ } else {
+ mail_config_signature_register_client ((MailConfigSignatureClient) sig_event_client, gui);
}
-
- gtk_option_menu_remove_menu (service->use_ssl);
- gtk_option_menu_set_menu (service->use_ssl, menu);
-
- gtk_option_menu_set_history (service->use_ssl, i - 1);
- gtk_signal_emit_by_name (GTK_OBJECT (item), "activate", service);
}
MailAccountGui *
-mail_account_gui_new (MailConfigAccount *account)
+mail_account_gui_new (MailConfigAccount *account, MailAccountsDialog *dialog)
{
MailAccountGui *gui;
gui = g_new0 (MailAccountGui, 1);
gui->account = account;
+ gui->dialog = dialog;
gui->xml = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL);
/* Management */
@@ -1312,21 +1377,8 @@ mail_account_gui_new (MailConfigAccount *account)
gui->full_name = GTK_ENTRY (glade_xml_get_widget (gui->xml, "identity_full_name"));
gui->email_address = GTK_ENTRY (glade_xml_get_widget (gui->xml, "identity_address"));
gui->organization = GTK_ENTRY (glade_xml_get_widget (gui->xml, "identity_organization"));
- gui->signature = GNOME_FILE_ENTRY (glade_xml_get_widget (gui->xml, "fileentry_signature"));
- gui->html_signature = GNOME_FILE_ENTRY (glade_xml_get_widget (gui->xml, "fileentry_html_signature"));
- gui->has_html_signature = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "check_html_signature"));
- gnome_file_entry_set_default_path (gui->signature, g_get_home_dir ());
- gnome_file_entry_set_default_path (gui->html_signature, g_get_home_dir ());
- gui->edit_signature = GTK_BUTTON (glade_xml_get_widget (gui->xml, "button_edit_signature"));
- gtk_widget_set_sensitive (GTK_WIDGET (gui->edit_signature), FALSE);
- gui->edit_html_signature = GTK_BUTTON (glade_xml_get_widget (gui->xml, "button_edit_html_signature"));
- gtk_widget_set_sensitive (GTK_WIDGET (gui->edit_html_signature), FALSE);
-
- gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (gui->signature)), "changed", signature_changed, gui);
- gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (gui->html_signature)), "changed",
- html_signature_changed, gui);
- gtk_signal_connect (GTK_OBJECT (gui->edit_signature), "clicked", edit_signature, gui);
- gtk_signal_connect (GTK_OBJECT (gui->edit_html_signature), "clicked", edit_html_signature, gui);
+
+ prepare_signatures (gui);
if (account->id) {
if (account->id->name)
@@ -1335,17 +1387,8 @@ mail_account_gui_new (MailConfigAccount *account)
gtk_entry_set_text (gui->email_address, account->id->address);
if (account->id->organization)
e_utf8_gtk_entry_set_text (gui->organization, account->id->organization);
- if (account->id->signature) {
- gnome_file_entry_set_default_path (gui->signature, account->id->signature);
- gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (gui->signature)),
- account->id->signature);
- }
- if (account->id->html_signature) {
- gnome_file_entry_set_default_path (gui->html_signature, account->id->html_signature);
- gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (gui->html_signature)),
- account->id->html_signature);
- }
- gtk_toggle_button_set_active (gui->has_html_signature, account->id->has_html_signature);
+
+ setup_signatures (gui);
}
/* Source */
@@ -1755,10 +1798,9 @@ mail_account_gui_save (MailAccountGui *gui)
account->id->name = e_utf8_gtk_entry_get_text (gui->full_name);
account->id->address = e_utf8_gtk_entry_get_text (gui->email_address);
account->id->organization = e_utf8_gtk_entry_get_text (gui->organization);
- account->id->signature = gnome_file_entry_get_full_path (gui->signature, TRUE);
- account->id->html_signature = gnome_file_entry_get_full_path (gui->html_signature, TRUE);
- account->id->has_html_signature = gtk_toggle_button_get_active (gui->has_html_signature);
-
+
+ sig_set_and_write (gui);
+
old_enabled = account->source && account->source->enabled;
service_destroy (account->source);
account->source = g_new0 (MailConfigService, 1);
@@ -1849,6 +1891,9 @@ mail_account_gui_save (MailAccountGui *gui)
void
mail_account_gui_destroy (MailAccountGui *gui)
{
+ if (gui->dialog)
+ mail_config_signature_unregister_client ((MailConfigSignatureClient) sig_event_client, gui);
+
gtk_object_unref (GTK_OBJECT (gui->xml));
if (gui->extra_config)
g_hash_table_destroy (gui->extra_config);