diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-signature-combo-box.c | 6 | ||||
-rw-r--r-- | widgets/misc/e-signature-editor.c | 32 | ||||
-rw-r--r-- | widgets/misc/e-signature-manager.c | 47 | ||||
-rw-r--r-- | widgets/misc/e-signature-preview.c | 13 | ||||
-rw-r--r-- | widgets/misc/e-signature-tree-view.c | 7 |
5 files changed, 61 insertions, 44 deletions
diff --git a/widgets/misc/e-signature-combo-box.c b/widgets/misc/e-signature-combo-box.c index d447cccb8e..fe4e474729 100644 --- a/widgets/misc/e-signature-combo-box.c +++ b/widgets/misc/e-signature-combo-box.c @@ -98,11 +98,7 @@ signature_combo_box_refresh_cb (ESignatureList *signature_list, const gchar *string; signature = iter->data; - - if (signature->autogen) - string = _("Autogenerated"); - else - string = signature->name; + string = e_signature_get_name (signature); gtk_list_store_append (store, &tree_iter); gtk_list_store_set ( diff --git a/widgets/misc/e-signature-editor.c b/widgets/misc/e-signature-editor.c index 53cb34906b..699216784f 100644 --- a/widgets/misc/e-signature-editor.c +++ b/widgets/misc/e-signature-editor.c @@ -124,19 +124,23 @@ action_save_and_close_cb (GtkAction *action, html = gtkhtml_editor_get_html_mode (GTKHTML_EDITOR (editor)); if (editor->priv->signature == NULL) { + gchar *new_filename; + signature = e_signature_new (); - signature->name = g_strdup (_("Unnamed")); - signature->script = FALSE; - signature->html = html; + e_signature_set_name (signature, _("Unnamed")); + e_signature_set_is_script (signature, FALSE); + e_signature_set_is_html (signature, html); /* FIXME Pass a GError and deal with it. */ - signature->filename = e_create_signature_file (NULL); + new_filename = e_create_signature_file (NULL); + e_signature_set_filename (signature, new_filename); + g_free (new_filename); } 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) { @@ -167,7 +171,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", @@ -177,8 +181,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); @@ -428,6 +432,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; @@ -449,9 +454,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; @@ -467,7 +473,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); @@ -478,7 +484,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"); diff --git a/widgets/misc/e-signature-manager.c b/widgets/misc/e-signature-manager.c index a70bc1dc60..7e29f75cef 100644 --- a/widgets/misc/e-signature-manager.c +++ b/widgets/misc/e-signature-manager.c @@ -92,9 +92,12 @@ signature_manager_run_script_dialog (ESignatureManager *manager, { GtkWidget *dialog; GFile *script_file; + const gchar *name; + const gchar *filename; const gchar *script_name; gboolean success = FALSE; gpointer parent; + gchar *path; parent = gtk_widget_get_toplevel (GTK_WIDGET (manager)); parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; @@ -102,10 +105,13 @@ signature_manager_run_script_dialog (ESignatureManager *manager, dialog = e_signature_script_dialog_new (parent); gtk_window_set_title (GTK_WINDOW (dialog), title); - if (signature->filename != NULL && signature->name != NULL) { + name = e_signature_get_name (signature); + filename = e_signature_get_filename (signature); - script_file = g_file_new_for_path (signature->filename); - script_name = signature->name; + if (filename != NULL && name != NULL) { + + script_file = g_file_new_for_path (filename); + script_name = name; e_signature_script_dialog_set_script_file ( E_SIGNATURE_SCRIPT_DIALOG (dialog), script_file); @@ -123,11 +129,10 @@ signature_manager_run_script_dialog (ESignatureManager *manager, script_name = e_signature_script_dialog_get_script_name ( E_SIGNATURE_SCRIPT_DIALOG (dialog)); - g_free (signature->filename); - signature->filename = g_file_get_path (script_file); - - g_free (signature->name); - signature->name = g_strdup (script_name); + path = g_file_get_path (script_file); + e_signature_set_name (signature, script_name); + e_signature_set_filename (signature, path); + g_free (path); g_object_unref (script_file); @@ -291,8 +296,8 @@ signature_manager_add_signature_script (ESignatureManager *manager) signature_list = e_signature_manager_get_signature_list (manager); signature = e_signature_new (); - signature->script = TRUE; - signature->html = TRUE; + e_signature_set_is_script (signature, TRUE); + e_signature_set_is_html (signature, TRUE); if (signature_manager_run_script_dialog (manager, signature, title)) e_signature_list_add (signature_list, signature); @@ -327,7 +332,7 @@ signature_manager_edit_signature (ESignatureManager *manager) ESignature *signature; GtkWidget *editor; const gchar *title; - gchar *filename; + const gchar *filename; tree_view = e_signature_manager_get_tree_view (manager); signature = e_signature_tree_view_get_selected (tree_view); @@ -336,15 +341,12 @@ signature_manager_edit_signature (ESignatureManager *manager) if (signature == NULL) return; - if (signature->script) + if (e_signature_get_is_script (signature)) goto script; - filename = signature->filename; - if (filename == NULL || *filename == '\0') { - g_free (filename); - filename = g_strdup (_("Unnamed")); - signature->filename = filename; - } + filename = e_signature_get_filename (signature); + if (filename == NULL || *filename == '\0') + e_signature_set_filename (signature, _("Unnamed")); editor = e_signature_editor_new (); e_signature_editor_set_signature ( @@ -373,6 +375,8 @@ signature_manager_remove_signature (ESignatureManager *manager) ESignatureTreeView *tree_view; ESignatureList *signature_list; ESignature *signature; + const gchar *filename; + gboolean is_script; tree_view = e_signature_manager_get_tree_view (manager); signature = e_signature_tree_view_get_selected (tree_view); @@ -381,8 +385,11 @@ signature_manager_remove_signature (ESignatureManager *manager) if (signature == NULL) return; - if (signature->filename != NULL && !signature->script) - g_unlink (signature->filename); + 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 (signature_list, signature); e_signature_list_save (signature_list); diff --git a/widgets/misc/e-signature-preview.c b/widgets/misc/e-signature-preview.c index f8e168cd5a..bbef65f39c 100644 --- a/widgets/misc/e-signature-preview.c +++ b/widgets/misc/e-signature-preview.c @@ -155,6 +155,8 @@ signature_preview_refresh (ESignaturePreview *preview) { GtkHTML *html; ESignature *signature; + const gchar *filename; + gboolean is_script; gchar *content = NULL; gsize length; @@ -166,11 +168,14 @@ signature_preview_refresh (ESignaturePreview *preview) if (signature == NULL) goto clear; - if (signature->script && !preview->priv->allow_scripts) + filename = e_signature_get_filename (signature); + is_script = e_signature_get_is_script (signature); + + if (is_script && !preview->priv->allow_scripts) goto clear; - if (signature->script) - content = e_run_signature_script (signature->filename); + if (is_script) + content = e_run_signature_script (filename); else content = e_read_signature_file (signature, FALSE, NULL); @@ -179,7 +184,7 @@ signature_preview_refresh (ESignaturePreview *preview) length = strlen (content); - if (signature->html) + if (e_signature_get_is_html (signature)) gtk_html_load_from_string (html, content, length); else { GtkHTMLStream *stream; diff --git a/widgets/misc/e-signature-tree-view.c b/widgets/misc/e-signature-tree-view.c index b2cc9d6f66..5c931c8d93 100644 --- a/widgets/misc/e-signature-tree-view.c +++ b/widgets/misc/e-signature-tree-view.c @@ -89,17 +89,20 @@ signature_tree_view_refresh_cb (ESignatureList *signature_list, for (iter = list; iter != NULL; iter = iter->next) { GtkTreeRowReference *reference; GtkTreePath *path; + const gchar *name; signature = iter->data; /* Skip autogenerated signatures. */ - if (signature->autogen) + if (e_signature_get_autogenerated (signature)) continue; + name = e_signature_get_name (signature); + gtk_list_store_append (store, &tree_iter); gtk_list_store_set ( store, &tree_iter, - COLUMN_STRING, signature->name, + COLUMN_STRING, name, COLUMN_SIGNATURE, signature, -1); path = gtk_tree_model_get_path (model, &tree_iter); |