diff options
Diffstat (limited to 'mail/em-composer-prefs.c')
-rw-r--r-- | mail/em-composer-prefs.c | 54 |
1 files changed, 34 insertions, 20 deletions
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); |