]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-ui-utils.h
Merge commit 'ka/empathy-tpl-20100225-ifdef'
[empathy.git] / libempathy-gtk / empathy-ui-utils.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2002-2007 Imendio AB
4  * Copyright (C) 2007-2008 Collabora Ltd.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA  02110-1301  USA
20  *
21  * Authors: Mikael Hallendal <micke@imendio.com>
22  *          Richard Hult <richard@imendio.com>
23  *          Martyn Russell <martyn@imendio.com>
24  *          Xavier Claessens <xclaesse@gmail.com>
25  *          Jonny Lamb <jonny.lamb@collabora.co.uk>
26  *
27  *          Part of this file is copied from GtkSourceView (gtksourceiter.c):
28  *          Paolo Maggi
29  *          Jeroen Zwartepoorte
30  */
31
32 #ifndef __EMPATHY_UI_UTILS_H__
33 #define __EMPATHY_UI_UTILS_H__
34
35 #include <gtk/gtk.h>
36
37 #include <libempathy/empathy-contact.h>
38 #include <libempathy/empathy-ft-handler.h>
39
40 #include "empathy-chat-view.h"
41
42 G_BEGIN_DECLS
43
44 #define EMPATHY_RECT_IS_ON_SCREEN(x,y,w,h) ((x) + (w) > 0 && \
45                                             (y) + (h) > 0 && \
46                                             (x) < gdk_screen_width () && \
47                                             (y) < gdk_screen_height ())
48
49 void            empathy_gtk_init                        (void);
50 GRegex *        empathy_uri_regex_dup_singleton         (void);
51
52 /* Glade */
53 GtkBuilder *    empathy_builder_get_file                (const gchar      *filename,
54                                                          const gchar      *first_object,
55                                                          ...);
56 void            empathy_builder_connect                 (GtkBuilder       *gui,
57                                                          gpointer          user_data,
58                                                          gchar            *first_object,
59                                                          ...);
60 GtkWidget     *empathy_builder_unref_and_keep_widget    (GtkBuilder       *gui,
61                                                          GtkWidget        *root);
62
63 /* Pixbufs */
64 const gchar * empathy_icon_name_for_presence            (TpConnectionPresenceType  presence);
65 const gchar * empathy_icon_name_for_contact             (EmpathyContact   *contact);
66 const gchar * empathy_protocol_name_for_contact         (EmpathyContact   *contact);
67 GdkPixbuf *   empathy_pixbuf_from_data                  (gchar            *data,
68                                                          gsize             data_size);
69 GdkPixbuf *   empathy_pixbuf_from_data_and_mime         (gchar            *data,
70                                                          gsize             data_size,
71                                                          gchar           **mime_type);
72 GdkPixbuf *   empathy_pixbuf_from_avatar_scaled         (EmpathyAvatar    *avatar,
73                                                          gint              width,
74                                                          gint              height);
75 GdkPixbuf *   empathy_pixbuf_avatar_from_contact_scaled (EmpathyContact   *contact,
76                                                          gint              width,
77                                                          gint              height);
78 GdkPixbuf *   empathy_pixbuf_protocol_from_contact_scaled (EmpathyContact   *contact,
79                                                          gint              width,
80                                                          gint              height);
81 GdkPixbuf *   empathy_pixbuf_contact_status_icon (EmpathyContact   *contact,
82                                                          gboolean          show_protocol);
83 GdkPixbuf *   empathy_pixbuf_contact_status_icon_with_icon_name (EmpathyContact   *contact,
84                                                          const gchar       *icon_name,
85                                                          gboolean          show_protocol);
86 GdkPixbuf *   empathy_pixbuf_scale_down_if_necessary    (GdkPixbuf        *pixbuf,
87                                                          gint              max_size);
88 GdkPixbuf *   empathy_pixbuf_from_icon_name             (const gchar      *icon_name,
89                                                          GtkIconSize       icon_size);
90 GdkPixbuf *   empathy_pixbuf_from_icon_name_sized       (const gchar      *icon_name,
91                                                          gint              size);
92 gchar *       empathy_filename_from_icon_name           (const gchar      *icon_name,
93                                                          GtkIconSize       icon_size);
94
95 /* Text view */
96 gboolean    empathy_text_iter_forward_search            (const GtkTextIter*iter,
97                                                          const gchar      *str,
98                                                          GtkTextIter      *match_start,
99                                                          GtkTextIter      *match_end,
100                                                          const GtkTextIter*limit);
101 gboolean    empathy_text_iter_backward_search           (const GtkTextIter*iter,
102                                                          const gchar      *str,
103                                                          GtkTextIter      *match_start,
104                                                          GtkTextIter      *match_end,
105                                                          const GtkTextIter*limit);
106 /* Windows */
107 gboolean    empathy_window_get_is_visible               (GtkWindow        *window);
108 void        empathy_window_present                      (GtkWindow        *window,
109                                                          gboolean          steal_focus);
110 void        empathy_window_iconify                      (GtkWindow        *window,
111                                                          GtkStatusIcon    *status_icon);
112 GtkWindow * empathy_get_toplevel_window                 (GtkWidget        *widget);
113 void        empathy_url_show                            (GtkWidget        *parent,
114                                                          const char       *url);
115 void        empathy_toggle_button_set_state_quietly     (GtkWidget        *widget,
116                                                          GCallback         callback,
117                                                          gpointer          user_data,
118                                                          gboolean          active);
119 GtkWidget * empathy_link_button_new                     (const gchar      *url,
120                                                          const gchar      *title);
121
122 void        empathy_send_file                           (EmpathyContact   *contact,
123                                                          GFile            *file);
124 void        empathy_send_file_from_uri_list             (EmpathyContact   *contact,
125                                                          const gchar      *uri_list);
126 void        empathy_send_file_with_file_chooser         (EmpathyContact   *contact);
127 void        empathy_receive_file_with_file_chooser      (EmpathyFTHandler *handler);
128
129 gchar *     empathy_make_absolute_url                   (const gchar *url);
130 gchar *     empathy_make_absolute_url_len               (const gchar *url,
131                                                          guint len);
132
133 /* String parser */
134 typedef struct _EmpathyStringParser EmpathyStringParser;
135
136 typedef void (*EmpathyStringReplace) (const gchar *text,
137                                       gssize len,
138                                       gpointer match_data,
139                                       gpointer user_data);
140 typedef void (*EmpathyStringMatch) (const gchar *text,
141                                     gssize len,
142                                     EmpathyStringReplace replace_func,
143                                     EmpathyStringParser *sub_parsers,
144                                     gpointer user_data);
145
146 struct _EmpathyStringParser {
147         EmpathyStringMatch match_func;
148         EmpathyStringReplace replace_func;
149 };
150
151 void
152 empathy_string_parser_substr (const gchar *text,
153                               gssize len,
154                               EmpathyStringParser *parsers,
155                               gpointer user_data);
156
157 void
158 empathy_string_match_link (const gchar *text,
159                            gssize len,
160                            EmpathyStringReplace replace_func,
161                            EmpathyStringParser *sub_parsers,
162                            gpointer user_data);
163
164 void
165 empathy_string_match_smiley (const gchar *text,
166                              gssize len,
167                              EmpathyStringReplace replace_func,
168                              EmpathyStringParser *sub_parsers,
169                              gpointer user_data);
170
171 void
172 empathy_string_match_all (const gchar *text,
173                           gssize len,
174                           EmpathyStringReplace replace_func,
175                           EmpathyStringParser *sub_parsers,
176                           gpointer user_data);
177
178 G_END_DECLS
179
180 #endif /*  __EMPATHY_UI_UTILS_H__ */