Mercurial > pidgin
annotate src/gtkdialogs.c @ 10195:fa4973f356a1
[gaim-migrate @ 11310]
Minor updates to these 2 protocols. Yahoo! no longer crashes and
oscar is one step closer to being able to set an away message
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 16 Nov 2004 03:56:09 +0000 |
parents | 17dcff7a5c77 |
children | f37516ae6a0b |
rev | line source |
---|---|
9709 | 1 /* |
2 * gaim | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
9791 | 22 #include "internal.h" |
23 #include "gtkgaim.h" | |
9709 | 24 |
25 #include "debug.h" | |
26 #include "notify.h" | |
27 #include "prpl.h" | |
28 #include "request.h" | |
29 #include "util.h" | |
30 | |
31 #include "gtkdialogs.h" | |
32 #include "gtkimhtml.h" | |
33 #include "gtkimhtmltoolbar.h" | |
34 #include "gtklog.h" | |
35 #include "gtkutils.h" | |
36 #include "stock.h" | |
37 | |
9753 | 38 static GList *dialogwindows = NULL; |
9709 | 39 |
9753 | 40 static GtkWidget *about = NULL; |
9709 | 41 |
42 struct warning { | |
43 GtkWidget *window; | |
44 GtkWidget *anon; | |
45 char *who; | |
46 GaimConnection *gc; | |
47 }; | |
48 | |
9758 | 49 struct developer { |
50 char *name; | |
51 char *role; | |
52 char *email; | |
53 }; | |
54 | |
55 struct translator { | |
56 char *language; | |
57 char *abbr; | |
58 char *name; | |
59 char *email; | |
60 }; | |
61 | |
62 static struct developer developers[] = { | |
63 {"Rob Flynn", N_("maintainer"), "gaim@robflynn.com"}, | |
64 {"Sean Egan", N_("lead developer"), "sean.egan@binghamton.edu"}, | |
65 {"Christian 'ChipX86' Hammond", N_("developer & webmaster"), NULL}, | |
10095
b28f9be379b3
[gaim-migrate @ 11114]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
9991
diff
changeset
|
66 {"Herman Bloggs", N_("win32 port"), "herman@bluedigits.com"}, |
9758 | 67 {"Nathan 'faceprint' Walp", N_("developer"), NULL}, |
68 {"Mark 'KingAnt' Doliner", N_("developer"), NULL}, | |
69 {"Ethan 'Paco-Paco' Blanton", N_("developer"), NULL}, | |
70 {"Tim 'marv' Ringenbach", N_("developer"), NULL}, | |
71 {"Luke 'LSchiere' Schierer", N_("support"), NULL}, | |
10116 | 72 {"Stu 'nosnilmot' Tomlinson", N_("developer"), NULL}, |
9758 | 73 {NULL, NULL, NULL} |
74 }; | |
75 | |
76 static struct developer retired_developers[] = { | |
77 {"Adam Fritzler", N_("former libfaim maintainer"), NULL}, | |
78 {"Eric Warmenhoven", N_("former lead developer"), "warmenhoven@yahoo.com"}, | |
79 {"Jim Duchek", N_("former maintainer"), NULL}, | |
80 {"Jim Seymour", N_("former Jabber developer"), NULL}, | |
81 {"Mark Spencer", N_("original author"), "markster@marko.net"}, | |
82 {"Syd Logan", N_("hacker and designated driver [lazy bum]"), NULL}, | |
83 {NULL, NULL, NULL} | |
84 }; | |
85 | |
86 static struct translator current_translators[] = { | |
87 {N_("Bulgarian"), "bg", "Alexander Shopov", "al_shopov@users.sf.net"}, | |
10131 | 88 {N_("Catalan"), "ca", "Josep Puigdemont", "tradgnome@softcatala.org"}, |
9758 | 89 {N_("Czech"), "cs", "Miloslav Trmac", "mitr@volny.cz"}, |
90 {N_("Danish"), "da", "Morten Brix Pedersen", "morten@wtf.dk"}, | |
10131 | 91 {N_("Australian English"), "en_AU", "Peter Lawler", "trans@six-by-nine.com.au"}, |
9758 | 92 {N_("British English"), "en_GB", "Luke Ross", "lukeross@sys3175.co.uk"}, |
93 {N_("Canadian English"), "en_CA", "Adam Weinberger", "adamw@gnome.org"}, | |
94 {N_("German"), "de", "Björn Voigt", "bjoern@cs.tu-berlin.de"}, | |
95 {N_("Spanish"), "es", "Javier Fernández-Sanguino Peña", "jfs@debian.org"}, | |
96 {N_("Finnish"), "fi", "Arto Alakulju", "arto@alakulju.net"}, | |
97 {N_("French"), "fr", "Éric Boumaour", "zongo_fr@users.sourceforge.net"}, | |
98 {N_("Hebrew"), "he", "Pavel Bibergal", "cyberkm203@hotmail.com"}, | |
99 {N_("Hindi"), "hi", "Ravishankar Shrivastava", "raviratlami@yahoo.com"}, | |
100 {N_("Hungarian"), "hu", "Zoltan Sutto", "suttozoltan@chello.hu"}, | |
101 {N_("Italian"), "it", "Claudio Satriano", "satriano@na.infn.it"}, | |
102 {N_("Japanese"), "ja", "Takashi Aihana", "aihana@gnome.gr.jp"}, | |
103 {N_("Lithuanian"), "lt", "Gediminas Čičinskas", "gediminas@parok.lt"}, | |
104 {N_("Korean"), "ko", "Kyung-uk Son", "vvs740@chol.com"}, | |
105 {N_("Dutch; Flemish"), "nl", "Vincent van Adrighem", "V.vanAdrighem@dirck.mine.nu"}, | |
106 {N_("Macedonian"), "mk", "Tomislav Markovski", "herrera@users.sf.net"}, | |
107 {N_("Norwegian"), "no", "Petter Johan Olsen", "petter.olsen@cc.uit.no"}, | |
108 {N_("Polish"), "pl", "Krzysztof Foltman, Emil Nowak", "krzysztof@foltman.com;emil5@go2.pl"}, | |
109 {N_("Portuguese"), "pt", "Duarte Henriques", "duarte_henriques@myrealbox.com"}, | |
110 {N_("Portuguese-Brazil"), "pt_BR", "Maurício de Lemos Rodrigues Collares Neto", "mauricioc@gmail.com"}, | |
111 {N_("Romanian"), "ro", "Mişu Moldovan", "dumol@go.ro"}, | |
112 {N_("Russian"), "ru", "Dmitry Beloglazov", "dmaa@users.sf.net"}, | |
113 {N_("Serbian"), "sr", "Danilo Šegan, Aleksandar Urosevic", "dsegan@gmx.net;urke@users.sourceforge.net"}, | |
114 {N_("Slovenian"), "sl", "Matjaz Horvat", "matjaz@owca.info"}, | |
115 {N_("Swedish"), "sv", "Tore Lundqvist", "tlt@mima.x.se"}, | |
116 {N_("Vietnamese"), "vi", N_("T.M.Thanh and the Gnome-Vi Team"), "gnomevi-list@lists.sf.net"}, | |
117 {N_("Simplified Chinese"), "zh_CN", "Funda Wang", "fundawang@linux.net.cn"}, | |
118 {N_("Traditional Chinese"), "zh_TW", "Ambrose C. Li, Paladin R. Liu", "acli@ada.dhs.org;paladin@ms1.hinet.net"}, | |
119 {NULL, NULL, NULL, NULL} | |
120 }; | |
121 | |
122 | |
123 static struct translator past_translators[] = { | |
124 {N_("Amharic"), "am", "Daniel Yacob", NULL}, | |
125 {N_("Bulgarian"), "bg", "Hristo Todorov", NULL}, | |
126 {N_("Catalan"), "ca", "JM Pérez Cáncer", NULL}, | |
10131 | 127 {N_("Catalan"), "ca", "Robert Millan", NULL}, |
9758 | 128 {N_("Czech"), "cs", "Honza Král", NULL}, |
129 {N_("German"), "de", "Daniel Seifert, Karsten Weiss", NULL}, | |
130 {N_("Spanish"), "es", "Amaya Rodrigo, Alejandro G Villar, Nicolás Lichtmaier, JM Pérez Cáncer", NULL}, | |
131 {N_("Finnish"), "fi", "Tero Kuusela", NULL}, | |
132 {N_("French"), "fr", "Sébastien François, Stéphane Pontier, Stéphane Wirtel, Loïc Jeannin", NULL}, | |
133 {N_("Italian"), "it", "Salvatore di Maggio", NULL}, | |
134 {N_("Japanese"), "ja", "Ryosuke Kutsuna, Taku Yasui, Junichi Uekawa", NULL}, | |
135 {N_("Korean"), "ko", "Sang-hyun S, A Ho-seok Lee", NULL}, | |
136 {N_("Polish"), "pl", "Przemysław Sułek", NULL}, | |
137 {N_("Russian"), "ru", "Sergey Volozhanin", NULL}, | |
138 {N_("Russian"), "ru", "Alexandre Prokoudine", NULL}, | |
139 {N_("Slovak"), "sk", "Daniel Režný", NULL}, | |
140 {N_("Swedish"), "sv", "Christian Rose", NULL}, | |
141 {N_("Chinese"), "zh_CN, zh_TW", "Hashao, Rocky S. Lee", NULL}, | |
142 {NULL, NULL, NULL, NULL} | |
143 }; | |
144 | |
9730 | 145 void |
146 gaim_gtkdialogs_destroy_all() | |
9709 | 147 { |
9753 | 148 while (dialogwindows) { |
149 gtk_widget_destroy(dialogwindows->data); | |
150 dialogwindows = g_list_remove(dialogwindows, dialogwindows->data); | |
151 } | |
152 } | |
153 | |
154 static void destroy_about() | |
155 { | |
156 if (about != NULL) | |
157 gtk_widget_destroy(about); | |
158 about = NULL; | |
159 } | |
160 | |
161 void gaim_gtkdialogs_about(GtkWidget *w, void *data) | |
162 { | |
163 GtkWidget *hbox; | |
164 GtkWidget *vbox; | |
165 GtkWidget *logo; | |
10175 | 166 GtkWidget *frame; |
9753 | 167 GtkWidget *text; |
168 GtkWidget *bbox; | |
169 GtkWidget *button; | |
170 GtkTextIter iter; | |
9758 | 171 GString *str; |
172 int i; | |
9753 | 173 |
174 if (about != NULL) { | |
175 gtk_window_present(GTK_WINDOW(about)); | |
176 return; | |
177 } | |
178 | |
179 GAIM_DIALOG(about); | |
180 gtk_window_set_default_size(GTK_WINDOW(about), 450, -1); | |
181 gtk_window_set_title(GTK_WINDOW(about), _("About Gaim")); | |
182 gtk_window_set_role(GTK_WINDOW(about), "about"); | |
183 gtk_window_set_resizable(GTK_WINDOW(about), TRUE); | |
9778 | 184 gtk_window_set_default_size(GTK_WINDOW(about), 340, 550); /* Golden ratio in da hizzy */ |
9753 | 185 |
186 hbox = gtk_hbox_new(FALSE, 12); | |
187 gtk_container_set_border_width(GTK_CONTAINER(hbox), 12); | |
188 gtk_container_add(GTK_CONTAINER(about), hbox); | |
189 | |
190 vbox = gtk_vbox_new(FALSE, 12); | |
191 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
192 | |
193 logo = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO)); | |
194 gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 0); | |
195 | |
10175 | 196 frame = gaim_gtk_create_imhtml(FALSE, &text, NULL); |
197 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
9753 | 198 |
9758 | 199 str = g_string_sized_new(4096); |
9753 | 200 |
10153 | 201 g_string_append(str, |
9758 | 202 _("Gaim is a modular messaging client capable of using " |
203 "AIM, MSN, Yahoo!, Jabber, ICQ, IRC, SILC, " | |
204 "Novell GroupWise, Napster, Zephyr, and Gadu-Gadu " | |
205 "all at once. It is written using " | |
206 "Gtk+ and is licensed under the GPL.<BR><BR>")); | |
9753 | 207 |
9758 | 208 g_string_append(str, "<FONT SIZE=\"4\">URL:</FONT> <A HREF=\"" |
209 GAIM_WEBSITE "\">" GAIM_WEBSITE "</A><BR/><BR/>"); | |
210 | |
211 g_string_append_printf(str, _("<FONT SIZE=\"4\">IRC:</FONT> " | |
212 "#gaim on irc.freenode.net<BR><BR>")); | |
9753 | 213 |
214 /* Active Developers */ | |
9758 | 215 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
216 _("Active Developers")); | |
217 for (i = 0; developers[i].name != NULL; i++) { | |
218 if (developers[i].email != NULL) { | |
10116 | 219 g_string_append_printf(str, " %s (%s) <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 220 developers[i].name, _(developers[i].role), |
221 developers[i].email, developers[i].email); | |
222 } else { | |
223 g_string_append_printf(str, " %s (%s)<br/>", | |
224 developers[i].name, _(developers[i].role)); | |
225 } | |
226 } | |
227 g_string_append(str, "<BR/>"); | |
9709 | 228 |
9753 | 229 /* Crazy Patch Writers */ |
9758 | 230 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
231 _("Crazy Patch Writers")); | |
232 g_string_append(str, | |
233 " Daniel 'datallah' Atallah<BR>" | |
234 " Ka-Hing 'javabsp' Cheung<BR>" | |
9905 | 235 " Felipe 'shx' Contreras<BR>" |
9758 | 236 " Decklin Foster<BR>" |
237 " Gary 'grim' Kramlich<BR>" | |
238 " Robert 'Robot101' McQueen<BR>" | |
239 " Benjamin Miller<BR>" | |
240 " Etan 'deryni' Reisner<BR>" | |
241 " Kevin 'SimGuy' Stange<BR>" | |
242 "<BR>"); | |
9753 | 243 |
244 /* Retired Developers */ | |
9758 | 245 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
246 _("Retired Developers")); | |
247 for (i = 0; retired_developers[i].name != NULL; i++) { | |
248 if (retired_developers[i].email != NULL) { | |
10116 | 249 g_string_append_printf(str, " %s (%s) <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 250 retired_developers[i].name, _(retired_developers[i].role), |
251 retired_developers[i].email, retired_developers[i].email); | |
252 } else { | |
253 g_string_append_printf(str, " %s (%s)<br/>", | |
254 retired_developers[i].name, _(retired_developers[i].role)); | |
255 } | |
256 } | |
257 g_string_append(str, "<BR/>"); | |
9753 | 258 |
259 /* Current Translators */ | |
9758 | 260 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
261 _("Current Translators")); | |
262 for (i = 0; current_translators[i].language != NULL; i++) { | |
263 if (current_translators[i].email != NULL) { | |
10116 | 264 g_string_append_printf(str, " <b>%s (%s)</b> - %s <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 265 _(current_translators[i].language), |
266 current_translators[i].abbr, | |
267 _(current_translators[i].name), | |
268 current_translators[i].email, | |
269 current_translators[i].email); | |
270 } else { | |
271 g_string_append_printf(str, " <b>%s (%s)</b> - %s<br/>", | |
272 _(current_translators[i].language), | |
273 current_translators[i].abbr, | |
274 _(current_translators[i].name)); | |
275 } | |
276 } | |
277 g_string_append(str, "<BR/>"); | |
9753 | 278 |
279 /* Past Translators */ | |
9758 | 280 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
281 _("Past Translators")); | |
282 for (i = 0; past_translators[i].language != NULL; i++) { | |
283 if (past_translators[i].email != NULL) { | |
10116 | 284 g_string_append_printf(str, " <b>%s (%s)</b> - %s <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 285 _(past_translators[i].language), |
286 past_translators[i].abbr, | |
287 _(past_translators[i].name), | |
288 past_translators[i].email, | |
289 past_translators[i].email); | |
290 } else { | |
291 g_string_append_printf(str, " <b>%s (%s)</b> - %s<br/>", | |
292 _(past_translators[i].language), | |
293 past_translators[i].abbr, | |
294 _(past_translators[i].name)); | |
295 } | |
296 } | |
297 g_string_append(str, "<BR/>"); | |
298 | |
299 gtk_imhtml_append_text(GTK_IMHTML(text), str->str, GTK_IMHTML_NO_SCROLL); | |
300 g_string_free(str, TRUE); | |
9753 | 301 |
302 gtk_text_buffer_get_start_iter(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), &iter); | |
303 gtk_text_buffer_place_cursor(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), &iter); | |
10153 | 304 |
9753 | 305 /* Close Button */ |
306 bbox = gtk_hbutton_box_new(); | |
307 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
308 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
309 | |
310 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
311 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
312 | |
313 g_signal_connect_swapped(G_OBJECT(button), "clicked", | |
314 G_CALLBACK(destroy_about), G_OBJECT(about)); | |
315 g_signal_connect(G_OBJECT(about), "destroy", | |
316 G_CALLBACK(destroy_about), G_OBJECT(about)); | |
317 | |
318 /* this makes the sizes not work? */ | |
319 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
320 gtk_widget_grab_default(button); | |
321 | |
322 /* Let's give'em something to talk about -- woah woah woah */ | |
323 gtk_widget_show_all(about); | |
324 gtk_window_present(GTK_WINDOW(about)); | |
9709 | 325 } |
326 | |
9730 | 327 static void |
328 gaim_gtkdialogs_im_cb(gpointer data, GaimRequestFields *fields) | |
9709 | 329 { |
9730 | 330 GaimAccount *account; |
331 const char *username; | |
9709 | 332 |
9730 | 333 account = gaim_request_fields_get_account(fields, "account"); |
334 username = gaim_request_fields_get_string(fields, "screenname"); | |
9709 | 335 |
9730 | 336 gaim_gtkdialogs_im_with_user(account, username); |
9709 | 337 } |
338 | |
9730 | 339 void |
340 gaim_gtkdialogs_im(void) | |
9709 | 341 { |
9730 | 342 GaimRequestFields *fields; |
343 GaimRequestFieldGroup *group; | |
344 GaimRequestField *field; | |
9709 | 345 |
9730 | 346 fields = gaim_request_fields_new(); |
9709 | 347 |
9730 | 348 group = gaim_request_field_group_new(NULL); |
349 gaim_request_fields_add_group(fields, group); | |
9709 | 350 |
9730 | 351 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
352 NULL, FALSE); | |
353 gaim_request_field_set_required(field, TRUE); | |
354 gaim_request_field_set_type_hint(field, "screenname"); | |
355 gaim_request_field_group_add_field(group, field); | |
9709 | 356 |
9730 | 357 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
358 gaim_request_field_set_visible(field, | |
359 (gaim_connections_get_all() != NULL && | |
360 gaim_connections_get_all()->next != NULL)); | |
361 gaim_request_field_set_required(field, TRUE); | |
362 gaim_request_field_group_add_field(group, field); | |
363 | |
364 gaim_request_fields(gaim_get_blist(), _("New Instant Message"), | |
365 NULL, | |
366 _("Please enter the screen name of the person you " | |
367 "would like to IM."), | |
368 fields, | |
369 _("OK"), G_CALLBACK(gaim_gtkdialogs_im_cb), | |
370 _("Cancel"), NULL, | |
371 NULL); | |
9709 | 372 } |
373 | |
9730 | 374 void |
375 gaim_gtkdialogs_im_with_user(GaimAccount *account, const char *username) | |
9709 | 376 { |
9730 | 377 GaimConversation *conv; |
378 GaimConvWindow *win; | |
379 GaimGtkWindow *gtkwin; | |
9709 | 380 |
9753 | 381 g_return_if_fail(account != NULL); |
382 g_return_if_fail(username != NULL); | |
383 | |
9730 | 384 conv = gaim_find_conversation_with_account(username, account); |
9709 | 385 |
9730 | 386 if (conv == NULL) |
387 conv = gaim_conversation_new(GAIM_CONV_IM, account, username); | |
9709 | 388 |
9730 | 389 win = gaim_conversation_get_window(conv); |
390 gtkwin = GAIM_GTK_WINDOW(win); | |
9709 | 391 |
9730 | 392 gtk_window_present(GTK_WINDOW(gtkwin->window)); |
393 gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv)); | |
9709 | 394 } |
395 | |
9730 | 396 static gboolean |
397 gaim_gtkdialogs_ee(const char *ee) | |
9709 | 398 { |
399 GtkWidget *window; | |
400 GtkWidget *hbox; | |
401 GtkWidget *label; | |
402 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_COOL, GTK_ICON_SIZE_DIALOG); | |
403 gchar *norm = gaim_strreplace(ee, "rocksmyworld", ""); | |
404 | |
405 label = gtk_label_new(NULL); | |
406 if (!strcmp(norm, "zilding")) | |
407 gtk_label_set_markup(GTK_LABEL(label), | |
408 "<span weight=\"bold\" size=\"large\" foreground=\"purple\">Amazing! Simply Amazing!</span>"); | |
409 else if (!strcmp(norm, "robflynn")) | |
410 gtk_label_set_markup(GTK_LABEL(label), | |
411 "<span weight=\"bold\" size=\"large\" foreground=\"#1f6bad\">Pimpin\' Penguin Style! *Waddle Waddle*</span>"); | |
412 else if (!strcmp(norm, "flynorange")) | |
413 gtk_label_set_markup(GTK_LABEL(label), | |
414 "<span weight=\"bold\" size=\"large\" foreground=\"blue\">You should be me. I'm so cute!</span>"); | |
415 else if (!strcmp(norm, "ewarmenhoven")) | |
416 gtk_label_set_markup(GTK_LABEL(label), | |
417 "<span weight=\"bold\" size=\"large\" foreground=\"orange\">Now that's what I like!</span>"); | |
418 else if (!strcmp(norm, "markster97")) | |
419 gtk_label_set_markup(GTK_LABEL(label), | |
420 "<span weight=\"bold\" size=\"large\" foreground=\"brown\">Ahh, and excellent choice!</span>"); | |
421 else if (!strcmp(norm, "seanegn")) | |
422 gtk_label_set_markup(GTK_LABEL(label), | |
423 "<span weight=\"bold\" size=\"large\" foreground=\"#009900\">Everytime you click my name, an angel gets its wings.</span>"); | |
424 else if (!strcmp(norm, "chipx86")) | |
425 gtk_label_set_markup(GTK_LABEL(label), | |
426 "<span weight=\"bold\" size=\"large\" foreground=\"red\">This sunflower seed taste like pizza.</span>"); | |
427 else if (!strcmp(norm, "markdoliner")) | |
428 gtk_label_set_markup(GTK_LABEL(label), | |
429 "<span weight=\"bold\" size=\"large\" foreground=\"#6364B1\">Hey! I was in that tumbleweed!</span>"); | |
430 else if (!strcmp(norm, "lschiere")) | |
431 gtk_label_set_markup(GTK_LABEL(label), | |
432 "<span weight=\"bold\" size=\"large\" foreground=\"gray\">I'm not anything.</span>"); | |
433 g_free(norm); | |
434 | |
435 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0) | |
436 return FALSE; | |
437 | |
438 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
439 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); | |
440 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL); | |
441 | |
442 gtk_container_set_border_width (GTK_CONTAINER(window), 6); | |
443 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
444 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); | |
445 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); | |
446 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); | |
447 | |
448 hbox = gtk_hbox_new(FALSE, 12); | |
449 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); | |
450 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
451 | |
452 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
453 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
454 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
455 | |
456 gtk_widget_show_all(window); | |
457 return TRUE; | |
458 } | |
459 | |
460 static void | |
9730 | 461 gaim_gtkdialogs_info_cb(gpointer data, GaimRequestFields *fields) |
9709 | 462 { |
463 char *username; | |
464 gboolean found = FALSE; | |
465 GaimAccount *account; | |
466 | |
467 account = gaim_request_fields_get_account(fields, "account"); | |
468 | |
469 username = g_strdup(gaim_normalize(account, | |
470 gaim_request_fields_get_string(fields, "screenname"))); | |
471 | |
472 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld")) | |
9730 | 473 found = gaim_gtkdialogs_ee(username); |
9709 | 474 |
475 if (!found && username != NULL && *username != '\0' && account != NULL) | |
476 serv_get_info(gaim_account_get_connection(account), username); | |
477 | |
478 g_free(username); | |
479 } | |
480 | |
481 void | |
9714 | 482 gaim_gtkdialogs_info(void) |
9709 | 483 { |
484 GaimRequestFields *fields; | |
485 GaimRequestFieldGroup *group; | |
486 GaimRequestField *field; | |
487 | |
488 fields = gaim_request_fields_new(); | |
489 | |
490 group = gaim_request_field_group_new(NULL); | |
491 gaim_request_fields_add_group(fields, group); | |
492 | |
493 field = gaim_request_field_string_new("screenname", _("_Screen name"), | |
494 NULL, FALSE); | |
495 gaim_request_field_set_type_hint(field, "screenname"); | |
496 gaim_request_field_set_required(field, TRUE); | |
497 gaim_request_field_group_add_field(group, field); | |
498 | |
499 field = gaim_request_field_account_new("account", _("_Account"), NULL); | |
500 gaim_request_field_set_visible(field, | |
501 (gaim_connections_get_all() != NULL && | |
502 gaim_connections_get_all()->next != NULL)); | |
503 gaim_request_field_set_required(field, TRUE); | |
504 gaim_request_field_group_add_field(group, field); | |
505 | |
506 gaim_request_fields(gaim_get_blist(), _("Get User Info"), | |
507 NULL, | |
508 _("Please enter the screen name of the person whose " | |
509 "info you would like to view."), | |
510 fields, | |
9730 | 511 _("OK"), G_CALLBACK(gaim_gtkdialogs_info_cb), |
9709 | 512 _("Cancel"), NULL, |
513 NULL); | |
514 } | |
515 | |
516 static void | |
9730 | 517 gaim_gtkdialogs_log_cb(gpointer data, GaimRequestFields *fields) |
9709 | 518 { |
519 char *username; | |
520 GaimAccount *account; | |
521 | |
522 account = gaim_request_fields_get_account(fields, "account"); | |
523 | |
524 username = g_strdup(gaim_normalize(account, | |
525 gaim_request_fields_get_string(fields, "screenname"))); | |
526 | |
9917 | 527 if(username != NULL && *username != '\0' && account != NULL ) |
528 gaim_gtk_log_show(GAIM_LOG_IM, username, account); | |
9709 | 529 |
530 g_free(username); | |
531 } | |
532 | |
9991 | 533 /* |
534 * TODO - This needs to deal with logs of all types, not just IM logs. | |
535 */ | |
9709 | 536 void |
9714 | 537 gaim_gtkdialogs_log(void) |
9709 | 538 { |
539 GaimRequestFields *fields; | |
540 GaimRequestFieldGroup *group; | |
541 GaimRequestField *field; | |
542 | |
543 fields = gaim_request_fields_new(); | |
544 | |
545 group = gaim_request_field_group_new(NULL); | |
546 gaim_request_fields_add_group(fields, group); | |
547 | |
548 field = gaim_request_field_string_new("screenname", _("_Screen name"), | |
549 NULL, FALSE); | |
550 gaim_request_field_set_type_hint(field, "screenname"); | |
551 gaim_request_field_set_required(field, TRUE); | |
552 gaim_request_field_group_add_field(group, field); | |
553 | |
554 field = gaim_request_field_account_new("account", _("_Account"), NULL); | |
555 gaim_request_field_account_set_show_all(field, TRUE); | |
556 gaim_request_field_set_visible(field, | |
557 (gaim_accounts_get_all() != NULL && | |
558 gaim_accounts_get_all()->next != NULL)); | |
559 gaim_request_field_set_required(field, TRUE); | |
560 gaim_request_field_group_add_field(group, field); | |
561 | |
562 gaim_request_fields(gaim_get_blist(), _("Get User Log"), | |
563 NULL, | |
564 _("Please enter the screen name of the person whose " | |
565 "log you would like to view."), | |
566 fields, | |
9730 | 567 _("OK"), G_CALLBACK(gaim_gtkdialogs_log_cb), |
9709 | 568 _("Cancel"), NULL, |
569 NULL); | |
570 } | |
571 | |
9730 | 572 static void |
573 gaim_gtkdialogs_warn_cb(GtkWidget *widget, gint resp, struct warning *w) | |
9709 | 574 { |
9730 | 575 if (resp == GTK_RESPONSE_OK) |
9753 | 576 serv_warn(w->gc, w->who, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))); |
9709 | 577 |
9753 | 578 dialogwindows = g_list_remove(dialogwindows, w->window); |
579 gtk_widget_destroy(w->window); | |
580 | |
9730 | 581 g_free(w->who); |
582 g_free(w); | |
9709 | 583 } |
584 | |
9753 | 585 /* |
9991 | 586 * TODO - Make this use the request API, if possible. |
9753 | 587 */ |
9730 | 588 void |
589 gaim_gtkdialogs_warn(GaimConnection *gc, const char *who) | |
9709 | 590 { |
9753 | 591 gchar *labeltext; |
9730 | 592 GtkWidget *hbox, *vbox; |
9709 | 593 GtkWidget *label; |
9753 | 594 GtkWidget *img; |
595 struct warning *w; | |
9730 | 596 |
9753 | 597 g_return_if_fail(gc != NULL); |
598 g_return_if_fail(who != NULL); | |
599 | |
600 w = g_new0(struct warning, 1); | |
9730 | 601 w->who = g_strdup(who); |
602 w->gc = gc; | |
603 | |
9753 | 604 w->window = gtk_dialog_new_with_buttons(_("Warn User"), NULL, 0, |
9730 | 605 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
606 GAIM_STOCK_WARN, GTK_RESPONSE_OK, NULL); | |
607 gtk_dialog_set_default_response (GTK_DIALOG(w->window), GTK_RESPONSE_OK); | |
608 g_signal_connect(G_OBJECT(w->window), "response", G_CALLBACK(gaim_gtkdialogs_warn_cb), w); | |
609 | |
610 gtk_container_set_border_width (GTK_CONTAINER(w->window), 6); | |
611 gtk_window_set_resizable(GTK_WINDOW(w->window), FALSE); | |
612 gtk_dialog_set_has_separator(GTK_DIALOG(w->window), FALSE); | |
613 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(w->window)->vbox), 12); | |
614 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), 6); | |
9709 | 615 |
616 hbox = gtk_hbox_new(FALSE, 12); | |
9730 | 617 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), hbox); |
9753 | 618 |
619 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); | |
620 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
9730 | 621 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
9709 | 622 |
9730 | 623 vbox = gtk_vbox_new(FALSE, 0); |
624 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
625 labeltext = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">Warn %s?</span>\n\n" | |
626 "This will increase %s's warning level and he or she will be subject to harsher rate limiting.\n"), who, who); | |
627 label = gtk_label_new(NULL); | |
628 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
629 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
630 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
631 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
632 g_free(labeltext); | |
9709 | 633 |
9730 | 634 w->anon = gtk_check_button_new_with_mnemonic(_("Warn _anonymously?")); |
635 gtk_box_pack_start(GTK_BOX(vbox), w->anon, FALSE, FALSE, 0); | |
636 | |
637 hbox = gtk_hbox_new(FALSE, 6); | |
638 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
639 img = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU); | |
640 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
641 labeltext = _("<b>Anonymous warnings are less severe.</b>"); | |
642 label = gtk_label_new(NULL); | |
643 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
644 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
9709 | 645 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
646 | |
9730 | 647 dialogwindows = g_list_prepend(dialogwindows, w->window); |
648 gtk_widget_show_all(w->window); | |
9709 | 649 } |
650 | |
651 static void | |
9730 | 652 gaim_gtkdialogs_alias_contact_cb(GaimContact *contact, const char *new_alias) |
653 { | |
654 gaim_contact_set_alias(contact, new_alias); | |
655 } | |
656 | |
657 void | |
658 gaim_gtkdialogs_alias_contact(GaimContact *contact) | |
659 { | |
9753 | 660 g_return_if_fail(contact != NULL); |
661 | |
9730 | 662 gaim_request_input(NULL, _("Alias Contact"), NULL, |
663 _("Enter an alias for this contact."), | |
664 contact->alias, FALSE, FALSE, NULL, | |
665 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_contact_cb), | |
666 _("Cancel"), NULL, contact); | |
667 } | |
668 | |
669 static void | |
670 gaim_gtkdialogs_alias_buddy_cb(GaimBuddy *buddy, const char *new_alias) | |
671 { | |
672 gaim_blist_alias_buddy(buddy, new_alias); | |
673 serv_alias_buddy(buddy); | |
674 } | |
675 | |
676 void | |
9753 | 677 gaim_gtkdialogs_alias_buddy(GaimBuddy *buddy) |
9730 | 678 { |
9753 | 679 gchar *secondary; |
680 | |
681 g_return_if_fail(buddy != NULL); | |
682 | |
683 secondary = g_strdup_printf(_("Enter an alias for %s."), buddy->name); | |
9730 | 684 |
685 gaim_request_input(NULL, _("Alias Buddy"), NULL, | |
9753 | 686 secondary, buddy->alias, FALSE, FALSE, NULL, |
9730 | 687 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_buddy_cb), |
9753 | 688 _("Cancel"), NULL, buddy); |
9730 | 689 |
690 g_free(secondary); | |
691 } | |
692 | |
693 static void | |
694 gaim_gtkdialogs_alias_chat_cb(GaimChat *chat, const char *new_alias) | |
9709 | 695 { |
696 gaim_blist_alias_chat(chat, new_alias); | |
697 } | |
698 | |
699 void | |
9730 | 700 gaim_gtkdialogs_alias_chat(GaimChat *chat) |
9709 | 701 { |
9753 | 702 g_return_if_fail(chat != NULL); |
703 | |
9709 | 704 gaim_request_input(NULL, _("Alias Chat"), NULL, |
705 _("Enter an alias for this chat."), | |
706 chat->alias, FALSE, FALSE, NULL, | |
9730 | 707 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_chat_cb), |
9709 | 708 _("Cancel"), NULL, chat); |
709 } | |
710 | |
711 static void | |
9753 | 712 gaim_gtkdialogs_remove_contact_cb(GaimContact *contact) |
9709 | 713 { |
9730 | 714 GaimBlistNode *bnode, *cnode; |
715 GaimGroup *group; | |
716 | |
717 cnode = (GaimBlistNode *)contact; | |
718 group = (GaimGroup*)cnode->parent; | |
719 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
720 GaimBuddy *buddy = (GaimBuddy*)bnode; | |
721 if (gaim_account_is_connected(buddy->account)) | |
722 serv_remove_buddy(buddy->account->gc, buddy, group); | |
723 } | |
724 gaim_blist_remove_contact(contact); | |
725 } | |
726 | |
727 void | |
728 gaim_gtkdialogs_remove_contact(GaimContact *contact) | |
729 { | |
730 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact); | |
731 | |
9753 | 732 g_return_if_fail(contact != NULL); |
733 g_return_if_fail(buddy != NULL); | |
9730 | 734 |
735 if (((GaimBlistNode*)contact)->child == (GaimBlistNode*)buddy && | |
736 !((GaimBlistNode*)buddy)->next) { | |
737 gaim_gtkdialogs_remove_buddy(buddy); | |
738 } else { | |
9753 | 739 gchar *text = g_strdup_printf(_("You are about to remove the contact containing %s and %d other buddies from your buddy list. Do you want to continue?"), |
9730 | 740 buddy->name, contact->totalsize - 1); |
741 | |
9976 | 742 gaim_request_action(NULL, NULL, _("Remove Contact"), text, 0, contact, 2, |
9753 | 743 _("Remove Contact"), G_CALLBACK(gaim_gtkdialogs_remove_contact_cb), |
9730 | 744 _("Cancel"), NULL); |
745 | |
746 g_free(text); | |
747 } | |
9709 | 748 } |
749 | |
750 void | |
9753 | 751 gaim_gtkdialogs_remove_group_cb(GaimGroup *group) |
9709 | 752 { |
9730 | 753 GaimBlistNode *cnode, *bnode; |
754 | |
755 cnode = ((GaimBlistNode*)group)->child; | |
756 | |
757 while (cnode) { | |
758 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
759 bnode = cnode->child; | |
760 cnode = cnode->next; | |
761 while (bnode) { | |
762 GaimBuddy *buddy; | |
763 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
764 GaimConversation *conv; | |
765 buddy = (GaimBuddy*)bnode; | |
766 bnode = bnode->next; | |
767 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); | |
768 if (gaim_account_is_connected(buddy->account)) { | |
769 serv_remove_buddy(buddy->account->gc, buddy, group); | |
770 gaim_blist_remove_buddy(buddy); | |
771 if (conv) | |
772 gaim_conversation_update(conv, | |
773 GAIM_CONV_UPDATE_REMOVE); | |
774 } | |
775 } else { | |
776 bnode = bnode->next; | |
777 } | |
778 } | |
779 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
780 GaimChat *chat = (GaimChat *)cnode; | |
781 cnode = cnode->next; | |
782 if (gaim_account_is_connected(chat->account)) | |
783 gaim_blist_remove_chat(chat); | |
784 } else { | |
785 cnode = cnode->next; | |
786 } | |
787 } | |
788 | |
789 gaim_blist_remove_group(group); | |
790 } | |
791 | |
792 void | |
793 gaim_gtkdialogs_remove_group(GaimGroup *group) | |
794 { | |
9753 | 795 gchar *text; |
796 | |
797 g_return_if_fail(group != NULL); | |
798 | |
799 text = g_strdup_printf(_("You are about to remove the group %s and all its members from your buddy list. Do you want to continue?"), | |
800 group->name); | |
9730 | 801 |
9976 | 802 gaim_request_action(NULL, NULL, _("Remove Group"), text, 0, group, 2, |
9753 | 803 _("Remove Group"), G_CALLBACK(gaim_gtkdialogs_remove_group_cb), |
9730 | 804 _("Cancel"), NULL); |
805 | |
806 g_free(text); | |
9709 | 807 } |
808 | |
809 static void | |
9753 | 810 gaim_gtkdialogs_remove_buddy_cb(GaimBuddy *buddy) |
9709 | 811 { |
9730 | 812 GaimGroup *group; |
813 GaimConversation *conv; | |
814 gchar *name; | |
815 GaimAccount *account; | |
816 | |
817 group = gaim_find_buddys_group(buddy); | |
818 name = g_strdup(buddy->name); /* b->name is a crasher after remove_buddy */ | |
819 account = buddy->account; | |
820 | |
9753 | 821 gaim_debug_info("blist", "Removing '%s' from buddy list.\n", buddy->name); |
9991 | 822 /* TODO - Should remove from blist first... then call serv_remove_buddy()? */ |
9730 | 823 serv_remove_buddy(buddy->account->gc, buddy, group); |
824 gaim_blist_remove_buddy(buddy); | |
825 | |
826 conv = gaim_find_conversation_with_account(name, account); | |
827 | |
828 if (conv != NULL) | |
829 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
830 | |
831 g_free(name); | |
9709 | 832 } |
833 | |
834 void | |
9730 | 835 gaim_gtkdialogs_remove_buddy(GaimBuddy *buddy) |
9709 | 836 { |
9753 | 837 gchar *text; |
9730 | 838 |
9753 | 839 g_return_if_fail(buddy != NULL); |
9730 | 840 |
9753 | 841 text = g_strdup_printf(_("You are about to remove %s from your buddy list. Do you want to continue?"), |
842 buddy->name); | |
9730 | 843 |
9976 | 844 gaim_request_action(NULL, NULL, _("Remove Buddy"), text, 0, buddy, 2, |
9753 | 845 _("Remove Buddy"), G_CALLBACK(gaim_gtkdialogs_remove_buddy_cb), |
9730 | 846 _("Cancel"), NULL); |
847 | |
848 g_free(text); | |
849 } | |
9709 | 850 |
9730 | 851 static void |
9753 | 852 gaim_gtkdialogs_remove_chat_cb(GaimChat *chat) |
9730 | 853 { |
9918 | 854 char *name = NULL; |
10167 | 855 GaimAccount *account; |
9918 | 856 GaimConversation *conv = NULL; |
857 | |
10167 | 858 account = chat->account; |
859 | |
860 if (GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl)->get_chat_name != NULL) | |
861 name = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl)->get_chat_name(chat->components); | |
9918 | 862 |
9730 | 863 gaim_blist_remove_chat(chat); |
9918 | 864 |
865 if (name != NULL) { | |
10167 | 866 conv = gaim_find_conversation_with_account(name, account); |
9918 | 867 g_free(name); |
868 } | |
869 | |
870 if (conv != NULL) | |
871 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
9730 | 872 } |
9709 | 873 |
9730 | 874 void |
875 gaim_gtkdialogs_remove_chat(GaimChat *chat) | |
876 { | |
9753 | 877 gchar *name = gaim_chat_get_display_name(chat); |
878 gchar *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name); | |
879 | |
880 g_return_if_fail(chat != NULL); | |
9730 | 881 |
9976 | 882 gaim_request_action(NULL, NULL, _("Remove Chat"), text, 0, chat, 2, |
9753 | 883 _("Remove Chat"), G_CALLBACK(gaim_gtkdialogs_remove_chat_cb), |
9730 | 884 _("Cancel"), NULL); |
885 | |
886 g_free(name); | |
887 g_free(text); | |
9709 | 888 } |