evolution-3.6.4/widgets/misc/e-mail-signature-manager.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-signature-manager.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-signature-manager.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * e-mail-signature-manager.c
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  */
 18 
 19 #include "e-mail-signature-manager.h"
 20 
 21 #include <glib/gi18n.h>
 22 #include <glib/gstdio.h>
 23 #include <gdk/gdkkeysyms.h>
 24 
 25 #include <libedataserver/libedataserver.h>
 26 
 27 #include "e-mail-signature-preview.h"
 28 #include "e-mail-signature-tree-view.h"
 29 #include "e-mail-signature-script-dialog.h"
 30 
 31 #define E_MAIL_SIGNATURE_MANAGER_GET_PRIVATE(obj) \
 32 	(G_TYPE_INSTANCE_GET_PRIVATE \
 33 	((obj), E_TYPE_MAIL_SIGNATURE_MANAGER, EMailSignatureManagerPrivate))
 34 
 35 #define PREVIEW_HEIGHT 200
 36 
 37 struct _EMailSignatureManagerPrivate {
 38 	ESourceRegistry *registry;
 39 
 40 	GtkWidget *tree_view;		/* not referenced */
 41 	GtkWidget *add_button;		/* not referenced */
 42 	GtkWidget *add_script_button;	/* not referenced */
 43 	GtkWidget *edit_button;		/* not referenced */
 44 	GtkWidget *remove_button;	/* not referenced */
 45 	GtkWidget *preview;		/* not referenced */
 46 
 47 	gboolean prefer_html;
 48 };
 49 
 50 enum {
 51 	PROP_0,
 52 	PROP_PREFER_HTML,
 53 	PROP_REGISTRY
 54 };
 55 
 56 enum {
 57 	ADD_SIGNATURE,
 58 	ADD_SIGNATURE_SCRIPT,
 59 	EDITOR_CREATED,
 60 	EDIT_SIGNATURE,
 61 	REMOVE_SIGNATURE,
 62 	LAST_SIGNAL
 63 };
 64 
 65 static guint signals[LAST_SIGNAL];
 66 
 67 G_DEFINE_TYPE (
 68 	EMailSignatureManager,
 69 	e_mail_signature_manager,
 70 	GTK_TYPE_PANED)
 71 
 72 static void
 73 mail_signature_manager_emit_editor_created (EMailSignatureManager *manager,
 74                                             GtkWidget *editor)
 75 {
 76 	g_return_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (editor));
 77 
 78 	g_signal_emit (manager, signals[EDITOR_CREATED], 0, editor);
 79 }
 80 
 81 static gboolean
 82 mail_signature_manager_key_press_event_cb (EMailSignatureManager *manager,
 83                                            GdkEventKey *event)
 84 {
 85 	if (event->keyval == GDK_KEY_Delete) {
 86 		e_mail_signature_manager_remove_signature (manager);
 87 		return TRUE;
 88 	}
 89 
 90 	return FALSE;
 91 }
 92 
 93 static void
 94 mail_signature_manager_run_script_dialog (EMailSignatureManager *manager,
 95                                           ESource *source,
 96                                           const gchar *title)
 97 {
 98 	ESourceRegistry *registry;
 99 	GtkWidget *dialog;
100 	gpointer parent;
101 
102 	registry = e_mail_signature_manager_get_registry (manager);
103 
104 	parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
105 	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
106 
107 	dialog = e_mail_signature_script_dialog_new (registry, parent, source);
108 	gtk_window_set_title (GTK_WINDOW (dialog), title);
109 
110 	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
111 		EAsyncClosure *closure;
112 		GAsyncResult *result;
113 		GError *error = NULL;
114 
115 		closure = e_async_closure_new ();
116 
117 		/* FIXME Make this cancellable. */
118 		e_mail_signature_script_dialog_commit (
119 			E_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog), NULL,
120 			e_async_closure_callback, closure);
121 
122 		result = e_async_closure_wait (closure);
123 
124 		e_mail_signature_script_dialog_commit_finish (
125 			E_MAIL_SIGNATURE_SCRIPT_DIALOG (dialog),
126 			result, &error);
127 
128 		e_async_closure_free (closure);
129 
130 		/* FIXME Make this into an EAlert. */
131 		if (error != NULL) {
132 			g_warning ("%s: %s", G_STRFUNC, error->message);
133 			g_error_free (error);
134 		}
135 	}
136 
137 	gtk_widget_destroy (dialog);
138 }
139 
140 static void
141 mail_signature_manager_selection_changed_cb (EMailSignatureManager *manager,
142                                              GtkTreeSelection *selection)
143 {
144 	EMailSignaturePreview *preview;
145 	EMailSignatureTreeView *tree_view;
146 	ESource *source;
147 	GtkWidget *edit_button;
148 	GtkWidget *remove_button;
149 	gboolean sensitive;
150 	const gchar *uid = NULL;
151 
152 	edit_button = manager->priv->edit_button;
153 	remove_button = manager->priv->remove_button;
154 
155 	tree_view = E_MAIL_SIGNATURE_TREE_VIEW (manager->priv->tree_view);
156 	source = e_mail_signature_tree_view_ref_selected_source (tree_view);
157 
158 	if (source != NULL)
159 		uid = e_source_get_uid (source);
160 
161 	preview = E_MAIL_SIGNATURE_PREVIEW (manager->priv->preview);
162 	e_mail_signature_preview_set_source_uid (preview, uid);
163 
164 	sensitive = (source != NULL);
165 	gtk_widget_set_sensitive (edit_button, sensitive);
166 	gtk_widget_set_sensitive (remove_button, sensitive);
167 
168 	if (source != NULL)
169 		g_object_unref (source);
170 }
171 
172 static void
173 mail_signature_manager_set_registry (EMailSignatureManager *manager,
174                                      ESourceRegistry *registry)
175 {
176 	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
177 	g_return_if_fail (manager->priv->registry == NULL);
178 
179 	manager->priv->registry = g_object_ref (registry);
180 }
181 
182 static void
183 mail_signature_manager_set_property (GObject *object,
184                                 guint property_id,
185                                 const GValue *value,
186                                 GParamSpec *pspec)
187 {
188 	switch (property_id) {
189 		case PROP_PREFER_HTML:
190 			e_mail_signature_manager_set_prefer_html (
191 				E_MAIL_SIGNATURE_MANAGER (object),
192 				g_value_get_boolean (value));
193 			return;
194 
195 		case PROP_REGISTRY:
196 			mail_signature_manager_set_registry (
197 				E_MAIL_SIGNATURE_MANAGER (object),
198 				g_value_get_object (value));
199 			return;
200 	}
201 
202 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
203 }
204 
205 static void
206 mail_signature_manager_get_property (GObject *object,
207                                 guint property_id,
208                                 GValue *value,
209                                 GParamSpec *pspec)
210 {
211 	switch (property_id) {
212 		case PROP_PREFER_HTML:
213 			g_value_set_boolean (
214 				value,
215 				e_mail_signature_manager_get_prefer_html (
216 				E_MAIL_SIGNATURE_MANAGER (object)));
217 			return;
218 
219 		case PROP_REGISTRY:
220 			g_value_set_object (
221 				value,
222 				e_mail_signature_manager_get_registry (
223 				E_MAIL_SIGNATURE_MANAGER (object)));
224 			return;
225 	}
226 
227 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
228 }
229 
230 static void
231 mail_signature_manager_dispose (GObject *object)
232 {
233 	EMailSignatureManagerPrivate *priv;
234 
235 	priv = E_MAIL_SIGNATURE_MANAGER_GET_PRIVATE (object);
236 
237 	if (priv->registry != NULL) {
238 		g_object_unref (priv->registry);
239 		priv->registry = NULL;
240 	}
241 
242 	/* Chain up to parent's dispose() method. */
243 	G_OBJECT_CLASS (e_mail_signature_manager_parent_class)->
244 		dispose (object);
245 }
246 
247 static void
248 mail_signature_manager_constructed (GObject *object)
249 {
250 	EMailSignatureManager *manager;
251 	GtkTreeSelection *selection;
252 	ESourceRegistry *registry;
253 	GSettings *settings;
254 	GtkWidget *container;
255 	GtkWidget *widget;
256 	GtkWidget *hbox;
257 
258 	/* Chain up to parent's constructed() method. */
259 	G_OBJECT_CLASS (e_mail_signature_manager_parent_class)->
260 		constructed (object);
261 
262 	manager = E_MAIL_SIGNATURE_MANAGER (object);
263 	registry = e_mail_signature_manager_get_registry (manager);
264 
265 	gtk_orientable_set_orientation (
266 		GTK_ORIENTABLE (manager), GTK_ORIENTATION_VERTICAL);
267 
268 	container = GTK_WIDGET (manager);
269 
270 	widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
271 	gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 12, 0, 0);
272 	gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
273 	gtk_widget_show (widget);
274 
275 	container = widget;
276 
277 	widget = gtk_hbox_new (FALSE, 6);
278 	gtk_container_add (GTK_CONTAINER (container), widget);
279 	gtk_widget_show (widget);
280 
281 	container = hbox = widget;
282 
283 	widget = gtk_scrolled_window_new (NULL, NULL);
284 	gtk_scrolled_window_set_policy (
285 		GTK_SCROLLED_WINDOW (widget),
286 		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
287 	gtk_scrolled_window_set_shadow_type (
288 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
289 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
290 	gtk_widget_show (widget);
291 
292 	container = widget;
293 
294 	widget = e_mail_signature_tree_view_new (registry);
295 	gtk_container_add (GTK_CONTAINER (container), widget);
296 	manager->priv->tree_view = widget;  /* not referenced */
297 	gtk_widget_show (widget);
298 
299 	g_signal_connect_swapped (
300 		widget, "key-press-event",
301 		G_CALLBACK (mail_signature_manager_key_press_event_cb),
302 		manager);
303 
304 	g_signal_connect_swapped (
305 		widget, "row-activated",
306 		G_CALLBACK (e_mail_signature_manager_edit_signature),
307 		manager);
308 
309 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
310 
311 	g_signal_connect_swapped (
312 		selection, "changed",
313 		G_CALLBACK (mail_signature_manager_selection_changed_cb),
314 		manager);
315 
316 	container = hbox;
317 
318 	widget = gtk_vbutton_box_new ();
319 	gtk_button_box_set_layout (
320 		GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_START);
321 	gtk_box_set_spacing (GTK_BOX (widget), 6);
322 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
323 	gtk_widget_show (widget);
324 
325 	container = widget;
326 
327 	widget = gtk_button_new_from_stock (GTK_STOCK_ADD);
328 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
329 	manager->priv->add_button = widget;  /* not referenced */
330 	gtk_widget_show (widget);
331 
332 	g_signal_connect_swapped (
333 		widget, "clicked",
334 		G_CALLBACK (e_mail_signature_manager_add_signature),
335 		manager);
336 
337 	widget = gtk_button_new_with_mnemonic (_("Add _Script"));
338 	gtk_button_set_image (
339 		GTK_BUTTON (widget), gtk_image_new_from_stock (
340 		GTK_STOCK_EXECUTE, GTK_ICON_SIZE_BUTTON));
341 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
342 	manager->priv->add_script_button = widget;  /* not referenced */
343 	gtk_widget_show (widget);
344 
345 	settings = g_settings_new ("org.gnome.desktop.lockdown");
346 
347 	g_settings_bind (
348 		settings, "disable-command-line",
349 		widget, "visible",
350 		G_SETTINGS_BIND_GET |
351 		G_SETTINGS_BIND_INVERT_BOOLEAN);
352 
353 	g_object_unref (settings);
354 
355 	g_signal_connect_swapped (
356 		widget, "clicked",
357 		G_CALLBACK (e_mail_signature_manager_add_signature_script),
358 		manager);
359 
360 	widget = gtk_button_new_from_stock (GTK_STOCK_EDIT);
361 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
362 	manager->priv->edit_button = widget;  /* not referenced */
363 	gtk_widget_show (widget);
364 
365 	g_signal_connect_swapped (
366 		widget, "clicked",
367 		G_CALLBACK (e_mail_signature_manager_edit_signature),
368 		manager);
369 
370 	widget = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
371 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
372 	manager->priv->remove_button = widget;  /* not referenced */
373 	gtk_widget_show (widget);
374 
375 	g_signal_connect_swapped (
376 		widget, "clicked",
377 		G_CALLBACK (e_mail_signature_manager_remove_signature),
378 		manager);
379 
380 	container = GTK_WIDGET (manager);
381 
382 	widget = gtk_scrolled_window_new (NULL, NULL);
383 	gtk_scrolled_window_set_policy (
384 		GTK_SCROLLED_WINDOW (widget),
385 		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
386 	gtk_scrolled_window_set_shadow_type (
387 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
388 	gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
389 	gtk_widget_show (widget);
390 
391 	container = widget;
392 
393 	widget = e_mail_signature_preview_new (registry);
394 	gtk_container_add (GTK_CONTAINER (container), widget);
395 	manager->priv->preview = widget;  /* not referenced */
396 	gtk_widget_show (widget);
397 
398 	gtk_paned_set_position (GTK_PANED (manager), PREVIEW_HEIGHT);
399 }
400 
401 static void
402 mail_signature_manager_add_signature (EMailSignatureManager *manager)
403 {
404 	ESourceRegistry *registry;
405 	GtkWidget *editor;
406 
407 	registry = e_mail_signature_manager_get_registry (manager);
408 
409 	editor = e_mail_signature_editor_new (registry, NULL);
410 	gtkhtml_editor_set_html_mode (
411 		GTKHTML_EDITOR (editor), manager->priv->prefer_html);
412 	mail_signature_manager_emit_editor_created (manager, editor);
413 
414 	gtk_widget_grab_focus (manager->priv->tree_view);
415 }
416 
417 static void
418 mail_signature_manager_add_signature_script (EMailSignatureManager *manager)
419 {
420 	const gchar *title;
421 
422 	title = _("Add Signature Script");
423 	mail_signature_manager_run_script_dialog (manager, NULL, title);
424 
425 	gtk_widget_grab_focus (manager->priv->tree_view);
426 }
427 
428 static void
429 mail_signature_manager_editor_created (EMailSignatureManager *manager,
430                                        EMailSignatureEditor *editor)
431 {
432 	GtkWindowPosition position;
433 	gpointer parent;
434 
435 	position = GTK_WIN_POS_CENTER_ON_PARENT;
436 	parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
437 	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
438 
439 	gtk_window_set_transient_for (GTK_WINDOW (editor), parent);
440 	gtk_window_set_position (GTK_WINDOW (editor), position);
441 	gtk_widget_show (GTK_WIDGET (editor));
442 }
443 
444 static void
445 mail_signature_manager_edit_signature (EMailSignatureManager *manager)
446 {
447 	EMailSignatureTreeView *tree_view;
448 	ESourceMailSignature *extension;
449 	ESourceRegistry *registry;
450 	GtkWidget *editor;
451 	ESource *source;
452 	GFileInfo *file_info;
453 	GFile *file;
454 	const gchar *attribute;
455 	const gchar *extension_name;
456 	const gchar *title;
457 	GError *error = NULL;
458 
459 	registry = e_mail_signature_manager_get_registry (manager);
460 	tree_view = E_MAIL_SIGNATURE_TREE_VIEW (manager->priv->tree_view);
461 	source = e_mail_signature_tree_view_ref_selected_source (tree_view);
462 	g_return_if_fail (source != NULL);
463 
464 	extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
465 	extension = e_source_get_extension (source, extension_name);
466 	file = e_source_mail_signature_get_file (extension);
467 
468 	attribute = G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE;
469 
470 	/* XXX This blocks but it should just be a local file. */
471 	file_info = g_file_query_info (
472 		file, attribute, G_FILE_QUERY_INFO_NONE, NULL, &error);
473 
474 	/* FIXME Make this into an EAlert. */
475 	if (error != NULL) {
476 		g_warn_if_fail (file_info == NULL);
477 		g_warning ("%s: %s", G_STRFUNC, error->message);
478 		g_object_unref (source);
479 		g_error_free (error);
480 		return;
481 	}
482 
483 	if (g_file_info_get_attribute_boolean (file_info, attribute))
484 		goto script;
485 
486 	editor = e_mail_signature_editor_new (registry, source);
487 	mail_signature_manager_emit_editor_created (manager, editor);
488 
489 	goto exit;
490 
491 script:
492 	title = _("Edit Signature Script");
493 	mail_signature_manager_run_script_dialog (manager, source, title);
494 
495 exit:
496 	gtk_widget_grab_focus (GTK_WIDGET (tree_view));
497 
498 	g_object_unref (file_info);
499 	g_object_unref (source);
500 }
501 
502 static void
503 mail_signature_manager_remove_signature (EMailSignatureManager *manager)
504 {
505 	EMailSignatureTreeView *tree_view;
506 	ESourceMailSignature *extension;
507 	ESource *source;
508 	GFile *file;
509 	const gchar *extension_name;
510 	GError *error = NULL;
511 
512 	tree_view = E_MAIL_SIGNATURE_TREE_VIEW (manager->priv->tree_view);
513 	source = e_mail_signature_tree_view_ref_selected_source (tree_view);
514 
515 	if (source == NULL)
516 		return;
517 
518 	extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
519 	extension = e_source_get_extension (source, extension_name);
520 
521 	file = e_source_mail_signature_get_file (extension);
522 
523 	/* XXX This blocks but it should just be a local file. */
524 	if (!g_file_delete (file, NULL, &error)) {
525 		g_warning ("%s", error->message);
526 		g_clear_error (&error);
527 	}
528 
529 	/* Remove the mail signature data source asynchronously.
530 	 * XXX No callback function because there's not much we can do
531 	 *     if this fails.  We should probably implement EAlertSink. */
532 	e_source_remove (source, NULL, NULL, NULL);
533 
534 	gtk_widget_grab_focus (GTK_WIDGET (tree_view));
535 
536 	g_object_unref (source);
537 }
538 
539 static void
540 e_mail_signature_manager_class_init (EMailSignatureManagerClass *class)
541 {
542 	GObjectClass *object_class;
543 
544 	g_type_class_add_private (
545 		class, sizeof (EMailSignatureManagerPrivate));
546 
547 	object_class = G_OBJECT_CLASS (class);
548 	object_class->set_property = mail_signature_manager_set_property;
549 	object_class->get_property = mail_signature_manager_get_property;
550 	object_class->dispose = mail_signature_manager_dispose;
551 	object_class->constructed = mail_signature_manager_constructed;
552 
553 	class->add_signature = mail_signature_manager_add_signature;
554 	class->add_signature_script =
555 		mail_signature_manager_add_signature_script;
556 	class->editor_created = mail_signature_manager_editor_created;
557 	class->edit_signature = mail_signature_manager_edit_signature;
558 	class->remove_signature = mail_signature_manager_remove_signature;
559 
560 	g_object_class_install_property (
561 		object_class,
562 		PROP_PREFER_HTML,
563 		g_param_spec_boolean (
564 			"prefer-html",
565 			"Prefer HTML",
566 			NULL,
567 			TRUE,
568 			G_PARAM_READWRITE |
569 			G_PARAM_CONSTRUCT |
570 			G_PARAM_STATIC_STRINGS));
571 
572 	g_object_class_install_property (
573 		object_class,
574 		PROP_REGISTRY,
575 		g_param_spec_object (
576 			"registry",
577 			"Registry",
578 			NULL,
579 			E_TYPE_SOURCE_REGISTRY,
580 			G_PARAM_READWRITE |
581 			G_PARAM_CONSTRUCT |
582 			G_PARAM_STATIC_STRINGS));
583 
584 	signals[ADD_SIGNATURE] = g_signal_new (
585 		"add-signature",
586 		G_OBJECT_CLASS_TYPE (class),
587 		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
588 		G_STRUCT_OFFSET (EMailSignatureManagerClass, add_signature),
589 		NULL, NULL,
590 		g_cclosure_marshal_VOID__VOID,
591 		G_TYPE_NONE, 0);
592 
593 	signals[ADD_SIGNATURE_SCRIPT] = g_signal_new (
594 		"add-signature-script",
595 		G_OBJECT_CLASS_TYPE (class),
596 		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
597 		G_STRUCT_OFFSET (
598 			EMailSignatureManagerClass, add_signature_script),
599 		NULL, NULL,
600 		g_cclosure_marshal_VOID__VOID,
601 		G_TYPE_NONE, 0);
602 
603 	signals[EDITOR_CREATED] = g_signal_new (
604 		"editor-created",
605 		G_OBJECT_CLASS_TYPE (class),
606 		G_SIGNAL_RUN_LAST,
607 		G_STRUCT_OFFSET (EMailSignatureManagerClass, editor_created),
608 		NULL, NULL,
609 		g_cclosure_marshal_VOID__OBJECT,
610 		G_TYPE_NONE, 1,
611 		E_TYPE_MAIL_SIGNATURE_EDITOR);
612 
613 	signals[EDIT_SIGNATURE] = g_signal_new (
614 		"edit-signature",
615 		G_OBJECT_CLASS_TYPE (class),
616 		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
617 		G_STRUCT_OFFSET (EMailSignatureManagerClass, edit_signature),
618 		NULL, NULL,
619 		g_cclosure_marshal_VOID__VOID,
620 		G_TYPE_NONE, 0);
621 
622 	signals[REMOVE_SIGNATURE] = g_signal_new (
623 		"remove-signature",
624 		G_OBJECT_CLASS_TYPE (class),
625 		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
626 		G_STRUCT_OFFSET (EMailSignatureManagerClass, remove_signature),
627 		NULL, NULL,
628 		g_cclosure_marshal_VOID__VOID,
629 		G_TYPE_NONE, 0);
630 }
631 
632 static void
633 e_mail_signature_manager_init (EMailSignatureManager *manager)
634 {
635 	manager->priv = E_MAIL_SIGNATURE_MANAGER_GET_PRIVATE (manager);
636 }
637 
638 GtkWidget *
639 e_mail_signature_manager_new (ESourceRegistry *registry)
640 {
641 	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
642 
643 	return g_object_new (
644 		E_TYPE_MAIL_SIGNATURE_MANAGER,
645 		"registry", registry, NULL);
646 }
647 
648 void
649 e_mail_signature_manager_add_signature (EMailSignatureManager *manager)
650 {
651 	g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
652 
653 	g_signal_emit (manager, signals[ADD_SIGNATURE], 0);
654 }
655 
656 void
657 e_mail_signature_manager_add_signature_script (EMailSignatureManager *manager)
658 {
659 	g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
660 
661 	g_signal_emit (manager, signals[ADD_SIGNATURE_SCRIPT], 0);
662 }
663 
664 void
665 e_mail_signature_manager_edit_signature (EMailSignatureManager *manager)
666 {
667 	g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
668 
669 	g_signal_emit (manager, signals[EDIT_SIGNATURE], 0);
670 }
671 
672 void
673 e_mail_signature_manager_remove_signature (EMailSignatureManager *manager)
674 {
675 	g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
676 
677 	g_signal_emit (manager, signals[REMOVE_SIGNATURE], 0);
678 }
679 
680 gboolean
681 e_mail_signature_manager_get_prefer_html (EMailSignatureManager *manager)
682 {
683 	g_return_val_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager), FALSE);
684 
685 	return manager->priv->prefer_html;
686 }
687 
688 void
689 e_mail_signature_manager_set_prefer_html (EMailSignatureManager *manager,
690                                           gboolean prefer_html)
691 {
692 	g_return_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager));
693 
694 	if (manager->priv->prefer_html == prefer_html)
695 		return;
696 
697 	manager->priv->prefer_html = prefer_html;
698 
699 	g_object_notify (G_OBJECT (manager), "prefer-html");
700 }
701 
702 ESourceRegistry *
703 e_mail_signature_manager_get_registry (EMailSignatureManager *manager)
704 {
705 	g_return_val_if_fail (E_IS_MAIL_SIGNATURE_MANAGER (manager), NULL);
706 
707 	return manager->priv->registry;
708 }