annotate src/gtknotify.c @ 6241:9ce44a7f9ae7

[gaim-migrate @ 6735] We now initialize FT's preferences. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 20 Jul 2003 03:44:39 +0000
parents 99f4bbeb27bc
children 76af8c066f8c
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>
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 *
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 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
23 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
24
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
25 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
26 #include "connection.h"
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #include "stock.h"
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
29 #include "gtknotify.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
30
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
31 #include "ui.h"
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
32
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
33 typedef struct
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
34 {
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5543
diff changeset
35 GaimConnection *gc;
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
36 char *url;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
37 GtkWidget *dialog;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
38 GtkWidget *label;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
39
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
40 } GaimNotifyMailData;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
41
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
42 static void *gaim_gtk_notify_emails(size_t count, gboolean detailed,
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
43 const char **subjects,
5476
9bcd8cd625ae [gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents: 5437
diff changeset
44 const char **froms, const char **tos,
9bcd8cd625ae [gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents: 5437
diff changeset
45 const char **urls, GCallback cb,
9bcd8cd625ae [gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents: 5437
diff changeset
46 void *user_data);
9bcd8cd625ae [gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents: 5437
diff changeset
47
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
48 static void
6104
29ddc42ff402 [gaim-migrate @ 6565]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
49 message_response_cb(GtkDialog *dialog, gint id, GaimNotifyMailData *data)
29ddc42ff402 [gaim-migrate @ 6565]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
50 {
29ddc42ff402 [gaim-migrate @ 6565]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
51 gaim_notify_close(GAIM_NOTIFY_MESSAGE, data);
29ddc42ff402 [gaim-migrate @ 6565]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
52 }
29ddc42ff402 [gaim-migrate @ 6565]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
53
29ddc42ff402 [gaim-migrate @ 6565]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
54 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
55 email_response_cb(GtkDialog *dialog, gint id, GaimNotifyMailData *data)
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
56 {
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
57 if (id == 0)
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
58 open_url(NULL, data->url);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
59
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
60 gaim_notify_close(GAIM_NOTIFY_EMAILS, data);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
61 }
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
62
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 static void *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 const char *primary, const char *secondary,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 GCallback cb, void *user_data)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 GtkWidget *dialog;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 GtkWidget *hbox;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 GtkWidget *label;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 GtkWidget *img = NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 char label_text[2048];
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 const char *icon_name = NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 switch (type) {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 case GAIM_NOTIFY_MSG_ERROR:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 icon_name = GAIM_STOCK_DIALOG_ERROR;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 case GAIM_NOTIFY_MSG_WARNING:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 icon_name = GAIM_STOCK_DIALOG_WARNING;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 case GAIM_NOTIFY_MSG_INFO:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 icon_name = GAIM_STOCK_DIALOG_INFO;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 default:
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 icon_name = NULL;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 break;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 if (icon_name != NULL) {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_DIALOG);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97
6106
99f4bbeb27bc [gaim-migrate @ 6567]
Mark Doliner <mark@kingant.net>
parents: 6104
diff changeset
98 dialog = gtk_dialog_new_with_buttons(title, NULL, 0,
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 NULL);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 g_signal_connect(G_OBJECT(dialog), "response",
6104
29ddc42ff402 [gaim-migrate @ 6565]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
102 G_CALLBACK(message_response_cb), dialog);
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 hbox = gtk_hbox_new(FALSE, 12);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 if (img != NULL)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 g_snprintf(label_text, sizeof(label_text),
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 primary, (secondary ? secondary : ""));
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 label = gtk_label_new(NULL);
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_label_set_markup(GTK_LABEL(label), label_text);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 gtk_widget_show_all(dialog);
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 return dialog;
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
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 static void *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 gaim_gtk_notify_email(const char *subject, const char *from,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 const char *to, const char *url,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 GCallback cb, void *user_data)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 {
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
137 return gaim_gtk_notify_emails(1, TRUE,
5524
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
138 (subject == NULL ? NULL : &subject),
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
139 (from == NULL ? NULL : &from),
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
140 (to == NULL ? NULL : &to),
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
141 (url == NULL ? NULL : &url),
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
142 cb, user_data);
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 }
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 static void *
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
146 gaim_gtk_notify_emails(size_t count, gboolean detailed,
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
147 const char **subjects, const char **froms,
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
148 const char **tos, const char **urls,
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
149 GCallback cb, void *user_data)
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 {
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
151 GaimNotifyMailData *data;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
152 GtkWidget *dialog;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
153 GtkWidget *vbox;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
154 GtkWidget *hbox;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
155 GtkWidget *label;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
156 GtkWidget *img;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
157 char *detail_text;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
158 char *label_text;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
159
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
160 data = g_new0(GaimNotifyMailData, 1);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
161
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
162 data->url = g_strdup(urls[0]);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
163
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
164 /* Create the dialog. */
5524
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
165 data->dialog = dialog = gtk_dialog_new();
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
166
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
167 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, 1);
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
168
101384b068c1 [gaim-migrate @ 5924]
Christian Hammond <chipx86@chipx86.com>
parents: 5519
diff changeset
169 if (urls != NULL)
5536
8bf28c2d100e [gaim-migrate @ 5936]
Christian Hammond <chipx86@chipx86.com>
parents: 5524
diff changeset
170 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
171
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
172 g_signal_connect(G_OBJECT(dialog), "response",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
173 G_CALLBACK(email_response_cb), data);
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
174
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
175 /* Setup the dialog */
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
176 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
177 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
178 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
179 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
180 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
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 /* Setup the main horizontal box */
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
183 hbox = gtk_hbox_new(FALSE, 12);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
184 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
185
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
186 /* Dialog icon. */
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
187 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_INFO,
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
188 GTK_ICON_SIZE_DIALOG);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
189 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
190 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
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 /* Vertical box */
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
193 vbox = gtk_vbox_new(FALSE, 12);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
194
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
195 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
196
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
197 /* Descriptive label */
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
198 detail_text = g_strdup_printf(
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
199 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
200 *tos, count);
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 if (count == 1) {
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
203 char *from_text = NULL, *subject_text = NULL;
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 if (froms != NULL) {
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
206 from_text = g_strdup_printf(
5543
7a36a3644887 [gaim-migrate @ 5944]
Luke Schierer <lschiere@pidgin.im>
parents: 5537
diff changeset
207 _("<span weight=\"bold\">From:</span> %s\n"), *froms);
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
208 }
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
209
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
210 if (subjects != NULL) {
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
211 subject_text = g_strdup_printf(
5543
7a36a3644887 [gaim-migrate @ 5944]
Luke Schierer <lschiere@pidgin.im>
parents: 5537
diff changeset
212 _("<span weight=\"bold\">Subject:</span> %s\n"), *subjects);
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
213 }
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
214
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
215 label_text = g_strdup_printf(
5543
7a36a3644887 [gaim-migrate @ 5944]
Luke Schierer <lschiere@pidgin.im>
parents: 5537
diff changeset
216 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>"
7a36a3644887 [gaim-migrate @ 5944]
Luke Schierer <lschiere@pidgin.im>
parents: 5537
diff changeset
217 "\n\n%s%s%s%s"),
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
218 detail_text,
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
219 (from_text == NULL && subject_text == NULL ? "" : "\n\n"),
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
220 (from_text == NULL ? "" : from_text),
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
221 (subject_text == NULL ? "" : subject_text));
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
222
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
223 if (from_text != NULL)
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
224 g_free(from_text);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
225
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
226 if (subject_text != NULL)
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
227 g_free(subject_text);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
228 }
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
229 else {
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
230 label_text = g_strdup_printf(
5543
7a36a3644887 [gaim-migrate @ 5944]
Luke Schierer <lschiere@pidgin.im>
parents: 5537
diff changeset
231 _("<span weight=\"bold\" size=\"larger\">You have mail!</span>"
7a36a3644887 [gaim-migrate @ 5944]
Luke Schierer <lschiere@pidgin.im>
parents: 5537
diff changeset
232 "\n\n%s"), detail_text);
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
233 }
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 g_free(detail_text);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
236
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
237 label = gtk_label_new(NULL);
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 gtk_label_set_markup(GTK_LABEL(label), label_text);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
240 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
241 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
242 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
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 g_free(label_text);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
245
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
246 /* Show everything. */
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
247 gtk_widget_show_all(dialog);
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 return data;
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 static void
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
253 gaim_gtk_close_notify(GaimNotifyType type, void *ui_handle)
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 {
5519
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
255 if (type == GAIM_NOTIFY_EMAIL || type == GAIM_NOTIFY_EMAILS) {
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
256 GaimNotifyMailData *data = (GaimNotifyMailData *)ui_handle;
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
257
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
258 gtk_widget_destroy(data->dialog);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
259
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
260 g_free(data->url);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
261 g_free(data);
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
262 }
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
263 else
42a20beb80a7 [gaim-migrate @ 5919]
Christian Hammond <chipx86@chipx86.com>
parents: 5476
diff changeset
264 gtk_widget_destroy(GTK_WIDGET(ui_handle));
5437
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 }
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 static GaimNotifyUiOps ops =
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 gaim_gtk_notify_message,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 gaim_gtk_notify_email,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 gaim_gtk_notify_emails,
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 gaim_gtk_close_notify
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 };
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 GaimNotifyUiOps *
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 gaim_get_gtk_notify_ui_ops(void)
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 {
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 return &ops;
0031a613a87d [gaim-migrate @ 5819]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 }