1 # include "thread_view_activatable.h"
2 # include <gtk/gtk.h>
3 # include <webkit2/webkit2.h>
4
5 /**
6 * SECTION: astroid_threadview_activatable
7 * @short_description: Interface for activatable extensions on the shell
8 * @see_also: #PeasExtensionSet
9 *
10 * #AstroidthreadviewActivatable is an interface which should be implemented by
11 * extensions that should be activated on the Liferea main window.
12 **/
13
G_DEFINE_INTERFACE(AstroidThreadViewActivatable,astroid_threadview_activatable,G_TYPE_OBJECT)14 G_DEFINE_INTERFACE (AstroidThreadViewActivatable, astroid_threadview_activatable, G_TYPE_OBJECT)
15
16 void
17 astroid_threadview_activatable_default_init (AstroidThreadViewActivatableInterface *iface)
18 {
19 static gboolean initialized = FALSE;
20
21 if (!initialized) {
22 /**
23 * AstroidthreadviewActivatable:window:
24 *
25 * The window property contains the gtr window for this
26 * #AstroidActivatable instance.
27 */
28 g_object_interface_install_property (iface,
29 g_param_spec_object ("thread_view",
30 "thread_view",
31 "The threadview box",
32 GTK_TYPE_BOX,
33 G_PARAM_READWRITE));
34
35 g_object_interface_install_property (iface,
36 g_param_spec_object ("web_view",
37 "web_view",
38 "The WebKit Webview",
39 WEBKIT_TYPE_WEB_VIEW,
40 G_PARAM_READWRITE));
41
42 initialized = TRUE;
43 }
44 }
45
46 /**
47 * astroid_threadview_activatable_activate:
48 * @activatable: A #AstroidThreadViewActivatable.
49 *
50 * Activates the extension on the shell property.
51 */
52 void
astroid_threadview_activatable_activate(AstroidThreadViewActivatable * activatable)53 astroid_threadview_activatable_activate (AstroidThreadViewActivatable * activatable)
54 {
55 AstroidThreadViewActivatableInterface *iface;
56
57 g_return_if_fail (ASTROID_IS_THREADVIEW_ACTIVATABLE (activatable));
58
59 iface = ASTROID_THREADVIEW_ACTIVATABLE_GET_IFACE (activatable);
60 if (iface->activate)
61 iface->activate (activatable);
62 }
63
64 /**
65 * astroid_threadview_activatable_deactivate:
66 * @activatable: A #AstroidThreadViewActivatable.
67 *
68 * Deactivates the extension on the shell property.
69 */
70 void
astroid_threadview_activatable_deactivate(AstroidThreadViewActivatable * activatable)71 astroid_threadview_activatable_deactivate (AstroidThreadViewActivatable * activatable)
72 {
73 AstroidThreadViewActivatableInterface *iface;
74
75 g_return_if_fail (ASTROID_IS_THREADVIEW_ACTIVATABLE (activatable));
76
77 iface = ASTROID_THREADVIEW_ACTIVATABLE_GET_IFACE (activatable);
78 if (iface->deactivate)
79 iface->deactivate (activatable);
80 }
81
82 /**
83 * astroid_threadview_activatable_update_state:
84 * @activatable: A #AstroidThreadViewActivatable.
85 *
86 * Triggers an update of the extension internal state to take into account
87 * state changes in the window, due to some event or user action.
88 */
89 void
astroid_threadview_activatable_update_state(AstroidThreadViewActivatable * activatable)90 astroid_threadview_activatable_update_state (AstroidThreadViewActivatable * activatable)
91 {
92 AstroidThreadViewActivatableInterface *iface;
93
94 g_return_if_fail (ASTROID_IS_THREADVIEW_ACTIVATABLE (activatable));
95
96 iface = ASTROID_THREADVIEW_ACTIVATABLE_GET_IFACE (activatable);
97 if (iface->update_state)
98 iface->update_state (activatable);
99 }
100
101
102 /**
103 * astroid_activatable_get_avatar_uri:
104 * @activatable: A #AstroidThreadViewActivatable.
105 * @email: A #utf8.
106 * @type: A #string.
107 * @size: A #int.
108 * @message: A #GMime.Message.
109 *
110 * Returns: (transfer none): A #string.
111 */
112 char *
astroid_threadview_activatable_get_avatar_uri(AstroidThreadViewActivatable * activatable,const char * email,const char * type,int size,GMimeMessage * message)113 astroid_threadview_activatable_get_avatar_uri (AstroidThreadViewActivatable * activatable, const char * email, const char * type, int size, GMimeMessage * message)
114 {
115 AstroidThreadViewActivatableInterface *iface;
116
117 if (!ASTROID_IS_THREADVIEW_ACTIVATABLE (activatable)) return NULL;
118
119 iface = ASTROID_THREADVIEW_ACTIVATABLE_GET_IFACE (activatable);
120 if (iface->get_avatar_uri)
121 return iface->get_avatar_uri (activatable, email, type, size, message);
122
123 return NULL;
124 }
125
126 /**
127 * astroid_threadview_activatable_get_allowed_uris:
128 * @activatable: A #AstroidThreadViewActivatable.
129 *
130 * Returns: (element-type utf8) (transfer container): List of allowed uris.
131 */
132 GList *
astroid_threadview_activatable_get_allowed_uris(AstroidThreadViewActivatable * activatable)133 astroid_threadview_activatable_get_allowed_uris (AstroidThreadViewActivatable * activatable)
134 {
135 AstroidThreadViewActivatableInterface *iface;
136
137 if (!ASTROID_IS_THREADVIEW_ACTIVATABLE (activatable)) return NULL;
138
139 iface = ASTROID_THREADVIEW_ACTIVATABLE_GET_IFACE (activatable);
140 if (iface->get_allowed_uris)
141 return iface->get_allowed_uris (activatable);
142
143 return NULL;
144 }
145
146 /**
147 * astroid_threadview_activatable_format_tags:
148 * @activatable: A #AstroidThreadViewActivatable.
149 * @bg : A #utf8.
150 * @tags: (element-type utf8) (transfer none): List of #utf8.
151 * @selected: A #bool.
152 *
153 */
154 char *
astroid_threadview_activatable_format_tags(AstroidThreadViewActivatable * activatable,const char * bg,GList * tags,bool selected)155 astroid_threadview_activatable_format_tags (AstroidThreadViewActivatable * activatable, const char * bg, GList * tags, bool selected)
156 {
157 AstroidThreadViewActivatableInterface *iface;
158
159 if (!ASTROID_IS_THREADVIEW_ACTIVATABLE (activatable)) return NULL;
160
161 iface = ASTROID_THREADVIEW_ACTIVATABLE_GET_IFACE (activatable);
162 if (iface->format_tags)
163 return iface->format_tags (activatable, bg, tags, selected);
164
165 return NULL;
166 }
167
168 /**
169 * astroid_threadview_activatable_filter_part:
170 * @activatable: A #AstroidThreadViewActivatable.
171 * @input_text : A #utf8.
172 * @input_html : A #utf8.
173 * @mime_type : A #utf8.
174 * @is_patch : A #bool.
175 *
176 */
177 char *
astroid_threadview_activatable_filter_part(AstroidThreadViewActivatable * activatable,const char * input_text,const char * input_html,const char * mime_type,bool is_patch)178 astroid_threadview_activatable_filter_part (
179 AstroidThreadViewActivatable * activatable,
180 const char * input_text,
181 const char * input_html,
182 const char * mime_type,
183 bool is_patch)
184 {
185 AstroidThreadViewActivatableInterface *iface;
186
187 if (!ASTROID_IS_THREADVIEW_ACTIVATABLE (activatable)) return NULL;
188
189 iface = ASTROID_THREADVIEW_ACTIVATABLE_GET_IFACE (activatable);
190 if (iface->filter_part)
191 return iface->filter_part (activatable, input_text, input_html, mime_type, is_patch);
192
193 return NULL;
194 }
195
196