1 /*
2  * Copyright (C) 2016 Red Hat, Inc. (www.redhat.com)
3  *
4  * This library is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #include "evolution-config.h"
18 
19 #include <glib.h>
20 #include <glib-object.h>
21 
22 #include <libedataserver/libedataserver.h>
23 
24 #include "e-html-editor.h"
25 #include "e-util-enumtypes.h"
26 #include "e-misc-utils.h"
27 #include "e-content-editor.h"
28 
29 G_DEFINE_INTERFACE (EContentEditor, e_content_editor, GTK_TYPE_WIDGET);
30 
31 enum {
32 	LOAD_FINISHED,
33 	PASTE_CLIPBOARD,
34 	PASTE_PRIMARY_CLIPBOARD,
35 	CONTEXT_MENU_REQUESTED,
36 	FIND_DONE,
37 	REPLACE_ALL_DONE,
38 	DROP_HANDLED,
39 	CONTENT_CHANGED,
40 	REF_MIME_PART,
41 	LAST_SIGNAL
42 };
43 
44 static guint signals[LAST_SIGNAL] = { 0 };
45 
46 static void
e_content_editor_default_init(EContentEditorInterface * iface)47 e_content_editor_default_init (EContentEditorInterface *iface)
48 {
49 	/**
50 	 * EContentEditor:is-malfunction
51 	 *
52 	 * Determines whether the composer is malfunction. If it does, then
53 	 * the result of calling functions like get_content() is undefined.
54 	 */
55 	g_object_interface_install_property (
56 		iface,
57 		g_param_spec_boolean (
58 			"is-malfunction",
59 			"Is Malfunction",
60 			NULL,
61 			FALSE,
62 			G_PARAM_READABLE |
63 			G_PARAM_STATIC_STRINGS));
64 
65 	/**
66 	 * EContentEditor:can-copy
67 	 *
68 	 * Determines whether it's possible to copy to clipboard. The action
69 	 * is usually disabled when there is no selection to copy.
70 	 */
71 	g_object_interface_install_property (
72 		iface,
73 		g_param_spec_boolean (
74 			"can-copy",
75 			"Can Copy",
76 			NULL,
77 			FALSE,
78 			G_PARAM_READABLE |
79 			G_PARAM_STATIC_STRINGS));
80 
81 	/**
82 	 * EContentEditor:can-cut
83 	 *
84 	 * Determines whether it's possible to cut to clipboard. The action
85 	 * is usually disabled when there is no selection to cut.
86 	 */
87 	g_object_interface_install_property (
88 		iface,
89 		g_param_spec_boolean (
90 			"can-cut",
91 			"Can Cut",
92 			NULL,
93 			FALSE,
94 			G_PARAM_READABLE |
95 			G_PARAM_STATIC_STRINGS));
96 
97 	/**
98 	 * EContentEditor:can-paste
99 	 *
100 	 * Determines whether it's possible to paste from clipboard. The action
101 	 * is usually disabled when there is no valid content in clipboard to
102 	 * paste.
103 	 */
104 	g_object_interface_install_property (
105 		iface,
106 		g_param_spec_boolean (
107 			"can-paste",
108 			"Can Paste",
109 			NULL,
110 			FALSE,
111 			G_PARAM_READABLE |
112 			G_PARAM_STATIC_STRINGS));
113 
114 	/**
115 	 * EContentEditor:can-redo
116 	 *
117 	 * Determines whether it's possible to redo previous action. The action
118 	 * is usually disabled when there is no action to redo.
119 	 */
120 	g_object_interface_install_property (
121 		iface,
122 		g_param_spec_boolean (
123 			"can-redo",
124 			"Can Redo",
125 			NULL,
126 			FALSE,
127 			G_PARAM_READABLE |
128 			G_PARAM_STATIC_STRINGS));
129 
130 	/**
131 	 * EContentEditor:can-undo
132 	 *
133 	 * Determines whether it's possible to undo last action. The action
134 	 * is usually disabled when there is no previous action to undo.
135 	 */
136 	g_object_interface_install_property (
137 		iface,
138 		g_param_spec_boolean (
139 			"can-undo",
140 			"Can Undo",
141 			NULL,
142 			FALSE,
143 			G_PARAM_READABLE |
144 			G_PARAM_STATIC_STRINGS));
145 
146 	/**
147 	 * EContentEditor:editable
148 	 *
149 	 * Determines whether the editor is editable or read-only.
150 	 **/
151 	g_object_interface_install_property (
152 		iface,
153 		g_param_spec_boolean (
154 			"editable",
155 			"Editable",
156 			"Wheter editor is editable",
157 			TRUE,
158 			G_PARAM_READWRITE |
159 			G_PARAM_STATIC_STRINGS));
160 
161 	/**
162 	 * EContentEditor:changed
163 	 *
164 	 * Determines whether document has been modified
165 	 */
166 	g_object_interface_install_property (
167 		iface,
168 		g_param_spec_boolean (
169 			"changed",
170 			"Changed property",
171 			"Whether editor changed",
172 			FALSE,
173 			G_PARAM_READWRITE |
174 			G_PARAM_STATIC_STRINGS));
175 
176 	/**
177 	 * EContentEditor:html-mode
178 	 *
179 	 * Determines whether HTML or plain text mode is enabled.
180 	 **/
181 	g_object_interface_install_property (
182 		iface,
183 		g_param_spec_boolean (
184 			"html-mode",
185 			"HTML Mode",
186 			"Edit HTML or plain text",
187 			TRUE,
188 			G_PARAM_READWRITE |
189 			G_PARAM_STATIC_STRINGS));
190 
191 	/**
192 	 * EContentEditor:alignment
193 	 *
194 	 * Holds alignment of current paragraph.
195 	 */
196 	g_object_interface_install_property (
197 		iface,
198 		g_param_spec_enum (
199 			"alignment",
200 			NULL,
201 			NULL,
202 			E_TYPE_CONTENT_EDITOR_ALIGNMENT,
203 			E_CONTENT_EDITOR_ALIGNMENT_LEFT,
204 			G_PARAM_READWRITE));
205 
206 	/**
207 	 * EContentEditor:background-color
208 	 *
209 	 * Holds background color of current selection or at current cursor
210 	 * position.
211 	 */
212 	g_object_interface_install_property (
213 		iface,
214 		g_param_spec_boxed (
215 			"background-color",
216 			NULL,
217 			NULL,
218 			GDK_TYPE_RGBA,
219 			G_PARAM_READWRITE));
220 
221 	/**
222 	 * EContentEditor:block-format
223 	 *
224 	 * Holds block format of current paragraph. See
225 	 * #EContentEditorBlockFormat for valid values.
226 	 */
227 	g_object_interface_install_property (
228 		iface,
229 		g_param_spec_enum (
230 			"block-format",
231 			NULL,
232 			NULL,
233 			E_TYPE_CONTENT_EDITOR_BLOCK_FORMAT,
234 			E_CONTENT_EDITOR_BLOCK_FORMAT_NONE,
235 			G_PARAM_READWRITE));
236 
237 	/**
238 	 * EContentEditor:bold
239 	 *
240 	 * Holds whether current selection or text at current cursor position
241 	 * is bold.
242 	 */
243 	g_object_interface_install_property (
244 		iface,
245 		g_param_spec_boolean (
246 			"bold",
247 			NULL,
248 			NULL,
249 			FALSE,
250 			G_PARAM_READWRITE |
251 			G_PARAM_STATIC_STRINGS));
252 
253 	/**
254 	 * EContentEditor:font-color
255 	 *
256 	 * Holds font color of current selection or at current cursor position.
257 	 */
258 	g_object_interface_install_property (
259 		iface,
260 		g_param_spec_boxed (
261 			"font-color",
262 			NULL,
263 			NULL,
264 			GDK_TYPE_RGBA,
265 			G_PARAM_READWRITE |
266 			G_PARAM_STATIC_STRINGS));
267 
268 	/**
269 	 * EContentEditor:font-name
270 	 *
271 	 * Holds name of font in current selection or at current cursor
272 	 * position.
273 	 */
274 	g_object_interface_install_property (
275 		iface,
276 		g_param_spec_string (
277 			"font-name",
278 			NULL,
279 			NULL,
280 			NULL,
281 			G_PARAM_READWRITE |
282 			G_PARAM_STATIC_STRINGS));
283 
284 	/**
285 	 * EContentEditor:font-size
286 	 *
287 	 * Holds point size of current selection or at current cursor position.
288 	 */
289 	g_object_interface_install_property (
290 		iface,
291 		g_param_spec_int (
292 			"font-size",
293 			NULL,
294 			NULL,
295 			1,
296 			7,
297 			3,
298 			G_PARAM_READWRITE |
299 			G_PARAM_STATIC_STRINGS));
300 
301 	/**
302 	 * EContentEditor:indent-level
303 	 *
304 	 * Holds current paragraph indent level. This does not include
305 	 * citations.
306 	 */
307 	g_object_interface_install_property (
308 		iface,
309 		g_param_spec_int (
310 			"indent-level",
311 			NULL,
312 			NULL,
313 			0, E_HTML_EDITOR_MAX_INDENT_LEVEL, 0,
314 			G_PARAM_READABLE |
315 			G_PARAM_STATIC_STRINGS));
316 
317 	/**
318 	 * EContentEditor:italic
319 	 *
320 	 * Holds whether current selection or letter at current cursor position
321 	 * is italic.
322 	 */
323 	g_object_interface_install_property (
324 		iface,
325 		g_param_spec_boolean (
326 			"italic",
327 			NULL,
328 			NULL,
329 			FALSE,
330 			G_PARAM_READWRITE |
331 			G_PARAM_STATIC_STRINGS));
332 
333 	/**
334 	 * EContentEditor:strikethrough
335 	 *
336 	 * Holds whether current selection or letter at current cursor position
337 	 * is strikethrough.
338 	 */
339 	g_object_interface_install_property (
340 		iface,
341 		g_param_spec_boolean (
342 			"strikethrough",
343 			NULL,
344 			NULL,
345 			FALSE,
346 			G_PARAM_READWRITE |
347 			G_PARAM_STATIC_STRINGS));
348 
349 	/**
350 	 * EContentEditor:superscript
351 	 *
352 	 * Holds whether current selection or letter at current cursor position
353 	 * is in superscript.
354 	 */
355 	g_object_interface_install_property (
356 		iface,
357 		g_param_spec_boolean (
358 			"superscript",
359 			NULL,
360 			NULL,
361 			FALSE,
362 			G_PARAM_READWRITE |
363 			G_PARAM_STATIC_STRINGS));
364 
365 	/**
366 	 * EContentEditor:subscript
367 	 *
368 	 * Holds whether current selection or letter at current cursor position
369 	 * is in subscript.
370 	 */
371 	g_object_interface_install_property (
372 		iface,
373 		g_param_spec_boolean (
374 			"subscript",
375 			NULL,
376 			NULL,
377 			FALSE,
378 			G_PARAM_READWRITE |
379 			G_PARAM_STATIC_STRINGS));
380 
381 	/**
382 	 * EContentEditor:underline
383 	 *
384 	 * Holds whether current selection or letter at current cursor position
385 	 * is underlined.
386 	 */
387 	g_object_interface_install_property (
388 		iface,
389 		g_param_spec_boolean (
390 			"underline",
391 			NULL,
392 			NULL,
393 			FALSE,
394 			G_PARAM_READWRITE |
395 			G_PARAM_STATIC_STRINGS));
396 
397 	/**
398 	 * EContentEditor:start-bottom
399 	 *
400 	 * Holds where the cursor should be positioned after body of
401 	 * a reply or forward is loaded.
402 	 *
403 	 * Since: 3.26
404 	 */
405 	g_object_interface_install_property (
406 		iface,
407 		g_param_spec_enum (
408 			"start-bottom",
409 			NULL,
410 			NULL,
411 			E_TYPE_THREE_STATE,
412 			E_THREE_STATE_INCONSISTENT,
413 			G_PARAM_READWRITE |
414 			G_PARAM_STATIC_STRINGS));
415 
416 	/**
417 	 * EContentEditor:top-signature
418 	 *
419 	 * Holds where the signature should be positioned after body of
420 	 * a reply or forward is loaded.
421 	 *
422 	 * Since: 3.26
423 	 */
424 	g_object_interface_install_property (
425 		iface,
426 		g_param_spec_enum (
427 			"top-signature",
428 			NULL,
429 			NULL,
430 			E_TYPE_THREE_STATE,
431 			E_THREE_STATE_INCONSISTENT,
432 			G_PARAM_READWRITE |
433 			G_PARAM_STATIC_STRINGS));
434 
435 	/**
436 	 * EContentEditor:spell-check-enabled
437 	 *
438 	 * Holds whether the spell checking is enabled.
439 	 */
440 	g_object_interface_install_property (
441 		iface,
442 		g_param_spec_boolean (
443 			"spell-check-enabled",
444 			NULL,
445 			NULL,
446 			FALSE,
447 			G_PARAM_READWRITE |
448 			G_PARAM_STATIC_STRINGS));
449 
450 	/**
451 	 * EContentEditor:spell-checker:
452 	 *
453 	 * The #ESpellChecker used for spell checking.
454 	 **/
455 	g_object_interface_install_property (
456 		iface,
457 		g_param_spec_object (
458 			"spell-checker",
459 			"Spell Checker",
460 			"The spell checker",
461 			E_TYPE_SPELL_CHECKER,
462 			G_PARAM_READABLE |
463 			G_PARAM_STATIC_STRINGS));
464 
465 	/**
466 	 * EContentEditor:visually-wrap-long-lines:
467 	 *
468 	 * Whether to visually wrap long preformatted lines.
469 	 *
470 	 * Since: 3.28
471 	 */
472 	g_object_interface_install_property (
473 		iface,
474 		g_param_spec_boolean (
475 			"visually-wrap-long-lines",
476 			NULL,
477 			NULL,
478 			FALSE,
479 			G_PARAM_READWRITE |
480 			G_PARAM_STATIC_STRINGS));
481 
482 	/**
483 	 * EContentEditor:last-error:
484 	 *
485 	 * GError of the last operation; can be %NULL.
486 	 *
487 	 * Since: 3.34
488 	 */
489 	g_object_interface_install_property (
490 		iface,
491 		g_param_spec_boxed (
492 			"last-error",
493 			NULL,
494 			NULL,
495 			G_TYPE_ERROR,
496 			G_PARAM_READWRITE |
497 			G_PARAM_STATIC_STRINGS));
498 
499 	/**
500 	 * EContentEditor:paste-clipboard
501 	 *
502 	 * Emitted when user presses middle button on EContentEditor.
503 	 */
504 	signals[PASTE_CLIPBOARD] = g_signal_new (
505 		"paste-clipboard",
506 		E_TYPE_CONTENT_EDITOR,
507 		G_SIGNAL_RUN_LAST,
508 		G_STRUCT_OFFSET (EContentEditorInterface, paste_clipboard),
509 		g_signal_accumulator_true_handled, NULL,
510 		NULL,
511 		G_TYPE_BOOLEAN, 0);
512 
513 	/**
514 	 * EContentEditor:paste-primary-clipboard
515 	 *
516 	 * Emitted when user presses middle button on EWebKitContentEditor.
517 	 */
518 	signals[PASTE_PRIMARY_CLIPBOARD] = g_signal_new (
519 		"paste-primary-clipboard",
520 		E_TYPE_CONTENT_EDITOR,
521 		G_SIGNAL_RUN_LAST,
522 		G_STRUCT_OFFSET (EContentEditorInterface, paste_primary_clipboard),
523 		g_signal_accumulator_true_handled, NULL,
524 		NULL,
525 		G_TYPE_BOOLEAN, 0);
526 
527 	/**
528 	 * EContentEditor:load-finished
529 	 *
530 	 * Emitted when the content editor has finished loading.
531 	 */
532 	signals[LOAD_FINISHED] = g_signal_new (
533 		"load-finished",
534 		E_TYPE_CONTENT_EDITOR,
535 		G_SIGNAL_RUN_LAST,
536 		G_STRUCT_OFFSET (EContentEditorInterface, load_finished),
537 		NULL, NULL,
538 		NULL,
539 		G_TYPE_NONE, 0);
540 
541 	/**
542 	 * EContentEditor:context-menu-requested
543 	 *
544 	 * Emitted whenever a context menu is requested.
545 	 */
546 	signals[CONTEXT_MENU_REQUESTED] = g_signal_new (
547 		"context-menu-requested",
548 		E_TYPE_CONTENT_EDITOR,
549 		G_SIGNAL_RUN_LAST,
550 		G_STRUCT_OFFSET (EContentEditorInterface, context_menu_requested),
551 		NULL, NULL,
552 		NULL,
553 		G_TYPE_NONE, 3,
554 		G_TYPE_INT,
555 		G_TYPE_STRING,
556 		GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
557 
558 	/**
559 	 * EContentEditor::find-done
560 	 *
561 	 * Emitted when the call to e_content_editor_find() is done.
562 	 **/
563 	signals[FIND_DONE] = g_signal_new (
564 		"find-done",
565 		E_TYPE_CONTENT_EDITOR,
566 		G_SIGNAL_RUN_LAST,
567 		G_STRUCT_OFFSET (EContentEditorInterface, find_done),
568 		NULL, NULL,
569 		NULL,
570 		G_TYPE_NONE, 1,
571 		G_TYPE_UINT);
572 
573 	/**
574 	 * EContentEditor::replace-all-done
575 	 *
576 	 * Emitted when the call to e_content_editor_replace_all() is done.
577 	 **/
578 	signals[REPLACE_ALL_DONE] = g_signal_new (
579 		"replace-all-done",
580 		E_TYPE_CONTENT_EDITOR,
581 		G_SIGNAL_RUN_LAST,
582 		G_STRUCT_OFFSET (EContentEditorInterface, replace_all_done),
583 		NULL, NULL,
584 		NULL,
585 		G_TYPE_NONE, 1,
586 		G_TYPE_UINT);
587 
588 	/**
589 	 * EContentEditor:drop-handled
590 	 *
591 	 * Emitted when the content editor successfully handled the drop operation.
592 	 */
593 	signals[DROP_HANDLED] = g_signal_new (
594 		"drop-handled",
595 		E_TYPE_CONTENT_EDITOR,
596 		G_SIGNAL_RUN_LAST,
597 		G_STRUCT_OFFSET (EContentEditorInterface, drop_handled),
598 		NULL, NULL,
599 		NULL,
600 		G_TYPE_NONE, 0);
601 
602 	/**
603 	 * EContentEditor:content-changed
604 	 *
605 	 * Emitted when the content of the editor changes. It can be used in connection
606 	 * to the #EContentEditor::changed property, except this signal is emitted
607 	 * whenever the inner content changes, which the 'changed' property notifies
608 	 * about its change only when the value truly changes.
609 	 *
610 	 * Since: 3.26
611 	 */
612 	signals[CONTENT_CHANGED] = g_signal_new (
613 		"content-changed",
614 		E_TYPE_CONTENT_EDITOR,
615 		G_SIGNAL_RUN_LAST,
616 		G_STRUCT_OFFSET (EContentEditorInterface, content_changed),
617 		NULL, NULL,
618 		NULL,
619 		G_TYPE_NONE, 0);
620 
621 	/**
622 	 * EContentEditor:ref-mime-part
623 	 *
624 	 * This is used by the content editor, when it wants to get
625 	 * a #CamelMimePart of given URI (aka "cid:..."). The returned
626 	 * object, if not %NULL, should be freed with g_object_unref(),
627 	 * when no longer needed.
628 	 *
629 	 * Since: 3.38
630 	 */
631 	signals[REF_MIME_PART] = g_signal_new (
632 		"ref-mime-part",
633 		E_TYPE_CONTENT_EDITOR,
634 		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
635 		G_STRUCT_OFFSET (EContentEditorInterface, ref_mime_part),
636 		NULL, NULL,
637 		NULL,
638 		CAMEL_TYPE_MIME_PART, 1,
639 		G_TYPE_STRING);
640 }
641 
642 ESpellChecker *
e_content_editor_ref_spell_checker(EContentEditor * editor)643 e_content_editor_ref_spell_checker (EContentEditor *editor)
644 {
645 	ESpellChecker *spell_checker = NULL;
646 
647 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
648 
649 	g_object_get (G_OBJECT (editor), "spell-checker", &spell_checker, NULL);
650 
651 	return spell_checker;
652 }
653 
654 gboolean
e_content_editor_is_malfunction(EContentEditor * editor)655 e_content_editor_is_malfunction (EContentEditor *editor)
656 {
657 	gboolean value = FALSE;
658 
659 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
660 
661 	g_object_get (G_OBJECT (editor), "is-malfunction", &value, NULL);
662 
663 	return value;
664 }
665 
666 gboolean
e_content_editor_can_cut(EContentEditor * editor)667 e_content_editor_can_cut (EContentEditor *editor)
668 {
669 	gboolean value = FALSE;
670 
671 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
672 
673 	g_object_get (G_OBJECT (editor), "can-cut", &value, NULL);
674 
675 	return value;
676 }
677 
678 gboolean
e_content_editor_can_copy(EContentEditor * editor)679 e_content_editor_can_copy (EContentEditor *editor)
680 {
681 	gboolean value = FALSE;
682 
683 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
684 
685 	g_object_get (G_OBJECT (editor), "can-copy", &value, NULL);
686 
687 	return value;
688 }
689 
690 gboolean
e_content_editor_can_paste(EContentEditor * editor)691 e_content_editor_can_paste (EContentEditor *editor)
692 {
693 	gboolean value = FALSE;
694 
695 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
696 
697 	g_object_get (G_OBJECT (editor), "can-paste", &value, NULL);
698 
699 	return value;
700 }
701 
702 gboolean
e_content_editor_can_undo(EContentEditor * editor)703 e_content_editor_can_undo (EContentEditor *editor)
704 {
705 	gboolean value = FALSE;
706 
707 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
708 
709 	g_object_get (G_OBJECT (editor), "can-undo", &value, NULL);
710 
711 	return value;
712 }
713 
714 gboolean
e_content_editor_can_redo(EContentEditor * editor)715 e_content_editor_can_redo (EContentEditor *editor)
716 {
717 	gboolean value = FALSE;
718 
719 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
720 
721 	g_object_get (G_OBJECT (editor), "can-redo", &value, NULL);
722 
723 	return value;
724 }
725 
726 /**
727  * e_content_editor_indent_level:
728  * @editor: an #EContentEditor
729  *
730  * Returns the indent level for the current selection/caret position.
731  * This does not include citations.
732  *
733  * Returns: the indent level.
734  *
735  * Since: 3.38
736  **/
737 gint
e_content_editor_indent_level(EContentEditor * editor)738 e_content_editor_indent_level (EContentEditor *editor)
739 {
740 	gint value = 0;
741 
742 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
743 
744 	g_object_get (G_OBJECT (editor), "indent-level", &value, NULL);
745 
746 	return value;
747 }
748 
749 gboolean
e_content_editor_get_spell_check_enabled(EContentEditor * editor)750 e_content_editor_get_spell_check_enabled (EContentEditor *editor)
751 {
752 	gboolean value = FALSE;
753 
754 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
755 
756 	g_object_get (G_OBJECT (editor), "spell-check-enabled", &value, NULL);
757 
758 	return value;
759 }
760 
761 void
e_content_editor_set_spell_check_enabled(EContentEditor * editor,gboolean enable)762 e_content_editor_set_spell_check_enabled (EContentEditor *editor,
763 					  gboolean enable)
764 {
765 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
766 
767 	g_object_set (G_OBJECT (editor), "spell-check-enabled", enable, NULL);
768 }
769 
770 gboolean
e_content_editor_is_editable(EContentEditor * editor)771 e_content_editor_is_editable (EContentEditor *editor)
772 {
773 	gboolean value = FALSE;
774 
775 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
776 
777 	g_object_get (G_OBJECT (editor), "editable", &value, NULL);
778 
779 	return value;
780 }
781 
782 void
e_content_editor_set_editable(EContentEditor * editor,gboolean editable)783 e_content_editor_set_editable (EContentEditor *editor,
784 			       gboolean editable)
785 {
786 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
787 
788 	g_object_set (G_OBJECT (editor), "editable", editable, NULL);
789 }
790 
791 gboolean
e_content_editor_get_changed(EContentEditor * editor)792 e_content_editor_get_changed (EContentEditor *editor)
793 {
794 	gboolean value = FALSE;
795 
796 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
797 
798 	g_object_get (G_OBJECT (editor), "changed", &value, NULL);
799 
800 	return value;
801 }
802 
803 void
e_content_editor_set_changed(EContentEditor * editor,gboolean changed)804 e_content_editor_set_changed (EContentEditor *editor,
805 			      gboolean changed)
806 {
807 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
808 
809 	g_object_set (G_OBJECT (editor), "changed", changed, NULL);
810 }
811 
812 gboolean
e_content_editor_get_html_mode(EContentEditor * editor)813 e_content_editor_get_html_mode (EContentEditor *editor)
814 {
815 	gboolean value = FALSE;
816 
817 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
818 
819 	g_object_get (G_OBJECT (editor), "html-mode", &value, NULL);
820 
821 	return value;
822 }
823 
824 void
e_content_editor_set_html_mode(EContentEditor * editor,gboolean html_mode)825 e_content_editor_set_html_mode (EContentEditor *editor,
826 				gboolean html_mode)
827 {
828 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
829 
830 	g_object_set (G_OBJECT (editor), "html-mode", html_mode, NULL);
831 }
832 
833 /**
834  * e_content_editor_set_alignment:
835  * @editor: an #EContentEditor
836  * @value: an #EContentEditorAlignment value to apply
837  *
838  * Sets alignment of current paragraph to @value.
839  *
840  * Since: 3.22
841  **/
842 void
e_content_editor_set_alignment(EContentEditor * editor,EContentEditorAlignment value)843 e_content_editor_set_alignment (EContentEditor *editor,
844 				EContentEditorAlignment value)
845 {
846 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
847 
848 	g_object_set (G_OBJECT (editor), "alignment", value, NULL);
849 }
850 
851 /**
852  * e_content_editor_get_alignment:
853  * @editor: #an EContentEditor
854  *
855  * Returns alignment of the current paragraph.
856  *
857  * Returns: #EContentEditorAlignment
858  *
859  * Since: 3.22
860  **/
861 EContentEditorAlignment
e_content_editor_get_alignment(EContentEditor * editor)862 e_content_editor_get_alignment (EContentEditor *editor)
863 {
864 	EContentEditorAlignment value = E_CONTENT_EDITOR_ALIGNMENT_LEFT;
865 
866 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), E_CONTENT_EDITOR_ALIGNMENT_LEFT);
867 
868 	g_object_get (G_OBJECT (editor), "alignment", &value, NULL);
869 
870 	return value;
871 }
872 
873 /**
874  * e_content_editor_set_background_color:
875  * @editor: an #EContentEditor
876  * @value: a #GdkRGBA
877  *
878  * Sets the background color of the current selection or letter at the current cursor position to
879  * a color defined by @value.
880  *
881  * Since: 3.22
882  **/
883 void
e_content_editor_set_background_color(EContentEditor * editor,const GdkRGBA * value)884 e_content_editor_set_background_color (EContentEditor *editor,
885 				       const GdkRGBA *value)
886 {
887 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
888 	g_return_if_fail (value != NULL);
889 
890 	g_object_set (G_OBJECT (editor), "background-color", value, NULL);
891 }
892 
893 /**
894  * e_content_editor_dup_background_color:
895  * @editor: an #EContentEditor
896  *
897  * Returns the background color used in the current selection or at letter
898  * at the current cursor position.
899  *
900  * Returns: (transfer-full): A newly allocated #GdkRGBA structure with
901  *   the current background color. Free the returned value with gdk_rgba_free()
902  *   when done with it.
903  *
904  * Since: 3.22
905  **/
906 GdkRGBA *
e_content_editor_dup_background_color(EContentEditor * editor)907 e_content_editor_dup_background_color (EContentEditor *editor)
908 {
909 	GdkRGBA *value = NULL;
910 
911 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
912 
913 	g_object_get (G_OBJECT (editor), "background-color", &value, NULL);
914 
915 	return value;
916 }
917 
918 /**
919  * e_content_editor_set_font_color:
920  * @editor: an #EContentEditor
921  * @value: a #GdkRGBA
922  *
923  * Sets the font color of the current selection or letter at the current cursor position to
924  * a color defined by @value.
925  *
926  * Since: 3.22
927  **/
928 void
e_content_editor_set_font_color(EContentEditor * editor,const GdkRGBA * value)929 e_content_editor_set_font_color (EContentEditor *editor,
930 				 const GdkRGBA *value)
931 {
932 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
933 	g_return_if_fail (value != NULL);
934 
935 	g_object_set (G_OBJECT (editor), "font-color", value, NULL);
936 }
937 
938 /**
939  * e_content_editor_dup_font_color:
940  * @editor: an #EContentEditor
941  *
942  * Returns the font color used in the current selection or at letter
943  * at the current cursor position.
944  *
945  * Returns: (transfer-full): A newly allocated #GdkRGBA structure with
946  *   the current font color. Free the returned value with gdk_rgba_free()
947  *   when done with it.
948  *
949  * Since: 3.22
950  **/
951 GdkRGBA *
e_content_editor_dup_font_color(EContentEditor * editor)952 e_content_editor_dup_font_color (EContentEditor *editor)
953 {
954 	GdkRGBA *value = NULL;
955 
956 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
957 
958 	g_object_get (G_OBJECT (editor), "font-color", &value, NULL);
959 
960 	return value;
961 }
962 
963 /**
964  * e_content_editor_set_font_name:
965  * @editor: an #EContentEditor
966  * @value: a font name to apply
967  *
968  * Sets font name of current selection or of letter at current cursor position
969  * to @value.
970  *
971  * Since: 3.22
972  **/
973 void
e_content_editor_set_font_name(EContentEditor * editor,const gchar * value)974 e_content_editor_set_font_name (EContentEditor *editor,
975 				const gchar *value)
976 {
977 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
978 	g_return_if_fail (value != NULL);
979 
980 	g_object_set (G_OBJECT (editor), "font-name", value, NULL);
981 }
982 
983 /**
984  * e_content_editor_dup_font_name:
985  * @editor: an #EContentEditor
986  *
987  * Returns a name of the font used in the current selection or at letter
988  * at the current cursor position.
989  *
990  * Returns: (transfer-full): A newly allocated string with the font name.
991  *    Free it with g_free() when done with it.
992  *
993  * Since: 3.22
994  **/
995 gchar *
e_content_editor_dup_font_name(EContentEditor * editor)996 e_content_editor_dup_font_name (EContentEditor *editor)
997 {
998 	gchar *value = NULL;
999 
1000 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
1001 
1002 	g_object_get (G_OBJECT (editor), "font-name", &value, NULL);
1003 
1004 	return value;
1005 }
1006 
1007 /**
1008  * e_content_editor_set_font_size:
1009  * @editor: an #EContentEditor
1010  * @value: font size to apply
1011  *
1012  * Sets font size of current selection or of letter at current cursor position
1013  * to @value.
1014  *
1015  * Since: 3.22
1016  **/
1017 void
e_content_editor_set_font_size(EContentEditor * editor,gint value)1018 e_content_editor_set_font_size (EContentEditor *editor,
1019 				gint value)
1020 {
1021 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1022 
1023 	g_object_set (G_OBJECT (editor), "font-size", value, NULL);
1024 }
1025 
1026 /**
1027  * e_content_editor_get_font_size:
1028  * @editor: an #EContentEditor
1029  *
1030  * Returns fotn size of the current selection or letter at the current
1031  * cursor position.
1032  *
1033  * Returns: Current font size.
1034  *
1035  * Since: 3.22
1036  **/
1037 gint
e_content_editor_get_font_size(EContentEditor * editor)1038 e_content_editor_get_font_size (EContentEditor *editor)
1039 {
1040 	gint value = -1;
1041 
1042 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), -1);
1043 
1044 	g_object_get (G_OBJECT (editor), "font-size", &value, NULL);
1045 
1046 	return value;
1047 }
1048 
1049 /**
1050  * e_content_editor_set_block_format:
1051  * @editor: an #EContentEditor
1052  * @value: an #EContentEditorBlockFormat value
1053  *
1054  * Changes block format of the current paragraph to @value.
1055  *
1056  * Since: 3.22
1057  **/
1058 void
e_content_editor_set_block_format(EContentEditor * editor,EContentEditorBlockFormat value)1059 e_content_editor_set_block_format (EContentEditor *editor,
1060 				   EContentEditorBlockFormat value)
1061 {
1062 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1063 
1064 	g_object_set (G_OBJECT (editor), "block-format", value, NULL);
1065 }
1066 
1067 /**
1068  * e_content_editor_get_block_format:
1069  * @editor: an #EContentEditor
1070  *
1071  * Returns block format of the current paragraph.
1072  *
1073  * Returns: #EContentEditorBlockFormat
1074  *
1075  * Since: 3.22
1076  **/
1077 EContentEditorBlockFormat
e_content_editor_get_block_format(EContentEditor * editor)1078 e_content_editor_get_block_format (EContentEditor *editor)
1079 {
1080 	EContentEditorBlockFormat value = E_CONTENT_EDITOR_BLOCK_FORMAT_NONE;
1081 
1082 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), E_CONTENT_EDITOR_BLOCK_FORMAT_NONE);
1083 
1084 	g_object_get (G_OBJECT (editor), "block-format", &value, NULL);
1085 
1086 	return value;
1087 }
1088 
1089 /**
1090  * e_content_editor_set_bold:
1091  * @editor: an #EContentEditor
1092  * @bold: %TRUE to enable bold, %FALSE to disable
1093  *
1094  * Changes bold formatting of current selection or letter at current
1095  * cursor position.
1096  *
1097  * Since: 3.22
1098  **/
1099 void
e_content_editor_set_bold(EContentEditor * editor,gboolean bold)1100 e_content_editor_set_bold (EContentEditor *editor,
1101 			   gboolean bold)
1102 {
1103 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1104 
1105 	g_object_set (G_OBJECT (editor), "bold", bold, NULL);
1106 }
1107 
1108 /**
1109  * e_content_editor_is_bold:
1110  * @editor: an #EContentEditor
1111  *
1112  * Returns whether current selection or letter at current cursor position is bold.
1113  *
1114  * Returns: %TRUE when selection is bold, %FALSE otherwise.
1115  *
1116  * Since: 3.22
1117  **/
1118 gboolean
e_content_editor_is_bold(EContentEditor * editor)1119 e_content_editor_is_bold (EContentEditor *editor)
1120 {
1121 	gboolean value = FALSE;
1122 
1123 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1124 
1125 	g_object_get (G_OBJECT (editor), "bold", &value, NULL);
1126 
1127 	return value;
1128 }
1129 
1130 /**
1131  * e_content_editor_set_italic:
1132  * @editor: an #EContentEditor
1133  * @italic: %TRUE to enable italic, %FALSE to disable
1134  *
1135  * Changes italic formatting of current selection or letter at current
1136  * cursor position.
1137  *
1138  * Since: 3.22
1139  **/
1140 void
e_content_editor_set_italic(EContentEditor * editor,gboolean italic)1141 e_content_editor_set_italic (EContentEditor *editor,
1142 			     gboolean italic)
1143 {
1144 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1145 
1146 	g_object_set (G_OBJECT (editor), "italic", italic, NULL);
1147 }
1148 
1149 /**
1150  * e_content_editor_is_italic:
1151  * @editor: an #EContentEditor
1152  *
1153  * Returns whether current selection or letter at current cursor position
1154  * is italic.
1155  *
1156  * Returns: %TRUE when selection is italic, %FALSE otherwise.
1157  *
1158  * Since: 3.22
1159  **/
1160 gboolean
e_content_editor_is_italic(EContentEditor * editor)1161 e_content_editor_is_italic (EContentEditor *editor)
1162 {
1163 	gboolean value = FALSE;
1164 
1165 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1166 
1167 	g_object_get (G_OBJECT (editor), "italic", &value, NULL);
1168 
1169 	return value;
1170 }
1171 
1172 /**
1173  * e_content_editor_set_strikethrough:
1174  * @editor: an #EContentEditor
1175  * @strikethrough: %TRUE to enable strikethrough, %FALSE to disable
1176  *
1177  * Changes strike through formatting of current selection or letter at current
1178  * cursor position.
1179  *
1180  * Since: 3.22
1181  **/
1182 void
e_content_editor_set_strikethrough(EContentEditor * editor,gboolean strikethrough)1183 e_content_editor_set_strikethrough (EContentEditor *editor,
1184 				    gboolean strikethrough)
1185 {
1186 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1187 
1188 	g_object_set (G_OBJECT (editor), "strikethrough", strikethrough, NULL);
1189 }
1190 
1191 /**
1192  * e_content_editor_is_strikethrough:
1193  * @editor: an #EContentEditor
1194  *
1195  * Returns whether current selection or letter at current cursor position
1196  * is striked through.
1197  *
1198  * Returns: %TRUE when selection is striked through, %FALSE otherwise.
1199  *
1200  * Since: 3.22
1201  **/
1202 gboolean
e_content_editor_is_strikethrough(EContentEditor * editor)1203 e_content_editor_is_strikethrough (EContentEditor *editor)
1204 {
1205 	gboolean value = FALSE;
1206 
1207 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1208 
1209 	g_object_get (G_OBJECT (editor), "strikethrough", &value, NULL);
1210 
1211 	return value;
1212 }
1213 
1214 /**
1215  * e_content_editor_set_subscript:
1216  * @editor: an #EContentEditor
1217  * @subscript: %TRUE to enable subscript, %FALSE to disable
1218  *
1219  * Changes subscript of current selection or letter at current
1220  * cursor position.
1221  *
1222  * Since: 3.22
1223  **/
1224 void
e_content_editor_set_subscript(EContentEditor * editor,gboolean subscript)1225 e_content_editor_set_subscript (EContentEditor *editor,
1226 				gboolean subscript)
1227 {
1228 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1229 
1230 	g_object_set (G_OBJECT (editor), "subscript", subscript, NULL);
1231 }
1232 
1233 /**
1234  * e_content_editor_is_subscript:
1235  * @editor: an #EContentEditor
1236  *
1237  * Returns whether current selection or letter at current cursor position
1238  * is in subscript.
1239  *
1240  * Returns: %TRUE when selection is in subscript, %FALSE otherwise.
1241  *
1242  * Since: 3.22
1243  **/
1244 gboolean
e_content_editor_is_subscript(EContentEditor * editor)1245 e_content_editor_is_subscript (EContentEditor *editor)
1246 {
1247 	gboolean value = FALSE;
1248 
1249 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1250 
1251 	g_object_get (G_OBJECT (editor), "subscript", &value, NULL);
1252 
1253 	return value;
1254 }
1255 
1256 /**
1257  * e_content_editor_set_superscript:
1258  * @editor: an #EContentEditor
1259  * @superscript: %TRUE to enable superscript, %FALSE to disable
1260  *
1261  * Changes superscript of the current selection or letter at current
1262  * cursor position.
1263  *
1264  * Since: 3.22
1265  **/
1266 void
e_content_editor_set_superscript(EContentEditor * editor,gboolean superscript)1267 e_content_editor_set_superscript (EContentEditor *editor,
1268 				  gboolean superscript)
1269 {
1270 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1271 
1272 	g_object_set (G_OBJECT (editor), "superscript", superscript, NULL);
1273 }
1274 
1275 /**
1276  * e_content_editor_is_superscript:
1277  * @editor: an #EContentEditor
1278  *
1279  * Returns whether current selection or letter at current cursor position
1280  * is in superscript.
1281  *
1282  * Returns: %TRUE when selection is in superscript, %FALSE otherwise.
1283  *
1284  * Since: 3.22
1285  **/
1286 gboolean
e_content_editor_is_superscript(EContentEditor * editor)1287 e_content_editor_is_superscript (EContentEditor *editor)
1288 {
1289 	gboolean value = FALSE;
1290 
1291 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1292 
1293 	g_object_get (G_OBJECT (editor), "superscript", &value, NULL);
1294 
1295 	return value;
1296 }
1297 
1298 /**
1299  * e_content_editor_set_underline:
1300  * @editor: an #EContentEditor
1301  * @underline: %TRUE to enable underline, %FALSE to disable
1302  *
1303  * Changes underline formatting of current selection or letter
1304  * at current cursor position.
1305  *
1306  * Since: 3.22
1307  **/
1308 void
e_content_editor_set_underline(EContentEditor * editor,gboolean underline)1309 e_content_editor_set_underline (EContentEditor *editor,
1310 				gboolean underline)
1311 {
1312 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1313 
1314 	g_object_set (G_OBJECT (editor), "underline", underline, NULL);
1315 }
1316 
1317 /**
1318  * e_content_editor_is_underline:
1319  * @editor: an #EContentEditor
1320  *
1321  * Returns whether current selection or letter at current cursor position
1322  * is underlined.
1323  *
1324  * Returns: %TRUE when selection is underlined, %FALSE otherwise.
1325  *
1326  * Since: 3.22
1327  **/
1328 gboolean
e_content_editor_is_underline(EContentEditor * editor)1329 e_content_editor_is_underline (EContentEditor *editor)
1330 {
1331 	gboolean value = FALSE;
1332 
1333 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1334 
1335 	g_object_get (G_OBJECT (editor), "underline", &value, NULL);
1336 
1337 	return value;
1338 }
1339 
1340 /**
1341  * e_content_editor_set_start_bottom:
1342  * @editor: an #EContentEditor
1343  * @value: an #EThreeState value to set
1344  *
1345  * Changes start-bottom property, which is used to position
1346  * cursor after setting message body in replies and forwards.
1347  *
1348  * Since: 3.26
1349  **/
1350 void
e_content_editor_set_start_bottom(EContentEditor * editor,EThreeState value)1351 e_content_editor_set_start_bottom (EContentEditor *editor,
1352 				   EThreeState value)
1353 {
1354 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1355 
1356 	g_object_set (G_OBJECT (editor), "start-bottom", value, NULL);
1357 }
1358 
1359 /**
1360  * e_content_editor_get_start_bottom:
1361  * @editor: an #EContentEditor
1362  *
1363  * Returns: the current value of start-bottom property.
1364  *
1365  * Since: 3.26
1366  **/
1367 EThreeState
e_content_editor_get_start_bottom(EContentEditor * editor)1368 e_content_editor_get_start_bottom (EContentEditor *editor)
1369 {
1370 	EThreeState value = E_THREE_STATE_INCONSISTENT;
1371 
1372 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1373 
1374 	g_object_get (G_OBJECT (editor), "start-bottom", &value, NULL);
1375 
1376 	return value;
1377 }
1378 
1379 /**
1380  * e_content_editor_set_top_signature:
1381  * @editor: an #EContentEditor
1382  * @value: an #EThreeState value to set
1383  *
1384  * Changes top-signature property, which is used to position
1385  * signature after setting message body in replies and forwards.
1386  *
1387  * Since: 3.26
1388  **/
1389 void
e_content_editor_set_top_signature(EContentEditor * editor,EThreeState value)1390 e_content_editor_set_top_signature (EContentEditor *editor,
1391 				    EThreeState value)
1392 {
1393 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1394 
1395 	g_object_set (G_OBJECT (editor), "top-signature", value, NULL);
1396 }
1397 
1398 /**
1399  * e_content_editor_get_top_signature:
1400  * @editor: an #EContentEditor
1401  *
1402  * Returns: the current value of top-signature property.
1403  *
1404  * Since: 3.26
1405  **/
1406 EThreeState
e_content_editor_get_top_signature(EContentEditor * editor)1407 e_content_editor_get_top_signature (EContentEditor *editor)
1408 {
1409 	EThreeState value = E_THREE_STATE_INCONSISTENT;
1410 
1411 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1412 
1413 	g_object_get (G_OBJECT (editor), "top-signature", &value, NULL);
1414 
1415 	return value;
1416 }
1417 
1418 /**
1419  * e_content_editor_set_visually_wrap_long_lines:
1420  * @editor: an #EContactEditor
1421  * @value: value to set
1422  *
1423  * Sets whether to visually wrap long preformatted lines.
1424  *
1425  * Since: 3.28
1426  **/
1427 void
e_content_editor_set_visually_wrap_long_lines(EContentEditor * editor,gboolean value)1428 e_content_editor_set_visually_wrap_long_lines (EContentEditor *editor,
1429 					       gboolean value)
1430 {
1431 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1432 
1433 	g_object_set (G_OBJECT (editor), "visually-wrap-long-lines", value, NULL);
1434 }
1435 
1436 /**
1437  * e_content_editor_get_visually_wrap_long_lines:
1438  * @editor: an #EContactEditor
1439  *
1440  * Returns: Whether visually wraps long preformatted lines.
1441  *
1442  * Since: 3.28
1443  **/
1444 gboolean
e_content_editor_get_visually_wrap_long_lines(EContentEditor * editor)1445 e_content_editor_get_visually_wrap_long_lines (EContentEditor *editor)
1446 {
1447 	gboolean value = FALSE;
1448 
1449 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
1450 
1451 	g_object_get (G_OBJECT (editor), "visually-wrap-long-lines", &value, NULL);
1452 
1453 	return value;
1454 }
1455 
1456 /**
1457  * e_content_editor_setup_editor:
1458  * @content_editor: an #EContentEditor
1459  * @callback: an #EContentEditorInitializedCallback function
1460  * @user_data: data to pass to @callback
1461  *
1462  * Initilizes the @content_editor. Once the initialization is done,
1463  * the @callback is called with the passed @user_data.
1464  *
1465  * Since: 3.22
1466  **/
1467 void
e_content_editor_initialize(EContentEditor * content_editor,EContentEditorInitializedCallback callback,gpointer user_data)1468 e_content_editor_initialize (EContentEditor *content_editor,
1469 			     EContentEditorInitializedCallback callback,
1470 			     gpointer user_data)
1471 {
1472 	EContentEditorInterface *iface;
1473 
1474 	g_return_if_fail (E_IS_CONTENT_EDITOR (content_editor));
1475 	g_return_if_fail (callback != NULL);
1476 
1477 	iface = E_CONTENT_EDITOR_GET_IFACE (content_editor);
1478 	g_return_if_fail (iface != NULL);
1479 	g_return_if_fail (iface->initialize != NULL);
1480 
1481 	iface->initialize (content_editor, callback, user_data);
1482 }
1483 
1484 /**
1485  * e_content_editor_setup_editor:
1486  * @content_editor: an #EContentEditor
1487  * @html_editor: an #EHTMLEditor
1488  *
1489  * Called the first time the @content_editor is picked to be used within
1490  * the @html_editor. This is typically used to modify the UI
1491  * of the @html_editor. This method implementation is optional.
1492  *
1493  * Since: 3.22
1494  **/
1495 void
e_content_editor_setup_editor(EContentEditor * content_editor,EHTMLEditor * html_editor)1496 e_content_editor_setup_editor (EContentEditor *content_editor,
1497 			       EHTMLEditor *html_editor)
1498 {
1499 	EContentEditorInterface *iface;
1500 
1501 	g_return_if_fail (E_IS_CONTENT_EDITOR (content_editor));
1502 	g_return_if_fail (E_IS_HTML_EDITOR (html_editor));
1503 
1504 	iface = E_CONTENT_EDITOR_GET_IFACE (content_editor);
1505 	g_return_if_fail (iface != NULL);
1506 
1507 	if (iface->setup_editor)
1508 		iface->setup_editor (content_editor, html_editor);
1509 }
1510 
1511 void
e_content_editor_update_styles(EContentEditor * editor)1512 e_content_editor_update_styles (EContentEditor *editor)
1513 {
1514 	EContentEditorInterface *iface;
1515 
1516 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1517 
1518 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1519 	g_return_if_fail (iface != NULL);
1520 	g_return_if_fail (iface->update_styles != NULL);
1521 
1522 	iface->update_styles (editor);
1523 }
1524 
1525 void
e_content_editor_insert_content(EContentEditor * editor,const gchar * content,EContentEditorInsertContentFlags flags)1526 e_content_editor_insert_content (EContentEditor *editor,
1527                                  const gchar *content,
1528                                  EContentEditorInsertContentFlags flags)
1529 {
1530 	EContentEditorInterface *iface;
1531 
1532 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1533 	g_return_if_fail (content != NULL);
1534 
1535 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1536 	g_return_if_fail (iface != NULL);
1537 	g_return_if_fail (iface->insert_content != NULL);
1538 
1539 	iface->insert_content (editor, content, flags);
1540 }
1541 
1542 /*
1543  Finish the operation with e_content_editor_get_content_finish().
1544  */
1545 void
e_content_editor_get_content(EContentEditor * editor,guint32 flags,const gchar * inline_images_from_domain,GCancellable * cancellable,GAsyncReadyCallback callback,gpointer user_data)1546 e_content_editor_get_content (EContentEditor *editor,
1547 			      guint32 flags,
1548 			      const gchar *inline_images_from_domain,
1549 			      GCancellable *cancellable,
1550 			      GAsyncReadyCallback callback,
1551 			      gpointer user_data)
1552 {
1553 	EContentEditorInterface *iface;
1554 
1555 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1556 
1557 	if ((flags & E_CONTENT_EDITOR_GET_INLINE_IMAGES))
1558 		g_return_if_fail (inline_images_from_domain != NULL);
1559 
1560 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1561 	g_return_if_fail (iface != NULL);
1562 	g_return_if_fail (iface->get_content != NULL);
1563 
1564 	iface->get_content (editor, flags, inline_images_from_domain, cancellable, callback, user_data);
1565 }
1566 
1567 /*
1568  Finishes previous call of e_content_editor_get_content(). The implementation
1569  creates the GHashTable with e_content_editor_util_new_content_hash() and fills
1570  it with e_content_editor_util_put_content_data(), e_content_editor_util_take_content_data()
1571  or e_content_editor_util_take_content_data_images(). The caller can access
1572  the members with e_content_editor_util_get_content_data().
1573 
1574  The returned pointer should be freed with e_content_editor_util_free_content_hash(),
1575  when done with it.
1576  */
1577 EContentEditorContentHash *
e_content_editor_get_content_finish(EContentEditor * editor,GAsyncResult * result,GError ** error)1578 e_content_editor_get_content_finish (EContentEditor *editor,
1579 				     GAsyncResult *result,
1580 				     GError **error)
1581 {
1582 	EContentEditorInterface *iface;
1583 
1584 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
1585 
1586 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1587 	g_return_val_if_fail (iface != NULL, NULL);
1588 	g_return_val_if_fail (iface->get_content != NULL, NULL);
1589 
1590 	return iface->get_content_finish (editor, result, error);
1591 }
1592 
1593 typedef struct _ContentHashData {
1594 	gpointer data;
1595 	GDestroyNotify destroy_data;
1596 } ContentHashData;
1597 
1598 static ContentHashData *
content_hash_data_new(gpointer data,GDestroyNotify destroy_data)1599 content_hash_data_new (gpointer data,
1600 		       GDestroyNotify destroy_data)
1601 {
1602 	ContentHashData *chd;
1603 
1604 	chd = g_slice_new (ContentHashData);
1605 	chd->data = data;
1606 	chd->destroy_data = destroy_data;
1607 
1608 	return chd;
1609 }
1610 
1611 static void
content_hash_data_free(gpointer ptr)1612 content_hash_data_free (gpointer ptr)
1613 {
1614 	ContentHashData *chd = ptr;
1615 
1616 	if (ptr) {
1617 		if (chd->destroy_data && chd->data)
1618 			chd->destroy_data (chd->data);
1619 
1620 		g_slice_free (ContentHashData, chd);
1621 	}
1622 }
1623 
1624 static void
content_data_free_obj_slist(gpointer ptr)1625 content_data_free_obj_slist (gpointer ptr)
1626 {
1627 	GSList *lst = ptr;
1628 
1629 	g_slist_free_full (lst, g_object_unref);
1630 }
1631 
1632 EContentEditorContentHash *
e_content_editor_util_new_content_hash(void)1633 e_content_editor_util_new_content_hash (void)
1634 {
1635 	return (EContentEditorContentHash *) g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, content_hash_data_free);
1636 }
1637 
1638 void
e_content_editor_util_free_content_hash(EContentEditorContentHash * content_hash)1639 e_content_editor_util_free_content_hash (EContentEditorContentHash *content_hash)
1640 {
1641 	if (content_hash)
1642 		g_hash_table_unref ((GHashTable *) content_hash);
1643 }
1644 
1645 void
e_content_editor_util_put_content_data(EContentEditorContentHash * content_hash,EContentEditorGetContentFlags flag,const gchar * data)1646 e_content_editor_util_put_content_data (EContentEditorContentHash *content_hash,
1647 					EContentEditorGetContentFlags flag,
1648 					const gchar *data)
1649 {
1650 	g_return_if_fail (content_hash != NULL);
1651 	g_return_if_fail (flag != E_CONTENT_EDITOR_GET_ALL);
1652 	g_return_if_fail (data != NULL);
1653 
1654 	e_content_editor_util_take_content_data (content_hash, flag, g_strdup (data), g_free);
1655 }
1656 
1657 void
e_content_editor_util_take_content_data(EContentEditorContentHash * content_hash,EContentEditorGetContentFlags flag,gpointer data,GDestroyNotify destroy_data)1658 e_content_editor_util_take_content_data (EContentEditorContentHash *content_hash,
1659 					 EContentEditorGetContentFlags flag,
1660 					 gpointer data,
1661 					 GDestroyNotify destroy_data)
1662 {
1663 	g_return_if_fail (content_hash != NULL);
1664 	g_return_if_fail (flag != E_CONTENT_EDITOR_GET_ALL);
1665 	g_return_if_fail (data != NULL);
1666 
1667 	g_hash_table_insert ((GHashTable *) content_hash, GUINT_TO_POINTER (flag), content_hash_data_new (data, destroy_data));
1668 }
1669 
1670 void
e_content_editor_util_take_content_data_images(EContentEditorContentHash * content_hash,GSList * image_parts)1671 e_content_editor_util_take_content_data_images (EContentEditorContentHash *content_hash,
1672 						GSList *image_parts) /* CamelMimePart * */
1673 {
1674 	g_return_if_fail (content_hash != NULL);
1675 	g_return_if_fail (image_parts != NULL);
1676 
1677 	g_hash_table_insert ((GHashTable *) content_hash, GUINT_TO_POINTER (E_CONTENT_EDITOR_GET_INLINE_IMAGES),
1678 		content_hash_data_new (image_parts, content_data_free_obj_slist));
1679 }
1680 
1681 /* The actual data type depends on the @flag. The E_CONTENT_EDITOR_GET_INLINE_IMAGES returns
1682    a GSList of CamelMimePart-s of inline images. All the other flags return plain strings.
1683 
1684    The returned pointer is owned by content_hash and cannot be freed
1685    neither modified. It's freed together with the content_hash, or
1686    when its key is overwritten.
1687  */
1688 gpointer
e_content_editor_util_get_content_data(EContentEditorContentHash * content_hash,EContentEditorGetContentFlags flag)1689 e_content_editor_util_get_content_data (EContentEditorContentHash *content_hash,
1690 					EContentEditorGetContentFlags flag)
1691 {
1692 	ContentHashData *chd;
1693 
1694 	g_return_val_if_fail (content_hash != NULL, NULL);
1695 	g_return_val_if_fail (flag != E_CONTENT_EDITOR_GET_ALL, NULL);
1696 
1697 	chd = g_hash_table_lookup ((GHashTable *) content_hash, GUINT_TO_POINTER (flag));
1698 
1699 	return chd ? chd->data : NULL;
1700 }
1701 
1702 /* The same rules apply as with e_content_editor_util_get_content_data(). The difference is
1703    that after calling this function the data is stoled from the content_hash and the caller
1704    is responsible to free it. Any following calls with the same flag will return %NULL.
1705  */
1706 gpointer
e_content_editor_util_steal_content_data(EContentEditorContentHash * content_hash,EContentEditorGetContentFlags flag,GDestroyNotify * out_destroy_data)1707 e_content_editor_util_steal_content_data (EContentEditorContentHash *content_hash,
1708 					  EContentEditorGetContentFlags flag,
1709 					  GDestroyNotify *out_destroy_data)
1710 {
1711 	ContentHashData *chd;
1712 	gpointer data;
1713 
1714 	if (out_destroy_data)
1715 		*out_destroy_data = NULL;
1716 
1717 	g_return_val_if_fail (content_hash != NULL, NULL);
1718 	g_return_val_if_fail (flag != E_CONTENT_EDITOR_GET_ALL, NULL);
1719 
1720 	chd = g_hash_table_lookup ((GHashTable *) content_hash, GUINT_TO_POINTER (flag));
1721 
1722 	if (!chd)
1723 		return NULL;
1724 
1725 	data = chd->data;
1726 
1727 	if (out_destroy_data)
1728 		*out_destroy_data = chd->destroy_data;
1729 
1730 	chd->data = NULL;
1731 	chd->destroy_data = NULL;
1732 
1733 	return data;
1734 }
1735 
1736 /**
1737  * e_content_editor_util_create_data_mimepart:
1738  * @uri: a file:// or data: URI of the data to convert to MIME part
1739  * @cid: content ID to use for the MIME part, should start with "cid:"; can be %NULL
1740  * @as_inline: whether to use "inline" content disposition; will use "attachment", if set to %FALSE
1741  * @prefer_filename: preferred file name to use, can be %NULL
1742  * @prefer_mime_type: preferred MIME type for the part, can be %NULL
1743  * @cancellable: optional #GCancellable object, or %NULL
1744  *
1745  * Converts URI into a #CamelMimePart. Supports file:// and data: URIs.
1746  * The @prefer_filename can override the file name from the @uri.
1747  *
1748  * Free the returned pointer, if not %NULL, with g_object_unref(), when
1749  * no longer needed.
1750  *
1751  * Returns: (transfer full) (nullable): a new #CamelMimePart containing
1752  *    the referenced data, or %NULL, when cannot be converted (due to
1753  *    unsupported URI, file not found or such).
1754  *
1755  * Since: 3.38
1756  **/
1757 CamelMimePart *
e_content_editor_util_create_data_mimepart(const gchar * uri,const gchar * cid,gboolean as_inline,const gchar * prefer_filename,const gchar * prefer_mime_type,GCancellable * cancellable)1758 e_content_editor_util_create_data_mimepart (const gchar *uri,
1759 					    const gchar *cid,
1760 					    gboolean as_inline,
1761 					    const gchar *prefer_filename,
1762 					    const gchar *prefer_mime_type,
1763 					    GCancellable *cancellable)
1764 {
1765 	CamelMimePart *mime_part = NULL;
1766 	GInputStream *input_stream = NULL;
1767 	GFileInfo *file_info = NULL;
1768 	gchar *mime_type = NULL;
1769 	guchar *data = NULL;
1770 	gsize data_length = 0;
1771 
1772 	g_return_val_if_fail (uri != NULL, NULL);
1773 
1774 	/* base64-encoded "data:" URIs */
1775 	if (g_ascii_strncasecmp (uri, "data:", 5) == 0) {
1776 		/* data:[<mime type>][;charset=<charset>][;base64],<encoded data> */
1777 		const gchar *ptr, *from;
1778 		gboolean is_base64 = FALSE;
1779 
1780 		ptr = uri + 5;
1781 		from = ptr;
1782 		while (*ptr && *ptr != ',') {
1783 			ptr++;
1784 
1785 			if (*ptr == ',' || *ptr == ';') {
1786 				if (g_ascii_strncasecmp (from, "base64", ptr - from) == 0)
1787 					is_base64 = TRUE;
1788 
1789 				if (from == uri + 5 && *ptr == ';' && !prefer_mime_type)
1790 					mime_type = g_strndup (from, ptr - from);
1791 
1792 				from = ptr + 1;
1793 			}
1794 		}
1795 
1796 		if (is_base64 && *ptr == ',') {
1797 			data = g_base64_decode (ptr + 1, &data_length);
1798 
1799 			if (data && data_length && !mime_type && !prefer_mime_type) {
1800 				gchar *content_type;
1801 
1802 				content_type = g_content_type_guess (NULL, data, data_length, NULL);
1803 
1804 				if (content_type) {
1805 					mime_type = g_content_type_get_mime_type (content_type);
1806 					g_free (content_type);
1807 				}
1808 			}
1809 		}
1810 
1811 	/* files on the disk */
1812 	} else if (g_ascii_strncasecmp (uri, "file://", 7) == 0 ||
1813 		   g_ascii_strncasecmp (uri, "evo-file://", 11) == 0) {
1814 		GFileInputStream *file_stream;
1815 		GFile *file;
1816 
1817 		if (g_ascii_strncasecmp (uri, "evo-", 4) == 0)
1818 			uri += 4;
1819 
1820 		file = g_file_new_for_uri (uri);
1821 		file_stream = g_file_read (file, NULL, NULL);
1822 
1823 		if (file_stream) {
1824 			if (!prefer_filename) {
1825 				file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_QUERY_INFO_NONE, cancellable, NULL);
1826 
1827 				if (file_info)
1828 					prefer_filename = g_file_info_get_display_name (file_info);
1829 			}
1830 
1831 			if (!prefer_mime_type)
1832 				mime_type = e_util_guess_mime_type (uri, TRUE);
1833 
1834 			input_stream = (GInputStream *) file_stream;
1835 		}
1836 
1837 		g_clear_object (&file);
1838 	}
1839 
1840 	if (data || input_stream) {
1841 		if (!prefer_mime_type)
1842 			prefer_mime_type = mime_type;
1843 
1844 		if (!prefer_mime_type)
1845 			prefer_mime_type = "application/octet-stream";
1846 
1847 		if (input_stream) {
1848 			CamelDataWrapper *wrapper;
1849 
1850 			wrapper = camel_data_wrapper_new ();
1851 
1852 			if (camel_data_wrapper_construct_from_input_stream_sync (wrapper, input_stream, cancellable, NULL)) {
1853 				camel_data_wrapper_set_mime_type (wrapper, prefer_mime_type);
1854 
1855 				mime_part = camel_mime_part_new ();
1856 				camel_medium_set_content (CAMEL_MEDIUM (mime_part), wrapper);
1857 			}
1858 
1859 			g_object_unref (wrapper);
1860 		} else {
1861 			mime_part = camel_mime_part_new ();
1862 			camel_mime_part_set_content (mime_part, (const gchar *) data, data_length, prefer_mime_type);
1863 		}
1864 
1865 		if (mime_part) {
1866 			camel_mime_part_set_disposition (mime_part, as_inline ? "inline" : "attachment");
1867 
1868 			if (cid && g_ascii_strncasecmp (cid, "cid:", 4) == 0)
1869 				cid += 4;
1870 
1871 			if (cid && *cid)
1872 				camel_mime_part_set_content_id (mime_part, cid);
1873 
1874 			if (prefer_filename && *prefer_filename)
1875 				camel_mime_part_set_filename (mime_part, prefer_filename);
1876 
1877 			camel_mime_part_set_encoding (mime_part, CAMEL_TRANSFER_ENCODING_BASE64);
1878 		}
1879 	}
1880 
1881 	g_clear_object (&input_stream);
1882 	g_clear_object (&file_info);
1883 	g_free (mime_type);
1884 	g_free (data);
1885 
1886 	return mime_part;
1887 }
1888 
1889 /**
1890  * e_content_editor_insert_image:
1891  * @editor: an #EContentEditor
1892  * @uri: an URI of the source image
1893  *
1894  * Inserts image at current cursor position using @uri as source. When a
1895  * text range is selected, it will be replaced by the image.
1896  *
1897  * Since: 3.22
1898  **/
1899 void
e_content_editor_insert_image(EContentEditor * editor,const gchar * uri)1900 e_content_editor_insert_image (EContentEditor *editor,
1901                                const gchar *uri)
1902 {
1903 	EContentEditorInterface *iface;
1904 
1905 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1906 	g_return_if_fail (uri != NULL);
1907 
1908 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1909 	g_return_if_fail (iface != NULL);
1910 	g_return_if_fail (iface->insert_image != NULL);
1911 
1912 	iface->insert_image (editor, uri);
1913 }
1914 
1915 void
e_content_editor_insert_emoticon(EContentEditor * editor,EEmoticon * emoticon)1916 e_content_editor_insert_emoticon (EContentEditor *editor,
1917                                   EEmoticon *emoticon)
1918 {
1919 	EContentEditorInterface *iface;
1920 
1921 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1922 	g_return_if_fail (emoticon != NULL);
1923 
1924 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1925 	g_return_if_fail (iface != NULL);
1926 	g_return_if_fail (iface->insert_emoticon != NULL);
1927 
1928 	iface->insert_emoticon (editor, emoticon);
1929 }
1930 
1931 void
e_content_editor_move_caret_on_coordinates(EContentEditor * editor,gint x,gint y,gboolean cancel_if_not_collapsed)1932 e_content_editor_move_caret_on_coordinates (EContentEditor *editor,
1933                                             gint x,
1934                                             gint y,
1935                                             gboolean cancel_if_not_collapsed)
1936 {
1937 	EContentEditorInterface *iface;
1938 
1939 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1940 	g_return_if_fail (x > 0);
1941 	g_return_if_fail (y > 0);
1942 
1943 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1944 	g_return_if_fail (iface != NULL);
1945 	g_return_if_fail (iface->move_caret_on_coordinates != NULL);
1946 
1947 	iface->move_caret_on_coordinates (editor, x, y, cancel_if_not_collapsed);
1948 }
1949 
1950 void
e_content_editor_cut(EContentEditor * editor)1951 e_content_editor_cut (EContentEditor *editor)
1952 {
1953 	EContentEditorInterface *iface;
1954 
1955 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1956 
1957 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1958 	g_return_if_fail (iface != NULL);
1959 	g_return_if_fail (iface->cut != NULL);
1960 
1961 	iface->cut (editor);
1962 }
1963 
1964 void
e_content_editor_copy(EContentEditor * editor)1965 e_content_editor_copy (EContentEditor *editor)
1966 {
1967 	EContentEditorInterface *iface;
1968 
1969 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1970 
1971 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1972 	g_return_if_fail (iface != NULL);
1973 	g_return_if_fail (iface->copy != NULL);
1974 
1975 	iface->copy (editor);
1976 }
1977 
1978 void
e_content_editor_paste(EContentEditor * editor)1979 e_content_editor_paste (EContentEditor *editor)
1980 {
1981 	EContentEditorInterface *iface;
1982 
1983 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1984 
1985 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
1986 	g_return_if_fail (iface != NULL);
1987 	g_return_if_fail (iface->paste != NULL);
1988 
1989 	iface->paste (editor);
1990 }
1991 
1992 void
e_content_editor_paste_primary(EContentEditor * editor)1993 e_content_editor_paste_primary (EContentEditor *editor)
1994 {
1995 	EContentEditorInterface *iface;
1996 
1997 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
1998 
1999 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2000 	g_return_if_fail (iface != NULL);
2001 	g_return_if_fail (iface->paste_primary != NULL);
2002 
2003 	iface->paste_primary (editor);
2004 }
2005 
2006 void
e_content_editor_undo(EContentEditor * editor)2007 e_content_editor_undo (EContentEditor *editor)
2008 {
2009 	EContentEditorInterface *iface;
2010 
2011 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2012 
2013 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2014 	g_return_if_fail (iface != NULL);
2015 	g_return_if_fail (iface->undo != NULL);
2016 
2017 	iface->undo (editor);
2018 }
2019 
2020 void
e_content_editor_redo(EContentEditor * editor)2021 e_content_editor_redo (EContentEditor *editor)
2022 {
2023 	EContentEditorInterface *iface;
2024 
2025 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2026 
2027 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2028 	g_return_if_fail (iface != NULL);
2029 	g_return_if_fail (iface->redo != NULL);
2030 
2031 	iface->redo (editor);
2032 }
2033 
2034 void
e_content_editor_clear_undo_redo_history(EContentEditor * editor)2035 e_content_editor_clear_undo_redo_history (EContentEditor *editor)
2036 {
2037 	EContentEditorInterface *iface;
2038 
2039 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2040 
2041 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2042 	g_return_if_fail (iface != NULL);
2043 	g_return_if_fail (iface->clear_undo_redo_history != NULL);
2044 
2045 	iface->clear_undo_redo_history (editor);
2046 }
2047 
2048 void
e_content_editor_set_spell_checking_languages(EContentEditor * editor,const gchar ** languages)2049 e_content_editor_set_spell_checking_languages (EContentEditor *editor,
2050                                                const gchar **languages)
2051 {
2052 	EContentEditorInterface *iface;
2053 
2054 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2055 
2056 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2057 	g_return_if_fail (iface != NULL);
2058 	g_return_if_fail (iface->set_spell_checking_languages != NULL);
2059 
2060 	iface->set_spell_checking_languages (editor, languages);
2061 }
2062 
2063 void
e_content_editor_select_all(EContentEditor * editor)2064 e_content_editor_select_all (EContentEditor *editor)
2065 {
2066 	EContentEditorInterface *iface;
2067 
2068 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2069 
2070 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2071 	g_return_if_fail (iface != NULL);
2072 	g_return_if_fail (iface->select_all != NULL);
2073 
2074 	iface->select_all (editor);
2075 }
2076 
2077 /**
2078  * e_content_editor_get_caret_word:
2079  * @editor: an #EContentEditor
2080  *
2081  * Returns word under cursor.
2082  *
2083  * Returns: (transfer-full): A newly allocated string with current caret word or %NULL
2084  * when there is no text under cursor or when selection is active.
2085  *
2086  * Since: 3.22
2087  **/
2088 gchar *
e_content_editor_get_caret_word(EContentEditor * editor)2089 e_content_editor_get_caret_word (EContentEditor *editor)
2090 {
2091 	EContentEditorInterface *iface;
2092 
2093 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
2094 
2095 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2096 	g_return_val_if_fail (iface != NULL, NULL);
2097 	g_return_val_if_fail (iface->get_caret_word != NULL, NULL);
2098 
2099 	return iface->get_caret_word (editor);
2100 }
2101 
2102 /**
2103  * e_content_editor_replace_caret_word:
2104  * @editor: an #EContentEditor
2105  * @replacement: a string to replace current caret word with
2106  *
2107  * Replaces current word under cursor with @replacement.
2108  *
2109  * Since: 3.22
2110  **/
2111 void
e_content_editor_replace_caret_word(EContentEditor * editor,const gchar * replacement)2112 e_content_editor_replace_caret_word (EContentEditor *editor,
2113                                      const gchar *replacement)
2114 {
2115 	EContentEditorInterface *iface;
2116 
2117 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2118 	g_return_if_fail (replacement != NULL);
2119 
2120 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2121 	g_return_if_fail (iface != NULL);
2122 	g_return_if_fail (iface->replace_caret_word != NULL);
2123 
2124 	iface->replace_caret_word (editor, replacement);
2125 }
2126 
2127 void
e_content_editor_selection_indent(EContentEditor * editor)2128 e_content_editor_selection_indent (EContentEditor *editor)
2129 {
2130 	EContentEditorInterface *iface;
2131 
2132 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2133 
2134 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2135 	g_return_if_fail (iface != NULL);
2136 	g_return_if_fail (iface->selection_indent != NULL);
2137 
2138 	iface->selection_indent (editor);
2139 }
2140 
2141 void
e_content_editor_selection_unindent(EContentEditor * editor)2142 e_content_editor_selection_unindent (EContentEditor *editor)
2143 {
2144 	EContentEditorInterface *iface;
2145 
2146 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2147 
2148 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2149 	g_return_if_fail (iface != NULL);
2150 	g_return_if_fail (iface->selection_unindent != NULL);
2151 
2152 	iface->selection_unindent (editor);
2153 }
2154 
2155 /**
2156  * e_content_editor_selection_unlink:
2157  * @editor: an #EContentEditor
2158  *
2159  * Removes any links (&lt;A&gt; elements) from current selection or at current
2160  * cursor position.
2161  *
2162  * Since: 3.22
2163  **/
2164 void
e_content_editor_selection_unlink(EContentEditor * editor)2165 e_content_editor_selection_unlink (EContentEditor *editor)
2166 {
2167 	EContentEditorInterface *iface;
2168 
2169 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2170 
2171 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2172 	g_return_if_fail (iface != NULL);
2173 	g_return_if_fail (iface->selection_unlink != NULL);
2174 
2175 	iface->selection_unlink (editor);
2176 }
2177 
2178 /**
2179  * e_content_editor_find:
2180  * @editor: an #EContentEditor
2181  * @flags: a bit-OR of #EContentEditorFindFlags flags
2182  * @text: a text to find
2183  *
2184  * Searches the content of the @editor for the occurrence of the @text.
2185  * The @flags modify the behaviour of the search. The found text,
2186  * if any, is supposed to be selected.
2187  *
2188  * Once the search is done, the "find-done" signal should be
2189  * emitted, by using e_content_editor_emit_find_done().
2190  *
2191  * Since: 3.22
2192  **/
2193 void
e_content_editor_find(EContentEditor * editor,guint32 flags,const gchar * text)2194 e_content_editor_find (EContentEditor *editor,
2195 		       guint32 flags,
2196 		       const gchar *text)
2197 {
2198 	EContentEditorInterface *iface;
2199 
2200 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2201 	g_return_if_fail (text != NULL);
2202 
2203 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2204 	g_return_if_fail (iface != NULL);
2205 	g_return_if_fail (iface->find != NULL);
2206 
2207 	iface->find (editor, flags, text);
2208 }
2209 
2210 /**
2211  * e_content_editor_replace:
2212  * @editor: an #EContentEditor
2213  * @replacement: a string to replace current selection with
2214  *
2215  * Replaces currently selected text with @replacement.
2216  *
2217  * Since: 3.22
2218  **/
2219 void
e_content_editor_replace(EContentEditor * editor,const gchar * replacement)2220 e_content_editor_replace (EContentEditor *editor,
2221 			  const gchar *replacement)
2222 {
2223 	EContentEditorInterface *iface;
2224 
2225 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2226 	g_return_if_fail (replacement != NULL);
2227 
2228 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2229 	g_return_if_fail (iface != NULL);
2230 	g_return_if_fail (iface->replace != NULL);
2231 
2232 	iface->replace (editor, replacement);
2233 }
2234 
2235 /**
2236  * e_content_editor_replace_all:
2237  * @editor: an #EContentEditor
2238  * @flags: a bit-OR of #EContentEditorFindFlags flags
2239  * @find_text: a text to find
2240  * @replace_with: a text to replace the found text with
2241  *
2242  * Searches the content of the @editor for all the occurrences of
2243  * the @find_text and replaces them with the @replace_with.
2244  * The @flags modify the behaviour of the search.
2245  *
2246  * Once the replace is done, the "replace-all-done" signal should be
2247  * emitted, by using e_content_editor_emit_replace_all_done().
2248  *
2249  * Since: 3.22
2250  **/
2251 void
e_content_editor_replace_all(EContentEditor * editor,guint32 flags,const gchar * find_text,const gchar * replace_with)2252 e_content_editor_replace_all (EContentEditor *editor,
2253 			      guint32 flags,
2254 			      const gchar *find_text,
2255 			      const gchar *replace_with)
2256 {
2257 	EContentEditorInterface *iface;
2258 
2259 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2260 	g_return_if_fail (find_text != NULL);
2261 	g_return_if_fail (replace_with != NULL);
2262 
2263 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2264 	g_return_if_fail (iface != NULL);
2265 	g_return_if_fail (iface->replace_all != NULL);
2266 
2267 	iface->replace_all (editor, flags, find_text, replace_with);
2268 }
2269 
2270 /**
2271  * e_content_editor_selection_save:
2272  * @editor: an #EContentEditor
2273  *
2274  * Saves current cursor position or current selection range. The selection can
2275  * be later restored by calling e_content_editor_selection_restore().
2276  *
2277  * Note that calling e_content_editor_selection_save() overwrites previously saved
2278  * position.
2279  *
2280  * Note that this method inserts special markings into the HTML code that are
2281  * used to later restore the selection. It can happen that by deleting some
2282  * segments of the document some of the markings are deleted too. In that case
2283  * restoring the selection by e_content_editor_selection_restore() can fail. Also by
2284  * moving text segments (Cut & Paste) can result in moving the markings
2285  * elsewhere, thus e_content_editor_selection_restore() will restore the selection
2286  * incorrectly.
2287  *
2288  * It is recommended to use this method only when you are not planning to make
2289  * bigger changes to content or structure of the document (formatting changes
2290  * are usually OK).
2291  *
2292  * Since: 3.22
2293  **/
2294 void
e_content_editor_selection_save(EContentEditor * editor)2295 e_content_editor_selection_save (EContentEditor *editor)
2296 {
2297 	EContentEditorInterface *iface;
2298 
2299 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2300 
2301 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2302 	g_return_if_fail (iface != NULL);
2303 	g_return_if_fail (iface->selection_save != NULL);
2304 
2305 	iface->selection_save (editor);
2306 }
2307 
2308 /**
2309  * e_content_editor_selection_restore:
2310  * @editor: an #EContentEditor
2311  *
2312  * Restores cursor position or selection range that was saved by
2313  * e_content_editor_selection_save().
2314  *
2315  * Note that calling this function without calling e_content_editor_selection_save()
2316  * before is a programming error and the behavior is undefined.
2317  *
2318  * Since: 3.22
2319  **/
2320 void
e_content_editor_selection_restore(EContentEditor * editor)2321 e_content_editor_selection_restore (EContentEditor *editor)
2322 {
2323 	EContentEditorInterface *iface;
2324 
2325 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2326 
2327 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2328 	g_return_if_fail (iface != NULL);
2329 	g_return_if_fail (iface->selection_restore != NULL);
2330 
2331 	iface->selection_restore (editor);
2332 }
2333 
2334 void
e_content_editor_selection_wrap(EContentEditor * editor)2335 e_content_editor_selection_wrap (EContentEditor *editor)
2336 {
2337 	EContentEditorInterface *iface;
2338 
2339 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2340 
2341 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2342 	g_return_if_fail (iface != NULL);
2343 	g_return_if_fail (iface->selection_wrap != NULL);
2344 
2345 	iface->selection_wrap (editor);
2346 }
2347 
2348 gchar *
e_content_editor_get_current_signature_uid(EContentEditor * editor)2349 e_content_editor_get_current_signature_uid (EContentEditor *editor)
2350 {
2351 	EContentEditorInterface *iface;
2352 
2353 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
2354 
2355 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2356 	g_return_val_if_fail (iface != NULL, NULL);
2357 	g_return_val_if_fail (iface->get_current_signature_uid != NULL, NULL);
2358 
2359 	return iface->get_current_signature_uid (editor);
2360 }
2361 
2362 gboolean
e_content_editor_is_ready(EContentEditor * editor)2363 e_content_editor_is_ready (EContentEditor *editor)
2364 {
2365 	EContentEditorInterface *iface;
2366 
2367 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2368 
2369 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2370 	g_return_val_if_fail (iface != NULL, FALSE);
2371 	g_return_val_if_fail (iface->is_ready != NULL, FALSE);
2372 
2373 	return iface->is_ready (editor);
2374 }
2375 
2376 GError *
e_content_editor_dup_last_error(EContentEditor * editor)2377 e_content_editor_dup_last_error (EContentEditor *editor)
2378 {
2379 	GError *last_error = NULL;
2380 
2381 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
2382 
2383 	g_object_get (G_OBJECT (editor), "last-error", &last_error, NULL);
2384 
2385 	return last_error;
2386 }
2387 
2388 void
e_content_editor_take_last_error(EContentEditor * editor,GError * error)2389 e_content_editor_take_last_error (EContentEditor *editor,
2390 				  GError *error)
2391 {
2392 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2393 
2394 	g_object_set (G_OBJECT (editor), "last-error", error, NULL);
2395 
2396 	g_clear_error (&error);
2397 }
2398 
2399 gchar *
e_content_editor_insert_signature(EContentEditor * editor,const gchar * content,gboolean is_html,gboolean can_reposition_caret,const gchar * signature_id,gboolean * set_signature_from_message,gboolean * check_if_signature_is_changed,gboolean * ignore_next_signature_change)2400 e_content_editor_insert_signature (EContentEditor *editor,
2401                                    const gchar *content,
2402                                    gboolean is_html,
2403 				   gboolean can_reposition_caret,
2404                                    const gchar *signature_id,
2405                                    gboolean *set_signature_from_message,
2406                                    gboolean *check_if_signature_is_changed,
2407                                    gboolean *ignore_next_signature_change)
2408 {
2409 	EContentEditorInterface *iface;
2410 
2411 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2412 
2413 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2414 	g_return_val_if_fail (iface != NULL, FALSE);
2415 	g_return_val_if_fail (iface->insert_signature != NULL, FALSE);
2416 
2417 	return iface->insert_signature (
2418 		editor,
2419 		content,
2420 		is_html,
2421 		can_reposition_caret,
2422 		signature_id,
2423 		set_signature_from_message,
2424 		check_if_signature_is_changed,
2425 		ignore_next_signature_change);
2426 }
2427 
2428 void
e_content_editor_delete_cell_contents(EContentEditor * editor)2429 e_content_editor_delete_cell_contents (EContentEditor *editor)
2430 {
2431 	EContentEditorInterface *iface;
2432 
2433 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2434 
2435 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2436 	g_return_if_fail (iface != NULL);
2437 	g_return_if_fail (iface->delete_cell_contents != NULL);
2438 
2439 	iface->delete_cell_contents (editor);
2440 }
2441 
2442 void
e_content_editor_delete_column(EContentEditor * editor)2443 e_content_editor_delete_column (EContentEditor *editor)
2444 {
2445 	EContentEditorInterface *iface;
2446 
2447 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2448 
2449 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2450 	g_return_if_fail (iface != NULL);
2451 	g_return_if_fail (iface->delete_column != NULL);
2452 
2453 	iface->delete_column (editor);
2454 }
2455 
2456 void
e_content_editor_delete_row(EContentEditor * editor)2457 e_content_editor_delete_row (EContentEditor *editor)
2458 {
2459 	EContentEditorInterface *iface;
2460 
2461 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2462 
2463 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2464 	g_return_if_fail (iface != NULL);
2465 	g_return_if_fail (iface->delete_row != NULL);
2466 
2467 	iface->delete_row (editor);
2468 }
2469 
2470 void
e_content_editor_delete_table(EContentEditor * editor)2471 e_content_editor_delete_table (EContentEditor *editor)
2472 {
2473 	EContentEditorInterface *iface;
2474 
2475 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2476 
2477 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2478 	g_return_if_fail (iface != NULL);
2479 	g_return_if_fail (iface->delete_table != NULL);
2480 
2481 	iface->delete_table (editor);
2482 }
2483 
2484 void
e_content_editor_insert_column_after(EContentEditor * editor)2485 e_content_editor_insert_column_after (EContentEditor *editor)
2486 {
2487 	EContentEditorInterface *iface;
2488 
2489 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2490 
2491 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2492 	g_return_if_fail (iface != NULL);
2493 	g_return_if_fail (iface->insert_column_after != NULL);
2494 
2495 	iface->insert_column_after (editor);
2496 }
2497 
2498 void
e_content_editor_insert_column_before(EContentEditor * editor)2499 e_content_editor_insert_column_before (EContentEditor *editor)
2500 {
2501 	EContentEditorInterface *iface;
2502 
2503 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2504 
2505 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2506 	g_return_if_fail (iface != NULL);
2507 	g_return_if_fail (iface->insert_column_before != NULL);
2508 
2509 	iface->insert_column_before (editor);
2510 }
2511 
2512 void
e_content_editor_insert_row_above(EContentEditor * editor)2513 e_content_editor_insert_row_above (EContentEditor *editor)
2514 {
2515 	EContentEditorInterface *iface;
2516 
2517 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2518 
2519 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2520 	g_return_if_fail (iface != NULL);
2521 	g_return_if_fail (iface->insert_row_above != NULL);
2522 
2523 	iface->insert_row_above (editor);
2524 }
2525 
2526 void
e_content_editor_insert_row_below(EContentEditor * editor)2527 e_content_editor_insert_row_below (EContentEditor *editor)
2528 {
2529 	EContentEditorInterface *iface;
2530 
2531 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2532 
2533 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2534 	g_return_if_fail (iface != NULL);
2535 	g_return_if_fail (iface->insert_row_below != NULL);
2536 
2537 	iface->insert_row_below (editor);
2538 }
2539 
2540 void
e_content_editor_on_dialog_open(EContentEditor * editor,const gchar * name)2541 e_content_editor_on_dialog_open (EContentEditor *editor,
2542 				 const gchar *name)
2543 {
2544 	EContentEditorInterface *iface;
2545 
2546 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2547 
2548 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2549 	g_return_if_fail (iface != NULL);
2550 	g_return_if_fail (iface->on_dialog_open != NULL);
2551 
2552 	iface->on_dialog_open (editor, name);
2553 }
2554 
2555 void
e_content_editor_on_dialog_close(EContentEditor * editor,const gchar * name)2556 e_content_editor_on_dialog_close (EContentEditor *editor,
2557 				  const gchar *name)
2558 {
2559 	EContentEditorInterface *iface;
2560 
2561 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2562 
2563 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2564 	g_return_if_fail (iface != NULL);
2565 	g_return_if_fail (iface->on_dialog_close != NULL);
2566 
2567 	iface->on_dialog_close (editor, name);
2568 }
2569 
2570 void
e_content_editor_h_rule_set_align(EContentEditor * editor,const gchar * value)2571 e_content_editor_h_rule_set_align (EContentEditor *editor,
2572                                    const gchar *value)
2573 {
2574 	EContentEditorInterface *iface;
2575 
2576 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2577 
2578 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2579 	g_return_if_fail (iface != NULL);
2580 	g_return_if_fail (iface->h_rule_set_align != NULL);
2581 
2582 	iface->h_rule_set_align (editor, value);
2583 }
2584 
2585 gchar *
e_content_editor_h_rule_get_align(EContentEditor * editor)2586 e_content_editor_h_rule_get_align (EContentEditor *editor)
2587 {
2588 	EContentEditorInterface *iface;
2589 
2590 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
2591 
2592 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2593 	g_return_val_if_fail (iface != NULL, NULL);
2594 	g_return_val_if_fail (iface->h_rule_get_align != NULL, NULL);
2595 
2596 	return iface->h_rule_get_align (editor);
2597 }
2598 
2599 void
e_content_editor_h_rule_set_size(EContentEditor * editor,gint value)2600 e_content_editor_h_rule_set_size (EContentEditor *editor,
2601                                   gint value)
2602 {
2603 	EContentEditorInterface *iface;
2604 
2605 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2606 
2607 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2608 	g_return_if_fail (iface != NULL);
2609 	g_return_if_fail (iface->h_rule_set_size != NULL);
2610 
2611 	iface->h_rule_set_size (editor, value);
2612 }
2613 
2614 gint
e_content_editor_h_rule_get_size(EContentEditor * editor)2615 e_content_editor_h_rule_get_size (EContentEditor *editor)
2616 {
2617 	EContentEditorInterface *iface;
2618 
2619 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2620 
2621 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2622 	g_return_val_if_fail (iface != NULL, 0);
2623 	g_return_val_if_fail (iface->h_rule_get_size != NULL, 0);
2624 
2625 	return iface->h_rule_get_size (editor);
2626 }
2627 
2628 void
e_content_editor_h_rule_set_width(EContentEditor * editor,gint value,EContentEditorUnit unit)2629 e_content_editor_h_rule_set_width (EContentEditor *editor,
2630                                    gint value,
2631                                    EContentEditorUnit unit)
2632 {
2633 	EContentEditorInterface *iface;
2634 
2635 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2636 
2637 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2638 	g_return_if_fail (iface != NULL);
2639 	g_return_if_fail (iface->h_rule_set_width != NULL);
2640 
2641 	iface->h_rule_set_width (editor, value, unit);
2642 }
2643 
2644 gint
e_content_editor_h_rule_get_width(EContentEditor * editor,EContentEditorUnit * unit)2645 e_content_editor_h_rule_get_width (EContentEditor *editor,
2646                                    EContentEditorUnit *unit)
2647 {
2648 	EContentEditorInterface *iface;
2649 
2650 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2651 	g_return_val_if_fail (unit != NULL, 0);
2652 
2653 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2654 	g_return_val_if_fail (iface != NULL, 0);
2655 	g_return_val_if_fail (iface->h_rule_get_width != NULL, 0);
2656 
2657 	return iface->h_rule_get_width (editor, unit);
2658 }
2659 
2660 void
e_content_editor_h_rule_set_no_shade(EContentEditor * editor,gboolean value)2661 e_content_editor_h_rule_set_no_shade (EContentEditor *editor,
2662                                       gboolean value)
2663 {
2664 	EContentEditorInterface *iface;
2665 
2666 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2667 
2668 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2669 	g_return_if_fail (iface != NULL);
2670 	g_return_if_fail (iface->h_rule_set_no_shade != NULL);
2671 
2672 	iface->h_rule_set_no_shade (editor, value);
2673 }
2674 
2675 gboolean
e_content_editor_h_rule_get_no_shade(EContentEditor * editor)2676 e_content_editor_h_rule_get_no_shade (EContentEditor *editor)
2677 {
2678 	EContentEditorInterface *iface;
2679 
2680 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2681 
2682 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2683 	g_return_val_if_fail (iface != NULL, FALSE);
2684 	g_return_val_if_fail (iface->h_rule_get_no_shade != NULL, FALSE);
2685 
2686 	return iface->h_rule_get_no_shade (editor);
2687 }
2688 
2689 void
e_content_editor_image_set_width_follow(EContentEditor * editor,gboolean value)2690 e_content_editor_image_set_width_follow (EContentEditor *editor,
2691                                          gboolean value)
2692 {
2693 	EContentEditorInterface *iface;
2694 
2695 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2696 
2697 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2698 	g_return_if_fail (iface != NULL);
2699 	g_return_if_fail (iface->image_set_width_follow != NULL);
2700 
2701 	iface->image_set_width_follow (editor, value);
2702 }
2703 
2704 void
e_content_editor_image_set_src(EContentEditor * editor,const gchar * value)2705 e_content_editor_image_set_src (EContentEditor *editor,
2706                                 const gchar *value)
2707 {
2708 	EContentEditorInterface *iface;
2709 
2710 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2711 
2712 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2713 	g_return_if_fail (iface != NULL);
2714 	g_return_if_fail (iface->image_set_src != NULL);
2715 
2716 	iface->image_set_src (editor, value);
2717 }
2718 
2719 gchar *
e_content_editor_image_get_src(EContentEditor * editor)2720 e_content_editor_image_get_src (EContentEditor *editor)
2721 {
2722 	EContentEditorInterface *iface;
2723 
2724 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2725 
2726 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2727 	g_return_val_if_fail (iface != NULL, FALSE);
2728 	g_return_val_if_fail (iface->image_get_src != NULL, FALSE);
2729 
2730 	return iface->image_get_src (editor);
2731 }
2732 
2733 void
e_content_editor_image_set_alt(EContentEditor * editor,const gchar * value)2734 e_content_editor_image_set_alt (EContentEditor *editor,
2735                                 const gchar *value)
2736 {
2737 	EContentEditorInterface *iface;
2738 
2739 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2740 
2741 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2742 	g_return_if_fail (iface != NULL);
2743 	g_return_if_fail (iface->image_set_alt != NULL);
2744 
2745 	iface->image_set_alt (editor, value);
2746 }
2747 
2748 gchar *
e_content_editor_image_get_alt(EContentEditor * editor)2749 e_content_editor_image_get_alt (EContentEditor *editor)
2750 {
2751 	EContentEditorInterface *iface;
2752 
2753 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2754 
2755 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2756 	g_return_val_if_fail (iface != NULL, FALSE);
2757 	g_return_val_if_fail (iface->image_get_alt != NULL, FALSE);
2758 
2759 	return iface->image_get_alt (editor);
2760 }
2761 
2762 void
e_content_editor_image_set_url(EContentEditor * editor,const gchar * value)2763 e_content_editor_image_set_url (EContentEditor *editor,
2764                                 const gchar *value)
2765 {
2766 	EContentEditorInterface *iface;
2767 
2768 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2769 
2770 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2771 	g_return_if_fail (iface != NULL);
2772 	g_return_if_fail (iface->image_set_url != NULL);
2773 
2774 	iface->image_set_url (editor, value);
2775 }
2776 
2777 gchar *
e_content_editor_image_get_url(EContentEditor * editor)2778 e_content_editor_image_get_url (EContentEditor *editor)
2779 {
2780 	EContentEditorInterface *iface;
2781 
2782 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2783 
2784 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2785 	g_return_val_if_fail (iface != NULL, FALSE);
2786 	g_return_val_if_fail (iface->image_get_url != NULL, FALSE);
2787 
2788 	return iface->image_get_url (editor);
2789 }
2790 
2791 void
e_content_editor_image_set_vspace(EContentEditor * editor,gint value)2792 e_content_editor_image_set_vspace (EContentEditor *editor,
2793                                    gint value)
2794 {
2795 	EContentEditorInterface *iface;
2796 
2797 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2798 
2799 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2800 	g_return_if_fail (iface != NULL);
2801 	g_return_if_fail (iface->image_set_vspace != NULL);
2802 
2803 	iface->image_set_vspace (editor, value);
2804 }
2805 
2806 gint
e_content_editor_image_get_vspace(EContentEditor * editor)2807 e_content_editor_image_get_vspace (EContentEditor *editor)
2808 {
2809 	EContentEditorInterface *iface;
2810 
2811 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2812 
2813 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2814 	g_return_val_if_fail (iface != NULL, 0);
2815 	g_return_val_if_fail (iface->image_get_vspace != NULL, 0);
2816 
2817 	return iface->image_get_vspace (editor);
2818 }
2819 
2820 
2821 void
e_content_editor_image_set_hspace(EContentEditor * editor,gint value)2822 e_content_editor_image_set_hspace (EContentEditor *editor,
2823                                    gint value)
2824 {
2825 	EContentEditorInterface *iface;
2826 
2827 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2828 
2829 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2830 	g_return_if_fail (iface != NULL);
2831 	g_return_if_fail (iface->image_set_hspace != NULL);
2832 
2833 	iface->image_set_hspace (editor, value);
2834 }
2835 
2836 gint
e_content_editor_image_get_hspace(EContentEditor * editor)2837 e_content_editor_image_get_hspace (EContentEditor *editor)
2838 {
2839 	EContentEditorInterface *iface;
2840 
2841 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2842 
2843 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2844 	g_return_val_if_fail (iface != NULL, 0);
2845 	g_return_val_if_fail (iface->image_get_hspace != NULL, 0);
2846 
2847 	return iface->image_get_hspace (editor);
2848 }
2849 
2850 void
e_content_editor_image_set_border(EContentEditor * editor,gint value)2851 e_content_editor_image_set_border (EContentEditor *editor,
2852                                    gint value)
2853 {
2854 	EContentEditorInterface *iface;
2855 
2856 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2857 
2858 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2859 	g_return_if_fail (iface != NULL);
2860 	g_return_if_fail (iface->image_set_border != NULL);
2861 
2862 	iface->image_set_border (editor, value);
2863 }
2864 
2865 gint
e_content_editor_image_get_border(EContentEditor * editor)2866 e_content_editor_image_get_border (EContentEditor *editor)
2867 {
2868 	EContentEditorInterface *iface;
2869 
2870 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2871 
2872 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2873 	g_return_val_if_fail (iface != NULL, FALSE);
2874 	g_return_val_if_fail (iface->image_get_border != NULL, FALSE);
2875 
2876 	return iface->image_get_border (editor);
2877 }
2878 
2879 void
e_content_editor_image_set_align(EContentEditor * editor,const gchar * value)2880 e_content_editor_image_set_align (EContentEditor *editor,
2881                                   const gchar *value)
2882 {
2883 	EContentEditorInterface *iface;
2884 
2885 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2886 
2887 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2888 	g_return_if_fail (iface != NULL);
2889 	g_return_if_fail (iface->image_set_align != NULL);
2890 
2891 	iface->image_set_align (editor, value);
2892 }
2893 
2894 gchar *
e_content_editor_image_get_align(EContentEditor * editor)2895 e_content_editor_image_get_align (EContentEditor *editor)
2896 {
2897 	EContentEditorInterface *iface;
2898 
2899 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
2900 
2901 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2902 	g_return_val_if_fail (iface != NULL, FALSE);
2903 	g_return_val_if_fail (iface->image_get_align != NULL, FALSE);
2904 
2905 	return iface->image_get_align (editor);
2906 }
2907 
2908 gint32
e_content_editor_image_get_natural_width(EContentEditor * editor)2909 e_content_editor_image_get_natural_width (EContentEditor *editor)
2910 {
2911 	EContentEditorInterface *iface;
2912 
2913 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2914 
2915 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2916 	g_return_val_if_fail (iface != NULL, 0);
2917 	g_return_val_if_fail (iface->image_get_natural_width != NULL, 0);
2918 
2919 	return iface->image_get_natural_width (editor);
2920 }
2921 
2922 gint32
e_content_editor_image_get_natural_height(EContentEditor * editor)2923 e_content_editor_image_get_natural_height (EContentEditor *editor)
2924 {
2925 	EContentEditorInterface *iface;
2926 
2927 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2928 
2929 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2930 	g_return_val_if_fail (iface != NULL, 0);
2931 	g_return_val_if_fail (iface->image_get_natural_height != NULL, 0);
2932 
2933 	return iface->image_get_natural_height (editor);
2934 }
2935 
2936 void
e_content_editor_image_set_width(EContentEditor * editor,gint value)2937 e_content_editor_image_set_width (EContentEditor *editor,
2938                                   gint value)
2939 {
2940 	EContentEditorInterface *iface;
2941 
2942 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2943 
2944 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2945 	g_return_if_fail (iface != NULL);
2946 	g_return_if_fail (iface->image_set_width != NULL);
2947 
2948 	iface->image_set_width (editor, value);
2949 }
2950 
2951 gint32
e_content_editor_image_get_width(EContentEditor * editor)2952 e_content_editor_image_get_width (EContentEditor *editor)
2953 {
2954 	EContentEditorInterface *iface;
2955 
2956 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2957 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2958 
2959 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2960 	g_return_val_if_fail (iface != NULL, 0);
2961 	g_return_val_if_fail (iface->image_get_width != NULL, 0);
2962 
2963 	return iface->image_get_width (editor);
2964 }
2965 
2966 void
e_content_editor_image_set_height(EContentEditor * editor,gint value)2967 e_content_editor_image_set_height (EContentEditor *editor,
2968                                    gint value)
2969 {
2970 	EContentEditorInterface *iface;
2971 
2972 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
2973 
2974 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2975 	g_return_if_fail (iface != NULL);
2976 	g_return_if_fail (iface->image_set_height != NULL);
2977 
2978 	iface->image_set_height (editor, value);
2979 }
2980 
2981 gint32
e_content_editor_image_get_height(EContentEditor * editor)2982 e_content_editor_image_get_height (EContentEditor *editor)
2983 {
2984 	EContentEditorInterface *iface;
2985 
2986 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
2987 
2988 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
2989 	g_return_val_if_fail (iface != NULL, 0);
2990 	g_return_val_if_fail (iface->image_get_height != NULL, 0);
2991 
2992 	return iface->image_get_height (editor);
2993 }
2994 
2995 void
e_content_editor_image_set_height_follow(EContentEditor * editor,gboolean value)2996 e_content_editor_image_set_height_follow (EContentEditor *editor,
2997                                           gboolean value)
2998 {
2999 	EContentEditorInterface *iface;
3000 
3001 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3002 
3003 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3004 	g_return_if_fail (iface != NULL);
3005 	g_return_if_fail (iface->image_set_height_follow != NULL);
3006 
3007 	iface->image_set_height_follow (editor, value);
3008 }
3009 
3010 void
e_content_editor_link_get_properties(EContentEditor * editor,gchar ** href,gchar ** text)3011 e_content_editor_link_get_properties (EContentEditor *editor,
3012 				      gchar **href,
3013 				      gchar **text)
3014 {
3015 	EContentEditorInterface *iface;
3016 
3017 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3018 
3019 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3020 	g_return_if_fail (iface != NULL);
3021 	g_return_if_fail (iface->link_get_properties != NULL);
3022 
3023 	iface->link_get_properties (editor, href, text);
3024 }
3025 
3026 void
e_content_editor_link_set_properties(EContentEditor * editor,const gchar * href,const gchar * text)3027 e_content_editor_link_set_properties (EContentEditor *editor,
3028 				      const gchar *href,
3029 				      const gchar *text)
3030 {
3031 	EContentEditorInterface *iface;
3032 
3033 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3034 
3035 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3036 	g_return_if_fail (iface != NULL);
3037 	g_return_if_fail (iface->link_set_properties != NULL);
3038 
3039 	iface->link_set_properties (editor, href, text);
3040 }
3041 
3042 void
e_content_editor_page_set_text_color(EContentEditor * editor,const GdkRGBA * value)3043 e_content_editor_page_set_text_color (EContentEditor *editor,
3044                                       const GdkRGBA *value)
3045 {
3046 	EContentEditorInterface *iface;
3047 
3048 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3049 	g_return_if_fail (value != NULL);
3050 
3051 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3052 	g_return_if_fail (iface != NULL);
3053 	g_return_if_fail (iface->page_set_text_color != NULL);
3054 
3055 	iface->page_set_text_color (editor, value);
3056 }
3057 
3058 void
e_content_editor_page_get_text_color(EContentEditor * editor,GdkRGBA * value)3059 e_content_editor_page_get_text_color (EContentEditor *editor,
3060                                       GdkRGBA *value)
3061 {
3062 	EContentEditorInterface *iface;
3063 
3064 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3065 	g_return_if_fail (value != NULL);
3066 
3067 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3068 	g_return_if_fail (iface != NULL);
3069 	g_return_if_fail (iface->page_get_text_color != NULL);
3070 
3071 	return iface->page_get_text_color (editor, value);
3072 }
3073 
3074 void
e_content_editor_page_set_background_color(EContentEditor * editor,const GdkRGBA * value)3075 e_content_editor_page_set_background_color (EContentEditor *editor,
3076                                             const GdkRGBA *value)
3077 {
3078 	EContentEditorInterface *iface;
3079 
3080 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3081 	g_return_if_fail (value != NULL);
3082 
3083 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3084 	g_return_if_fail (iface != NULL);
3085 	g_return_if_fail (iface->page_set_background_color != NULL);
3086 
3087 	iface->page_set_background_color (editor, value);
3088 }
3089 
3090 void
e_content_editor_page_get_background_color(EContentEditor * editor,GdkRGBA * value)3091 e_content_editor_page_get_background_color (EContentEditor *editor,
3092                                             GdkRGBA *value)
3093 {
3094 	EContentEditorInterface *iface;
3095 
3096 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3097 	g_return_if_fail (value != NULL);
3098 
3099 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3100 	g_return_if_fail (iface != NULL);
3101 	g_return_if_fail (iface->page_get_background_color != NULL);
3102 
3103 	return iface->page_get_background_color (editor, value);
3104 }
3105 
3106 void
e_content_editor_page_set_link_color(EContentEditor * editor,const GdkRGBA * value)3107 e_content_editor_page_set_link_color (EContentEditor *editor,
3108                                       const GdkRGBA *value)
3109 {
3110 	EContentEditorInterface *iface;
3111 
3112 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3113 	g_return_if_fail (value != NULL);
3114 
3115 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3116 	g_return_if_fail (iface != NULL);
3117 	g_return_if_fail (iface->page_set_link_color != NULL);
3118 
3119 	iface->page_set_link_color (editor, value);
3120 }
3121 
3122 void
e_content_editor_page_get_link_color(EContentEditor * editor,GdkRGBA * value)3123 e_content_editor_page_get_link_color (EContentEditor *editor,
3124                                       GdkRGBA *value)
3125 {
3126 	EContentEditorInterface *iface;
3127 
3128 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3129 	g_return_if_fail (value != NULL);
3130 
3131 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3132 	g_return_if_fail (iface != NULL);
3133 	g_return_if_fail (iface->page_get_link_color != NULL);
3134 
3135 	return iface->page_get_link_color (editor, value);
3136 }
3137 
3138 void
e_content_editor_page_set_visited_link_color(EContentEditor * editor,const GdkRGBA * value)3139 e_content_editor_page_set_visited_link_color (EContentEditor *editor,
3140                                               const GdkRGBA *value)
3141 {
3142 	EContentEditorInterface *iface;
3143 
3144 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3145 	g_return_if_fail (value != NULL);
3146 
3147 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3148 	g_return_if_fail (iface != NULL);
3149 	g_return_if_fail (iface->page_set_visited_link_color != NULL);
3150 
3151 	iface->page_set_visited_link_color (editor, value);
3152 }
3153 
3154 void
e_content_editor_page_get_visited_link_color(EContentEditor * editor,GdkRGBA * value)3155 e_content_editor_page_get_visited_link_color (EContentEditor *editor,
3156                                               GdkRGBA *value)
3157 {
3158 	EContentEditorInterface *iface;
3159 
3160 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3161 	g_return_if_fail (value != NULL);
3162 
3163 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3164 	g_return_if_fail (iface != NULL);
3165 	g_return_if_fail (iface->page_get_visited_link_color != NULL);
3166 
3167 	return iface->page_get_visited_link_color (editor, value);
3168 }
3169 
3170 void
e_content_editor_page_set_font_name(EContentEditor * editor,const gchar * value)3171 e_content_editor_page_set_font_name (EContentEditor *editor,
3172 				     const gchar *value)
3173 {
3174 	EContentEditorInterface *iface;
3175 
3176 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3177 
3178 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3179 	g_return_if_fail (iface != NULL);
3180 	g_return_if_fail (iface->page_set_font_name != NULL);
3181 
3182 	iface->page_set_font_name (editor, value);
3183 }
3184 
3185 const gchar *
e_content_editor_page_get_font_name(EContentEditor * editor)3186 e_content_editor_page_get_font_name (EContentEditor *editor)
3187 {
3188 	EContentEditorInterface *iface;
3189 
3190 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3191 
3192 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3193 	g_return_val_if_fail (iface != NULL, NULL);
3194 	g_return_val_if_fail (iface->page_get_font_name != NULL, NULL);
3195 
3196 	return iface->page_get_font_name (editor);
3197 }
3198 
3199 /* uri could be NULL -> removes the current image */
3200 void
e_content_editor_page_set_background_image_uri(EContentEditor * editor,const gchar * uri)3201 e_content_editor_page_set_background_image_uri (EContentEditor *editor,
3202                                                 const gchar *uri)
3203 {
3204 	EContentEditorInterface *iface;
3205 
3206 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3207 
3208 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3209 	g_return_if_fail (iface != NULL);
3210 	g_return_if_fail (iface->page_set_background_image_uri != NULL);
3211 
3212 	iface->page_set_background_image_uri (editor, uri);
3213 }
3214 
3215 gchar *
e_content_editor_page_get_background_image_uri(EContentEditor * editor)3216 e_content_editor_page_get_background_image_uri (EContentEditor *editor)
3217 {
3218 	EContentEditorInterface *iface;
3219 
3220 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3221 
3222 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3223 	g_return_val_if_fail (iface != NULL, NULL);
3224 	g_return_val_if_fail (iface->page_get_background_image_uri != NULL, NULL);
3225 
3226 	return iface->page_get_background_image_uri (editor);
3227 }
3228 
3229 void
e_content_editor_cell_set_v_align(EContentEditor * editor,const gchar * value,EContentEditorScope scope)3230 e_content_editor_cell_set_v_align (EContentEditor *editor,
3231                                    const gchar *value,
3232                                    EContentEditorScope scope)
3233 {
3234 	EContentEditorInterface *iface;
3235 
3236 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3237 	g_return_if_fail (value != NULL);
3238 
3239 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3240 	g_return_if_fail (iface != NULL);
3241 	g_return_if_fail (iface->cell_set_v_align != NULL);
3242 
3243 	iface->cell_set_v_align (editor, value, scope);
3244 }
3245 
3246 gchar *
e_content_editor_cell_get_v_align(EContentEditor * editor)3247 e_content_editor_cell_get_v_align (EContentEditor *editor)
3248 {
3249 	EContentEditorInterface *iface;
3250 
3251 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3252 
3253 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3254 	g_return_val_if_fail (iface != NULL, NULL);
3255 	g_return_val_if_fail (iface->cell_get_v_align != NULL, NULL);
3256 
3257 	return iface->cell_get_v_align (editor);
3258 }
3259 
3260 void
e_content_editor_cell_set_align(EContentEditor * editor,const gchar * value,EContentEditorScope scope)3261 e_content_editor_cell_set_align	(EContentEditor *editor,
3262                                  const gchar *value,
3263                                  EContentEditorScope scope)
3264 {
3265 	EContentEditorInterface *iface;
3266 
3267 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3268 	g_return_if_fail (value != NULL);
3269 
3270 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3271 	g_return_if_fail (iface != NULL);
3272 	g_return_if_fail (iface->cell_set_align != NULL);
3273 
3274 	iface->cell_set_align (editor, value, scope);
3275 }
3276 
3277 gchar *
e_content_editor_cell_get_align(EContentEditor * editor)3278 e_content_editor_cell_get_align (EContentEditor *editor)
3279 {
3280 	EContentEditorInterface *iface;
3281 
3282 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3283 
3284 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3285 	g_return_val_if_fail (iface != NULL, NULL);
3286 	g_return_val_if_fail (iface->cell_get_align != NULL, NULL);
3287 
3288 	return iface->cell_get_align (editor);
3289 }
3290 
3291 void
e_content_editor_cell_set_wrap(EContentEditor * editor,gboolean value,EContentEditorScope scope)3292 e_content_editor_cell_set_wrap (EContentEditor *editor,
3293                                 gboolean value,
3294                                 EContentEditorScope scope)
3295 {
3296 	EContentEditorInterface *iface;
3297 
3298 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3299 
3300 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3301 	g_return_if_fail (iface != NULL);
3302 	g_return_if_fail (iface->cell_set_wrap != NULL);
3303 
3304 	iface->cell_set_wrap (editor, value, scope);
3305 }
3306 
3307 gboolean
e_content_editor_cell_get_wrap(EContentEditor * editor)3308 e_content_editor_cell_get_wrap (EContentEditor *editor)
3309 {
3310 	EContentEditorInterface *iface;
3311 
3312 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
3313 
3314 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3315 	g_return_val_if_fail (iface != NULL, FALSE);
3316 	g_return_val_if_fail (iface->cell_get_wrap != NULL, FALSE);
3317 
3318 	return iface->cell_get_wrap (editor);
3319 }
3320 
3321 void
e_content_editor_cell_set_header_style(EContentEditor * editor,gboolean value,EContentEditorScope scope)3322 e_content_editor_cell_set_header_style (EContentEditor *editor,
3323                                         gboolean value,
3324                                         EContentEditorScope scope)
3325 {
3326 	EContentEditorInterface *iface;
3327 
3328 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3329 
3330 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3331 	g_return_if_fail (iface != NULL);
3332 	g_return_if_fail (iface->cell_set_header_style != NULL);
3333 
3334 	iface->cell_set_header_style (editor, value, scope);
3335 }
3336 
3337 gboolean
e_content_editor_cell_is_header(EContentEditor * editor)3338 e_content_editor_cell_is_header (EContentEditor *editor)
3339 {
3340 	EContentEditorInterface *iface;
3341 
3342 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
3343 
3344 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3345 	g_return_val_if_fail (iface != NULL, FALSE);
3346 	g_return_val_if_fail (iface->cell_is_header != NULL, FALSE);
3347 
3348 	return iface->cell_is_header (editor);
3349 }
3350 
3351 void
e_content_editor_cell_set_width(EContentEditor * editor,gint value,EContentEditorUnit unit,EContentEditorScope scope)3352 e_content_editor_cell_set_width (EContentEditor *editor,
3353                                  gint value,
3354                                  EContentEditorUnit unit,
3355                                  EContentEditorScope scope)
3356 {
3357 	EContentEditorInterface *iface;
3358 
3359 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3360 
3361 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3362 	g_return_if_fail (iface != NULL);
3363 	g_return_if_fail (iface->cell_set_width != NULL);
3364 
3365 	iface->cell_set_width (editor, value, unit, scope);
3366 }
3367 
3368 gint
e_content_editor_cell_get_width(EContentEditor * editor,EContentEditorUnit * unit)3369 e_content_editor_cell_get_width (EContentEditor *editor,
3370                                  EContentEditorUnit *unit)
3371 {
3372 	EContentEditorInterface *iface;
3373 
3374 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3375 	g_return_val_if_fail (unit != NULL, 0);
3376 
3377 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3378 	g_return_val_if_fail (iface != NULL, 0);
3379 	g_return_val_if_fail (iface->cell_get_width != NULL, 0);
3380 
3381 	return iface->cell_get_width (editor, unit);
3382 }
3383 
3384 void
e_content_editor_cell_set_row_span(EContentEditor * editor,gint value,EContentEditorScope scope)3385 e_content_editor_cell_set_row_span (EContentEditor *editor,
3386                                     gint value,
3387                                     EContentEditorScope scope)
3388 {
3389 	EContentEditorInterface *iface;
3390 
3391 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3392 
3393 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3394 	g_return_if_fail (iface != NULL);
3395 	g_return_if_fail (iface->cell_set_row_span != NULL);
3396 
3397 	iface->cell_set_row_span (editor, value, scope);
3398 }
3399 
3400 gint
e_content_editor_cell_get_row_span(EContentEditor * editor)3401 e_content_editor_cell_get_row_span (EContentEditor *editor)
3402 {
3403 	EContentEditorInterface *iface;
3404 
3405 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3406 
3407 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3408 	g_return_val_if_fail (iface != NULL, 0);
3409 	g_return_val_if_fail (iface->cell_get_row_span != NULL, 0);
3410 
3411 	return iface->cell_get_row_span (editor);
3412 }
3413 
3414 void
e_content_editor_cell_set_col_span(EContentEditor * editor,gint value,EContentEditorScope scope)3415 e_content_editor_cell_set_col_span (EContentEditor *editor,
3416                                     gint value,
3417                                     EContentEditorScope scope)
3418 {
3419 	EContentEditorInterface *iface;
3420 
3421 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3422 
3423 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3424 	g_return_if_fail (iface != NULL);
3425 	g_return_if_fail (iface->cell_set_col_span != NULL);
3426 
3427 	iface->cell_set_col_span (editor, value, scope);
3428 }
3429 
3430 gint
e_content_editor_cell_get_col_span(EContentEditor * editor)3431 e_content_editor_cell_get_col_span (EContentEditor *editor)
3432 {
3433 	EContentEditorInterface *iface;
3434 
3435 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3436 
3437 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3438 	g_return_val_if_fail (iface != NULL, 0);
3439 	g_return_val_if_fail (iface->cell_get_col_span != NULL, 0);
3440 
3441 	return iface->cell_get_col_span (editor);
3442 }
3443 
3444 /* uri could be NULL -> removes the current image */
3445 void
e_content_editor_cell_set_background_image_uri(EContentEditor * editor,const gchar * uri)3446 e_content_editor_cell_set_background_image_uri (EContentEditor *editor,
3447                                                 const gchar *uri)
3448 {
3449 	EContentEditorInterface *iface;
3450 
3451 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3452 
3453 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3454 	g_return_if_fail (iface != NULL);
3455 	g_return_if_fail (iface->cell_set_background_image_uri != NULL);
3456 
3457 	iface->cell_set_background_image_uri (editor, uri);
3458 }
3459 
3460 gchar *
e_content_editor_cell_get_background_image_uri(EContentEditor * editor)3461 e_content_editor_cell_get_background_image_uri (EContentEditor *editor)
3462 {
3463 	EContentEditorInterface *iface;
3464 
3465 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3466 
3467 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3468 	g_return_val_if_fail (iface != NULL, NULL);
3469 	g_return_val_if_fail (iface->cell_get_background_image_uri != NULL, NULL);
3470 
3471 	return iface->cell_get_background_image_uri (editor);
3472 }
3473 
3474 void
e_content_editor_cell_set_background_color(EContentEditor * editor,const GdkRGBA * value,EContentEditorScope scope)3475 e_content_editor_cell_set_background_color (EContentEditor *editor,
3476                                             const GdkRGBA *value,
3477                                             EContentEditorScope scope)
3478 {
3479 	EContentEditorInterface *iface;
3480 
3481 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3482 	g_return_if_fail (value != NULL);
3483 
3484 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3485 	g_return_if_fail (iface != NULL);
3486 	g_return_if_fail (iface->cell_set_background_color != NULL);
3487 
3488 	iface->cell_set_background_color (editor, value, scope);
3489 }
3490 
3491 void
e_content_editor_cell_get_background_color(EContentEditor * editor,GdkRGBA * value)3492 e_content_editor_cell_get_background_color (EContentEditor *editor,
3493                                             GdkRGBA *value)
3494 {
3495 	EContentEditorInterface *iface;
3496 
3497 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3498 
3499 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3500 	g_return_if_fail (iface != NULL);
3501 	g_return_if_fail (iface->cell_get_background_color != NULL);
3502 
3503 	iface->cell_get_background_color (editor, value);
3504 }
3505 
3506 void
e_content_editor_table_set_row_count(EContentEditor * editor,guint value)3507 e_content_editor_table_set_row_count (EContentEditor *editor,
3508                                       guint value)
3509 {
3510 	EContentEditorInterface *iface;
3511 
3512 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3513 
3514 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3515 	g_return_if_fail (iface != NULL);
3516 	g_return_if_fail (iface->table_set_row_count != NULL);
3517 
3518 	iface->table_set_row_count (editor, value);
3519 }
3520 
3521 guint
e_content_editor_table_get_row_count(EContentEditor * editor)3522 e_content_editor_table_get_row_count (EContentEditor *editor)
3523 {
3524 	EContentEditorInterface *iface;
3525 
3526 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3527 
3528 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3529 	g_return_val_if_fail (iface != NULL, 0);
3530 	g_return_val_if_fail (iface->table_get_row_count != NULL, 0);
3531 
3532 	return iface->table_get_row_count (editor);
3533 }
3534 
3535 void
e_content_editor_table_set_column_count(EContentEditor * editor,guint value)3536 e_content_editor_table_set_column_count (EContentEditor *editor,
3537                                          guint value)
3538 {
3539 	EContentEditorInterface *iface;
3540 
3541 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3542 
3543 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3544 	g_return_if_fail (iface != NULL);
3545 	g_return_if_fail (iface->table_set_column_count != NULL);
3546 
3547 	iface->table_set_column_count (editor, value);
3548 }
3549 
3550 guint
e_content_editor_table_get_column_count(EContentEditor * editor)3551 e_content_editor_table_get_column_count (EContentEditor *editor)
3552 {
3553 	EContentEditorInterface *iface;
3554 
3555 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3556 
3557 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3558 	g_return_val_if_fail (iface != NULL, 0);
3559 	g_return_val_if_fail (iface->table_get_column_count != NULL, 0);
3560 
3561 	return iface->table_get_column_count (editor);
3562 }
3563 
3564 void
e_content_editor_table_set_width(EContentEditor * editor,gint value,EContentEditorUnit unit)3565 e_content_editor_table_set_width (EContentEditor *editor,
3566                                   gint value,
3567                                   EContentEditorUnit unit)
3568 {
3569 	EContentEditorInterface *iface;
3570 
3571 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3572 
3573 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3574 	g_return_if_fail (iface != NULL);
3575 	g_return_if_fail (iface->table_set_width != NULL);
3576 
3577 	iface->table_set_width (editor, value, unit);
3578 }
3579 
3580 guint
e_content_editor_table_get_width(EContentEditor * editor,EContentEditorUnit * unit)3581 e_content_editor_table_get_width (EContentEditor *editor,
3582                                   EContentEditorUnit *unit)
3583 {
3584 	EContentEditorInterface *iface;
3585 
3586 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3587 
3588 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3589 	g_return_val_if_fail (iface != NULL, 0);
3590 	g_return_val_if_fail (iface->table_get_width != NULL, 0);
3591 
3592 	return iface->table_get_width (editor, unit);
3593 }
3594 
3595 void
e_content_editor_table_set_align(EContentEditor * editor,const gchar * value)3596 e_content_editor_table_set_align (EContentEditor *editor,
3597                                   const gchar *value)
3598 {
3599 	EContentEditorInterface *iface;
3600 
3601 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3602 
3603 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3604 	g_return_if_fail (iface != NULL);
3605 	g_return_if_fail (iface->table_set_align != NULL);
3606 
3607 	iface->table_set_align (editor, value);
3608 }
3609 
3610 gchar *
e_content_editor_table_get_align(EContentEditor * editor)3611 e_content_editor_table_get_align (EContentEditor *editor)
3612 {
3613 	EContentEditorInterface *iface;
3614 
3615 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3616 
3617 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3618 	g_return_val_if_fail (iface != NULL, NULL);
3619 	g_return_val_if_fail (iface->table_get_align != NULL, NULL);
3620 
3621 	return iface->table_get_align (editor);
3622 }
3623 
3624 void
e_content_editor_table_set_padding(EContentEditor * editor,gint value)3625 e_content_editor_table_set_padding (EContentEditor *editor,
3626                                     gint value)
3627 {
3628 	EContentEditorInterface *iface;
3629 
3630 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3631 
3632 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3633 	g_return_if_fail (iface != NULL);
3634 	g_return_if_fail (iface->table_set_padding != NULL);
3635 
3636 	iface->table_set_padding (editor, value);
3637 }
3638 
3639 gint
e_content_editor_table_get_padding(EContentEditor * editor)3640 e_content_editor_table_get_padding (EContentEditor *editor)
3641 {
3642 	EContentEditorInterface *iface;
3643 
3644 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3645 
3646 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3647 	g_return_val_if_fail (iface != NULL, 0);
3648 	g_return_val_if_fail (iface->table_get_padding != NULL, 0);
3649 
3650 	return iface->table_get_padding (editor);
3651 }
3652 
3653 void
e_content_editor_table_set_spacing(EContentEditor * editor,gint value)3654 e_content_editor_table_set_spacing (EContentEditor *editor,
3655                                     gint value)
3656 {
3657 	EContentEditorInterface *iface;
3658 
3659 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3660 
3661 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3662 	g_return_if_fail (iface != NULL);
3663 	g_return_if_fail (iface->table_set_spacing != NULL);
3664 
3665 	iface->table_set_spacing (editor, value);
3666 }
3667 
3668 gint
e_content_editor_table_get_spacing(EContentEditor * editor)3669 e_content_editor_table_get_spacing (EContentEditor *editor)
3670 {
3671 	EContentEditorInterface *iface;
3672 
3673 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3674 
3675 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3676 	g_return_val_if_fail (iface != NULL, 0);
3677 	g_return_val_if_fail (iface->table_get_spacing != NULL, 0);
3678 
3679 	return iface->table_get_spacing (editor);
3680 }
3681 
3682 void
e_content_editor_table_set_border(EContentEditor * editor,gint value)3683 e_content_editor_table_set_border (EContentEditor *editor,
3684                                    gint value)
3685 {
3686 	EContentEditorInterface *iface;
3687 
3688 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3689 
3690 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3691 	g_return_if_fail (iface != NULL);
3692 	g_return_if_fail (iface->table_set_border != NULL);
3693 
3694 	iface->table_set_border (editor, value);
3695 }
3696 
3697 gint
e_content_editor_table_get_border(EContentEditor * editor)3698 e_content_editor_table_get_border (EContentEditor *editor)
3699 {
3700 	EContentEditorInterface *iface;
3701 
3702 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), 0);
3703 
3704 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3705 	g_return_val_if_fail (iface != NULL, 0);
3706 	g_return_val_if_fail (iface->table_get_border != NULL, 0);
3707 
3708 	return iface->table_get_border (editor);
3709 }
3710 
3711 gchar *
e_content_editor_table_get_background_image_uri(EContentEditor * editor)3712 e_content_editor_table_get_background_image_uri (EContentEditor *editor)
3713 {
3714 	EContentEditorInterface *iface;
3715 
3716 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3717 
3718 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3719 	g_return_val_if_fail (iface != NULL, NULL);
3720 	g_return_val_if_fail (iface->table_get_background_image_uri != NULL, NULL);
3721 
3722 	return iface->table_get_background_image_uri (editor);
3723 }
3724 
3725 void
e_content_editor_table_set_background_image_uri(EContentEditor * editor,const gchar * uri)3726 e_content_editor_table_set_background_image_uri (EContentEditor *editor,
3727                                                  const gchar *uri)
3728 {
3729 	EContentEditorInterface *iface;
3730 
3731 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3732 
3733 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3734 	g_return_if_fail (iface != NULL);
3735 	g_return_if_fail (iface->table_set_background_image_uri != NULL);
3736 
3737 	iface->table_set_background_image_uri (editor, uri);
3738 }
3739 
3740 void
e_content_editor_table_get_background_color(EContentEditor * editor,GdkRGBA * value)3741 e_content_editor_table_get_background_color (EContentEditor *editor,
3742                                              GdkRGBA *value)
3743 {
3744 	EContentEditorInterface *iface;
3745 
3746 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3747 
3748 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3749 	g_return_if_fail (iface != NULL);
3750 	g_return_if_fail (iface->table_get_background_color != NULL);
3751 
3752 	iface->table_get_background_color (editor, value);
3753 }
3754 
3755 void
e_content_editor_table_set_background_color(EContentEditor * editor,const GdkRGBA * value)3756 e_content_editor_table_set_background_color (EContentEditor *editor,
3757                                              const GdkRGBA *value)
3758 {
3759 	EContentEditorInterface *iface;
3760 
3761 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3762 
3763 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3764 	g_return_if_fail (iface != NULL);
3765 	g_return_if_fail (iface->table_set_background_color != NULL);
3766 
3767 	iface->table_set_background_color (editor, value);
3768 }
3769 
3770 gchar *
e_content_editor_spell_check_next_word(EContentEditor * editor,const gchar * word)3771 e_content_editor_spell_check_next_word (EContentEditor *editor,
3772                                         const gchar *word)
3773 {
3774 	EContentEditorInterface *iface;
3775 
3776 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3777 
3778 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3779 	g_return_val_if_fail (iface != NULL, NULL);
3780 	g_return_val_if_fail (iface->spell_check_next_word != NULL, NULL);
3781 
3782 	return iface->spell_check_next_word (editor, word);
3783 }
3784 
3785 gchar *
e_content_editor_spell_check_prev_word(EContentEditor * editor,const gchar * word)3786 e_content_editor_spell_check_prev_word (EContentEditor *editor,
3787                                         const gchar *word)
3788 {
3789 	EContentEditorInterface *iface;
3790 
3791 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3792 
3793 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3794 	g_return_val_if_fail (iface != NULL, NULL);
3795 	g_return_val_if_fail (iface->spell_check_prev_word != NULL, NULL);
3796 
3797 	return iface->spell_check_prev_word (editor, word);
3798 }
3799 
3800 void
e_content_editor_emit_load_finished(EContentEditor * editor)3801 e_content_editor_emit_load_finished (EContentEditor *editor)
3802 {
3803 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3804 
3805 	g_signal_emit (editor, signals[LOAD_FINISHED], 0);
3806 }
3807 
3808 gboolean
e_content_editor_emit_paste_clipboard(EContentEditor * editor)3809 e_content_editor_emit_paste_clipboard (EContentEditor *editor)
3810 {
3811 	gboolean handled = FALSE;
3812 
3813 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
3814 
3815 	g_signal_emit (editor, signals[PASTE_CLIPBOARD], 0, &handled);
3816 
3817 	return handled;
3818 }
3819 
3820 gboolean
e_content_editor_emit_paste_primary_clipboard(EContentEditor * editor)3821 e_content_editor_emit_paste_primary_clipboard (EContentEditor *editor)
3822 {
3823 	gboolean handled = FALSE;
3824 
3825 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
3826 
3827 	g_signal_emit (editor, signals[PASTE_PRIMARY_CLIPBOARD], 0, &handled);
3828 
3829 	return handled;
3830 }
3831 
3832 void
e_content_editor_emit_context_menu_requested(EContentEditor * editor,EContentEditorNodeFlags flags,const gchar * caret_word,GdkEvent * event)3833 e_content_editor_emit_context_menu_requested (EContentEditor *editor,
3834 					      EContentEditorNodeFlags flags,
3835 					      const gchar *caret_word,
3836 					      GdkEvent *event)
3837 {
3838 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3839 
3840 	g_signal_emit (editor, signals[CONTEXT_MENU_REQUESTED], 0, flags, caret_word, event, NULL);
3841 }
3842 
3843 void
e_content_editor_emit_find_done(EContentEditor * editor,guint match_count)3844 e_content_editor_emit_find_done (EContentEditor *editor,
3845                                  guint match_count)
3846 {
3847 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3848 
3849 	g_signal_emit (editor, signals[FIND_DONE], 0, match_count);
3850 }
3851 
3852 void
e_content_editor_emit_replace_all_done(EContentEditor * editor,guint replaced_count)3853 e_content_editor_emit_replace_all_done (EContentEditor *editor,
3854                                         guint replaced_count)
3855 {
3856 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3857 
3858 	g_signal_emit (editor, signals[REPLACE_ALL_DONE], 0, replaced_count);
3859 }
3860 
3861 void
e_content_editor_emit_drop_handled(EContentEditor * editor)3862 e_content_editor_emit_drop_handled (EContentEditor *editor)
3863 {
3864 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3865 
3866 	g_signal_emit (editor, signals[DROP_HANDLED], 0);
3867 }
3868 
3869 void
e_content_editor_emit_content_changed(EContentEditor * editor)3870 e_content_editor_emit_content_changed (EContentEditor *editor)
3871 {
3872 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3873 
3874 	g_signal_emit (editor, signals[CONTENT_CHANGED], 0);
3875 }
3876 
3877 CamelMimePart *
e_content_editor_emit_ref_mime_part(EContentEditor * editor,const gchar * uri)3878 e_content_editor_emit_ref_mime_part (EContentEditor *editor,
3879 				     const gchar *uri)
3880 {
3881 	CamelMimePart *mime_part = NULL;
3882 
3883 	g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), NULL);
3884 	g_return_val_if_fail (uri != NULL, NULL);
3885 
3886 	g_signal_emit (editor, signals[REF_MIME_PART], 0, uri, &mime_part);
3887 
3888 	return mime_part;
3889 }
3890 
3891 void
e_content_editor_delete_h_rule(EContentEditor * editor)3892 e_content_editor_delete_h_rule (EContentEditor *editor)
3893 {
3894 	EContentEditorInterface *iface;
3895 
3896 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3897 
3898 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3899 	g_return_if_fail (iface != NULL);
3900 	g_return_if_fail (iface->delete_h_rule != NULL);
3901 
3902 	iface->delete_h_rule (editor);
3903 }
3904 
3905 void
e_content_editor_delete_image(EContentEditor * editor)3906 e_content_editor_delete_image (EContentEditor *editor)
3907 {
3908 	EContentEditorInterface *iface;
3909 
3910 	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
3911 
3912 	iface = E_CONTENT_EDITOR_GET_IFACE (editor);
3913 	g_return_if_fail (iface != NULL);
3914 	g_return_if_fail (iface->delete_image != NULL);
3915 
3916 	iface->delete_image (editor);
3917 }
3918