annotate src/gtknotify.c @ 10353:fc7168f9ecb0

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