Mercurial > pidgin
annotate src/gtknotify.c @ 8277:e6ed38d28636
[gaim-migrate @ 9001]
"Wintry" really seems like it should be "Wintery," to me.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Tue, 17 Feb 2004 04:46:53 +0000 |
| parents | 9af78e73f0b2 |
| children | b00f3ac97c1f |
| 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 */ | |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
25 #include "gtkinternal.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
26 |
| 7455 | 27 #include <gdk/gdkkeysyms.h> |
| 28 | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
29 #include "connection.h" |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
30 #include "prefs.h" |
| 5437 | 31 #include "stock.h" |
|
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
32 #include "util.h" |
| 5437 | 33 |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
34 #include "gtkimhtml.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
35 #include "gtknotify.h" |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
36 #include "gtkutils.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
37 |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
38 #include "ui.h" |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
39 |
|
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) |
|
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
65 gaim_notify_uri(NULL, data->url); |
|
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 | |
| 88 switch (type) { | |
| 89 case GAIM_NOTIFY_MSG_ERROR: | |
| 90 icon_name = GAIM_STOCK_DIALOG_ERROR; | |
| 91 break; | |
| 92 | |
| 93 case GAIM_NOTIFY_MSG_WARNING: | |
| 94 icon_name = GAIM_STOCK_DIALOG_WARNING; | |
| 95 break; | |
| 96 | |
| 97 case GAIM_NOTIFY_MSG_INFO: | |
| 98 icon_name = GAIM_STOCK_DIALOG_INFO; | |
| 99 break; | |
| 100 | |
| 101 default: | |
| 102 icon_name = NULL; | |
| 103 break; | |
| 104 } | |
| 105 | |
| 106 if (icon_name != NULL) { | |
| 107 img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_DIALOG); | |
| 108 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
| 109 } | |
| 110 | |
| 7678 | 111 dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, |
| 112 NULL, 0, GTK_STOCK_OK, | |
| 113 GTK_RESPONSE_ACCEPT, NULL); | |
| 5437 | 114 g_signal_connect(G_OBJECT(dialog), "response", |
| 6104 | 115 G_CALLBACK(message_response_cb), dialog); |
| 5437 | 116 |
| 117 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); | |
| 118 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
| 119 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 120 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); | |
| 121 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); | |
| 122 | |
| 123 hbox = gtk_hbox_new(FALSE, 12); | |
| 124 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | |
| 125 | |
| 126 if (img != NULL) | |
| 127 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
| 128 | |
| 129 g_snprintf(label_text, sizeof(label_text), | |
| 130 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", | |
| 131 primary, (secondary ? secondary : "")); | |
| 132 | |
| 133 label = gtk_label_new(NULL); | |
| 134 | |
| 135 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
| 136 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
| 137 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 138 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 139 | |
| 140 gtk_widget_show_all(dialog); | |
| 141 | |
| 142 return dialog; | |
| 143 } | |
| 144 | |
| 145 static void * | |
| 146 gaim_gtk_notify_email(const char *subject, const char *from, | |
| 147 const char *to, const char *url, | |
| 148 GCallback cb, void *user_data) | |
| 149 { | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
150 return gaim_gtk_notify_emails(1, TRUE, |
|
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
151 (subject == NULL ? NULL : &subject), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
152 (from == NULL ? NULL : &from), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
153 (to == NULL ? NULL : &to), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
154 (url == NULL ? NULL : &url), |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
155 cb, user_data); |
| 5437 | 156 } |
| 157 | |
| 158 static void * | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
159 gaim_gtk_notify_emails(size_t count, gboolean detailed, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
160 const char **subjects, const char **froms, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
161 const char **tos, const char **urls, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
162 GCallback cb, void *user_data) |
| 5437 | 163 { |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
164 GaimNotifyMailData *data; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
165 GtkWidget *dialog; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
166 GtkWidget *vbox; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
167 GtkWidget *hbox; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
168 GtkWidget *label; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
169 GtkWidget *img; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
170 char *detail_text; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
171 char *label_text; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
172 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
173 data = g_new0(GaimNotifyMailData, 1); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
174 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
175 data->url = g_strdup(urls[0]); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
176 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
177 /* Create the dialog. */ |
|
5524
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
178 data->dialog = dialog = gtk_dialog_new(); |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
179 |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
180 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, 1); |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
181 |
|
101384b068c1
[gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents:
5519
diff
changeset
|
182 if (urls != NULL) |
|
5536
8bf28c2d100e
[gaim-migrate @ 5936]
Christian Hammond <chipx86@chipx86.com>
parents:
5524
diff
changeset
|
183 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
|
184 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
185 g_signal_connect(G_OBJECT(dialog), "response", |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
186 G_CALLBACK(email_response_cb), data); |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
187 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
188 /* Setup the dialog */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
189 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
190 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
|
191 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
192 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
193 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
194 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
195 /* Setup the main horizontal box */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
196 hbox = gtk_hbox_new(FALSE, 12); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
197 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
198 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
199 /* Dialog icon. */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
200 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_INFO, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
201 GTK_ICON_SIZE_DIALOG); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
202 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
203 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
204 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
205 /* Vertical box */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
206 vbox = gtk_vbox_new(FALSE, 12); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
207 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
208 gtk_box_pack_start(GTK_BOX(hbox), vbox, 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 /* Descriptive label */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
211 detail_text = g_strdup_printf( |
| 7386 | 212 ngettext("%s has %d new message.", "%s has %d new messages.", (int) count), |
| 213 *tos, (int) count); | |
|
5519
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 if (count == 1) { |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
216 char *from_text = NULL, *subject_text = NULL; |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
217 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
218 if (froms != NULL) { |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
219 from_text = g_strdup_printf( |
| 7817 | 220 _("<span weight=\"bold\">From:</span> %s\n"), *froms); |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
221 } |
|
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 if (subjects != NULL) { |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
224 subject_text = g_strdup_printf( |
| 7817 | 225 _("<span weight=\"bold\">Subject:</span> %s\n"), *subjects); |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
226 } |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
227 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
228 label_text = g_strdup_printf( |
| 5543 | 229 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>" |
| 230 "\n\n%s%s%s%s"), | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
231 detail_text, |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
232 (from_text == NULL && subject_text == NULL ? "" : "\n\n"), |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
233 (from_text == NULL ? "" : from_text), |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
234 (subject_text == NULL ? "" : subject_text)); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
235 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
236 if (from_text != NULL) |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
237 g_free(from_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 (subject_text != NULL) |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
240 g_free(subject_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 else { |
|
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"), detail_text); | |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
246 } |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
247 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
248 g_free(detail_text); |
|
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 label = gtk_label_new(NULL); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
251 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
252 gtk_label_set_markup(GTK_LABEL(label), label_text); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
253 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
254 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
255 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
256 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
257 g_free(label_text); |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
258 |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
259 /* Show everything. */ |
|
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
260 gtk_widget_show_all(dialog); |
|
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 return data; |
| 5437 | 263 } |
| 264 | |
| 7455 | 265 static |
| 266 gboolean formatted_input_cb(GtkWidget *dialog, | |
| 267 GdkEventKey *event, gpointer data) | |
| 268 { | |
| 269 if (event->keyval == GDK_Escape) { | |
| 270 gtk_object_destroy(GTK_OBJECT(dialog)); | |
| 271 return TRUE; | |
| 272 } | |
| 273 return FALSE; | |
| 274 } | |
| 275 | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
276 static void * |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
277 gaim_gtk_notify_formatted(const char *title, const char *primary, |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
278 const char *secondary, const char *text, |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
279 GCallback cb, void *user_data) |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
280 { |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
281 GtkWidget *window; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
282 GtkWidget *vbox; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
283 GtkWidget *label; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
284 GtkWidget *button; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
285 GtkWidget *imhtml; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
286 GtkWidget *sw; |
| 7078 | 287 GSList *images = NULL; |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
288 int options = 0; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
289 char label_text[2048]; |
| 8272 | 290 char *linked_text; |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
291 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
292 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
293 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
|
294 gtk_container_set_border_width(GTK_CONTAINER(window), 12); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
295 |
|
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
296 g_signal_connect(G_OBJECT(window), "delete_event", |
|
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
297 G_CALLBACK(formatted_close_cb), NULL); |
|
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
298 |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
299 /* Setup the main vbox */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
300 vbox = gtk_vbox_new(FALSE, 12); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
301 gtk_container_add(GTK_CONTAINER(window), vbox); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
302 gtk_widget_show(vbox); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
303 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
304 /* Setup the descriptive label */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
305 g_snprintf(label_text, sizeof(label_text), |
|
7039
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
306 "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", |
|
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
307 primary, |
|
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
308 (secondary ? "\n" : ""), |
|
9f2285b667a7
[gaim-migrate @ 7602]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
309 (secondary ? secondary : "")); |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
310 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
311 label = gtk_label_new(NULL); |
|
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 gtk_label_set_markup(GTK_LABEL(label), label_text); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
314 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
315 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
316 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
317 gtk_widget_show(label); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
318 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
319 /* Setup the scrolled window that we're putting the gtkimhtml in. */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
320 sw = gtk_scrolled_window_new(NULL, NULL); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
321 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
322 GTK_POLICY_NEVER, |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
323 GTK_POLICY_ALWAYS); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
324 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
325 GTK_SHADOW_IN); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
326 gtk_widget_set_size_request(sw, 300, 250); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
327 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
328 gtk_widget_show(sw); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
329 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
330 /* Now build that gtkimhtml */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
331 imhtml = gtk_imhtml_new(NULL, NULL); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
332 gtk_container_add(GTK_CONTAINER(sw), imhtml); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
333 gtk_widget_show(imhtml); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
334 gaim_setup_imhtml(imhtml); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
335 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
336 /* Add the Close button. */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
337 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
338 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
339 gtk_widget_show(button); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
340 |
| 6872 | 341 g_signal_connect_swapped(G_OBJECT(button), "clicked", |
|
7007
da1430478acf
[gaim-migrate @ 7564]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
342 G_CALLBACK(formatted_close_cb), window); |
| 7455 | 343 g_signal_connect(G_OBJECT(window), "key_press_event", |
| 344 G_CALLBACK(formatted_input_cb), NULL); | |
| 345 | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
346 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
347 /* Add the text to the gtkimhtml */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
348 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors")) |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
349 options ^= GTK_IMHTML_NO_COLOURS; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
350 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
351 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_fonts")) |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
352 options ^= GTK_IMHTML_NO_FONTS; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
353 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
354 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes")) |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
355 options ^= GTK_IMHTML_NO_SIZES; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
356 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
357 options ^= GTK_IMHTML_NO_COMMENTS; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
358 options ^= GTK_IMHTML_NO_TITLE; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
359 options ^= GTK_IMHTML_NO_NEWLINE; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
360 options ^= GTK_IMHTML_NO_SCROLL; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
361 |
| 7078 | 362 gaim_gtk_find_images(text, &images); |
| 8272 | 363 if(gaim_prefs_get_bool("/gaim/gtk/conversations/show_urls_as_links")){ |
| 364 linked_text = gaim_markup_linkify(text); | |
| 365 gtk_imhtml_append_text_with_images(GTK_IMHTML(imhtml), linked_text, | |
| 8107 | 366 options, images); |
| 8272 | 367 g_free(linked_text); |
| 368 } else | |
| 8107 | 369 gtk_imhtml_append_text_with_images(GTK_IMHTML(imhtml), text, options, images); |
| 7078 | 370 |
| 371 if (images) { | |
| 372 GSList *tmp; | |
| 373 | |
| 374 for (tmp = images; tmp; tmp = tmp->next) { | |
| 375 GdkPixbuf *pixbuf = tmp->data; | |
| 376 if(pixbuf) | |
| 377 g_object_unref(pixbuf); | |
| 378 } | |
| 379 | |
| 380 g_slist_free(images); | |
| 381 } | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
382 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
383 /* Show the window */ |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
384 gtk_widget_show(window); |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
385 |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
386 return window; |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
387 } |
|
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
388 |
| 5437 | 389 static void |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
390 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle) |
| 5437 | 391 { |
|
5519
42a20beb80a7
[gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
392 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) { |
|
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 | |
| 406 uri_command(const char *command, const gboolean sync) | |
| 407 { | |
| 408 GError *error = NULL; | |
| 409 gint ret = 0; | |
| 410 | |
| 411 if (!gaim_program_is_valid(command)) { | |
| 412 gchar *tmp = g_strdup_printf(_("The browser \"%s\" is invalid."), | |
| 413 command); | |
| 414 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); | |
| 415 g_free(tmp); | |
| 416 | |
| 417 } else if (sync) { | |
| 418 gint status; | |
| 419 | |
| 420 if (!g_spawn_command_line_sync(command, NULL, NULL, &status, &error)) { | |
| 421 char *tmp = g_strdup_printf( | |
| 422 _("Error launching \"command\": %s"), | |
| 423 error->message); | |
| 424 | |
| 425 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); | |
| 426 | |
| 427 g_free(tmp); | |
| 428 g_error_free(error); | |
| 429 } else { | |
| 430 ret = status; | |
| 431 } | |
| 432 | |
| 433 } else { | |
| 434 if (!g_spawn_command_line_async(command, &error)) { | |
| 435 char *tmp = g_strdup_printf( | |
| 436 _("Error launching \"command\": %s"), | |
| 437 error->message); | |
| 438 | |
| 439 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); | |
| 440 | |
| 441 g_free(tmp); | |
| 442 g_error_free(error); | |
| 443 } | |
| 444 } | |
| 445 | |
| 446 return ret; | |
| 447 } | |
| 448 #endif | |
| 449 | |
| 7136 | 450 static void * |
| 451 gaim_gtk_notify_uri(const char *uri) | |
| 452 { | |
| 453 #ifndef _WIN32 | |
| 454 char *command = NULL; | |
| 8272 | 455 char *remote_command = NULL; |
| 7136 | 456 const char *web_browser; |
| 8272 | 457 int place; |
| 7136 | 458 |
| 459 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); | |
| 8272 | 460 place = gaim_prefs_get_int("/gaim/gtk/browsers/place"); |
| 7136 | 461 |
| 462 if (!strcmp(web_browser, "netscape")) { | |
| 463 command = g_strdup_printf("netscape \"%s\"", uri); | |
| 8272 | 464 if (place == GAIM_BROWSER_NEW_WINDOW) |
| 465 remote_command = g_strdup_printf("netscape -remote \"openURL(\"%s\",new-window)\"", uri); | |
| 466 else if (place == GAIM_BROWSER_CURRENT) | |
| 467 remote_command = g_strdup_printf("netscape -remote \"openURL(\"%s\")\"", uri); | |
| 468 | |
| 7136 | 469 } else if (!strcmp(web_browser, "opera")) { |
| 8272 | 470 if (place == GAIM_BROWSER_NEW_WINDOW) |
| 7136 | 471 command = g_strdup_printf("opera -newwindow \"%s\"", uri); |
| 8272 | 472 else if (place == GAIM_BROWSER_NEW_TAB) |
| 473 command = g_strdup_printf("opera -newpage \"%s\"", uri); | |
| 474 else if (place == GAIM_BROWSER_CURRENT) { | |
| 475 remote_command = g_strdup_printf("opera -remote \"openURL(\"%s\")\"", uri); | |
| 7136 | 476 command = g_strdup_printf("opera \"%s\"", uri); |
| 8272 | 477 } else |
| 478 command = g_strdup_printf("opera \"%s\"", uri); | |
| 479 | |
| 7136 | 480 } else if (!strcmp(web_browser, "kfmclient")) { |
| 481 command = g_strdup_printf("kfmclient openURL \"%s\"", uri); | |
| 8272 | 482 /* does Konqueror have options to open in new tab and/or current window? */ |
| 483 | |
| 7920 | 484 } else if (!strcmp(web_browser, "galeon")) { |
| 8272 | 485 if (place == GAIM_BROWSER_NEW_WINDOW) |
| 7136 | 486 command = g_strdup_printf("galeon -w \"%s\"", uri); |
| 8272 | 487 else if (place == GAIM_BROWSER_NEW_TAB) |
| 488 command = g_strdup_printf("galeon -n \"%s\"", uri); | |
| 7136 | 489 else |
| 490 command = g_strdup_printf("galeon \"%s\"", uri); | |
| 8272 | 491 |
| 492 } else if (!strcmp(web_browser, "mozilla") || | |
| 493 !strcmp(web_browser, "mozilla-firebird") || | |
| 494 !strcmp(web_browser, "firefox")) { | |
| 495 command = g_strdup_printf("%s \"%s\"", web_browser, uri); | |
| 496 if (place == GAIM_BROWSER_NEW_WINDOW) | |
| 497 remote_command = g_strdup_printf("%s -remote \"openURL(\"%s\",new-window)\"", web_browser, uri); | |
| 498 else if (place == GAIM_BROWSER_NEW_TAB) | |
| 499 remote_command = g_strdup_printf("%s -remote \"openURL(\"%s\",new-tab)\"", web_browser, uri); | |
| 500 else if (place == GAIM_BROWSER_CURRENT) | |
| 501 remote_command = g_strdup_printf("%s -remote \"openURL(\"%s\")\"", web_browser, uri); | |
| 502 | |
| 7920 | 503 } else if (!strcmp(web_browser, "custom")) { |
| 7136 | 504 const char *web_command; |
| 505 | |
| 506 web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command"); | |
| 507 | |
| 508 if (web_command == NULL || *web_command == '\0') { | |
| 509 gaim_notify_error(NULL, NULL, _("Unable to open URL"), | |
| 510 _("The 'Manual' browser command has been " | |
| 511 "chosen, but no command has been set.")); | |
| 512 return NULL; | |
| 513 } | |
| 514 | |
| 515 if (strstr(web_command, "%s")) | |
| 516 command = gaim_strreplace(web_command, "%s", uri); | |
| 517 else { | |
| 518 /* | |
| 519 * There is no "%s" in the browser command. Assume the user | |
| 520 * wanted the URL tacked on to the end of the command. | |
| 521 */ | |
| 522 command = g_strdup_printf("%s %s", web_command, uri); | |
| 523 } | |
| 524 } | |
| 525 | |
| 8272 | 526 if (remote_command != NULL) { |
| 527 /* try the remote command first */ | |
| 528 if (uri_command(remote_command, TRUE) != 0) | |
| 529 uri_command(command, FALSE); | |
| 530 g_free(remote_command); | |
| 531 } else { | |
| 532 uri_command(command, FALSE); | |
| 7136 | 533 } |
| 534 | |
| 535 g_free(command); | |
| 536 | |
| 537 #else | |
| 538 ShellExecute(NULL, NULL, uri, NULL, ".\\", 0); | |
| 539 #endif | |
| 540 | |
| 541 return NULL; | |
| 542 } | |
| 543 | |
| 5437 | 544 static GaimNotifyUiOps ops = |
| 545 { | |
| 546 gaim_gtk_notify_message, | |
| 547 gaim_gtk_notify_email, | |
| 548 gaim_gtk_notify_emails, | |
|
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
549 gaim_gtk_notify_formatted, |
|
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
550 gaim_gtk_notify_uri, |
| 5437 | 551 gaim_gtk_close_notify |
| 552 }; | |
| 553 | |
| 554 GaimNotifyUiOps * | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7007
diff
changeset
|
555 gaim_gtk_notify_get_ui_ops(void) |
| 5437 | 556 { |
| 557 return &ops; | |
| 558 } |
