Mercurial > pidgin
annotate src/gtknotify.c @ 10212:08251403c871
[gaim-migrate @ 11336]
Both the installer and gaim make checks to see if an instance of gaim is
already running.
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sat, 20 Nov 2004 00:42:42 +0000 |
parents | 9e0b98c458b1 |
children | 95ca0db2d01d |
rev | line source |
---|---|
5437 | 1 /** |
2 * @file gtknotify.c GTK+ Notification API | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
10 * |
5437 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
27 |
7455 | 28 #include <gdk/gdkkeysyms.h> |
29 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
30 #include "connection.h" |
8284 | 31 #include "debug.h" |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
32 #include "prefs.h" |
5437 | 33 #include "stock.h" |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
34 #include "util.h" |
5437 | 35 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
36 #include "gtkimhtml.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
37 #include "gtknotify.h" |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
38 #include "gtkutils.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
39 |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
40 typedef struct |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
41 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5543
diff
changeset
|
42 GaimConnection *gc; |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
43 char *url; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
44 GtkWidget *dialog; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
45 GtkWidget *label; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
46 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
47 } GaimNotifyMailData; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
48 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
49 static void *gaim_gtk_notify_emails(size_t count, gboolean detailed, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
50 const char **subjects, |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
51 const char **froms, const char **tos, |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
52 const char **urls, GCallback cb, |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
53 void *user_data); |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
54 |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
55 static void |
6354
76af8c066f8c
[gaim-migrate @ 6853]
Christian Hammond <chipx86@chipx86.com>
parents:
6106
diff
changeset
|
56 message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
6104 | 57 { |
6357 | 58 gaim_notify_close(GAIM_NOTIFY_MESSAGE, widget); |
6104 | 59 } |
60 | |
61 static void | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
62 email_response_cb(GtkDialog *dialog, gint id, GaimNotifyMailData *data) |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
63 { |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
64 if (id == 0) |
10209
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
65 gaim_notify_uri(NULL, data->url, TRUE); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
66 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
67 gaim_notify_close(GAIM_NOTIFY_EMAILS, data); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
68 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
69 |
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
70 static void |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
71 formatted_close_cb(GtkWidget *win, GdkEvent *event, void *user_data) |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
72 { |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
73 gaim_notify_close(GAIM_NOTIFY_FORMATTED, win); |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
74 } |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
75 |
5437 | 76 static void * |
77 gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title, | |
78 const char *primary, const char *secondary, | |
79 GCallback cb, void *user_data) | |
80 { | |
81 GtkWidget *dialog; | |
82 GtkWidget *hbox; | |
83 GtkWidget *label; | |
84 GtkWidget *img = NULL; | |
85 char label_text[2048]; | |
86 const char *icon_name = NULL; | |
87 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
88 switch (type) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
89 { |
5437 | 90 case GAIM_NOTIFY_MSG_ERROR: |
91 icon_name = GAIM_STOCK_DIALOG_ERROR; | |
92 break; | |
93 | |
94 case GAIM_NOTIFY_MSG_WARNING: | |
95 icon_name = GAIM_STOCK_DIALOG_WARNING; | |
96 break; | |
97 | |
98 case GAIM_NOTIFY_MSG_INFO: | |
99 icon_name = GAIM_STOCK_DIALOG_INFO; | |
100 break; | |
101 | |
102 default: | |
103 icon_name = NULL; | |
104 break; | |
105 } | |
106 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
107 if (icon_name != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
108 { |
5437 | 109 img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_DIALOG); |
110 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
111 } | |
112 | |
7678 | 113 dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, |
9444
a88c8ca91518
[gaim-migrate @ 10265]
Christian Hammond <chipx86@chipx86.com>
parents:
9405
diff
changeset
|
114 NULL, 0, GTK_STOCK_CLOSE, |
7678 | 115 GTK_RESPONSE_ACCEPT, NULL); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
116 |
8523
013d256e8ded
[gaim-migrate @ 9262]
Christian Hammond <chipx86@chipx86.com>
parents:
8356
diff
changeset
|
117 gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog"); |
013d256e8ded
[gaim-migrate @ 9262]
Christian Hammond <chipx86@chipx86.com>
parents:
8356
diff
changeset
|
118 |
5437 | 119 g_signal_connect(G_OBJECT(dialog), "response", |
6104 | 120 G_CALLBACK(message_response_cb), dialog); |
5437 | 121 |
122 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); | |
123 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
124 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
125 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); | |
126 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); | |
127 | |
128 hbox = gtk_hbox_new(FALSE, 12); | |
129 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | |
130 | |
131 if (img != NULL) | |
132 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
133 | |
134 g_snprintf(label_text, sizeof(label_text), | |
135 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", | |
136 primary, (secondary ? secondary : "")); | |
137 | |
138 label = gtk_label_new(NULL); | |
139 | |
140 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
141 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
142 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
143 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
144 | |
145 gtk_widget_show_all(dialog); | |
146 | |
147 return dialog; | |
148 } | |
149 | |
150 static void * | |
151 gaim_gtk_notify_email(const char *subject, const char *from, | |
152 const char *to, const char *url, | |
153 GCallback cb, void *user_data) | |
154 { | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
155 return gaim_gtk_notify_emails(1, TRUE, |
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
156 (subject == NULL ? NULL : &subject), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
157 (from == NULL ? NULL : &from), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
158 (to == NULL ? NULL : &to), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
159 (url == NULL ? NULL : &url), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
160 cb, user_data); |
5437 | 161 } |
162 | |
163 static void * | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
164 gaim_gtk_notify_emails(size_t count, gboolean detailed, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
165 const char **subjects, const char **froms, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
166 const char **tos, const char **urls, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
167 GCallback cb, void *user_data) |
5437 | 168 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
169 GaimNotifyMailData *data; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
170 GtkWidget *dialog; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
171 GtkWidget *vbox; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
172 GtkWidget *hbox; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
173 GtkWidget *label; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
174 GtkWidget *img; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
175 char *detail_text; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
176 char *label_text; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
177 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
178 data = g_new0(GaimNotifyMailData, 1); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
179 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
180 data->url = g_strdup(urls[0]); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
181 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
182 /* Create the dialog. */ |
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
183 data->dialog = dialog = gtk_dialog_new(); |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
184 |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
185 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, 1); |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
186 |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
187 if (urls != NULL) |
5536
8bf28c2d100e
[gaim-migrate @ 5936]
Christian Hammond <chipx86@chipx86.com>
parents:
5524
diff
changeset
|
188 gtk_dialog_add_button(GTK_DIALOG(dialog), GAIM_STOCK_OPEN_MAIL, 0); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
189 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
190 g_signal_connect(G_OBJECT(dialog), "response", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
191 G_CALLBACK(email_response_cb), data); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
192 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
193 /* Setup the dialog */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
194 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
195 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
196 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
197 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
198 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
199 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
200 /* Setup the main horizontal box */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
201 hbox = gtk_hbox_new(FALSE, 12); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
202 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
203 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
204 /* Dialog icon. */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
205 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_INFO, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
206 GTK_ICON_SIZE_DIALOG); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
207 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
208 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
209 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
210 /* Vertical box */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
211 vbox = gtk_vbox_new(FALSE, 12); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
212 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
213 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
214 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
215 /* Descriptive label */ |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
216 detail_text = g_strdup_printf(ngettext("%s has %d new message.", |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
217 "%s has %d new messages.", |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
218 (int)count), |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
219 *tos, (int)count); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
220 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
221 if (count == 1) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
222 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
223 char *from_text = NULL, *subject_text = NULL; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
224 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
225 if (froms != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
226 { |
8920 | 227 char *from_enc; |
228 from_enc = g_markup_escape_text(*froms, -1); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
229 from_text = g_strdup_printf( |
8920 | 230 _("<span weight=\"bold\">From:</span> %s\n"), from_enc); |
231 g_free(from_enc); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
232 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
233 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
234 if (subjects != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
235 { |
8920 | 236 char *subject_enc; |
237 subject_enc = g_markup_escape_text(*subjects, -1); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
238 subject_text = g_strdup_printf( |
8920 | 239 _("<span weight=\"bold\">Subject:</span> %s\n"), subject_enc); |
240 g_free(subject_enc); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
241 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
242 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
243 label_text = g_strdup_printf( |
5543 | 244 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
245 "\n\n%s%s%s%s"), | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
246 detail_text, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
247 (from_text == NULL && subject_text == NULL ? "" : "\n\n"), |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
248 (from_text == NULL ? "" : from_text), |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
249 (subject_text == NULL ? "" : subject_text)); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
250 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
251 if (from_text != NULL) |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
252 g_free(from_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
253 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
254 if (subject_text != NULL) |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
255 g_free(subject_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
256 } |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
257 else |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
258 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
259 label_text = g_strdup_printf( |
5543 | 260 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
261 "\n\n%s"), detail_text); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
262 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
263 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
264 g_free(detail_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
265 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
266 label = gtk_label_new(NULL); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
267 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
268 gtk_label_set_markup(GTK_LABEL(label), label_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
269 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
270 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
271 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
272 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
273 g_free(label_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
274 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
275 /* Show everything. */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
276 gtk_widget_show_all(dialog); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
277 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
278 return data; |
5437 | 279 } |
280 | |
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
281 static gboolean |
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
282 formatted_input_cb(GtkWidget *dialog, GdkEventKey *event, gpointer data) |
7455 | 283 { |
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
284 if (event->keyval == GDK_Escape) |
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
285 { |
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
286 gtk_widget_destroy(dialog); |
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
287 |
7455 | 288 return TRUE; |
289 } | |
8337
65ae6930b45a
[gaim-migrate @ 9061]
Christian Hammond <chipx86@chipx86.com>
parents:
8284
diff
changeset
|
290 |
7455 | 291 return FALSE; |
292 } | |
293 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
294 static void * |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
295 gaim_gtk_notify_formatted(const char *title, const char *primary, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
296 const char *secondary, const char *text, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
297 GCallback cb, void *user_data) |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
298 { |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
299 GtkWidget *window; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
300 GtkWidget *vbox; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
301 GtkWidget *label; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
302 GtkWidget *button; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
303 GtkWidget *imhtml; |
10181 | 304 GtkWidget *frame; |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
305 int options = 0; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
306 char label_text[2048]; |
8272 | 307 char *linked_text; |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
308 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
309 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
8345 | 310 gtk_window_set_title(GTK_WINDOW(window), title); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
311 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
312 gtk_container_set_border_width(GTK_CONTAINER(window), 12); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
313 |
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
314 g_signal_connect(G_OBJECT(window), "delete_event", |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
315 G_CALLBACK(formatted_close_cb), NULL); |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
316 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
317 /* Setup the main vbox */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
318 vbox = gtk_vbox_new(FALSE, 12); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
319 gtk_container_add(GTK_CONTAINER(window), vbox); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
320 gtk_widget_show(vbox); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
321 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
322 /* Setup the descriptive label */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
323 g_snprintf(label_text, sizeof(label_text), |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
324 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
325 primary, |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
326 (secondary ? "\n" : ""), |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
327 (secondary ? secondary : "")); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
328 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
329 label = gtk_label_new(NULL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
330 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
331 gtk_label_set_markup(GTK_LABEL(label), label_text); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
332 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
333 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
334 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
335 gtk_widget_show(label); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
336 |
10181 | 337 /* Add the imhtml */ |
338 frame = gaim_gtk_create_imhtml(FALSE, &imhtml, NULL); | |
9005 | 339 gtk_widget_set_name(imhtml, "gaim_gtknotify_imhtml"); |
10181 | 340 gtk_widget_set_size_request(imhtml, 300, 250); |
341 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
342 gtk_widget_show(frame); | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
343 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
344 /* Add the Close button. */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
345 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
346 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
347 gtk_widget_show(button); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
348 |
6872 | 349 g_signal_connect_swapped(G_OBJECT(button), "clicked", |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
350 G_CALLBACK(formatted_close_cb), window); |
7455 | 351 g_signal_connect(G_OBJECT(window), "key_press_event", |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
352 G_CALLBACK(formatted_input_cb), NULL); |
7455 | 353 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
354 /* Add the text to the gtkimhtml */ |
9049 | 355 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors")) |
356 options ^= GTK_IMHTML_NO_COLOURS; | |
357 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_fonts")) | |
358 options ^= GTK_IMHTML_NO_FONTS; | |
359 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes")) | |
360 options ^= GTK_IMHTML_NO_SIZES; | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
361 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
362 options ^= GTK_IMHTML_NO_COMMENTS; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
363 options ^= GTK_IMHTML_NO_TITLE; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
364 options ^= GTK_IMHTML_NO_NEWLINE; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
365 options ^= GTK_IMHTML_NO_SCROLL; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
366 |
8882 | 367 /* Make sure URLs are clickable */ |
368 linked_text = gaim_markup_linkify(text); | |
10181 | 369 gtk_imhtml_append_text(GTK_IMHTML(imhtml), linked_text, options); |
8882 | 370 g_free(linked_text); |
7078 | 371 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
372 /* Show the window */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
373 gtk_widget_show(window); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
374 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
375 return window; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
376 } |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
377 |
9797 | 378 static void * |
379 gaim_gtk_notify_userinfo(GaimConnection *gc, const char *who, | |
380 const char *title, const char *primary, | |
381 const char *secondary, const char *text, | |
382 GCallback cb, void *user_data) | |
383 { | |
9800 | 384 return gaim_gtk_notify_formatted(title, primary, secondary, |
385 text, cb, user_data); | |
9797 | 386 } |
387 | |
5437 | 388 static void |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
389 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle) |
5437 | 390 { |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
391 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
392 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
393 GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
394 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
395 gtk_widget_destroy(data->dialog); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
396 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
397 g_free(data->url); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
398 g_free(data); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
399 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
400 else |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
401 gtk_widget_destroy(GTK_WIDGET(ui_handle)); |
5437 | 402 } |
403 | |
8272 | 404 #ifndef _WIN32 |
405 static gint | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
406 uri_command(const char *command, gboolean sync) |
8272 | 407 { |
9777 | 408 gchar *escaped, *tmp; |
8272 | 409 GError *error = NULL; |
410 gint ret = 0; | |
411 | |
9777 | 412 escaped = gaim_escape_html(command); |
413 gaim_debug_misc("gtknotify", "Executing %s\n", escaped); | |
8278 | 414 |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
415 if (!gaim_program_is_valid(command)) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
416 { |
9777 | 417 tmp = g_strdup_printf(_("The browser command <b>%s</b> is invalid."), |
418 escaped ? escaped : "(none)"); | |
8272 | 419 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
420 g_free(tmp); | |
421 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
422 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
423 else if (sync) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
424 { |
8272 | 425 gint status; |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
426 |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
427 if (!g_spawn_command_line_sync(command, NULL, NULL, &status, &error)) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
428 { |
9777 | 429 tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), |
430 escaped, error->message); | |
8272 | 431 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
432 g_free(tmp); | |
433 g_error_free(error); | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
434 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
435 else |
8272 | 436 ret = status; |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
437 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
438 else |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
439 { |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
440 if (!g_spawn_command_line_async(command, &error)) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
441 { |
9777 | 442 tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), |
443 escaped, error->message); | |
8272 | 444 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); |
445 g_free(tmp); | |
446 g_error_free(error); | |
447 } | |
448 } | |
449 | |
9777 | 450 g_free(escaped); |
451 | |
8272 | 452 return ret; |
453 } | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
454 #endif /* _WIN32 */ |
8272 | 455 |
7136 | 456 static void * |
10209
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
457 gaim_gtk_notify_uri(const char *uri, gboolean trusted) |
7136 | 458 { |
459 #ifndef _WIN32 | |
460 char *command = NULL; | |
8272 | 461 char *remote_command = NULL; |
7136 | 462 const char *web_browser; |
8272 | 463 int place; |
7136 | 464 |
465 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); | |
8272 | 466 place = gaim_prefs_get_int("/gaim/gtk/browsers/place"); |
7136 | 467 |
10060 | 468 /* if they are running gnome, use the gnome web browser */ |
10061 | 469 if (gaim_running_gnome() == TRUE) |
10060 | 470 { |
471 command = g_strdup_printf("gnome-open \"%s\"", uri); | |
10061 | 472 } |
10060 | 473 else if (!strcmp(web_browser, "epiphany") || |
9405 | 474 !strcmp(web_browser, "galeon")) |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
475 { |
8272 | 476 if (place == GAIM_BROWSER_NEW_WINDOW) |
9405 | 477 command = g_strdup_printf("%s -w \"%s\"", web_browser, uri); |
8272 | 478 else if (place == GAIM_BROWSER_NEW_TAB) |
9405 | 479 command = g_strdup_printf("%s -n \"%s\"", web_browser, uri); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
480 else |
9405 | 481 command = g_strdup_printf("%s \"%s\"", web_browser, uri); |
482 } | |
483 else if (!strcmp(web_browser, "gnome-open")) | |
484 { | |
485 command = g_strdup_printf("gnome-open \"%s\"", uri); | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
486 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
487 else if (!strcmp(web_browser, "kfmclient")) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
488 { |
7136 | 489 command = g_strdup_printf("kfmclient openURL \"%s\"", uri); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
490 /* |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
491 * Does Konqueror have options to open in new tab |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
492 * and/or current window? |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
493 */ |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
494 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
495 else if (!strcmp(web_browser, "mozilla") || |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
496 !strcmp(web_browser, "mozilla-firebird") || |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
497 !strcmp(web_browser, "firefox")) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
498 { |
9399 | 499 char *args = ""; |
500 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
501 command = g_strdup_printf("%s \"%s\"", web_browser, uri); |
8272 | 502 |
9399 | 503 /* |
504 * Firefox 0.9 and higher require a "-a firefox" option when | |
505 * using -remote commands. This breaks older versions of | |
506 * mozilla. So we include this other handly little string | |
507 * when calling firefox. If the API for remote calls changes | |
508 * any more in firefox then firefox should probably be split | |
509 * apart from mozilla-firebird and mozilla... but this is good | |
510 * for now. | |
511 */ | |
512 if (!strcmp(web_browser, "firefox")) | |
513 args = "-a firefox"; | |
514 | |
8272 | 515 if (place == GAIM_BROWSER_NEW_WINDOW) |
9399 | 516 remote_command = g_strdup_printf("%s %s -remote " |
9777 | 517 "\"openURL(%s,new-window)\"", |
9399 | 518 web_browser, args, uri); |
8272 | 519 else if (place == GAIM_BROWSER_NEW_TAB) |
9399 | 520 remote_command = g_strdup_printf("%s %s -remote " |
9777 | 521 "\"openURL(%s,new-tab)\"", |
9399 | 522 web_browser, args, uri); |
8272 | 523 else if (place == GAIM_BROWSER_CURRENT) |
9399 | 524 remote_command = g_strdup_printf("%s %s -remote " |
9777 | 525 "\"openURL(%s)\"", |
9399 | 526 web_browser, args, uri); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
527 } |
9405 | 528 else if (!strcmp(web_browser, "netscape")) |
529 { | |
530 command = g_strdup_printf("netscape \"%s\"", uri); | |
531 | |
532 if (place == GAIM_BROWSER_NEW_WINDOW) | |
533 { | |
534 remote_command = g_strdup_printf("netscape -remote " | |
9777 | 535 "\"openURL(%s,new-window)\"", |
9405 | 536 uri); |
537 } | |
538 else if (place == GAIM_BROWSER_CURRENT) | |
539 { | |
540 remote_command = g_strdup_printf("netscape -remote " | |
9777 | 541 "\"openURL(%s)\"", uri); |
9405 | 542 } |
543 } | |
544 else if (!strcmp(web_browser, "opera")) | |
545 { | |
546 if (place == GAIM_BROWSER_NEW_WINDOW) | |
547 command = g_strdup_printf("opera -newwindow \"%s\"", uri); | |
548 else if (place == GAIM_BROWSER_NEW_TAB) | |
549 command = g_strdup_printf("opera -newpage \"%s\"", uri); | |
550 else if (place == GAIM_BROWSER_CURRENT) | |
551 { | |
552 remote_command = g_strdup_printf("opera -remote " | |
9777 | 553 "\"openURL(%s)\"", uri); |
9405 | 554 command = g_strdup_printf("opera \"%s\"", uri); |
555 } | |
556 else | |
557 command = g_strdup_printf("opera \"%s\"", uri); | |
558 | |
559 } | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
560 else if (!strcmp(web_browser, "custom")) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
561 { |
7136 | 562 const char *web_command; |
563 | |
564 web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command"); | |
565 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
566 if (web_command == NULL || *web_command == '\0') |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
567 { |
7136 | 568 gaim_notify_error(NULL, NULL, _("Unable to open URL"), |
569 _("The 'Manual' browser command has been " | |
570 "chosen, but no command has been set.")); | |
571 return NULL; | |
572 } | |
573 | |
574 if (strstr(web_command, "%s")) | |
575 command = gaim_strreplace(web_command, "%s", uri); | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
576 else |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
577 { |
7136 | 578 /* |
579 * There is no "%s" in the browser command. Assume the user | |
580 * wanted the URL tacked on to the end of the command. | |
581 */ | |
582 command = g_strdup_printf("%s %s", web_command, uri); | |
583 } | |
584 } | |
585 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
586 if (remote_command != NULL) |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
587 { |
8272 | 588 /* try the remote command first */ |
589 if (uri_command(remote_command, TRUE) != 0) | |
590 uri_command(command, FALSE); | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
591 |
8272 | 592 g_free(remote_command); |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
593 |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
594 } |
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
595 else |
8272 | 596 uri_command(command, FALSE); |
7136 | 597 |
598 g_free(command); | |
599 | |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
600 #else /* !_WIN32 */ |
9520 | 601 /** |
10209
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
602 * If the URI is not trusted we limit ourselves to the following URI |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
603 * types (Execution of an untrusted local file URI could potentially |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
604 * be a security risk): |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
605 * http, https, ftp, mailto |
9520 | 606 */ |
10209
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
607 if(!trusted && |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
608 !(g_ascii_strncasecmp(uri, "http://", 7) == 0 || |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
609 g_ascii_strncasecmp(uri, "mailto:", 7) == 0 || |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
610 g_ascii_strncasecmp(uri, "https://", 8) == 0 || |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
611 g_ascii_strncasecmp(uri, "ftp://", 6) == 0)) { |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
612 gaim_debug_misc("gtknotify", |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
613 "Ignoring untrusted '%s' URI as it is not recognized as a secure URI.\n", |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
614 uri); |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
615 } |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
616 else { |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
617 int ret; |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
618 /* The URI is trusted */ |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
619 if((ret = ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL)) <= 32) |
9e0b98c458b1
[gaim-migrate @ 11331]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10181
diff
changeset
|
620 gaim_debug_error("gtknotify", "Opening URI: '%s' ShellExecute failure: %d\n", uri, ret); |
9520 | 621 } |
8338
354bba6ad254
[gaim-migrate @ 9062]
Christian Hammond <chipx86@chipx86.com>
parents:
8337
diff
changeset
|
622 #endif /* !_WIN32 */ |
7136 | 623 |
624 return NULL; | |
625 } | |
626 | |
5437 | 627 static GaimNotifyUiOps ops = |
628 { | |
629 gaim_gtk_notify_message, | |
630 gaim_gtk_notify_email, | |
631 gaim_gtk_notify_emails, | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
632 gaim_gtk_notify_formatted, |
9797 | 633 gaim_gtk_notify_userinfo, |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
634 gaim_gtk_notify_uri, |
5437 | 635 gaim_gtk_close_notify |
636 }; | |
637 | |
638 GaimNotifyUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7007
diff
changeset
|
639 gaim_gtk_notify_get_ui_ops(void) |
5437 | 640 { |
641 return &ops; | |
642 } |