annotate src/prpl.c @ 2553:d3e463a5cafc

[gaim-migrate @ 2566] rob, you should --enable-debug :) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 19 Oct 2001 20:31:40 +0000
parents 830a83209475
children 1ac93742d141
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
2417
5473c8c5378d [gaim-migrate @ 2430]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2403
diff changeset
22 #include "gaim.h"
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include "prpl.h"
2050
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
24 #include <sys/types.h>
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
25 #include <sys/stat.h>
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
26 #include <unistd.h>
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
27
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
28 #include "pixmaps/ok.xpm"
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
29 #include "pixmaps/cancel.xpm"
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
30 #include "pixmaps/tb_forward.xpm"
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
31
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 GSList *protocols = NULL;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
34 GtkWidget *protomenu = NULL;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
35
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
36 struct _prompt {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
37 GtkWidget *window;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
38 GtkWidget *entry;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
39 void (*doit)(void *, char *);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
40 void (*dont)(void *);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
41 void *data;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
42 };
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
43
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 struct prpl *find_prpl(int prot)
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 {
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 GSList *e = protocols;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 struct prpl *r;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 while (e) {
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 r = (struct prpl *)e->data;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 if (r->protocol == prot)
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 return r;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 e = e->next;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 }
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 return NULL;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 }
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
59 static gint proto_compare(struct prpl *a, struct prpl *b)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
60 {
1043
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
61 /* neg if a before b, 0 if equal, pos if a after b */
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
62 return a->protocol - b->protocol;
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
63 }
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
64
1443
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1436
diff changeset
65 void load_protocol(proto_init pi, int size)
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
66 {
1443
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1436
diff changeset
67 struct prpl *p;
1040
17cea517fd90 [gaim-migrate @ 1050]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
68 struct prpl *old;
1443
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1436
diff changeset
69 if (size != sizeof(struct prpl)) {
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1436
diff changeset
70 do_error_dialog(_("You have attempted to load a protocol which was not compiled"
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
71 " from the same version of the source as this application was."
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
72 " Unfortunately, because it is not the same version I cannot"
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
73 " safely tell you which one it was. Needless to say, it was not"
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
74 " successfully loaded."), _("Protocol Error"));
1443
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1436
diff changeset
75 return;
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1436
diff changeset
76 }
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1436
diff changeset
77 p = g_new0(struct prpl, 1);
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
78 pi(p);
2279
63102b44541a [gaim-migrate @ 2289]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2237
diff changeset
79 if ((old = find_prpl(p->protocol)) != NULL)
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
80 unload_protocol(old);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
81 protocols = g_slist_insert_sorted(protocols, p, (GCompareFunc)proto_compare);
2204
5014b802eb41 [gaim-migrate @ 2214]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2191
diff changeset
82 regenerate_user_list();
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
83 }
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
84
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
85 void unload_protocol(struct prpl *p)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
86 {
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
87 GSList *c = connections;
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
88 struct gaim_connection *g;
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
89 while (c) {
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
90 g = (struct gaim_connection *)c->data;
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
91 if (g->prpl == p) {
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
92 char buf[256];
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
93 g_snprintf(buf, sizeof buf, _("%s was using %s, which got removed."
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
94 " %s is now offline."), g->username,
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
95 (*p->name)(), g->username);
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
96 do_error_dialog(buf, _("Disconnect"));
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
97 signoff(g);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
98 c = connections;
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
99 } else
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
100 c = c->next;
1040
17cea517fd90 [gaim-migrate @ 1050]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
101 }
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
102 protocols = g_slist_remove(protocols, p);
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
103 g_free(p);
2204
5014b802eb41 [gaim-migrate @ 2214]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2191
diff changeset
104 regenerate_user_list();
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
105 }
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
106
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2050
diff changeset
107 STATIC_PROTO_INIT
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
108
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
109 static void des_win(GtkWidget *a, GtkWidget *b)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
110 {
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
111 gtk_widget_destroy(b);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
112 }
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
113
1333
b332d8f46b84 [gaim-migrate @ 1343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
114 static void rem_win(GtkWidget *a, GtkWidget *b)
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
115 {
1333
b332d8f46b84 [gaim-migrate @ 1343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
116 void *d = gtk_object_get_user_data(GTK_OBJECT(a));
b332d8f46b84 [gaim-migrate @ 1343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
117 if (d)
b332d8f46b84 [gaim-migrate @ 1343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
118 gtk_signal_disconnect_by_data(GTK_OBJECT(b), d);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
119 gtk_widget_destroy(b);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
120 }
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
121
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
122 void do_ask_dialog(const char *text, void *data, void *doit, void *dont)
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
123 {
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
124 GtkWidget *window;
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
125 GtkWidget *vbox;
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
126 GtkWidget *label;
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
127 GtkWidget *hbox;
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
128 GtkWidget *button;
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
129
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
130 window = gtk_window_new(GTK_WINDOW_DIALOG);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
131 gtk_window_set_wmclass(GTK_WINDOW(window), "accept", "Gaim");
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
132 gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
133 gtk_window_set_title(GTK_WINDOW(window), _("Accept?"));
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
134 gtk_widget_realize(window);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
135 aol_icon(window->window);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
136 if (dont)
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
137 gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(dont), data);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
138
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
139 vbox = gtk_vbox_new(FALSE, 5);
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
140 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
141 gtk_container_add(GTK_CONTAINER(window), vbox);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
142
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
143 label = gtk_label_new(text);
2151
ecd5f3d29f47 [gaim-migrate @ 2161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
144 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
ecd5f3d29f47 [gaim-migrate @ 2161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
145 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
146
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
147 hbox = gtk_hbox_new(FALSE, 5);
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
148 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
149
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
150 button = picture_button(window, _("Cancel"), cancel_xpm);
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
151 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
152 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(des_win), window);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
153
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
154 button = picture_button(window, _("Accept"), ok_xpm);
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
155 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
2007
948a67a691a6 [gaim-migrate @ 2017]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1536
diff changeset
156 if (dont)
948a67a691a6 [gaim-migrate @ 2017]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1536
diff changeset
157 gtk_object_set_user_data(GTK_OBJECT(button), data);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
158 if (doit)
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
159 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(doit), data);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
160 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(rem_win), window);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
161
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
162 gtk_widget_show_all(window);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
163 }
1333
b332d8f46b84 [gaim-migrate @ 1343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
164
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
165 static void des_prompt(GtkWidget *w, struct _prompt *p)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
166 {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
167 if (p->dont)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
168 (p->dont)(p->data);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
169 gtk_widget_destroy(p->window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
170 g_free(p);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
171 }
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
172
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
173 static void act_prompt(GtkWidget *w, struct _prompt *p)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
174 {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
175 if (p->doit)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
176 (p->doit)(p->data, gtk_entry_get_text(GTK_ENTRY(p->entry)));
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
177 gtk_widget_destroy(p->window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
178 }
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
179
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
180 void do_prompt_dialog(const char *text, const char *def, void *data, void *doit, void *dont)
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
181 {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
182 GtkWidget *window;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
183 GtkWidget *vbox;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
184 GtkWidget *hbox;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
185 GtkWidget *label;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
186 GtkWidget *entry;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
187 GtkWidget *button;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
188 struct _prompt *p;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
189
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
190 p = g_new0(struct _prompt, 1);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
191 p->data = data;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
192 p->doit = doit;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
193 p->dont = dont;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
194
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
195 window = gtk_window_new(GTK_WINDOW_DIALOG);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
196 p->window = window;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
197 gtk_window_set_wmclass(GTK_WINDOW(window), "prompt", "Gaim");
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
198 gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
199 gtk_window_set_title(GTK_WINDOW(window), _("Gaim - Prompt"));
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
200 gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(des_prompt), p);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
201 gtk_widget_realize(window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
202 aol_icon(window->window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
203
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
204 vbox = gtk_vbox_new(FALSE, 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
205 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
206 gtk_container_add(GTK_CONTAINER(window), vbox);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
207
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
208 hbox = gtk_hbox_new(FALSE, 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
209 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
210
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
211 label = gtk_label_new(text);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
212 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
213
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
214 entry = gtk_entry_new();
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
215 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
216 if (def)
2543
830a83209475 [gaim-migrate @ 2556]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
217 gtk_entry_set_text(GTK_ENTRY(entry), def);
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
218 gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(act_prompt), p);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
219 p->entry = entry;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
220
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
221 hbox = gtk_hbox_new(FALSE, 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
222 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
223
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
224 button = picture_button(window, _("Cancel"), cancel_xpm);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
225 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
226 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(des_win), window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
227
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
228 button = picture_button(window, _("Accept"), ok_xpm);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
229 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
230 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(act_prompt), p);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
231
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
232 gtk_widget_show_all(window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
233 }
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
234
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
235 static void proto_act(GtkObject *obj, struct gaim_connection *gc)
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
236 {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
237 char *act = gtk_object_get_user_data(obj);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
238 (*gc->prpl->do_action)(gc, act);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
239 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
240
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
241 void do_proto_menu()
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
242 {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
243 GtkWidget *menuitem;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
244 GtkWidget *submenu;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
245 GList *l;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
246 GSList *c = connections;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
247 struct gaim_connection *gc = NULL;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
248 int count = 0;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
249 char buf[256];
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
250
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
251 if (!protomenu)
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
252 return;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
253
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
254 l = gtk_container_children(GTK_CONTAINER(protomenu));
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
255 while (l) {
1530
0b6e4d52de63 [gaim-migrate @ 1540]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1500
diff changeset
256 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(l->data));
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
257 l = l->next;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
258 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
259
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
260 while (c) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
261 gc = c->data;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
262 if (gc->prpl->actions && gc->prpl->do_action)
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
263 count++;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
264 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
265 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
266 c = connections;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
267
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
268 if (!count) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
269 g_snprintf(buf, sizeof(buf), "No actions available");
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
270 menuitem = gtk_menu_item_new_with_label(buf);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
271 gtk_menu_append(GTK_MENU(protomenu), menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
272 gtk_widget_show(menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
273 return;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
274 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
275
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
276 if (count == 1) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
277 GList *tmp, *act;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
278 while (c) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
279 gc = c->data;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
280 if (gc->prpl->actions && gc->prpl->do_action)
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
281 break;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
282 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
283 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
284
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
285 tmp = act = (*gc->prpl->actions)();
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
286
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
287 while (act) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
288 if (act->data == NULL) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
289 gaim_separator(protomenu);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
290 act = g_list_next(act);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
291 continue;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
292 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
293
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
294 menuitem = gtk_menu_item_new_with_label(act->data);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
295 gtk_object_set_user_data(GTK_OBJECT(menuitem), act->data);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
296 gtk_menu_append(GTK_MENU(protomenu), menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
297 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
298 GTK_SIGNAL_FUNC(proto_act), gc);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
299 gtk_widget_show(menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
300
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
301 act = g_list_next(act);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
302 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
303
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
304 g_list_free(tmp);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
305 } else {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
306 while (c) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
307 GList *tmp, *act;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
308 gc = c->data;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
309 if (!gc->prpl->actions || !gc->prpl->do_action) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
310 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
311 continue;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
312 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
313
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
314 g_snprintf(buf, sizeof(buf), "%s (%s)", gc->username, (*gc->prpl->name)());
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
315 menuitem = gtk_menu_item_new_with_label(buf);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
316 gtk_menu_append(GTK_MENU(protomenu), menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
317 gtk_widget_show(menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
318
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
319 submenu = gtk_menu_new();
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
320 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
321 gtk_widget_show(submenu);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
322
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
323 tmp = act = (*gc->prpl->actions)();
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
324
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
325 while (act) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
326 if (act->data == NULL) {
1536
3a9f11c9278b [gaim-migrate @ 1546]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1530
diff changeset
327 gaim_separator(submenu);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
328 act = g_list_next(act);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
329 continue;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
330 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
331
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
332 menuitem = gtk_menu_item_new_with_label(act->data);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
333 gtk_object_set_user_data(GTK_OBJECT(menuitem), act->data);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
334 gtk_menu_append(GTK_MENU(submenu), menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
335 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
336 GTK_SIGNAL_FUNC(proto_act), gc);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
337 gtk_widget_show(menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
338
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
339 act = g_list_next(act);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
340 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
341
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
342 g_list_free(tmp);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
343 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
344 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
345 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
346 }
2050
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
347
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
348 struct mail_notify {
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
349 struct gaim_connection *gc;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
350 GtkWidget *email_win;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
351 GtkWidget *email_label;
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
352 char *url;
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
353 };
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
354 GSList *mailnots = NULL;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
355
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
356 static struct mail_notify *find_mail_notify(struct gaim_connection *gc)
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
357 {
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
358 GSList *m = mailnots;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
359 while (m) {
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
360 if (((struct mail_notify *)m->data)->gc == gc)
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
361 return m->data;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
362 m = m->next;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
363 }
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
364 return NULL;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
365 }
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
366
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
367 static void des_email_win(GtkWidget *w, struct mail_notify *mn)
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
368 {
2428
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
369 if (w != mn->email_win) {
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
370 gtk_widget_destroy(mn->email_win);
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
371 return;
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
372 }
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
373 debug_printf("removing mail notification\n");
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
374 mailnots = g_slist_remove(mailnots, mn);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
375 if (mn->url)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
376 g_free(mn->url);
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
377 g_free(mn);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
378 }
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
379
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
380 void connection_has_mail(struct gaim_connection *gc, int count, const char *from, const char *subject, const char *url)
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
381 {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
382 GtkWidget *hbox;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
383 GtkWidget *vbox;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
384 GtkWidget *urlbut;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
385 GtkWidget *close;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
386
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
387 struct mail_notify *mn;
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
388 char buf[2048];
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
389
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
390 if (!(gc->user->options & OPT_USR_MAIL_CHECK))
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
391 return;
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
392
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
393 if (!(mn = find_mail_notify(gc))) {
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
394 mn = g_new0(struct mail_notify, 1);
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
395 mn->gc = gc;
2403
8555e48c02df [gaim-migrate @ 2416]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2401
diff changeset
396 mailnots = g_slist_append(mailnots, mn);
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
397 }
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
398
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
399 if (count < 0 && from && subject) {
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
400 g_snprintf(buf, sizeof buf, "%s has mail from %s: %s", gc->username, from, subject);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
401 } else if (count) {
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
402 g_snprintf(buf, sizeof buf, "%s has %d new message%s.",
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
403 gc->username, count, count == 1 ? "" : "s");
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
404 } else if (mn->email_win) {
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
405 gtk_widget_destroy(mn->email_win);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
406 return;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
407 }
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
408
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
409 if (mn->email_win) {
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
410 gtk_label_set_text(GTK_LABEL(mn->email_label), buf);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
411 return;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
412 }
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
413
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
414
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
415 mn->email_win = gtk_window_new(GTK_WINDOW_DIALOG);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
416 gtk_window_set_wmclass(GTK_WINDOW(mn->email_win), "mail", "Gaim");
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
417 gtk_window_set_policy(GTK_WINDOW(mn->email_win), FALSE, TRUE, TRUE);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
418 gtk_window_set_title(GTK_WINDOW(mn->email_win), _("Gaim - New Mail"));
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
419 gtk_signal_connect(GTK_OBJECT(mn->email_win), "destroy", GTK_SIGNAL_FUNC(des_email_win), mn);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
420 gtk_widget_realize(mn->email_win);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
421 aol_icon(mn->email_win->window);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
422
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
423 vbox = gtk_vbox_new(FALSE, 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
424 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
425 gtk_container_add(GTK_CONTAINER(mn->email_win), vbox);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
426 gtk_widget_show(vbox);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
427
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
428 mn->email_label = gtk_label_new(buf);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
429 gtk_label_set_text(GTK_LABEL(mn->email_label), buf);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
430 gtk_box_pack_start(GTK_BOX(vbox), mn->email_label, 0, 0, 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
431 gtk_widget_show(mn->email_label);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
432
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
433 hbox = gtk_hbox_new(FALSE, 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
434 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
435 gtk_widget_show(hbox);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
436
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
437 close = picture_button(mn->email_win, _("Close"), cancel_xpm);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
438 gtk_window_set_focus(GTK_WINDOW(mn->email_win), close);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
439 gtk_box_pack_end(GTK_BOX(hbox), close, 0, 0, 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
440 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(des_email_win), mn);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
441
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
442 if (url) {
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
443 mn->url = g_strdup(url);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
444 urlbut = picture_button(mn->email_win, _("Open Mail"), tb_forward_xpm);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
445 gtk_box_pack_end(GTK_BOX(hbox), urlbut, 0, 0, 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
446 gtk_signal_connect(GTK_OBJECT(urlbut), "clicked", GTK_SIGNAL_FUNC(open_url_nw), mn->url);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
447 }
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
448
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
449 gtk_widget_show(mn->email_win);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
450 }
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
451
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
452 struct icon_data {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
453 struct gaim_connection *gc;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
454 char *who;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
455 void *data;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
456 int len;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
457 };
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
458
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
459 static GList *icons = NULL;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
460
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
461 static gint find_icon_data(gconstpointer a, gconstpointer b)
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
462 {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
463 const struct icon_data *x = a;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
464 const struct icon_data *y = b;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
465
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
466 return ((x->gc != y->gc) || g_strcasecmp(x->who, y->who));
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
467 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
468
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
469 void set_icon_data(struct gaim_connection *gc, char *who, void *data, int len)
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
470 {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
471 struct icon_data tmp = { gc, who, NULL, 0 };
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
472 GList *l = g_list_find_custom(icons, &tmp, find_icon_data);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
473 struct icon_data *id = l ? l->data : NULL;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
474
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
475 if (id) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
476 g_free(id->data);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
477 if (!data) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
478 icons = g_list_remove(icons, id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
479 g_free(id->who);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
480 g_free(id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
481 return;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
482 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
483 } else if (data) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
484 id = g_new0(struct icon_data, 1);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
485 icons = g_list_append(icons, id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
486 id->gc = gc;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
487 id->who = g_strdup(who);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
488 } else {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
489 return;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
490 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
491
2284
83c7123e5a7e [gaim-migrate @ 2294]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2279
diff changeset
492 debug_printf("Got icon for %s (length %d)\n", who, len);
83c7123e5a7e [gaim-migrate @ 2294]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2279
diff changeset
493
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
494 id->data = g_memdup(data, len);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
495 id->len = len;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
496
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
497 got_new_icon(gc, who);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
498 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
499
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
500 void remove_icon_data(struct gaim_connection *gc)
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
501 {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
502 GList *list = icons;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
503 struct icon_data *id;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
504
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
505 while (list) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
506 id = list->data;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
507 if (id->gc == gc) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
508 g_free(id->data);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
509 g_free(id->who);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
510 list = icons = g_list_remove(icons, id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
511 g_free(id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
512 } else
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
513 list = list->next;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
514 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
515 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
516
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
517 void *get_icon_data(struct gaim_connection *gc, char *who, int *len)
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
518 {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
519 struct icon_data tmp = { gc, who, NULL, 0 };
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
520 GList *l = g_list_find_custom(icons, &tmp, find_icon_data);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
521 struct icon_data *id = l ? l->data : NULL;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
522
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
523 if (id) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
524 *len = id->len;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
525 return id->data;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
526 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
527
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
528 *len = 0;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
529 return NULL;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
530 }