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 "e-webkit-editor-extension.h"
20 #include "e-webkit-editor.h"
21
22 #include <e-util/e-util.h>
23
24 #define E_WEBKIT_EDITOR_EXTENSION_GET_PRIVATE(obj) \
25 (G_TYPE_INSTANCE_GET_PRIVATE \
26 ((obj), E_TYPE_WEBKIT_EDITOR_EXTENSION, EWebKitEditorExtensionPrivate))
27
28 struct _EWebKitEditorExtensionPrivate {
29 EWebKitEditor *wk_editor;
30 };
31
G_DEFINE_DYNAMIC_TYPE(EWebKitEditorExtension,e_webkit_editor_extension,E_TYPE_EXTENSION)32 G_DEFINE_DYNAMIC_TYPE (
33 EWebKitEditorExtension,
34 e_webkit_editor_extension,
35 E_TYPE_EXTENSION)
36
37 static void
38 e_webkit_editor_extension_init (EWebKitEditorExtension *editor_extension)
39 {
40 editor_extension->priv = E_WEBKIT_EDITOR_EXTENSION_GET_PRIVATE (editor_extension);
41
42 editor_extension->priv->wk_editor = g_object_ref_sink (e_webkit_editor_new ());
43 }
44
45 static void
webkit_editor_extension_constructed(GObject * object)46 webkit_editor_extension_constructed (GObject *object)
47 {
48 EWebKitEditorExtensionPrivate *priv;
49 EExtensible *extensible;
50
51 /* Chain up to parent's constructed() method. */
52 G_OBJECT_CLASS (e_webkit_editor_extension_parent_class)->constructed (object);
53
54 priv = E_WEBKIT_EDITOR_EXTENSION_GET_PRIVATE (object);
55 extensible = e_extension_get_extensible (E_EXTENSION (object));
56
57 e_html_editor_register_content_editor (E_HTML_EDITOR (extensible),
58 DEFAULT_CONTENT_EDITOR_NAME, E_CONTENT_EDITOR (priv->wk_editor));
59 }
60
61 static void
webkit_editor_extension_dispose(GObject * object)62 webkit_editor_extension_dispose (GObject *object)
63 {
64 EWebKitEditorExtensionPrivate *priv;
65
66 priv = E_WEBKIT_EDITOR_EXTENSION_GET_PRIVATE (object);
67
68 g_clear_object (&priv->wk_editor);
69
70 /* Chain up to parent's dispose() method. */
71 G_OBJECT_CLASS (e_webkit_editor_extension_parent_class)->dispose (object);
72 }
73
74 static void
e_webkit_editor_extension_class_init(EWebKitEditorExtensionClass * class)75 e_webkit_editor_extension_class_init (EWebKitEditorExtensionClass *class)
76 {
77 EExtensionClass *extension_class;
78 GObjectClass *object_class;
79
80 g_type_class_add_private (class, sizeof (EWebKitEditorExtensionPrivate));
81
82 extension_class = E_EXTENSION_CLASS (class);
83 extension_class->extensible_type = E_TYPE_HTML_EDITOR;
84
85 object_class = G_OBJECT_CLASS (class);
86 object_class->dispose = webkit_editor_extension_dispose;
87 object_class->constructed = webkit_editor_extension_constructed;
88 }
89
90 static void
e_webkit_editor_extension_class_finalize(EWebKitEditorExtensionClass * class)91 e_webkit_editor_extension_class_finalize (EWebKitEditorExtensionClass *class)
92 {
93 }
94
95 void
e_webkit_editor_extension_type_register(GTypeModule * type_module)96 e_webkit_editor_extension_type_register (GTypeModule *type_module)
97 {
98 e_webkit_editor_extension_register_type (type_module);
99 }
100