]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-chat-view.c
Move should_create_salut_account to local-xmpp-assistant-widget
[empathy.git] / libempathy-gtk / empathy-chat-view.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2008 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA  02110-1301  USA
19  *
20  * Authors: Xavier Claessens <xclaesse@gmail.com>
21  */
22
23 #include "config.h"
24
25 #include "empathy-chat-view.h"
26 #include "empathy-smiley-manager.h"
27
28 static void chat_view_base_init (gpointer klass);
29
30 GType
31 empathy_chat_view_get_type (void)
32 {
33         static GType type = 0;
34
35         if (!type) {
36                 static const GTypeInfo type_info = {
37                         sizeof (EmpathyChatViewIface),
38                         chat_view_base_init,
39                         NULL,
40                 };
41
42                 type = g_type_register_static (G_TYPE_INTERFACE,
43                                                "EmpathyChatView",
44                                                &type_info, 0);
45
46                 g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
47         }
48
49         return type;
50 }
51
52 static void
53 chat_view_base_init (gpointer klass)
54 {
55         static gboolean initialized = FALSE;
56
57         if (!initialized) {
58                 initialized = TRUE;
59         }
60 }
61
62 void
63 empathy_chat_view_append_message (EmpathyChatView *view,
64                                   EmpathyMessage  *msg,
65                                   gboolean         should_highlight)
66 {
67         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
68
69         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message) {
70                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message (view,
71                                                                          msg,
72                                                                          should_highlight);
73         }
74 }
75
76 void
77 empathy_chat_view_append_event (EmpathyChatView *view,
78                                 const gchar    *str)
79 {
80         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
81
82         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event) {
83                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event (view,
84                                                                        str);
85         }
86 }
87
88 void
89 empathy_chat_view_append_event_markup (EmpathyChatView *view,
90                                        const gchar     *markup_text,
91                                        const gchar     *fallback_text)
92 {
93         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
94
95         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event_markup) {
96                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event_markup (view,
97                                                                               markup_text,
98                                                                               fallback_text);
99         } else {
100                 empathy_chat_view_append_event (view, fallback_text);
101         }
102 }
103
104 void
105 empathy_chat_view_edit_message (EmpathyChatView *view,
106                                 EmpathyMessage  *message)
107 {
108         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
109
110         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->edit_message) {
111                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->edit_message (
112                         view, message);
113         }
114 }
115
116 void
117 empathy_chat_view_scroll (EmpathyChatView *view,
118                           gboolean        allow_scrolling)
119 {
120         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
121
122         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll) {
123                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll (view,
124                                                                  allow_scrolling);
125         }
126 }
127
128 void
129 empathy_chat_view_scroll_down (EmpathyChatView *view)
130 {
131         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
132
133         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll_down) {
134                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll_down (view);
135         }
136 }
137
138 gboolean
139 empathy_chat_view_get_has_selection (EmpathyChatView *view)
140 {
141         g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE);
142
143         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_has_selection) {
144                 return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_has_selection (view);
145         }
146         return FALSE;
147 }
148
149 void
150 empathy_chat_view_clear (EmpathyChatView *view)
151 {
152         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
153
154         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->clear) {
155                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->clear (view);
156         }
157 }
158
159 gboolean
160 empathy_chat_view_find_previous (EmpathyChatView *view,
161                                  const gchar    *search_criteria,
162                                  gboolean        new_search,
163                                  gboolean        match_case)
164 {
165         g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE);
166
167         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_previous) {
168                 return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_previous (view,
169                                                                                search_criteria,
170                                                                                new_search,
171                                                                                match_case);
172         }
173         return FALSE;
174 }
175
176 gboolean
177 empathy_chat_view_find_next (EmpathyChatView *view,
178                              const gchar    *search_criteria,
179                              gboolean        new_search,
180                              gboolean        match_case)
181 {
182         g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE);
183
184         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_next) {
185                 return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_next (view,
186                                                                            search_criteria,
187                                                                            new_search,
188                                                                            match_case);
189         }
190         return FALSE;
191 }
192
193
194 void
195 empathy_chat_view_find_abilities (EmpathyChatView *view,
196                                   const gchar    *search_criteria,
197                                   gboolean        match_case,
198                                   gboolean       *can_do_previous,
199                                   gboolean       *can_do_next)
200 {
201         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
202
203         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities) {
204                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities (view,
205                                                                          search_criteria,
206                                                                          match_case,
207                                                                          can_do_previous,
208                                                                          can_do_next);
209         }
210 }
211
212 void
213 empathy_chat_view_highlight (EmpathyChatView *view,
214                              const gchar     *text,
215                              gboolean         match_case)
216 {
217         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
218
219         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->highlight) {
220                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->highlight (view, text, match_case);
221         }
222 }
223
224 void
225 empathy_chat_view_copy_clipboard (EmpathyChatView *view)
226 {
227         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
228
229         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->copy_clipboard) {
230                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->copy_clipboard (view);
231         }
232 }
233
234 void
235 empathy_chat_view_focus_toggled (EmpathyChatView *view,
236                                  gboolean         has_focus)
237 {
238         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
239
240         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->focus_toggled) {
241                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->focus_toggled (view, has_focus);
242         }
243 }
244
245 void
246 empathy_chat_view_message_acknowledged (EmpathyChatView *view,
247                                         EmpathyMessage  *message)
248 {
249         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
250
251         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->message_acknowledged) {
252                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->message_acknowledged (view, message);
253         }
254 }
255