Mercurial > pidgin.yaz
annotate src/gtkdialogs.c @ 10291:3f09e34b0928
[gaim-migrate @ 11468]
updated
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Thu, 02 Dec 2004 04:26:07 +0000 |
parents | 2a9ec10e0c4c |
children | ec140184437b |
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; | |
10266 | 173 AtkObject *obj; |
9753 | 174 |
175 if (about != NULL) { | |
176 gtk_window_present(GTK_WINDOW(about)); | |
177 return; | |
178 } | |
179 | |
180 GAIM_DIALOG(about); | |
181 gtk_window_set_default_size(GTK_WINDOW(about), 450, -1); | |
182 gtk_window_set_title(GTK_WINDOW(about), _("About Gaim")); | |
183 gtk_window_set_role(GTK_WINDOW(about), "about"); | |
184 gtk_window_set_resizable(GTK_WINDOW(about), TRUE); | |
9778 | 185 gtk_window_set_default_size(GTK_WINDOW(about), 340, 550); /* Golden ratio in da hizzy */ |
9753 | 186 |
187 hbox = gtk_hbox_new(FALSE, 12); | |
188 gtk_container_set_border_width(GTK_CONTAINER(hbox), 12); | |
189 gtk_container_add(GTK_CONTAINER(about), hbox); | |
190 | |
191 vbox = gtk_vbox_new(FALSE, 12); | |
192 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
193 | |
194 logo = gtk_image_new_from_stock(GAIM_STOCK_LOGO, gtk_icon_size_from_name(GAIM_ICON_SIZE_LOGO)); | |
10266 | 195 obj = gtk_widget_get_accessible(logo); |
196 atk_object_set_description(obj, "Gaim " VERSION); | |
9753 | 197 gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 0); |
198 | |
10175 | 199 frame = gaim_gtk_create_imhtml(FALSE, &text, NULL); |
200 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
9753 | 201 |
9758 | 202 str = g_string_sized_new(4096); |
9753 | 203 |
10153 | 204 g_string_append(str, |
9758 | 205 _("Gaim is a modular messaging client capable of using " |
206 "AIM, MSN, Yahoo!, Jabber, ICQ, IRC, SILC, " | |
207 "Novell GroupWise, Napster, Zephyr, and Gadu-Gadu " | |
208 "all at once. It is written using " | |
209 "Gtk+ and is licensed under the GPL.<BR><BR>")); | |
9753 | 210 |
9758 | 211 g_string_append(str, "<FONT SIZE=\"4\">URL:</FONT> <A HREF=\"" |
212 GAIM_WEBSITE "\">" GAIM_WEBSITE "</A><BR/><BR/>"); | |
213 | |
214 g_string_append_printf(str, _("<FONT SIZE=\"4\">IRC:</FONT> " | |
215 "#gaim on irc.freenode.net<BR><BR>")); | |
9753 | 216 |
217 /* Active Developers */ | |
9758 | 218 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
219 _("Active Developers")); | |
220 for (i = 0; developers[i].name != NULL; i++) { | |
221 if (developers[i].email != NULL) { | |
10116 | 222 g_string_append_printf(str, " %s (%s) <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 223 developers[i].name, _(developers[i].role), |
224 developers[i].email, developers[i].email); | |
225 } else { | |
226 g_string_append_printf(str, " %s (%s)<br/>", | |
227 developers[i].name, _(developers[i].role)); | |
228 } | |
229 } | |
230 g_string_append(str, "<BR/>"); | |
9709 | 231 |
9753 | 232 /* Crazy Patch Writers */ |
9758 | 233 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
234 _("Crazy Patch Writers")); | |
235 g_string_append(str, | |
236 " Daniel 'datallah' Atallah<BR>" | |
237 " Ka-Hing 'javabsp' Cheung<BR>" | |
9905 | 238 " Felipe 'shx' Contreras<BR>" |
9758 | 239 " Decklin Foster<BR>" |
240 " Gary 'grim' Kramlich<BR>" | |
241 " Robert 'Robot101' McQueen<BR>" | |
242 " Benjamin Miller<BR>" | |
243 " Etan 'deryni' Reisner<BR>" | |
244 " Kevin 'SimGuy' Stange<BR>" | |
245 "<BR>"); | |
9753 | 246 |
247 /* Retired Developers */ | |
9758 | 248 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
249 _("Retired Developers")); | |
250 for (i = 0; retired_developers[i].name != NULL; i++) { | |
251 if (retired_developers[i].email != NULL) { | |
10116 | 252 g_string_append_printf(str, " %s (%s) <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 253 retired_developers[i].name, _(retired_developers[i].role), |
254 retired_developers[i].email, retired_developers[i].email); | |
255 } else { | |
256 g_string_append_printf(str, " %s (%s)<br/>", | |
257 retired_developers[i].name, _(retired_developers[i].role)); | |
258 } | |
259 } | |
260 g_string_append(str, "<BR/>"); | |
9753 | 261 |
262 /* Current Translators */ | |
9758 | 263 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
264 _("Current Translators")); | |
265 for (i = 0; current_translators[i].language != NULL; i++) { | |
266 if (current_translators[i].email != NULL) { | |
10116 | 267 g_string_append_printf(str, " <b>%s (%s)</b> - %s <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 268 _(current_translators[i].language), |
269 current_translators[i].abbr, | |
270 _(current_translators[i].name), | |
271 current_translators[i].email, | |
272 current_translators[i].email); | |
273 } else { | |
274 g_string_append_printf(str, " <b>%s (%s)</b> - %s<br/>", | |
275 _(current_translators[i].language), | |
276 current_translators[i].abbr, | |
277 _(current_translators[i].name)); | |
278 } | |
279 } | |
280 g_string_append(str, "<BR/>"); | |
9753 | 281 |
282 /* Past Translators */ | |
9758 | 283 g_string_append_printf(str, "<FONT SIZE=\"4\">%s:</FONT><BR/>", |
284 _("Past Translators")); | |
285 for (i = 0; past_translators[i].language != NULL; i++) { | |
286 if (past_translators[i].email != NULL) { | |
10116 | 287 g_string_append_printf(str, " <b>%s (%s)</b> - %s <<a href=\"mailto:%s\">%s</a>><br/>", |
9758 | 288 _(past_translators[i].language), |
289 past_translators[i].abbr, | |
290 _(past_translators[i].name), | |
291 past_translators[i].email, | |
292 past_translators[i].email); | |
293 } else { | |
294 g_string_append_printf(str, " <b>%s (%s)</b> - %s<br/>", | |
295 _(past_translators[i].language), | |
296 past_translators[i].abbr, | |
297 _(past_translators[i].name)); | |
298 } | |
299 } | |
300 g_string_append(str, "<BR/>"); | |
301 | |
302 gtk_imhtml_append_text(GTK_IMHTML(text), str->str, GTK_IMHTML_NO_SCROLL); | |
303 g_string_free(str, TRUE); | |
9753 | 304 |
305 gtk_text_buffer_get_start_iter(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), &iter); | |
306 gtk_text_buffer_place_cursor(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), &iter); | |
10153 | 307 |
9753 | 308 /* Close Button */ |
309 bbox = gtk_hbutton_box_new(); | |
310 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
311 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
312 | |
313 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
314 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
315 | |
316 g_signal_connect_swapped(G_OBJECT(button), "clicked", | |
317 G_CALLBACK(destroy_about), G_OBJECT(about)); | |
318 g_signal_connect(G_OBJECT(about), "destroy", | |
319 G_CALLBACK(destroy_about), G_OBJECT(about)); | |
320 | |
321 /* this makes the sizes not work? */ | |
322 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
323 gtk_widget_grab_default(button); | |
324 | |
325 /* Let's give'em something to talk about -- woah woah woah */ | |
326 gtk_widget_show_all(about); | |
327 gtk_window_present(GTK_WINDOW(about)); | |
9709 | 328 } |
329 | |
9730 | 330 static void |
331 gaim_gtkdialogs_im_cb(gpointer data, GaimRequestFields *fields) | |
9709 | 332 { |
9730 | 333 GaimAccount *account; |
334 const char *username; | |
9709 | 335 |
9730 | 336 account = gaim_request_fields_get_account(fields, "account"); |
337 username = gaim_request_fields_get_string(fields, "screenname"); | |
9709 | 338 |
9730 | 339 gaim_gtkdialogs_im_with_user(account, username); |
9709 | 340 } |
341 | |
9730 | 342 void |
343 gaim_gtkdialogs_im(void) | |
9709 | 344 { |
9730 | 345 GaimRequestFields *fields; |
346 GaimRequestFieldGroup *group; | |
347 GaimRequestField *field; | |
9709 | 348 |
9730 | 349 fields = gaim_request_fields_new(); |
9709 | 350 |
9730 | 351 group = gaim_request_field_group_new(NULL); |
352 gaim_request_fields_add_group(fields, group); | |
9709 | 353 |
9730 | 354 field = gaim_request_field_string_new("screenname", _("_Screen name"), |
355 NULL, FALSE); | |
356 gaim_request_field_set_required(field, TRUE); | |
357 gaim_request_field_set_type_hint(field, "screenname"); | |
358 gaim_request_field_group_add_field(group, field); | |
9709 | 359 |
9730 | 360 field = gaim_request_field_account_new("account", _("_Account"), NULL); |
361 gaim_request_field_set_visible(field, | |
362 (gaim_connections_get_all() != NULL && | |
363 gaim_connections_get_all()->next != NULL)); | |
364 gaim_request_field_set_required(field, TRUE); | |
365 gaim_request_field_group_add_field(group, field); | |
366 | |
367 gaim_request_fields(gaim_get_blist(), _("New Instant Message"), | |
368 NULL, | |
369 _("Please enter the screen name of the person you " | |
370 "would like to IM."), | |
371 fields, | |
372 _("OK"), G_CALLBACK(gaim_gtkdialogs_im_cb), | |
373 _("Cancel"), NULL, | |
374 NULL); | |
9709 | 375 } |
376 | |
9730 | 377 void |
378 gaim_gtkdialogs_im_with_user(GaimAccount *account, const char *username) | |
9709 | 379 { |
9730 | 380 GaimConversation *conv; |
381 GaimConvWindow *win; | |
382 GaimGtkWindow *gtkwin; | |
9709 | 383 |
9753 | 384 g_return_if_fail(account != NULL); |
385 g_return_if_fail(username != NULL); | |
386 | |
10246 | 387 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, username, account); |
9709 | 388 |
9730 | 389 if (conv == NULL) |
390 conv = gaim_conversation_new(GAIM_CONV_IM, account, username); | |
9709 | 391 |
9730 | 392 win = gaim_conversation_get_window(conv); |
393 gtkwin = GAIM_GTK_WINDOW(win); | |
9709 | 394 |
9730 | 395 gtk_window_present(GTK_WINDOW(gtkwin->window)); |
396 gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv)); | |
9709 | 397 } |
398 | |
9730 | 399 static gboolean |
400 gaim_gtkdialogs_ee(const char *ee) | |
9709 | 401 { |
402 GtkWidget *window; | |
403 GtkWidget *hbox; | |
404 GtkWidget *label; | |
10219 | 405 GtkWidget *img; |
9709 | 406 gchar *norm = gaim_strreplace(ee, "rocksmyworld", ""); |
407 | |
408 label = gtk_label_new(NULL); | |
409 if (!strcmp(norm, "zilding")) | |
410 gtk_label_set_markup(GTK_LABEL(label), | |
411 "<span weight=\"bold\" size=\"large\" foreground=\"purple\">Amazing! Simply Amazing!</span>"); | |
412 else if (!strcmp(norm, "robflynn")) | |
413 gtk_label_set_markup(GTK_LABEL(label), | |
414 "<span weight=\"bold\" size=\"large\" foreground=\"#1f6bad\">Pimpin\' Penguin Style! *Waddle Waddle*</span>"); | |
415 else if (!strcmp(norm, "flynorange")) | |
416 gtk_label_set_markup(GTK_LABEL(label), | |
417 "<span weight=\"bold\" size=\"large\" foreground=\"blue\">You should be me. I'm so cute!</span>"); | |
418 else if (!strcmp(norm, "ewarmenhoven")) | |
419 gtk_label_set_markup(GTK_LABEL(label), | |
420 "<span weight=\"bold\" size=\"large\" foreground=\"orange\">Now that's what I like!</span>"); | |
421 else if (!strcmp(norm, "markster97")) | |
422 gtk_label_set_markup(GTK_LABEL(label), | |
423 "<span weight=\"bold\" size=\"large\" foreground=\"brown\">Ahh, and excellent choice!</span>"); | |
424 else if (!strcmp(norm, "seanegn")) | |
425 gtk_label_set_markup(GTK_LABEL(label), | |
426 "<span weight=\"bold\" size=\"large\" foreground=\"#009900\">Everytime you click my name, an angel gets its wings.</span>"); | |
427 else if (!strcmp(norm, "chipx86")) | |
428 gtk_label_set_markup(GTK_LABEL(label), | |
429 "<span weight=\"bold\" size=\"large\" foreground=\"red\">This sunflower seed taste like pizza.</span>"); | |
430 else if (!strcmp(norm, "markdoliner")) | |
431 gtk_label_set_markup(GTK_LABEL(label), | |
432 "<span weight=\"bold\" size=\"large\" foreground=\"#6364B1\">Hey! I was in that tumbleweed!</span>"); | |
433 else if (!strcmp(norm, "lschiere")) | |
434 gtk_label_set_markup(GTK_LABEL(label), | |
435 "<span weight=\"bold\" size=\"large\" foreground=\"gray\">I'm not anything.</span>"); | |
436 g_free(norm); | |
437 | |
438 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0) | |
439 return FALSE; | |
440 | |
441 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
442 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); | |
443 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL); | |
444 | |
445 gtk_container_set_border_width (GTK_CONTAINER(window), 6); | |
446 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
447 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE); | |
448 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12); | |
449 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6); | |
450 | |
451 hbox = gtk_hbox_new(FALSE, 12); | |
452 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox); | |
10219 | 453 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_COOL, gtk_icon_size_from_name(GAIM_ICON_SIZE_DIALOG_COOL)); |
9709 | 454 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
455 | |
456 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
457 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
458 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
459 | |
460 gtk_widget_show_all(window); | |
461 return TRUE; | |
462 } | |
463 | |
464 static void | |
9730 | 465 gaim_gtkdialogs_info_cb(gpointer data, GaimRequestFields *fields) |
9709 | 466 { |
467 char *username; | |
468 gboolean found = FALSE; | |
469 GaimAccount *account; | |
470 | |
471 account = gaim_request_fields_get_account(fields, "account"); | |
472 | |
473 username = g_strdup(gaim_normalize(account, | |
474 gaim_request_fields_get_string(fields, "screenname"))); | |
475 | |
476 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld")) | |
9730 | 477 found = gaim_gtkdialogs_ee(username); |
9709 | 478 |
479 if (!found && username != NULL && *username != '\0' && account != NULL) | |
480 serv_get_info(gaim_account_get_connection(account), username); | |
481 | |
482 g_free(username); | |
483 } | |
484 | |
485 void | |
9714 | 486 gaim_gtkdialogs_info(void) |
9709 | 487 { |
488 GaimRequestFields *fields; | |
489 GaimRequestFieldGroup *group; | |
490 GaimRequestField *field; | |
491 | |
492 fields = gaim_request_fields_new(); | |
493 | |
494 group = gaim_request_field_group_new(NULL); | |
495 gaim_request_fields_add_group(fields, group); | |
496 | |
497 field = gaim_request_field_string_new("screenname", _("_Screen name"), | |
498 NULL, FALSE); | |
499 gaim_request_field_set_type_hint(field, "screenname"); | |
500 gaim_request_field_set_required(field, TRUE); | |
501 gaim_request_field_group_add_field(group, field); | |
502 | |
503 field = gaim_request_field_account_new("account", _("_Account"), NULL); | |
504 gaim_request_field_set_visible(field, | |
505 (gaim_connections_get_all() != NULL && | |
506 gaim_connections_get_all()->next != NULL)); | |
507 gaim_request_field_set_required(field, TRUE); | |
508 gaim_request_field_group_add_field(group, field); | |
509 | |
510 gaim_request_fields(gaim_get_blist(), _("Get User Info"), | |
511 NULL, | |
512 _("Please enter the screen name of the person whose " | |
513 "info you would like to view."), | |
514 fields, | |
9730 | 515 _("OK"), G_CALLBACK(gaim_gtkdialogs_info_cb), |
9709 | 516 _("Cancel"), NULL, |
517 NULL); | |
518 } | |
519 | |
520 static void | |
9730 | 521 gaim_gtkdialogs_log_cb(gpointer data, GaimRequestFields *fields) |
9709 | 522 { |
523 char *username; | |
524 GaimAccount *account; | |
525 | |
526 account = gaim_request_fields_get_account(fields, "account"); | |
527 | |
528 username = g_strdup(gaim_normalize(account, | |
529 gaim_request_fields_get_string(fields, "screenname"))); | |
530 | |
9917 | 531 if(username != NULL && *username != '\0' && account != NULL ) |
532 gaim_gtk_log_show(GAIM_LOG_IM, username, account); | |
9709 | 533 |
534 g_free(username); | |
535 } | |
536 | |
9991 | 537 /* |
538 * TODO - This needs to deal with logs of all types, not just IM logs. | |
539 */ | |
9709 | 540 void |
9714 | 541 gaim_gtkdialogs_log(void) |
9709 | 542 { |
543 GaimRequestFields *fields; | |
544 GaimRequestFieldGroup *group; | |
545 GaimRequestField *field; | |
546 | |
547 fields = gaim_request_fields_new(); | |
548 | |
549 group = gaim_request_field_group_new(NULL); | |
550 gaim_request_fields_add_group(fields, group); | |
551 | |
552 field = gaim_request_field_string_new("screenname", _("_Screen name"), | |
553 NULL, FALSE); | |
554 gaim_request_field_set_type_hint(field, "screenname"); | |
555 gaim_request_field_set_required(field, TRUE); | |
556 gaim_request_field_group_add_field(group, field); | |
557 | |
558 field = gaim_request_field_account_new("account", _("_Account"), NULL); | |
559 gaim_request_field_account_set_show_all(field, TRUE); | |
560 gaim_request_field_set_visible(field, | |
561 (gaim_accounts_get_all() != NULL && | |
562 gaim_accounts_get_all()->next != NULL)); | |
563 gaim_request_field_set_required(field, TRUE); | |
564 gaim_request_field_group_add_field(group, field); | |
565 | |
566 gaim_request_fields(gaim_get_blist(), _("Get User Log"), | |
567 NULL, | |
568 _("Please enter the screen name of the person whose " | |
569 "log you would like to view."), | |
570 fields, | |
9730 | 571 _("OK"), G_CALLBACK(gaim_gtkdialogs_log_cb), |
9709 | 572 _("Cancel"), NULL, |
573 NULL); | |
574 } | |
575 | |
9730 | 576 static void |
577 gaim_gtkdialogs_warn_cb(GtkWidget *widget, gint resp, struct warning *w) | |
9709 | 578 { |
9730 | 579 if (resp == GTK_RESPONSE_OK) |
9753 | 580 serv_warn(w->gc, w->who, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))); |
9709 | 581 |
9753 | 582 dialogwindows = g_list_remove(dialogwindows, w->window); |
583 gtk_widget_destroy(w->window); | |
584 | |
9730 | 585 g_free(w->who); |
586 g_free(w); | |
9709 | 587 } |
588 | |
9753 | 589 /* |
9991 | 590 * TODO - Make this use the request API, if possible. |
9753 | 591 */ |
9730 | 592 void |
593 gaim_gtkdialogs_warn(GaimConnection *gc, const char *who) | |
9709 | 594 { |
9753 | 595 gchar *labeltext; |
9730 | 596 GtkWidget *hbox, *vbox; |
9709 | 597 GtkWidget *label; |
9753 | 598 GtkWidget *img; |
599 struct warning *w; | |
9730 | 600 |
9753 | 601 g_return_if_fail(gc != NULL); |
602 g_return_if_fail(who != NULL); | |
603 | |
604 w = g_new0(struct warning, 1); | |
9730 | 605 w->who = g_strdup(who); |
606 w->gc = gc; | |
607 | |
9753 | 608 w->window = gtk_dialog_new_with_buttons(_("Warn User"), NULL, 0, |
9730 | 609 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
610 GAIM_STOCK_WARN, GTK_RESPONSE_OK, NULL); | |
611 gtk_dialog_set_default_response (GTK_DIALOG(w->window), GTK_RESPONSE_OK); | |
612 g_signal_connect(G_OBJECT(w->window), "response", G_CALLBACK(gaim_gtkdialogs_warn_cb), w); | |
613 | |
614 gtk_container_set_border_width (GTK_CONTAINER(w->window), 6); | |
615 gtk_window_set_resizable(GTK_WINDOW(w->window), FALSE); | |
616 gtk_dialog_set_has_separator(GTK_DIALOG(w->window), FALSE); | |
617 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(w->window)->vbox), 12); | |
618 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), 6); | |
9709 | 619 |
620 hbox = gtk_hbox_new(FALSE, 12); | |
9730 | 621 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), hbox); |
9753 | 622 |
623 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); | |
624 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
9730 | 625 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
9709 | 626 |
9730 | 627 vbox = gtk_vbox_new(FALSE, 0); |
628 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
629 labeltext = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">Warn %s?</span>\n\n" | |
630 "This will increase %s's warning level and he or she will be subject to harsher rate limiting.\n"), who, who); | |
631 label = gtk_label_new(NULL); | |
632 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
633 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
634 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
635 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
636 g_free(labeltext); | |
9709 | 637 |
9730 | 638 w->anon = gtk_check_button_new_with_mnemonic(_("Warn _anonymously?")); |
639 gtk_box_pack_start(GTK_BOX(vbox), w->anon, FALSE, FALSE, 0); | |
640 | |
641 hbox = gtk_hbox_new(FALSE, 6); | |
642 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
643 img = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU); | |
644 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
645 labeltext = _("<b>Anonymous warnings are less severe.</b>"); | |
646 label = gtk_label_new(NULL); | |
647 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
648 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
9709 | 649 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
650 | |
9730 | 651 dialogwindows = g_list_prepend(dialogwindows, w->window); |
652 gtk_widget_show_all(w->window); | |
9709 | 653 } |
654 | |
655 static void | |
9730 | 656 gaim_gtkdialogs_alias_contact_cb(GaimContact *contact, const char *new_alias) |
657 { | |
658 gaim_contact_set_alias(contact, new_alias); | |
659 } | |
660 | |
661 void | |
662 gaim_gtkdialogs_alias_contact(GaimContact *contact) | |
663 { | |
9753 | 664 g_return_if_fail(contact != NULL); |
665 | |
9730 | 666 gaim_request_input(NULL, _("Alias Contact"), NULL, |
667 _("Enter an alias for this contact."), | |
668 contact->alias, FALSE, FALSE, NULL, | |
669 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_contact_cb), | |
670 _("Cancel"), NULL, contact); | |
671 } | |
672 | |
673 static void | |
674 gaim_gtkdialogs_alias_buddy_cb(GaimBuddy *buddy, const char *new_alias) | |
675 { | |
676 gaim_blist_alias_buddy(buddy, new_alias); | |
677 serv_alias_buddy(buddy); | |
678 } | |
679 | |
680 void | |
9753 | 681 gaim_gtkdialogs_alias_buddy(GaimBuddy *buddy) |
9730 | 682 { |
9753 | 683 gchar *secondary; |
684 | |
685 g_return_if_fail(buddy != NULL); | |
686 | |
687 secondary = g_strdup_printf(_("Enter an alias for %s."), buddy->name); | |
9730 | 688 |
689 gaim_request_input(NULL, _("Alias Buddy"), NULL, | |
9753 | 690 secondary, buddy->alias, FALSE, FALSE, NULL, |
9730 | 691 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_buddy_cb), |
9753 | 692 _("Cancel"), NULL, buddy); |
9730 | 693 |
694 g_free(secondary); | |
695 } | |
696 | |
697 static void | |
698 gaim_gtkdialogs_alias_chat_cb(GaimChat *chat, const char *new_alias) | |
9709 | 699 { |
700 gaim_blist_alias_chat(chat, new_alias); | |
701 } | |
702 | |
703 void | |
9730 | 704 gaim_gtkdialogs_alias_chat(GaimChat *chat) |
9709 | 705 { |
9753 | 706 g_return_if_fail(chat != NULL); |
707 | |
9709 | 708 gaim_request_input(NULL, _("Alias Chat"), NULL, |
709 _("Enter an alias for this chat."), | |
710 chat->alias, FALSE, FALSE, NULL, | |
9730 | 711 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_chat_cb), |
9709 | 712 _("Cancel"), NULL, chat); |
713 } | |
714 | |
715 static void | |
9753 | 716 gaim_gtkdialogs_remove_contact_cb(GaimContact *contact) |
9709 | 717 { |
9730 | 718 GaimBlistNode *bnode, *cnode; |
719 GaimGroup *group; | |
720 | |
721 cnode = (GaimBlistNode *)contact; | |
722 group = (GaimGroup*)cnode->parent; | |
723 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
724 GaimBuddy *buddy = (GaimBuddy*)bnode; | |
725 if (gaim_account_is_connected(buddy->account)) | |
726 serv_remove_buddy(buddy->account->gc, buddy, group); | |
727 } | |
728 gaim_blist_remove_contact(contact); | |
729 } | |
730 | |
731 void | |
732 gaim_gtkdialogs_remove_contact(GaimContact *contact) | |
733 { | |
734 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact); | |
735 | |
9753 | 736 g_return_if_fail(contact != NULL); |
737 g_return_if_fail(buddy != NULL); | |
9730 | 738 |
739 if (((GaimBlistNode*)contact)->child == (GaimBlistNode*)buddy && | |
740 !((GaimBlistNode*)buddy)->next) { | |
741 gaim_gtkdialogs_remove_buddy(buddy); | |
742 } else { | |
9753 | 743 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 | 744 buddy->name, contact->totalsize - 1); |
745 | |
10222 | 746 gaim_request_action(contact, NULL, _("Remove Contact"), text, 0, contact, 2, |
9753 | 747 _("Remove Contact"), G_CALLBACK(gaim_gtkdialogs_remove_contact_cb), |
9730 | 748 _("Cancel"), NULL); |
749 | |
750 g_free(text); | |
751 } | |
9709 | 752 } |
753 | |
754 void | |
9753 | 755 gaim_gtkdialogs_remove_group_cb(GaimGroup *group) |
9709 | 756 { |
9730 | 757 GaimBlistNode *cnode, *bnode; |
758 | |
759 cnode = ((GaimBlistNode*)group)->child; | |
760 | |
761 while (cnode) { | |
762 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
763 bnode = cnode->child; | |
764 cnode = cnode->next; | |
765 while (bnode) { | |
766 GaimBuddy *buddy; | |
767 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
768 GaimConversation *conv; | |
769 buddy = (GaimBuddy*)bnode; | |
770 bnode = bnode->next; | |
10246 | 771 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, |
772 buddy->name, | |
773 buddy->account); | |
9730 | 774 if (gaim_account_is_connected(buddy->account)) { |
775 serv_remove_buddy(buddy->account->gc, buddy, group); | |
776 gaim_blist_remove_buddy(buddy); | |
777 if (conv) | |
778 gaim_conversation_update(conv, | |
779 GAIM_CONV_UPDATE_REMOVE); | |
780 } | |
781 } else { | |
782 bnode = bnode->next; | |
783 } | |
784 } | |
785 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
786 GaimChat *chat = (GaimChat *)cnode; | |
787 cnode = cnode->next; | |
788 if (gaim_account_is_connected(chat->account)) | |
789 gaim_blist_remove_chat(chat); | |
790 } else { | |
791 cnode = cnode->next; | |
792 } | |
793 } | |
794 | |
795 gaim_blist_remove_group(group); | |
796 } | |
797 | |
798 void | |
799 gaim_gtkdialogs_remove_group(GaimGroup *group) | |
800 { | |
9753 | 801 gchar *text; |
802 | |
803 g_return_if_fail(group != NULL); | |
804 | |
805 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?"), | |
806 group->name); | |
9730 | 807 |
10222 | 808 gaim_request_action(group, NULL, _("Remove Group"), text, 0, group, 2, |
9753 | 809 _("Remove Group"), G_CALLBACK(gaim_gtkdialogs_remove_group_cb), |
9730 | 810 _("Cancel"), NULL); |
811 | |
812 g_free(text); | |
9709 | 813 } |
814 | |
10246 | 815 /* XXX - Some of this should be moved into the core, methinks. */ |
9709 | 816 static void |
9753 | 817 gaim_gtkdialogs_remove_buddy_cb(GaimBuddy *buddy) |
9709 | 818 { |
9730 | 819 GaimGroup *group; |
820 GaimConversation *conv; | |
821 gchar *name; | |
822 GaimAccount *account; | |
823 | |
824 group = gaim_find_buddys_group(buddy); | |
825 name = g_strdup(buddy->name); /* b->name is a crasher after remove_buddy */ | |
826 account = buddy->account; | |
827 | |
9753 | 828 gaim_debug_info("blist", "Removing '%s' from buddy list.\n", buddy->name); |
9991 | 829 /* TODO - Should remove from blist first... then call serv_remove_buddy()? */ |
9730 | 830 serv_remove_buddy(buddy->account->gc, buddy, group); |
831 gaim_blist_remove_buddy(buddy); | |
832 | |
10246 | 833 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); |
9730 | 834 if (conv != NULL) |
835 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
836 | |
837 g_free(name); | |
9709 | 838 } |
839 | |
840 void | |
9730 | 841 gaim_gtkdialogs_remove_buddy(GaimBuddy *buddy) |
9709 | 842 { |
9753 | 843 gchar *text; |
9730 | 844 |
9753 | 845 g_return_if_fail(buddy != NULL); |
9730 | 846 |
9753 | 847 text = g_strdup_printf(_("You are about to remove %s from your buddy list. Do you want to continue?"), |
848 buddy->name); | |
9730 | 849 |
10222 | 850 gaim_request_action(buddy, NULL, _("Remove Buddy"), text, 0, buddy, 2, |
9753 | 851 _("Remove Buddy"), G_CALLBACK(gaim_gtkdialogs_remove_buddy_cb), |
9730 | 852 _("Cancel"), NULL); |
853 | |
854 g_free(text); | |
855 } | |
9709 | 856 |
9730 | 857 static void |
9753 | 858 gaim_gtkdialogs_remove_chat_cb(GaimChat *chat) |
9730 | 859 { |
9918 | 860 char *name = NULL; |
10167 | 861 GaimAccount *account; |
9918 | 862 GaimConversation *conv = NULL; |
863 | |
10167 | 864 account = chat->account; |
865 | |
866 if (GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl)->get_chat_name != NULL) | |
867 name = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl)->get_chat_name(chat->components); | |
9918 | 868 |
9730 | 869 gaim_blist_remove_chat(chat); |
9918 | 870 |
871 if (name != NULL) { | |
10246 | 872 conv = gaim_find_conversation_with_account(GAIM_CONV_CHAT, name, account); |
9918 | 873 g_free(name); |
874 } | |
875 | |
876 if (conv != NULL) | |
877 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
9730 | 878 } |
9709 | 879 |
9730 | 880 void |
881 gaim_gtkdialogs_remove_chat(GaimChat *chat) | |
882 { | |
9753 | 883 gchar *name = gaim_chat_get_display_name(chat); |
884 gchar *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name); | |
885 | |
886 g_return_if_fail(chat != NULL); | |
9730 | 887 |
10222 | 888 gaim_request_action(chat, NULL, _("Remove Chat"), text, 0, chat, 2, |
9753 | 889 _("Remove Chat"), G_CALLBACK(gaim_gtkdialogs_remove_chat_cb), |
9730 | 890 _("Cancel"), NULL); |
891 | |
892 g_free(name); | |
893 g_free(text); | |
9709 | 894 } |