]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-chat-view.c
empathy_individual_store_remove_individual: use EMPATHY_INDIVIDUAL_STORE_COL_NAME
[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 {
66         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
67
68         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message) {
69                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_message (view,
70                                                                          msg);
71         }
72 }
73
74 void
75 empathy_chat_view_append_event (EmpathyChatView *view,
76                                 const gchar    *str)
77 {
78         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
79
80         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event) {
81                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event (view,
82                                                                        str);
83         }
84 }
85
86 void
87 empathy_chat_view_append_event_markup (EmpathyChatView *view,
88                                        const gchar     *markup_text,
89                                        const gchar     *fallback_text)
90 {
91         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
92
93         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event_markup) {
94                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->append_event_markup (view,
95                                                                               markup_text,
96                                                                               fallback_text);
97         } else {
98                 empathy_chat_view_append_event (view, fallback_text);
99         }
100 }
101
102 void
103 empathy_chat_view_edit_message (EmpathyChatView *view,
104                                 EmpathyMessage  *message)
105 {
106         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
107
108         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->edit_message) {
109                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->edit_message (
110                         view, message);
111         }
112 }
113
114 void
115 empathy_chat_view_scroll (EmpathyChatView *view,
116                           gboolean        allow_scrolling)
117 {
118         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
119
120         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll) {
121                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll (view,
122                                                                  allow_scrolling);
123         }
124 }
125
126 void
127 empathy_chat_view_scroll_down (EmpathyChatView *view)
128 {
129         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
130
131         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll_down) {
132                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->scroll_down (view);
133         }
134 }
135
136 gboolean
137 empathy_chat_view_get_has_selection (EmpathyChatView *view)
138 {
139         g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE);
140
141         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_has_selection) {
142                 return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_has_selection (view);
143         }
144         return FALSE;
145 }
146
147 void
148 empathy_chat_view_clear (EmpathyChatView *view)
149 {
150         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
151
152         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->clear) {
153                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->clear (view);
154         }
155 }
156
157 gboolean
158 empathy_chat_view_find_previous (EmpathyChatView *view,
159                                  const gchar    *search_criteria,
160                                  gboolean        new_search,
161                                  gboolean        match_case)
162 {
163         g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE);
164
165         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_previous) {
166                 return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_previous (view,
167                                                                                search_criteria,
168                                                                                new_search,
169                                                                                match_case);
170         }
171         return FALSE;
172 }
173
174 gboolean
175 empathy_chat_view_find_next (EmpathyChatView *view,
176                              const gchar    *search_criteria,
177                              gboolean        new_search,
178                              gboolean        match_case)
179 {
180         g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), FALSE);
181
182         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_next) {
183                 return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_next (view,
184                                                                            search_criteria,
185                                                                            new_search,
186                                                                            match_case);
187         }
188         return FALSE;
189 }
190
191
192 void
193 empathy_chat_view_find_abilities (EmpathyChatView *view,
194                                   const gchar    *search_criteria,
195                                   gboolean        match_case,
196                                   gboolean       *can_do_previous,
197                                   gboolean       *can_do_next)
198 {
199         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
200
201         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities) {
202                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->find_abilities (view,
203                                                                          search_criteria,
204                                                                          match_case,
205                                                                          can_do_previous,
206                                                                          can_do_next);
207         }
208 }
209
210 void
211 empathy_chat_view_highlight (EmpathyChatView *view,
212                              const gchar     *text,
213                              gboolean         match_case)
214 {
215         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
216
217         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->highlight) {
218                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->highlight (view, text, match_case);
219         }
220 }
221
222 void
223 empathy_chat_view_copy_clipboard (EmpathyChatView *view)
224 {
225         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
226
227         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->copy_clipboard) {
228                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->copy_clipboard (view);
229         }
230 }
231
232 void
233 empathy_chat_view_focus_toggled (EmpathyChatView *view,
234                                  gboolean         has_focus)
235 {
236         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
237
238         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->focus_toggled) {
239                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->focus_toggled (view, has_focus);
240         }
241 }
242
243 void
244 empathy_chat_view_message_acknowledged (EmpathyChatView *view,
245                                         EmpathyMessage  *message)
246 {
247         g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
248
249         if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->message_acknowledged) {
250                 EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->message_acknowledged (view, message);
251         }
252 }
253