annotate src/gtknotify.c @ 7152:cada5ddc21f5

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