diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/em-account-editor.c | 26 | ||||
-rw-r--r-- | mail/em-composer-prefs.c | 54 | ||||
-rw-r--r-- | mail/em-migrate.c | 2 | ||||
-rw-r--r-- | mail/mail-config.c | 28 | ||||
-rw-r--r-- | mail/mail-signature-editor.c | 20 |
5 files changed, 86 insertions, 44 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 21650d0624..dceaec5bb3 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -604,11 +604,16 @@ emae_signature_added (ESignatureList *signatures, ESignature *sig, EMAccountEdit { GtkTreeModel *model; GtkTreeIter iter; + const gchar *name; + const gchar *uid; + + name = e_signature_get_name (sig); + uid = e_signature_get_uid (sig); model = gtk_combo_box_get_model (emae->priv->signatures_dropdown); gtk_list_store_append ((GtkListStore *)model, &iter); - gtk_list_store_set ((GtkListStore *)model, &iter, 0, sig->autogen?_("Autogenerated"):sig->name, 1, sig->uid, -1); + gtk_list_store_set ((GtkListStore *)model, &iter, 0, name, 1, uid, -1); gtk_combo_box_set_active (emae->priv->signatures_dropdown, gtk_tree_model_iter_n_children (model, NULL)-1); } @@ -625,10 +630,13 @@ emae_signature_get_iter (EMAccountEditor *emae, ESignature *sig, GtkTreeModel ** return FALSE; do { + const gchar *signature_uid; gchar *uid; + signature_uid = e_signature_get_uid (sig); + gtk_tree_model_get (model, iter, 1, &uid, -1); - if (uid && !strcmp (uid, sig->uid)) + if (uid && !strcmp (uid, signature_uid)) found = TRUE; g_free (uid); } while (!found && gtk_tree_model_iter_next (model, iter)); @@ -651,9 +659,12 @@ emae_signature_changed (ESignatureList *signatures, ESignature *sig, EMAccountEd { GtkTreeIter iter; GtkTreeModel *model; + const gchar *name; + + name = e_signature_get_name (sig); if (emae_signature_get_iter (emae, sig, &model, &iter)) - gtk_list_store_set ((GtkListStore *)model, &iter, 0, sig->autogen?_("Autogenerated"):sig->name, -1); + gtk_list_store_set ((GtkListStore *)model, &iter, 0, name, -1); } static void @@ -718,11 +729,16 @@ emae_setup_signatures (EMAccountEditor *emae, GladeXML *xml) it = e_list_get_iterator ((EList *) signatures); while (e_iterator_is_valid (it)) { ESignature *sig = (ESignature *)e_iterator_get (it); + const gchar *name; + const gchar *uid; + + name = e_signature_get_name (sig); + uid = e_signature_get_uid (sig); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, sig->autogen?_("Autogenerated"):sig->name, 1, sig->uid, -1); + gtk_list_store_set (store, &iter, 0, name, 1, uid, -1); - if (current && !strcmp (current, sig->uid)) + if (current && !strcmp (current, uid)) active = i; e_iterator_next (it); diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c index ab2bb2d8a4..0a7312e837 100644 --- a/mail/em-composer-prefs.c +++ b/mail/em-composer-prefs.c @@ -155,6 +155,8 @@ sig_load_preview (EMComposerPrefs *prefs, { GtkHTML *html; gchar *str; + const gchar *filename; + gboolean is_html; html = prefs->sig_preview; @@ -163,20 +165,22 @@ sig_load_preview (EMComposerPrefs *prefs, return; } - if (signature->script) - str = mail_config_signature_run_script (signature->filename); + filename = e_signature_get_filename (signature); + is_html = e_signature_get_is_html (signature); + + if (e_signature_get_is_script (signature)) + str = mail_config_signature_run_script (filename); else - str = e_msg_composer_get_sig_file_content ( - signature->filename, signature->html); + str = e_msg_composer_get_sig_file_content (filename, is_html); if (!str || !*str) { /* make html stream happy and write at least one character */ g_free (str); str = g_strdup (" "); } - if (signature->html) { + if (is_html) gtk_html_load_from_string (html, str, strlen (str)); - } else { + else { GtkHTMLStream *stream; gint len; @@ -201,16 +205,19 @@ signature_added (ESignatureList *signature_list, GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; + const gchar *name; /* autogen signature is special */ - if (signature->autogen) + if (e_signature_get_autogenerated (signature)) return; + name = e_signature_get_name (signature); + model = gtk_tree_view_get_model (prefs->sig_list); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set ( GTK_LIST_STORE (model), &iter, - 0, signature->name, 1, signature, -1); + 0, name, 1, signature, -1); path = gtk_tree_model_get_path (model, &iter); row = gtk_tree_row_reference_new (model, path); @@ -255,6 +262,7 @@ signature_changed (ESignatureList *signature_list, GtkTreePath *path; GtkTreeIter iter; ESignature *cur; + const gchar *name; if (!(row = g_hash_table_lookup (prefs->sig_hash, signature))) return; @@ -269,7 +277,8 @@ signature_changed (ESignatureList *signature_list, gtk_tree_path_free (path); - gtk_list_store_set ((GtkListStore *) model, &iter, 0, signature->name, -1); + name = e_signature_get_name (signature); + gtk_list_store_set ((GtkListStore *) model, &iter, 0, name, -1); selection = gtk_tree_view_get_selection (prefs->sig_list); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { @@ -287,6 +296,8 @@ sig_edit_cb (GtkWidget *widget, EMComposerPrefs *prefs) GtkWidget *parent; GtkTreeIter iter; ESignature *signature; + const gchar *filename; + const gchar *name; selection = gtk_tree_view_get_selection (prefs->sig_list); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) @@ -294,13 +305,18 @@ sig_edit_cb (GtkWidget *widget, EMComposerPrefs *prefs) gtk_tree_model_get (model, &iter, 1, &signature, -1); - if (!signature->script) { + filename = e_signature_get_filename (signature); + name = e_signature_get_name (signature); + + if (!e_signature_get_is_script (signature)) { GtkWidget *editor; + filename = e_signature_get_filename (signature); + /* normal signature */ - if (!signature->filename || *signature->filename == '\0') { - g_free (signature->filename); - signature->filename = g_strdup (_("Unnamed")); + if (filename == NULL || *filename == '\0') { + e_signature_set_filename (signature, _("Unnamed")); + filename = e_signature_get_filename (signature); } editor = e_signature_editor_new (); @@ -318,10 +334,10 @@ sig_edit_cb (GtkWidget *widget, EMComposerPrefs *prefs) GtkWidget *entry; entry = glade_xml_get_widget (prefs->sig_script_gui, "filechooserbutton_add_script"); - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (entry), signature->filename); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (entry), filename); entry = glade_xml_get_widget (prefs->sig_script_gui, "entry_add_script_name"); - gtk_entry_set_text (GTK_ENTRY (entry), signature->name); + gtk_entry_set_text (GTK_ENTRY (entry), name); g_object_set_data ((GObject *) entry, "sig", signature); @@ -397,14 +413,12 @@ sig_add_script_response (GtkWidget *widget, gint button, EMComposerPrefs *prefs) if ((signature = g_object_get_data ((GObject *) entry, "sig"))) { /* we're just editing an existing signature script */ - g_free (signature->name); - signature->name = g_strdup (name); - g_free(signature->filename); - signature->filename = g_strdup(script); + e_signature_set_name (signature, name); + e_signature_set_filename (signature, script); e_signature_list_change (mail_config_get_signatures (), signature); } else { signature = mail_config_signature_new (script, TRUE, TRUE); - signature->name = g_strdup (name); + e_signature_set_name (signature, name); e_signature_list_add (mail_config_get_signatures (), signature); g_object_unref (signature); diff --git a/mail/em-migrate.c b/mail/em-migrate.c index fd59bafea9..b3888dc7c0 100644 --- a/mail/em-migrate.c +++ b/mail/em-migrate.c @@ -1916,7 +1916,7 @@ get_nth_sig (gint id) if (i == id && e_iterator_is_valid (iter)) { sig = (ESignature *) e_iterator_get (iter); - uid = g_strdup (sig->uid); + uid = g_strdup (e_signature_get_uid (sig)); } g_object_unref (iter); diff --git a/mail/mail-config.c b/mail/mail-config.c index 316957bf38..0c22f0036e 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -1157,14 +1157,18 @@ mail_config_signature_new (const gchar *filename, gboolean script, gboolean html ESignature *sig; sig = e_signature_new (); - sig->name = g_strdup (_("Unnamed")); - sig->script = script; - sig->html = html; + e_signature_set_name (sig, _("Unnamed")); + e_signature_set_is_script (sig, script); + e_signature_set_is_html (sig, html); - if (filename == NULL) - sig->filename = get_new_signature_filename (); - else - sig->filename = g_strdup (filename); + if (filename == NULL) { + gchar *new_filename; + + new_filename = get_new_signature_filename (); + e_signature_set_filename (sig, new_filename); + g_free (new_filename); + } else + e_signature_set_filaname (sig, filename); return sig; } @@ -1191,8 +1195,14 @@ mail_config_add_signature (ESignature *signature) void mail_config_remove_signature (ESignature *signature) { - if (signature->filename && !signature->script) - g_unlink (signature->filename); + const gchar *filename; + gboolean is_script; + + filename = e_signature_get_filename (signature); + is_script = e_signature_get_is_script (signature); + + if (filename == NULL && !is_script) + g_unlink (filename); e_signature_list_remove (config->signatures, signature); mail_config_save_signatures (); diff --git a/mail/mail-signature-editor.c b/mail/mail-signature-editor.c index 401f26feed..e00818e8a1 100644 --- a/mail/mail-signature-editor.c +++ b/mail/mail-signature-editor.c @@ -132,10 +132,10 @@ action_save_and_close_cb (GtkAction *action, signature = mail_config_signature_new (NULL, FALSE, html); else { signature = g_object_ref (editor->priv->signature); - signature->html = html; + e_signature_set_is_html (signature, html); } - filename = signature->filename; + filename = e_signature_get_filename (signature); gtkhtml_editor_save (GTKHTML_EDITOR (editor), filename, html, &error); if (error != NULL) { @@ -166,7 +166,7 @@ action_save_and_close_cb (GtkAction *action, * XXX ESignatureList misuses const. */ same_name = (ESignature *) e_signature_list_find ( signature_list, E_SIGNATURE_FIND_NAME, signature_name); - if (same_name != NULL && strcmp (signature->uid, same_name->uid) != 0) { + if (same_name != NULL && !e_signature_is_equal (signature, same_name)) { e_error_run ( GTK_WINDOW (editor), "mail:signature-already-exists", @@ -176,8 +176,8 @@ action_save_and_close_cb (GtkAction *action, return; } - g_free (signature->name); - signature->name = signature_name; + e_signature_set_name (signature, signature_name); + g_free (signature_name); if (editor->priv->signature != NULL) e_signature_list_change (signature_list, signature); @@ -426,6 +426,7 @@ e_signature_editor_set_signature (ESignatureEditor *editor, { const gchar *filename; const gchar *signature_name; + gboolean is_html; gchar *contents; gsize length; GError *error = NULL; @@ -447,9 +448,10 @@ e_signature_editor_set_signature (ESignatureEditor *editor, /* Load signature content. */ - filename = signature->filename; + filename = e_signature_get_filename (signature); + is_html = e_signature_get_is_html (signature); - if (signature->html) + if (is_html) g_file_get_contents (filename, &contents, &length, &error); else { gchar *data; @@ -462,7 +464,7 @@ e_signature_editor_set_signature (ESignatureEditor *editor, if (error == NULL) { gtkhtml_editor_set_html_mode ( - GTKHTML_EDITOR (editor), signature->html); + GTKHTML_EDITOR (editor), is_html); gtkhtml_editor_set_text_html ( GTKHTML_EDITOR (editor), contents, length); g_free (contents); @@ -473,7 +475,7 @@ e_signature_editor_set_signature (ESignatureEditor *editor, exit: if (signature != NULL) - signature_name = signature->name; + signature_name = e_signature_get_name (signature); else signature_name = _("Unnamed"); |