Mercurial > pidgin
annotate src/gtknotify.c @ 7760:7c4fbd9f1aed
[gaim-migrate @ 8405]
sv.po
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 05 Dec 2003 12:56:59 +0000 |
parents | 1363f91da9cc |
children | 954b986ad3e3 |
rev | line source |
---|---|
5437 | 1 /** |
2 * @file gtknotify.c GTK+ Notification API | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
8 * |
5437 | 9 * This program is free software; you can redistribute it and/or modify |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
23 #include "gtkinternal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
24 |
7455 | 25 #include <gdk/gdkkeysyms.h> |
26 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
27 #include "connection.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
28 #include "debug.h" |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
29 #include "prefs.h" |
5437 | 30 #include "stock.h" |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
31 #include "util.h" |
5437 | 32 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
33 #include "gtkimhtml.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
34 #include "gtknotify.h" |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
35 #include "gtkutils.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
36 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
37 #include "ui.h" |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
38 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
39 typedef struct |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
40 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5543
diff
changeset
|
41 GaimConnection *gc; |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
42 char *url; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
43 GtkWidget *dialog; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
44 GtkWidget *label; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
45 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
46 } GaimNotifyMailData; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
47 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
48 static void *gaim_gtk_notify_emails(size_t count, gboolean detailed, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
49 const char **subjects, |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
50 const char **froms, const char **tos, |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
51 const char **urls, GCallback cb, |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
52 void *user_data); |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
53 |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
54 static void |
6354
76af8c066f8c
[gaim-migrate @ 6853]
Christian Hammond <chipx86@chipx86.com>
parents:
6106
diff
changeset
|
55 message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) |
6104 | 56 { |
6357 | 57 gaim_notify_close(GAIM_NOTIFY_MESSAGE, widget); |
6104 | 58 } |
59 | |
60 static void | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
61 email_response_cb(GtkDialog *dialog, gint id, GaimNotifyMailData *data) |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
62 { |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
63 if (id == 0) |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
64 gaim_notify_uri(NULL, data->url); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
65 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
66 gaim_notify_close(GAIM_NOTIFY_EMAILS, data); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
67 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
68 |
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
69 static void |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
70 formatted_close_cb(GtkWidget *win, GdkEvent *event, void *user_data) |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
71 { |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
72 gaim_notify_close(GAIM_NOTIFY_FORMATTED, win); |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
73 } |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
74 |
5437 | 75 static void * |
76 gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title, | |
77 const char *primary, const char *secondary, | |
78 GCallback cb, void *user_data) | |
79 { | |
80 GtkWidget *dialog; | |
81 GtkWidget *hbox; | |
82 GtkWidget *label; | |
83 GtkWidget *img = NULL; | |
84 char label_text[2048]; | |
85 const char *icon_name = NULL; | |
86 | |
87 switch (type) { | |
88 case GAIM_NOTIFY_MSG_ERROR: | |
89 icon_name = GAIM_STOCK_DIALOG_ERROR; | |
90 break; | |
91 | |
92 case GAIM_NOTIFY_MSG_WARNING: | |
93 icon_name = GAIM_STOCK_DIALOG_WARNING; | |
94 break; | |
95 | |
96 case GAIM_NOTIFY_MSG_INFO: | |
97 icon_name = GAIM_STOCK_DIALOG_INFO; | |
98 break; | |
99 | |
100 default: | |
101 icon_name = NULL; | |
102 break; | |
103 } | |
104 | |
105 if (icon_name != NULL) { | |
106 img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_DIALOG); | |
107 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
108 } | |
109 | |
7678 | 110 dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, |
111 NULL, 0, GTK_STOCK_OK, | |
112 GTK_RESPONSE_ACCEPT, NULL); | |
5437 | 113 g_signal_connect(G_OBJECT(dialog), "response", |
6104 | 114 G_CALLBACK(message_response_cb), dialog); |
5437 | 115 |
116 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); | |
117 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
118 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
119 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); | |
120 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); | |
121 | |
122 hbox = gtk_hbox_new(FALSE, 12); | |
123 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | |
124 | |
125 if (img != NULL) | |
126 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
127 | |
128 g_snprintf(label_text, sizeof(label_text), | |
129 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", | |
130 primary, (secondary ? secondary : "")); | |
131 | |
132 label = gtk_label_new(NULL); | |
133 | |
134 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
135 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
136 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
137 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
138 | |
139 gtk_widget_show_all(dialog); | |
140 | |
141 return dialog; | |
142 } | |
143 | |
144 static void * | |
145 gaim_gtk_notify_email(const char *subject, const char *from, | |
146 const char *to, const char *url, | |
147 GCallback cb, void *user_data) | |
148 { | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
149 return gaim_gtk_notify_emails(1, TRUE, |
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
150 (subject == NULL ? NULL : &subject), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
151 (from == NULL ? NULL : &from), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
152 (to == NULL ? NULL : &to), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
153 (url == NULL ? NULL : &url), |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
154 cb, user_data); |
5437 | 155 } |
156 | |
157 static void * | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
158 gaim_gtk_notify_emails(size_t count, gboolean detailed, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
159 const char **subjects, const char **froms, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
160 const char **tos, const char **urls, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
161 GCallback cb, void *user_data) |
5437 | 162 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
163 GaimNotifyMailData *data; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
164 GtkWidget *dialog; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
165 GtkWidget *vbox; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
166 GtkWidget *hbox; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
167 GtkWidget *label; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
168 GtkWidget *img; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
169 char *detail_text; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
170 char *label_text; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
171 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
172 data = g_new0(GaimNotifyMailData, 1); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
173 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
174 data->url = g_strdup(urls[0]); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
175 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
176 /* Create the dialog. */ |
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
177 data->dialog = dialog = gtk_dialog_new(); |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
178 |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
179 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, 1); |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
180 |
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
181 if (urls != NULL) |
5536
8bf28c2d100e
[gaim-migrate @ 5936]
Christian Hammond <chipx86@chipx86.com>
parents:
5524
diff
changeset
|
182 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
|
183 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
184 g_signal_connect(G_OBJECT(dialog), "response", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
185 G_CALLBACK(email_response_cb), data); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
186 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
187 /* Setup the dialog */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
188 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
189 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
|
190 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
191 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
192 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
193 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
194 /* Setup the main horizontal box */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
195 hbox = gtk_hbox_new(FALSE, 12); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
196 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
197 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
198 /* Dialog icon. */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
199 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_INFO, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
200 GTK_ICON_SIZE_DIALOG); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
201 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
202 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
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 /* Vertical box */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
205 vbox = gtk_vbox_new(FALSE, 12); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
206 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
207 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
208 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
209 /* Descriptive label */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
210 detail_text = g_strdup_printf( |
7386 | 211 ngettext("%s has %d new message.", "%s has %d new messages.", (int) count), |
212 *tos, (int) count); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
213 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
214 if (count == 1) { |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
215 char *from_text = NULL, *subject_text = NULL; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
216 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
217 if (froms != NULL) { |
7679 | 218 char *from_decoded = gaim_mime_decode_field(*froms); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
219 from_text = g_strdup_printf( |
7679 | 220 _("<span weight=\"bold\">From:</span> %s\n"), from_decoded); |
221 g_free(from_decoded); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
222 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
223 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
224 if (subjects != NULL) { |
7679 | 225 char *subject_decoded = gaim_mime_decode_field(*subjects); |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
226 subject_text = g_strdup_printf( |
7679 | 227 _("<span weight=\"bold\">Subject:</span> %s\n"), subject_decoded); |
228 g_free(subject_decoded); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
229 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
230 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
231 label_text = g_strdup_printf( |
5543 | 232 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
233 "\n\n%s%s%s%s"), | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
234 detail_text, |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
235 (from_text == NULL && subject_text == NULL ? "" : "\n\n"), |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
236 (from_text == NULL ? "" : from_text), |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
237 (subject_text == NULL ? "" : subject_text)); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
238 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
239 if (from_text != NULL) |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
240 g_free(from_text); |
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 if (subject_text != NULL) |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
243 g_free(subject_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
244 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
245 else { |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
246 label_text = g_strdup_printf( |
5543 | 247 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
248 "\n\n%s"), detail_text); | |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
249 } |
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 g_free(detail_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
252 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
253 label = gtk_label_new(NULL); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
254 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
255 gtk_label_set_markup(GTK_LABEL(label), label_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
256 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
257 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
258 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
259 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
260 g_free(label_text); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
261 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
262 /* Show everything. */ |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
263 gtk_widget_show_all(dialog); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
264 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
265 return data; |
5437 | 266 } |
267 | |
7455 | 268 static |
269 gboolean formatted_input_cb(GtkWidget *dialog, | |
270 GdkEventKey *event, gpointer data) | |
271 { | |
272 if (event->keyval == GDK_Escape) { | |
273 gtk_object_destroy(GTK_OBJECT(dialog)); | |
274 return TRUE; | |
275 } | |
276 return FALSE; | |
277 } | |
278 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
279 static void * |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
280 gaim_gtk_notify_formatted(const char *title, const char *primary, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
281 const char *secondary, const char *text, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
282 GCallback cb, void *user_data) |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
283 { |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
284 GtkWidget *window; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
285 GtkWidget *vbox; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
286 GtkWidget *label; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
287 GtkWidget *button; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
288 GtkWidget *imhtml; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
289 GtkWidget *sw; |
7078 | 290 GSList *images = NULL; |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
291 int options = 0; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
292 char label_text[2048]; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
293 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
294 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
295 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
|
296 gtk_container_set_border_width(GTK_CONTAINER(window), 12); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
297 |
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
298 g_signal_connect(G_OBJECT(window), "delete_event", |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
299 G_CALLBACK(formatted_close_cb), NULL); |
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
300 |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
301 /* Setup the main vbox */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
302 vbox = gtk_vbox_new(FALSE, 12); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
303 gtk_container_add(GTK_CONTAINER(window), vbox); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
304 gtk_widget_show(vbox); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
305 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
306 /* Setup the descriptive label */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
307 g_snprintf(label_text, sizeof(label_text), |
7039
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
308 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", |
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
309 primary, |
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
310 (secondary ? "\n" : ""), |
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
311 (secondary ? secondary : "")); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
312 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
313 label = gtk_label_new(NULL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
314 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
315 gtk_label_set_markup(GTK_LABEL(label), label_text); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
316 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
317 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
318 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
319 gtk_widget_show(label); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
320 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
321 /* Setup the scrolled window that we're putting the gtkimhtml in. */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
322 sw = gtk_scrolled_window_new(NULL, NULL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
323 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
324 GTK_POLICY_NEVER, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
325 GTK_POLICY_ALWAYS); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
326 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
327 GTK_SHADOW_IN); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
328 gtk_widget_set_size_request(sw, 300, 250); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
329 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
330 gtk_widget_show(sw); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
331 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
332 /* Now build that gtkimhtml */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
333 imhtml = gtk_imhtml_new(NULL, NULL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
334 gtk_container_add(GTK_CONTAINER(sw), imhtml); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
335 gtk_widget_show(imhtml); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
336 gaim_setup_imhtml(imhtml); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
337 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
338 /* Add the Close button. */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
339 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
340 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
341 gtk_widget_show(button); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
342 |
6872 | 343 g_signal_connect_swapped(G_OBJECT(button), "clicked", |
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
344 G_CALLBACK(formatted_close_cb), window); |
7455 | 345 g_signal_connect(G_OBJECT(window), "key_press_event", |
346 G_CALLBACK(formatted_input_cb), NULL); | |
347 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
348 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
349 /* Add the text to the gtkimhtml */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
350 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors")) |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
351 options ^= GTK_IMHTML_NO_COLOURS; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
352 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
353 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_fonts")) |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
354 options ^= GTK_IMHTML_NO_FONTS; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
355 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
356 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes")) |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
357 options ^= GTK_IMHTML_NO_SIZES; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
358 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
359 options ^= GTK_IMHTML_NO_COMMENTS; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
360 options ^= GTK_IMHTML_NO_TITLE; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
361 options ^= GTK_IMHTML_NO_NEWLINE; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
362 options ^= GTK_IMHTML_NO_SCROLL; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
363 |
7078 | 364 gaim_gtk_find_images(text, &images); |
365 gtk_imhtml_append_text_with_images(GTK_IMHTML(imhtml), text, options, images); | |
366 | |
367 if (images) { | |
368 GSList *tmp; | |
369 | |
370 for (tmp = images; tmp; tmp = tmp->next) { | |
371 GdkPixbuf *pixbuf = tmp->data; | |
372 if(pixbuf) | |
373 g_object_unref(pixbuf); | |
374 } | |
375 | |
376 g_slist_free(images); | |
377 } | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
378 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
379 /* Show the window */ |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
380 gtk_widget_show(window); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
381 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
382 return window; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
383 } |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
384 |
5437 | 385 static void |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
386 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle) |
5437 | 387 { |
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
388 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) { |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
389 GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle; |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
390 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
391 gtk_widget_destroy(data->dialog); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
392 |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
393 g_free(data->url); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
394 g_free(data); |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
395 } |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
396 else |
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
397 gtk_widget_destroy(GTK_WIDGET(ui_handle)); |
5437 | 398 } |
399 | |
7136 | 400 static void * |
401 gaim_gtk_notify_uri(const char *uri) | |
402 { | |
403 #ifndef _WIN32 | |
404 char *command = NULL; | |
405 GError *error = NULL; | |
406 const char *web_browser; | |
407 | |
408 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); | |
409 | |
410 if (!strcmp(web_browser, "netscape")) { | |
411 command = g_strdup_printf("netscape \"%s\"", uri); | |
412 } else if (!strcmp(web_browser, "opera")) { | |
413 if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window")) | |
414 command = g_strdup_printf("opera -newwindow \"%s\"", uri); | |
415 else | |
416 command = g_strdup_printf("opera \"%s\"", uri); | |
417 } else if (!strcmp(web_browser, "kfmclient")) { | |
418 command = g_strdup_printf("kfmclient openURL \"%s\"", uri); | |
419 } else if (!strcmp(web_browser, "galeon")) { | |
420 if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window")) | |
421 command = g_strdup_printf("galeon -w \"%s\"", uri); | |
422 else | |
423 command = g_strdup_printf("galeon \"%s\"", uri); | |
424 } else if (!strcmp(web_browser, "mozilla")) { | |
425 command = g_strdup_printf("mozilla \"%s\"", uri); | |
426 } else if (!strcmp(web_browser, "custom")) { | |
427 const char *web_command; | |
428 | |
429 web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command"); | |
430 | |
431 if (web_command == NULL || *web_command == '\0') { | |
432 gaim_notify_error(NULL, NULL, _("Unable to open URL"), | |
433 _("The 'Manual' browser command has been " | |
434 "chosen, but no command has been set.")); | |
435 return NULL; | |
436 } | |
437 | |
438 if (strstr(web_command, "%s")) | |
439 command = gaim_strreplace(web_command, "%s", uri); | |
440 else { | |
441 /* | |
442 * There is no "%s" in the browser command. Assume the user | |
443 * wanted the URL tacked on to the end of the command. | |
444 */ | |
445 command = g_strdup_printf("%s %s", web_command, uri); | |
446 } | |
447 } | |
448 | |
449 if (!gaim_program_is_valid(command)) { | |
450 gchar *tmp = g_strdup_printf(_("The browser \"%s\" is invalid."), | |
451 command); | |
452 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); | |
453 g_free(tmp); | |
454 | |
455 } else if (!g_spawn_command_line_async(command, &error)) { | |
456 char *tmp = g_strdup_printf( | |
457 _("Error launching \"command\": %s"), | |
458 error->message); | |
459 | |
460 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); | |
461 | |
462 g_free(tmp); | |
463 g_error_free(error); | |
464 } | |
465 | |
466 g_free(command); | |
467 | |
468 #else | |
469 ShellExecute(NULL, NULL, uri, NULL, ".\\", 0); | |
470 #endif | |
471 | |
472 return NULL; | |
473 } | |
474 | |
5437 | 475 static GaimNotifyUiOps ops = |
476 { | |
477 gaim_gtk_notify_message, | |
478 gaim_gtk_notify_email, | |
479 gaim_gtk_notify_emails, | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
480 gaim_gtk_notify_formatted, |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
481 gaim_gtk_notify_uri, |
5437 | 482 gaim_gtk_close_notify |
483 }; | |
484 | |
485 GaimNotifyUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7007
diff
changeset
|
486 gaim_gtk_notify_get_ui_ops(void) |
5437 | 487 { |
488 return &ops; | |
489 } |