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