Mercurial > pidgin
annotate src/prpl.c @ 5469:df653f6f2978
[gaim-migrate @ 5861]
gaim_get_connections added
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Wed, 21 May 2003 15:57:31 +0000 |
parents | ad445074d239 |
children | 3e8487580024 |
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 | |
2417
5473c8c5378d
[gaim-migrate @ 2430]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2403
diff
changeset
|
22 #include "gaim.h" |
4687 | 23 #include "gtkutils.h" |
5228
1a53330dfd34
[gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
24 #include "gtkblist.h" |
981 | 25 #include "prpl.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
26 #include "notify.h" |
2050
ddd696ccb46b
[gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2007
diff
changeset
|
27 #include <sys/types.h> |
ddd696ccb46b
[gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2007
diff
changeset
|
28 #include <sys/stat.h> |
ddd696ccb46b
[gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2007
diff
changeset
|
29 #include <unistd.h> |
4235 | 30 #include <string.h> |
4802 | 31 #include <errno.h> |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
32 |
3738 | 33 #ifdef _WIN32 |
34 #include "win32dep.h" | |
35 #endif | |
36 | |
981 | 37 GSList *protocols = NULL; |
38 | |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
39 GtkWidget *protomenu = NULL; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
40 |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
41 struct _prompt { |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
42 GtkWidget *window; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
43 GtkWidget *entry; |
3466 | 44 void (*doit)(void *, const char *); |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
45 void (*dont)(void *); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
46 void *data; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
47 }; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
48 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
49 GaimPlugin * |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
50 gaim_find_prpl(GaimProtocol type) |
981 | 51 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
52 GSList *l; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
53 GaimPlugin *plugin; |
981 | 54 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
55 for (l = protocols; l != NULL; l = l->next) { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
56 plugin = (GaimPlugin *)l->data; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
57 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
58 /* Just In Case (TM) */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
59 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
60 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
61 if (GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol == type) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
62 return plugin; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
63 } |
981 | 64 } |
65 | |
66 return NULL; | |
67 } | |
68 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1210
diff
changeset
|
69 static void des_win(GtkWidget *a, GtkWidget *b) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1210
diff
changeset
|
70 { |
1064
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
71 gtk_widget_destroy(b); |
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
72 } |
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
73 |
4249 | 74 static GSList *do_ask_dialogs = NULL; |
75 | |
3730 | 76 struct doaskstruct { |
4249 | 77 GtkWidget *dialog; |
78 GModule *handle; | |
3730 | 79 void (*yesfunc)(gpointer); |
80 void (*nofunc)(gpointer); | |
81 gpointer data; | |
82 }; | |
83 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
84 void do_ask_cancel_by_handle(void *handle) |
4249 | 85 { |
86 GSList *d = do_ask_dialogs; | |
87 | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
88 gaim_debug(GAIM_DEBUG_MISC, "prpl", |
5271 | 89 "%d dialogs to search\n", g_slist_length(d)); |
4249 | 90 |
91 while (d) { | |
92 struct doaskstruct *doask = d->data; | |
93 | |
94 d = d->next; | |
95 | |
96 if (doask->handle == handle) { | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
97 gaim_debug(GAIM_DEBUG_MISC, "prpl", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
98 "Removing dialog, %d remain\n", g_slist_length(d)); |
4249 | 99 gtk_dialog_response(GTK_DIALOG(doask->dialog), GTK_RESPONSE_NONE); |
100 } | |
101 } | |
102 } | |
103 | |
3730 | 104 static void do_ask_callback(GtkDialog *d, gint resp, struct doaskstruct *doask) |
105 { | |
106 switch (resp) | |
107 { | |
108 case GTK_RESPONSE_YES: | |
109 if (doask->yesfunc) | |
110 doask->yesfunc(doask->data); | |
111 break; | |
4249 | 112 default: |
3730 | 113 if (doask->nofunc) |
114 doask->nofunc(doask->data); | |
115 break; | |
116 } | |
4249 | 117 do_ask_dialogs = g_slist_remove(do_ask_dialogs, doask); |
3730 | 118 g_free(doask); |
3738 | 119 gtk_widget_destroy(GTK_WIDGET(d)); |
3730 | 120 } |
121 | |
3753 | 122 #define STOCK_ITEMIZE(r, l) if (!strcmp(r,yestext)) \ |
123 yestext = l; \ | |
124 if (!strcmp(r,notext)) \ | |
125 notext = l; | |
3730 | 126 |
4249 | 127 void do_ask_dialog(const char *prim, const char *sec, void *data, char *yestext, void *doit, char *notext, void *dont, GModule *handle, gboolean modal) |
1064
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
128 { |
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
129 GtkWidget *window; |
3730 | 130 GtkWidget *hbox; |
1064
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
131 GtkWidget *label; |
3730 | 132 char labeltext[1024 * 2]; |
5024 | 133 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); |
3730 | 134 struct doaskstruct *doask = g_new0(struct doaskstruct, 1); |
1064
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
135 |
3730 | 136 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
1064
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
137 |
3753 | 138 /* This is ugly. GTK Stock items will take a button with a label "gtk-cancel" and turn it into a |
139 * Cancel button with a Cancel icon and whatnot. We want to avoid using anything gtk in the prpls | |
140 * so we replace "Cancel" with "gtk-cancel" right here. */ | |
141 STOCK_ITEMIZE("Add", GTK_STOCK_ADD); | |
142 STOCK_ITEMIZE("Apply", GTK_STOCK_APPLY); | |
143 STOCK_ITEMIZE("Cancel", GTK_STOCK_CANCEL); | |
144 STOCK_ITEMIZE("Close", GTK_STOCK_CLOSE); | |
145 STOCK_ITEMIZE("Delete", GTK_STOCK_DELETE); | |
146 STOCK_ITEMIZE("Remove", GTK_STOCK_REMOVE); | |
147 STOCK_ITEMIZE("Yes", GTK_STOCK_YES); | |
148 STOCK_ITEMIZE("No", GTK_STOCK_NO); | |
149 | |
4778 | 150 window = gtk_dialog_new_with_buttons("", NULL, 0, notext, GTK_RESPONSE_NO, yestext, GTK_RESPONSE_YES, NULL); |
4245 | 151 |
152 if (modal) { | |
153 gtk_window_set_modal(GTK_WINDOW(window), TRUE); | |
154 } | |
155 | |
3730 | 156 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_YES); |
157 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_ask_callback), doask); | |
4249 | 158 |
3730 | 159 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
160 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
161 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); | |
162 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); | |
163 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); | |
1210 | 164 |
3730 | 165 hbox = gtk_hbox_new(FALSE, 12); |
166 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); | |
167 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
168 | |
169 g_snprintf(labeltext, sizeof(labeltext), "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", prim, sec ? sec : ""); | |
170 label = gtk_label_new(NULL); | |
171 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
172 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
173 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
174 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
4249 | 175 |
176 doask->dialog = window; | |
177 doask->handle = handle; | |
178 doask->yesfunc = doit; | |
179 doask->nofunc = dont; | |
180 doask->data = data; | |
181 do_ask_dialogs = g_slist_append(do_ask_dialogs, doask); | |
182 | |
1210 | 183 gtk_widget_show_all(window); |
1064
b0b40b5faede
[gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
184 } |
1333
b332d8f46b84
[gaim-migrate @ 1343]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1252
diff
changeset
|
185 |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
186 static void des_prompt(GtkWidget *w, 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 if (p->dont) |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
189 (p->dont)(p->data); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
190 gtk_widget_destroy(p->window); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
191 g_free(p); |
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 |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
194 static void act_prompt(GtkWidget *w, struct _prompt *p) |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
195 { |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
196 if (p->doit) |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
197 (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
|
198 gtk_widget_destroy(p->window); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
199 } |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
200 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
201 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
|
202 { |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
203 GtkWidget *window; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
204 GtkWidget *vbox; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
205 GtkWidget *hbox; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
206 GtkWidget *label; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
207 GtkWidget *entry; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
208 GtkWidget *button; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
209 struct _prompt *p; |
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 p = g_new0(struct _prompt, 1); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
212 p->data = data; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
213 p->doit = doit; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
214 p->dont = dont; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
215 |
2725
f3c094e78609
[gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2718
diff
changeset
|
216 GAIM_DIALOG(window); |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
217 p->window = window; |
4074 | 218 gtk_window_set_role(GTK_WINDOW(window), "prompt"); |
4635 | 219 gtk_window_set_resizable(GTK_WINDOW(window), TRUE); |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
220 gtk_window_set_title(GTK_WINDOW(window), _("Gaim - Prompt")); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
221 g_signal_connect(G_OBJECT(window), "destroy", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
222 G_CALLBACK(des_prompt), p); |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
223 gtk_widget_realize(window); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
224 |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
225 vbox = gtk_vbox_new(FALSE, 5); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
226 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
227 gtk_container_add(GTK_CONTAINER(window), vbox); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
228 |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
229 hbox = gtk_hbox_new(FALSE, 5); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
230 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
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 label = gtk_label_new(text); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
233 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
234 |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
235 entry = gtk_entry_new(); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
236 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
|
237 if (def) |
2543
830a83209475
[gaim-migrate @ 2556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2541
diff
changeset
|
238 gtk_entry_set_text(GTK_ENTRY(entry), def); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
239 g_signal_connect(G_OBJECT(entry), "activate", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
240 G_CALLBACK(act_prompt), p); |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
241 p->entry = entry; |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
242 |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
243 hbox = gtk_hbox_new(FALSE, 5); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
244 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
245 |
5024 | 246 button = gaim_pixbuf_button_from_stock(_("OK"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL); |
4092 | 247 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
248 g_signal_connect(G_OBJECT(button), "clicked", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
249 G_CALLBACK(act_prompt), p); |
4092 | 250 |
5024 | 251 button = gaim_pixbuf_button_from_stock(_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
252 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
253 g_signal_connect(G_OBJECT(button), "clicked", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
254 G_CALLBACK(des_win), window); |
1500
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
255 |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
256 gtk_widget_show_all(window); |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
257 } |
a054c28735fb
[gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
258 |
4333 | 259 static void proto_act(GtkObject *obj, struct proto_actions_menu *pam) |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
260 { |
4333 | 261 if (pam->callback && pam->gc) |
262 pam->callback(pam->gc); | |
1499
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 |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
265 void do_proto_menu() |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
266 { |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
267 GtkWidget *menuitem; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
268 GtkWidget *submenu; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
269 GaimPluginProtocolInfo *prpl_info = NULL; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
270 GList *l; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
271 GSList *c = connections; |
4333 | 272 struct proto_actions_menu *pam; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
273 struct gaim_connection *gc = NULL; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
274 int count = 0; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
275 char buf[256]; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
276 |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
277 if (!protomenu) |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
278 return; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
279 |
4635 | 280 l = gtk_container_get_children(GTK_CONTAINER(protomenu)); |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
281 while (l) { |
4333 | 282 menuitem = l->data; |
4635 | 283 pam = g_object_get_data(G_OBJECT(menuitem), "proto_actions_menu"); |
4333 | 284 if (pam) |
285 g_free(pam); | |
286 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem)); | |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
287 l = l->next; |
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 while (c) { |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
291 gc = c->data; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
292 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
293 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
294 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
295 if (prpl_info->actions && gc->login_time) |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
296 count++; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
297 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
298 c = g_slist_next(c); |
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 c = connections; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
301 |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
302 if (!count) { |
4333 | 303 g_snprintf(buf, sizeof(buf), _("No actions available")); |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
304 menuitem = gtk_menu_item_new_with_label(buf); |
4635 | 305 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
306 gtk_widget_show(menuitem); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
307 return; |
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 if (count == 1) { |
4333 | 311 GList *act; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
312 while (c) { |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
313 gc = c->data; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
314 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
315 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
316 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
317 if (prpl_info->actions && gc->login_time) |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
318 break; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
319 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
320 c = g_slist_next(c); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
321 } |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
322 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
323 act = prpl_info->actions(gc); |
1499
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) { |
4333 | 326 if (act->data) { |
327 struct proto_actions_menu *pam = act->data; | |
328 menuitem = gtk_menu_item_new_with_label(pam->label); | |
4635 | 329 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
330 g_signal_connect(G_OBJECT(menuitem), "activate", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
331 G_CALLBACK(proto_act), pam); |
4635 | 332 g_object_set_data(G_OBJECT(menuitem), "proto_actions_menu", pam); |
4333 | 333 gtk_widget_show(menuitem); |
334 } else { | |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
335 gaim_separator(protomenu); |
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 act = g_list_next(act); |
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 } else { |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
340 while (c) { |
4333 | 341 GList *act; |
5154 | 342 GdkPixbuf *pixbuf, *scale; |
343 GtkWidget *image; | |
344 | |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
345 gc = c->data; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
346 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
347 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
348 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
349 if (!prpl_info->actions || !gc->login_time) { |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
350 c = g_slist_next(c); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
351 continue; |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
352 } |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
353 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
354 g_snprintf(buf, sizeof(buf), "%s (%s)", |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
355 gc->username, gc->prpl->info->name); |
5161 | 356 menuitem = gtk_image_menu_item_new_with_label(buf); |
357 | |
5154 | 358 pixbuf = create_prpl_icon(gc->account); |
359 if(pixbuf) { | |
360 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
361 GDK_INTERP_BILINEAR); | |
362 image = gtk_image_new_from_pixbuf(scale); | |
363 g_object_unref(G_OBJECT(pixbuf)); | |
364 g_object_unref(G_OBJECT(scale)); | |
5161 | 365 gtk_widget_show(image); |
366 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
5154 | 367 } |
368 | |
4635 | 369 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
370 gtk_widget_show(menuitem); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
371 |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
372 submenu = gtk_menu_new(); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
373 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
374 gtk_widget_show(submenu); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
375 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
376 act = prpl_info->actions(gc); |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
377 |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
378 while (act) { |
4333 | 379 if (act->data) { |
380 struct proto_actions_menu *pam = act->data; | |
381 menuitem = gtk_menu_item_new_with_label(pam->label); | |
4635 | 382 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
383 g_signal_connect(G_OBJECT(menuitem), "activate", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
384 G_CALLBACK(proto_act), pam); |
4635 | 385 g_object_set_data(G_OBJECT(menuitem), "proto_actions_menu", |
386 pam); | |
4333 | 387 gtk_widget_show(menuitem); |
388 } else { | |
1536
3a9f11c9278b
[gaim-migrate @ 1546]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1530
diff
changeset
|
389 gaim_separator(submenu); |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
390 } |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
391 act = g_list_next(act); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
392 } |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
393 c = g_slist_next(c); |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
394 } |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
395 } |
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1470
diff
changeset
|
396 } |
2050
ddd696ccb46b
[gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2007
diff
changeset
|
397 |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
398 struct mail_notify { |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
399 struct gaim_connection *gc; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
400 GtkWidget *email_win; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
401 GtkWidget *email_label; |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
402 char *url; |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
403 }; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
404 GSList *mailnots = NULL; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
405 |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
406 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
|
407 { |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
408 GSList *m = mailnots; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
409 while (m) { |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
410 if (((struct mail_notify *)m->data)->gc == gc) |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
411 return m->data; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
412 m = m->next; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
413 } |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
414 return NULL; |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
415 } |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
416 |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
417 static void des_email_win(GtkWidget *w, struct mail_notify *mn) |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
418 { |
2428
0394552f2aab
[gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2417
diff
changeset
|
419 if (w != mn->email_win) { |
0394552f2aab
[gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2417
diff
changeset
|
420 gtk_widget_destroy(mn->email_win); |
0394552f2aab
[gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2417
diff
changeset
|
421 return; |
0394552f2aab
[gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2417
diff
changeset
|
422 } |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
423 |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
424 gaim_debug(GAIM_DEBUG_INFO, "prpl", "Removing mail notification.\n"); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
425 |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
426 mailnots = g_slist_remove(mailnots, mn); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
427 if (mn->url) |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
428 g_free(mn->url); |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
429 g_free(mn); |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
430 } |
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
431 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
432 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
|
433 { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
434 GtkWidget *hbox; |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
435 GtkWidget *vbox; |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
436 GtkWidget *urlbut; |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
437 GtkWidget *close; |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
438 |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
439 struct mail_notify *mn; |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
440 char buf[2048]; |
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
441 |
4491 | 442 if (!(gc->account->options & OPT_ACCT_MAIL_CHECK)) |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
443 return; |
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
444 |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
445 if (!(mn = find_mail_notify(gc))) { |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
446 mn = g_new0(struct mail_notify, 1); |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
447 mn->gc = gc; |
2403
8555e48c02df
[gaim-migrate @ 2416]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2401
diff
changeset
|
448 mailnots = g_slist_append(mailnots, mn); |
2401
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
449 } |
86c9b44a35ae
[gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
450 |
3694 | 451 if (count < 0) { |
452 if (from && subject) | |
4276 | 453 g_snprintf(buf, sizeof buf, _("%s has mail from %s: %s"), gc->username, from, *subject ? subject : _("No Subject")); |
3694 | 454 else |
4276 | 455 g_snprintf(buf, sizeof buf, _("%s has new mail."), gc->username); |
3694 | 456 } else if (count > 0) { |
4276 | 457 g_snprintf(buf, sizeof buf, |
458 ngettext("%s has %d new message.","%s has %d new messages.",count), gc->username, count); | |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
459 } else if (mn->email_win) { |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
460 gtk_widget_destroy(mn->email_win); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
461 return; |
2606
f00549786a9c
[gaim-migrate @ 2619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2585
diff
changeset
|
462 } else |
f00549786a9c
[gaim-migrate @ 2619]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2585
diff
changeset
|
463 return; |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
464 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
465 if (mn->email_win) { |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
466 gtk_label_set_text(GTK_LABEL(mn->email_label), buf); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
467 return; |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
468 } |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
469 |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
470 |
2725
f3c094e78609
[gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2718
diff
changeset
|
471 GAIM_DIALOG(mn->email_win); |
4074 | 472 gtk_window_set_role(GTK_WINDOW(mn->email_win), "mail"); |
4635 | 473 gtk_window_set_resizable(GTK_WINDOW(mn->email_win), TRUE); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
474 gtk_window_set_title(GTK_WINDOW(mn->email_win), _("Gaim - New Mail")); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
475 g_signal_connect(G_OBJECT(mn->email_win), "destroy", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
476 G_CALLBACK(des_email_win), mn); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
477 gtk_widget_realize(mn->email_win); |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
478 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
479 vbox = gtk_vbox_new(FALSE, 5); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
480 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
481 gtk_container_add(GTK_CONTAINER(mn->email_win), vbox); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
482 |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
483 mn->email_label = gtk_label_new(buf); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
484 gtk_label_set_text(GTK_LABEL(mn->email_label), buf); |
3493 | 485 gtk_label_set_line_wrap(GTK_LABEL(mn->email_label), TRUE); |
486 gtk_box_pack_start(GTK_BOX(vbox), mn->email_label, FALSE, TRUE, 5); | |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
487 |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
488 hbox = gtk_hbox_new(FALSE, 5); |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
489 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
490 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
491 if (url) { |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
492 mn->url = g_strdup(url); |
5024 | 493 urlbut = gaim_pixbuf_button_from_stock(_("Open Mail"), GTK_STOCK_JUMP_TO, GAIM_BUTTON_HORIZONTAL); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
494 gtk_box_pack_end(GTK_BOX(hbox), urlbut, 0, 0, 5); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
495 g_signal_connect(G_OBJECT(urlbut), "clicked", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
496 G_CALLBACK(open_url), mn->url); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
497 g_signal_connect(G_OBJECT(urlbut), "clicked", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
498 G_CALLBACK(des_email_win), mn); |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
499 } |
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2428
diff
changeset
|
500 |
5024 | 501 close = gaim_pixbuf_button_from_stock(_("Close"), GTK_STOCK_CLOSE, GAIM_BUTTON_HORIZONTAL); |
4889 | 502 gtk_window_set_focus(GTK_WINDOW(mn->email_win), close); |
503 gtk_box_pack_end(GTK_BOX(hbox), close, 0, 0, 5); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
504 g_signal_connect(G_OBJECT(close), "clicked", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
505 G_CALLBACK(des_email_win), mn); |
4889 | 506 |
5024 | 507 gtk_widget_show_all(mn->email_win); |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2151
diff
changeset
|
508 } |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
509 |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
510 struct icon_data { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
511 struct gaim_connection *gc; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
512 char *who; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
513 void *data; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
514 int len; |
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 static GList *icons = NULL; |
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 static gint find_icon_data(gconstpointer a, gconstpointer b) |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
520 { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
521 const struct icon_data *x = a; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
522 const struct icon_data *y = b; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
523 |
4793 | 524 return ((x->gc != y->gc) || gaim_utf8_strcasecmp(x->who, y->who)); |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
525 } |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
526 |
4777 | 527 void set_icon_data(struct gaim_connection *gc, const char *who, void *data, int len) |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
528 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
529 struct gaim_conversation *conv; |
3281 | 530 struct icon_data tmp; |
531 GList *l; | |
532 struct icon_data *id; | |
4757 | 533 struct buddy *b; |
4799 | 534 /* i'm going to vent here a little bit about normalize(). normalize() |
535 * uses a static buffer, so when we call functions that use normalize() from | |
536 * functions that use normalize(), whose parameters are the result of running | |
537 * normalize(), bad things happen. To prevent some of this, we're going | |
538 * to make a copy of what we get from normalize(), so we know nothing else | |
539 * touches it, and buddy icons don't go to the wrong person. Some day I | |
540 * will kill normalize(), and dance on its grave. That will be a very happy | |
541 * day for everyone. | |
542 * --ndw | |
543 */ | |
544 char *realwho = g_strdup(normalize(who)); | |
3281 | 545 tmp.gc = gc; |
4799 | 546 tmp.who = realwho; |
3281 | 547 tmp.data=NULL; |
4799 | 548 tmp.len = 0; |
3281 | 549 l = g_list_find_custom(icons, &tmp, find_icon_data); |
550 id = l ? l->data : NULL; | |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
551 |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
552 if (id) { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
553 g_free(id->data); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
554 if (!data) { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
555 icons = g_list_remove(icons, id); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
556 g_free(id->who); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
557 g_free(id); |
4799 | 558 g_free(realwho); |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
559 return; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
560 } |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
561 } else if (data) { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
562 id = g_new0(struct icon_data, 1); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
563 icons = g_list_append(icons, id); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
564 id->gc = gc; |
4799 | 565 id->who = g_strdup(realwho); |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
566 } else { |
4799 | 567 g_free(realwho); |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
568 return; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
569 } |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
570 |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
571 gaim_debug(GAIM_DEBUG_MISC, "prpl", "Got icon for %s (length %d)\n", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
572 realwho, len); |
2284
83c7123e5a7e
[gaim-migrate @ 2294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2279
diff
changeset
|
573 |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
574 id->data = g_memdup(data, len); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
575 id->len = len; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
576 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
577 /* Update the buddy icon for this user. */ |
4799 | 578 conv = gaim_find_conversation(realwho); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
579 |
4687 | 580 /* XXX Buddy Icon should probalby be part of struct buddy instead of this weird global |
581 * linked list stuff. */ | |
582 | |
4799 | 583 if ((b = gaim_find_buddy(gc->account, realwho)) != NULL) { |
4757 | 584 char *random = g_strdup_printf("%x", g_random_int()); |
585 char *filename = g_build_filename(gaim_user_dir(), "icons", random, | |
586 NULL); | |
587 char *dirname = g_build_filename(gaim_user_dir(), "icons", NULL); | |
588 char *old_icon = gaim_buddy_get_setting(b, "buddy_icon"); | |
4687 | 589 FILE *file = NULL; |
590 | |
4757 | 591 g_free(random); |
592 | |
4802 | 593 if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
594 gaim_debug(GAIM_DEBUG_INFO, "buddy icons", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
595 "Creating icon cache directory.\n"); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
596 |
4802 | 597 if(mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
598 gaim_debug(GAIM_DEBUG_ERROR, "buddy icons", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
599 "Unable to create directory %s: %s\n", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
600 dirname, strerror(errno)); |
4802 | 601 } |
4757 | 602 |
603 g_free(dirname); | |
604 | |
4687 | 605 file = fopen(filename, "wb"); |
4757 | 606 if (file) { |
607 fwrite(data, 1, len, file); | |
608 fclose(file); | |
609 } | |
610 | |
611 if(old_icon) { | |
612 unlink(old_icon); | |
613 g_free(old_icon); | |
614 } | |
615 | |
616 gaim_buddy_set_setting(b, "buddy_icon", filename); | |
617 gaim_blist_save(); | |
618 | |
619 g_free(filename); | |
620 | |
621 gaim_blist_update_buddy_icon(b); | |
4687 | 622 } |
4757 | 623 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
624 if (conv != NULL && gaim_conversation_get_gc(conv) == gc) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
625 gaim_gtkconv_update_buddy_icon(conv); |
4799 | 626 |
627 g_free(realwho); | |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
628 } |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
629 |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
630 void remove_icon_data(struct gaim_connection *gc) |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
631 { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
632 GList *list = icons; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
633 struct icon_data *id; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
634 |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
635 while (list) { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
636 id = list->data; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
637 if (id->gc == gc) { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
638 g_free(id->data); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
639 g_free(id->who); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
640 list = icons = g_list_remove(icons, id); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
641 g_free(id); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
642 } else |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
643 list = list->next; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
644 } |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
645 } |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
646 |
4777 | 647 void *get_icon_data(struct gaim_connection *gc, const char *who, int *len) |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
648 { |
2718
757688c301b5
[gaim-migrate @ 2731]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2662
diff
changeset
|
649 struct icon_data tmp = { gc, normalize(who), NULL, 0 }; |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
650 GList *l = g_list_find_custom(icons, &tmp, find_icon_data); |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
651 struct icon_data *id = l ? l->data : NULL; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
652 |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
653 if (id) { |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
654 *len = id->len; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
655 return id->data; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
656 } |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
657 |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
658 *len = 0; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
659 return NULL; |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2189
diff
changeset
|
660 } |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
661 |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
662 struct got_add { |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
663 struct gaim_connection *gc; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
664 char *who; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
665 char *alias; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
666 }; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
667 |
3730 | 668 static void dont_add(struct got_add *ga) |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
669 { |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
670 g_free(ga->who); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
671 if (ga->alias) |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
672 g_free(ga->alias); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
673 g_free(ga); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
674 } |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
675 |
3730 | 676 static void do_add(struct got_add *ga) |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
677 { |
2585
4424c670021d
[gaim-migrate @ 2598]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2582
diff
changeset
|
678 if (g_slist_find(connections, ga->gc)) |
4424c670021d
[gaim-migrate @ 2598]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2582
diff
changeset
|
679 show_add_buddy(ga->gc, ga->who, NULL, ga->alias); |
3730 | 680 dont_add(ga); |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
681 } |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
682 |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
683 void show_got_added(struct gaim_connection *gc, const char *id, |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
684 const char *who, const char *alias, const char *msg) |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
685 { |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
686 char buf[BUF_LONG]; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
687 struct got_add *ga = g_new0(struct got_add, 1); |
4687 | 688 struct buddy *b = gaim_find_buddy(gc->account, who); |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
689 |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
690 ga->gc = gc; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
691 ga->who = g_strdup(who); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
692 ga->alias = alias ? g_strdup(alias) : NULL; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
693 |
4349 | 694 |
3150 | 695 g_snprintf(buf, sizeof(buf), _("%s%s%s%s has made %s his or her buddy%s%s%s"), |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
696 who, |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
697 alias ? " (" : "", |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
698 alias ? alias : "", |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
699 alias ? ")" : "", |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
700 id ? id : gc->displayname[0] ? gc->displayname : gc->username, |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
701 msg ? ": " : ".", |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
702 msg ? msg : "", |
4349 | 703 b ? "" : _("\n\nDo you wish to add him or her to your buddy list?")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
704 |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
705 if (b) { |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
706 gaim_notify_info(NULL, NULL, _("Gaim - Information"), buf); |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
707 } |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
708 else |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
709 do_ask_dialog(_("Gaim - Confirm"), buf, ga, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
710 _("Add"), do_add, _("Cancel"), dont_add, NULL, FALSE); |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2558
diff
changeset
|
711 } |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
712 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
713 static GtkWidget *regdlg = NULL; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
714 static GtkWidget *reg_list = NULL; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
715 static GtkWidget *reg_area = NULL; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
716 static GtkWidget *reg_reg = NULL; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
717 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
718 static void delete_regdlg() |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
719 { |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
720 GtkWidget *tmp = regdlg; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
721 regdlg = NULL; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
722 if (tmp) |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
723 gtk_widget_destroy(tmp); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
724 } |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
725 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
726 static void reset_reg_dlg() |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
727 { |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
728 GSList *P = protocols; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
729 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
730 if (!regdlg) |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
731 return; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
732 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
733 while (GTK_BOX(reg_list)->children) |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
734 gtk_container_remove(GTK_CONTAINER(reg_list), |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
735 ((GtkBoxChild *)GTK_BOX(reg_list)->children->data)->widget); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
736 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
737 while (GTK_BOX(reg_area)->children) |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
738 gtk_container_remove(GTK_CONTAINER(reg_area), |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
739 ((GtkBoxChild *)GTK_BOX(reg_area)->children->data)->widget); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
740 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
741 while (P) { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
742 GaimPlugin *p = P->data; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
743 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
744 if (GAIM_PLUGIN_PROTOCOL_INFO(p)->register_user) |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
745 break; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
746 |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
747 P = P->next; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
748 } |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
749 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
750 if (!P) { |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
751 GtkWidget *no = gtk_label_new(_("You do not currently have any protocols available" |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
752 " that are able to register new accounts.")); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
753 gtk_box_pack_start(GTK_BOX(reg_area), no, FALSE, FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
754 gtk_widget_show(no); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
755 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
756 gtk_widget_set_sensitive(reg_reg, FALSE); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
757 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
758 return; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
759 } |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
760 |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
761 gtk_widget_set_sensitive(reg_reg, TRUE); |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
762 |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
763 while (P) { /* we can safely ignore all the previous ones */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
764 GaimPlugin *p = P->data; |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
765 P = P->next; |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
766 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
767 if (GAIM_PLUGIN_PROTOCOL_INFO(p)->register_user) |
2843
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
768 continue; |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
769 |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
770 /* do stuff */ |
87d11d2a7d59
[gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
771 } |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
772 } |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
773 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
774 void register_dialog() |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
775 { |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
776 /* this is just one big hack */ |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
777 GtkWidget *vbox; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
778 GtkWidget *frame; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
779 GtkWidget *hbox; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
780 GtkWidget *close; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
781 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
782 if (regdlg) { |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
783 gdk_window_raise(regdlg->window); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
784 return; |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
785 } |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
786 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
787 regdlg = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
788 gtk_window_set_title(GTK_WINDOW(regdlg), _("Gaim - Registration")); |
4074 | 789 gtk_window_set_role(GTK_WINDOW(regdlg), "register"); |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
790 gtk_widget_realize(regdlg); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
791 g_signal_connect(G_OBJECT(regdlg), "destroy", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
792 G_CALLBACK(delete_regdlg), NULL); |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
793 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
794 vbox = gtk_vbox_new(FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
795 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
796 gtk_container_add(GTK_CONTAINER(regdlg), vbox); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
797 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
798 reg_list = gtk_hbox_new(FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
799 gtk_box_pack_start(GTK_BOX(vbox), reg_list, FALSE, FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
800 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
801 frame = gtk_frame_new(_("Registration Information")); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
802 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
803 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
804 reg_area = gtk_hbox_new(FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
805 gtk_container_add(GTK_CONTAINER(frame), reg_area); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
806 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
807 hbox = gtk_hbox_new(FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
808 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
809 |
5024 | 810 close = gaim_pixbuf_button_from_stock(_("Close"), GTK_STOCK_CLOSE, GAIM_BUTTON_HORIZONTAL); |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
811 gtk_box_pack_end(GTK_BOX(hbox), close, FALSE, FALSE, 5); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
812 g_signal_connect(G_OBJECT(close), "clicked", |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5271
diff
changeset
|
813 G_CALLBACK(delete_regdlg), NULL); |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
814 |
5024 | 815 reg_reg = gaim_pixbuf_button_from_stock(_("Register"), GTK_STOCK_JUMP_TO, GAIM_BUTTON_HORIZONTAL); |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
816 gtk_box_pack_end(GTK_BOX(hbox), reg_reg, FALSE, FALSE, 5); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
817 |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
818 /* fuck me */ |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
819 reset_reg_dlg(); |
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
820 |
5024 | 821 gtk_widget_show_all(regdlg); |
2827
51999a36c0b1
[gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2725
diff
changeset
|
822 } |
3035 | 823 |