]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-ui-utils.h
e5c3aa1faf76d88a97dc35feb193747e3d1c2d08
[empathy.git] / libempathy-gtk / empathy-ui-utils.h
1 /*
2  * Copyright (C) 2002-2007 Imendio AB
3  * Copyright (C) 2007-2010 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: Mikael Hallendal <micke@imendio.com>
21  *          Richard Hult <richard@imendio.com>
22  *          Martyn Russell <martyn@imendio.com>
23  *          Xavier Claessens <xclaesse@gmail.com>
24  *          Jonny Lamb <jonny.lamb@collabora.co.uk>
25  *          Travis Reitter <travis.reitter@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 <folks/folks.h>
38
39 #include <libempathy/empathy-contact.h>
40 #include <libempathy/empathy-ft-handler.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 typedef void (*EmpathyPixbufAvatarFromIndividualCb) (
50     FolksIndividual *individual,
51     GdkPixbuf *pixbuf,
52     gpointer user_data);
53
54 void empathy_gtk_init (void);
55
56 /* Glade */
57 GtkBuilder * empathy_builder_get_file (const gchar *filename,
58     const gchar *first_object,
59     ...);
60 GtkBuilder * empathy_builder_get_resource (const gchar *resourcename,
61     const gchar *first_object,
62     ...);
63 void empathy_builder_connect (GtkBuilder *gui,
64     gpointer user_data,
65     const gchar *first_object,
66     ...);
67 GtkWidget * empathy_builder_unref_and_keep_widget (GtkBuilder *gui,
68     GtkWidget *root);
69
70 /* Pixbufs */
71 const gchar * empathy_icon_name_for_presence (
72     TpConnectionPresenceType presence);
73 const gchar * empathy_icon_name_for_contact (EmpathyContact *contact);
74 const gchar * empathy_icon_name_for_individual (FolksIndividual *individual);
75 const gchar * empathy_protocol_name_for_contact (EmpathyContact *contact);
76 GdkPixbuf * empathy_pixbuf_from_data (gchar *data,
77     gsize data_size);
78 GdkPixbuf * empathy_pixbuf_from_data_and_mime (gchar *data,
79     gsize data_size,
80     gchar **mime_type);
81 void empathy_pixbuf_avatar_from_individual_scaled_async (
82     FolksIndividual *individual,
83     gint width,
84     gint height,
85     GCancellable *cancellable,
86     GAsyncReadyCallback callback,
87     gpointer user_data);
88 GdkPixbuf * empathy_pixbuf_avatar_from_individual_scaled_finish (
89     FolksIndividual *individual,
90     GAsyncResult *result,
91     GError **error);
92 GdkPixbuf * empathy_pixbuf_avatar_from_contact_scaled (EmpathyContact *contact,
93     gint width,
94     gint height);
95 GdkPixbuf * empathy_pixbuf_contact_status_icon (EmpathyContact *contact,
96     gboolean show_protocol);
97 GdkPixbuf * empathy_pixbuf_contact_status_icon_with_icon_name (
98     EmpathyContact *contact,
99     const gchar *icon_name,
100     gboolean show_protocol);
101 GdkPixbuf * empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf,
102     gint max_size);
103 GdkPixbuf * empathy_pixbuf_from_icon_name (const gchar *icon_name,
104     GtkIconSize icon_size);
105 GdkPixbuf * empathy_pixbuf_from_icon_name_sized (const gchar *icon_name,
106     gint size);
107 gchar * empathy_filename_from_icon_name (const gchar *icon_name,
108     GtkIconSize icon_size);
109
110 /* Windows */
111 void empathy_window_present (GtkWindow *window);
112 void empathy_window_present_with_time (GtkWindow *window,
113     guint32 timestamp);
114 GtkWindow * empathy_get_toplevel_window (GtkWidget *widget);
115
116 void empathy_move_to_window_desktop (GtkWindow *window,
117     guint32 timestamp);
118
119 /* URL */
120 gchar * empathy_make_absolute_url (const gchar *url);
121
122 gchar * empathy_make_absolute_url_len (const gchar *url,
123     guint len);
124 void empathy_url_show (GtkWidget *parent,
125     const char *url);
126
127 /* File transfer */
128 void empathy_send_file (EmpathyContact *contact,
129     GFile *file);
130 void empathy_send_file_from_uri_list (EmpathyContact *contact,
131     const gchar *uri_list);
132 void empathy_send_file_with_file_chooser (EmpathyContact *contact);
133 void empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler);
134
135 /* Misc */
136 void  empathy_make_color_whiter (GdkRGBA *color);
137
138 GtkWidget * empathy_context_menu_new (GtkWidget *attach_to);
139
140 gint64 empathy_get_current_action_time (void);
141
142 gboolean empathy_individual_match_string (
143     FolksIndividual *individual,
144     const gchar *text,
145     GPtrArray *words);
146
147 void empathy_launch_program (const gchar *dir,
148     const gchar *name,
149     const gchar *args);
150
151 void empathy_set_css_provider (GtkWidget *widget);
152
153 gboolean empathy_launch_external_app (const gchar *desktop_file,
154     const gchar *args,
155     GError **error);
156
157 G_END_DECLS
158
159 #endif /*  __EMPATHY_UI_UTILS_H__ */