Mercurial > pidgin
annotate src/gtkdialogs.c @ 10246:a66cf83552dc
[gaim-migrate @ 11386]
I changed gaim_find_conversation and gaim_find_conversation_with_account
The first parameter is now one of GAIM_CONV_IM, GAIM_CONV_CHAT or
GAIM_CONV_ANY. Unfortunately, this changes a bajillion files.
Please look over this and make sure I use the correct type everywhere.
Especially in Novell and MSN, and somewhat in SILC.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 23 Nov 2004 06:14:15 +0000 |
parents | 224c9f244a3a |
children | 2a9ec10e0c4c |
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 | |
10246 | 384 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, 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; | |
10219 | 402 GtkWidget *img; |
9709 | 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); | |
10219 | 450 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_COOL, gtk_icon_size_from_name(GAIM_ICON_SIZE_DIALOG_COOL)); |
9709 | 451 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
452 | |
453 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
454 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
455 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
456 | |
457 gtk_widget_show_all(window); | |
458 return TRUE; | |
459 } | |
460 | |
461 static void | |
9730 | 462 gaim_gtkdialogs_info_cb(gpointer data, GaimRequestFields *fields) |
9709 | 463 { |
464 char *username; | |
465 gboolean found = FALSE; | |
466 GaimAccount *account; | |
467 | |
468 account = gaim_request_fields_get_account(fields, "account"); | |
469 | |
470 username = g_strdup(gaim_normalize(account, | |
471 gaim_request_fields_get_string(fields, "screenname"))); | |
472 | |
473 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld")) | |
9730 | 474 found = gaim_gtkdialogs_ee(username); |
9709 | 475 |
476 if (!found && username != NULL && *username != '\0' && account != NULL) | |
477 serv_get_info(gaim_account_get_connection(account), username); | |
478 | |
479 g_free(username); | |
480 } | |
481 | |
482 void | |
9714 | 483 gaim_gtkdialogs_info(void) |
9709 | 484 { |
485 GaimRequestFields *fields; | |
486 GaimRequestFieldGroup *group; | |
487 GaimRequestField *field; | |
488 | |
489 fields = gaim_request_fields_new(); | |
490 | |
491 group = gaim_request_field_group_new(NULL); | |
492 gaim_request_fields_add_group(fields, group); | |
493 | |
494 field = gaim_request_field_string_new("screenname", _("_Screen name"), | |
495 NULL, FALSE); | |
496 gaim_request_field_set_type_hint(field, "screenname"); | |
497 gaim_request_field_set_required(field, TRUE); | |
498 gaim_request_field_group_add_field(group, field); | |
499 | |
500 field = gaim_request_field_account_new("account", _("_Account"), NULL); | |
501 gaim_request_field_set_visible(field, | |
502 (gaim_connections_get_all() != NULL && | |
503 gaim_connections_get_all()->next != NULL)); | |
504 gaim_request_field_set_required(field, TRUE); | |
505 gaim_request_field_group_add_field(group, field); | |
506 | |
507 gaim_request_fields(gaim_get_blist(), _("Get User Info"), | |
508 NULL, | |
509 _("Please enter the screen name of the person whose " | |
510 "info you would like to view."), | |
511 fields, | |
9730 | 512 _("OK"), G_CALLBACK(gaim_gtkdialogs_info_cb), |
9709 | 513 _("Cancel"), NULL, |
514 NULL); | |
515 } | |
516 | |
517 static void | |
9730 | 518 gaim_gtkdialogs_log_cb(gpointer data, GaimRequestFields *fields) |
9709 | 519 { |
520 char *username; | |
521 GaimAccount *account; | |
522 | |
523 account = gaim_request_fields_get_account(fields, "account"); | |
524 | |
525 username = g_strdup(gaim_normalize(account, | |
526 gaim_request_fields_get_string(fields, "screenname"))); | |
527 | |
9917 | 528 if(username != NULL && *username != '\0' && account != NULL ) |
529 gaim_gtk_log_show(GAIM_LOG_IM, username, account); | |
9709 | 530 |
531 g_free(username); | |
532 } | |
533 | |
9991 | 534 /* |
535 * TODO - This needs to deal with logs of all types, not just IM logs. | |
536 */ | |
9709 | 537 void |
9714 | 538 gaim_gtkdialogs_log(void) |
9709 | 539 { |
540 GaimRequestFields *fields; | |
541 GaimRequestFieldGroup *group; | |
542 GaimRequestField *field; | |
543 | |
544 fields = gaim_request_fields_new(); | |
545 | |
546 group = gaim_request_field_group_new(NULL); | |
547 gaim_request_fields_add_group(fields, group); | |
548 | |
549 field = gaim_request_field_string_new("screenname", _("_Screen name"), | |
550 NULL, FALSE); | |
551 gaim_request_field_set_type_hint(field, "screenname"); | |
552 gaim_request_field_set_required(field, TRUE); | |
553 gaim_request_field_group_add_field(group, field); | |
554 | |
555 field = gaim_request_field_account_new("account", _("_Account"), NULL); | |
556 gaim_request_field_account_set_show_all(field, TRUE); | |
557 gaim_request_field_set_visible(field, | |
558 (gaim_accounts_get_all() != NULL && | |
559 gaim_accounts_get_all()->next != NULL)); | |
560 gaim_request_field_set_required(field, TRUE); | |
561 gaim_request_field_group_add_field(group, field); | |
562 | |
563 gaim_request_fields(gaim_get_blist(), _("Get User Log"), | |
564 NULL, | |
565 _("Please enter the screen name of the person whose " | |
566 "log you would like to view."), | |
567 fields, | |
9730 | 568 _("OK"), G_CALLBACK(gaim_gtkdialogs_log_cb), |
9709 | 569 _("Cancel"), NULL, |
570 NULL); | |
571 } | |
572 | |
9730 | 573 static void |
574 gaim_gtkdialogs_warn_cb(GtkWidget *widget, gint resp, struct warning *w) | |
9709 | 575 { |
9730 | 576 if (resp == GTK_RESPONSE_OK) |
9753 | 577 serv_warn(w->gc, w->who, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))); |
9709 | 578 |
9753 | 579 dialogwindows = g_list_remove(dialogwindows, w->window); |
580 gtk_widget_destroy(w->window); | |
581 | |
9730 | 582 g_free(w->who); |
583 g_free(w); | |
9709 | 584 } |
585 | |
9753 | 586 /* |
9991 | 587 * TODO - Make this use the request API, if possible. |
9753 | 588 */ |
9730 | 589 void |
590 gaim_gtkdialogs_warn(GaimConnection *gc, const char *who) | |
9709 | 591 { |
9753 | 592 gchar *labeltext; |
9730 | 593 GtkWidget *hbox, *vbox; |
9709 | 594 GtkWidget *label; |
9753 | 595 GtkWidget *img; |
596 struct warning *w; | |
9730 | 597 |
9753 | 598 g_return_if_fail(gc != NULL); |
599 g_return_if_fail(who != NULL); | |
600 | |
601 w = g_new0(struct warning, 1); | |
9730 | 602 w->who = g_strdup(who); |
603 w->gc = gc; | |
604 | |
9753 | 605 w->window = gtk_dialog_new_with_buttons(_("Warn User"), NULL, 0, |
9730 | 606 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
607 GAIM_STOCK_WARN, GTK_RESPONSE_OK, NULL); | |
608 gtk_dialog_set_default_response (GTK_DIALOG(w->window), GTK_RESPONSE_OK); | |
609 g_signal_connect(G_OBJECT(w->window), "response", G_CALLBACK(gaim_gtkdialogs_warn_cb), w); | |
610 | |
611 gtk_container_set_border_width (GTK_CONTAINER(w->window), 6); | |
612 gtk_window_set_resizable(GTK_WINDOW(w->window), FALSE); | |
613 gtk_dialog_set_has_separator(GTK_DIALOG(w->window), FALSE); | |
614 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(w->window)->vbox), 12); | |
615 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), 6); | |
9709 | 616 |
617 hbox = gtk_hbox_new(FALSE, 12); | |
9730 | 618 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), hbox); |
9753 | 619 |
620 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); | |
621 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
9730 | 622 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
9709 | 623 |
9730 | 624 vbox = gtk_vbox_new(FALSE, 0); |
625 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
626 labeltext = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">Warn %s?</span>\n\n" | |
627 "This will increase %s's warning level and he or she will be subject to harsher rate limiting.\n"), who, who); | |
628 label = gtk_label_new(NULL); | |
629 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
630 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
631 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
632 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
633 g_free(labeltext); | |
9709 | 634 |
9730 | 635 w->anon = gtk_check_button_new_with_mnemonic(_("Warn _anonymously?")); |
636 gtk_box_pack_start(GTK_BOX(vbox), w->anon, FALSE, FALSE, 0); | |
637 | |
638 hbox = gtk_hbox_new(FALSE, 6); | |
639 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
640 img = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU); | |
641 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
642 labeltext = _("<b>Anonymous warnings are less severe.</b>"); | |
643 label = gtk_label_new(NULL); | |
644 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
645 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
9709 | 646 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
647 | |
9730 | 648 dialogwindows = g_list_prepend(dialogwindows, w->window); |
649 gtk_widget_show_all(w->window); | |
9709 | 650 } |
651 | |
652 static void | |
9730 | 653 gaim_gtkdialogs_alias_contact_cb(GaimContact *contact, const char *new_alias) |
654 { | |
655 gaim_contact_set_alias(contact, new_alias); | |
656 } | |
657 | |
658 void | |
659 gaim_gtkdialogs_alias_contact(GaimContact *contact) | |
660 { | |
9753 | 661 g_return_if_fail(contact != NULL); |
662 | |
9730 | 663 gaim_request_input(NULL, _("Alias Contact"), NULL, |
664 _("Enter an alias for this contact."), | |
665 contact->alias, FALSE, FALSE, NULL, | |
666 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_contact_cb), | |
667 _("Cancel"), NULL, contact); | |
668 } | |
669 | |
670 static void | |
671 gaim_gtkdialogs_alias_buddy_cb(GaimBuddy *buddy, const char *new_alias) | |
672 { | |
673 gaim_blist_alias_buddy(buddy, new_alias); | |
674 serv_alias_buddy(buddy); | |
675 } | |
676 | |
677 void | |
9753 | 678 gaim_gtkdialogs_alias_buddy(GaimBuddy *buddy) |
9730 | 679 { |
9753 | 680 gchar *secondary; |
681 | |
682 g_return_if_fail(buddy != NULL); | |
683 | |
684 secondary = g_strdup_printf(_("Enter an alias for %s."), buddy->name); | |
9730 | 685 |
686 gaim_request_input(NULL, _("Alias Buddy"), NULL, | |
9753 | 687 secondary, buddy->alias, FALSE, FALSE, NULL, |
9730 | 688 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_buddy_cb), |
9753 | 689 _("Cancel"), NULL, buddy); |
9730 | 690 |
691 g_free(secondary); | |
692 } | |
693 | |
694 static void | |
695 gaim_gtkdialogs_alias_chat_cb(GaimChat *chat, const char *new_alias) | |
9709 | 696 { |
697 gaim_blist_alias_chat(chat, new_alias); | |
698 } | |
699 | |
700 void | |
9730 | 701 gaim_gtkdialogs_alias_chat(GaimChat *chat) |
9709 | 702 { |
9753 | 703 g_return_if_fail(chat != NULL); |
704 | |
9709 | 705 gaim_request_input(NULL, _("Alias Chat"), NULL, |
706 _("Enter an alias for this chat."), | |
707 chat->alias, FALSE, FALSE, NULL, | |
9730 | 708 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_chat_cb), |
9709 | 709 _("Cancel"), NULL, chat); |
710 } | |
711 | |
712 static void | |
9753 | 713 gaim_gtkdialogs_remove_contact_cb(GaimContact *contact) |
9709 | 714 { |
9730 | 715 GaimBlistNode *bnode, *cnode; |
716 GaimGroup *group; | |
717 | |
718 cnode = (GaimBlistNode *)contact; | |
719 group = (GaimGroup*)cnode->parent; | |
720 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
721 GaimBuddy *buddy = (GaimBuddy*)bnode; | |
722 if (gaim_account_is_connected(buddy->account)) | |
723 serv_remove_buddy(buddy->account->gc, buddy, group); | |
724 } | |
725 gaim_blist_remove_contact(contact); | |
726 } | |
727 | |
728 void | |
729 gaim_gtkdialogs_remove_contact(GaimContact *contact) | |
730 { | |
731 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact); | |
732 | |
9753 | 733 g_return_if_fail(contact != NULL); |
734 g_return_if_fail(buddy != NULL); | |
9730 | 735 |
736 if (((GaimBlistNode*)contact)->child == (GaimBlistNode*)buddy && | |
737 !((GaimBlistNode*)buddy)->next) { | |
738 gaim_gtkdialogs_remove_buddy(buddy); | |
739 } else { | |
9753 | 740 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 | 741 buddy->name, contact->totalsize - 1); |
742 | |
10222 | 743 gaim_request_action(contact, NULL, _("Remove Contact"), text, 0, contact, 2, |
9753 | 744 _("Remove Contact"), G_CALLBACK(gaim_gtkdialogs_remove_contact_cb), |
9730 | 745 _("Cancel"), NULL); |
746 | |
747 g_free(text); | |
748 } | |
9709 | 749 } |
750 | |
751 void | |
9753 | 752 gaim_gtkdialogs_remove_group_cb(GaimGroup *group) |
9709 | 753 { |
9730 | 754 GaimBlistNode *cnode, *bnode; |
755 | |
756 cnode = ((GaimBlistNode*)group)->child; | |
757 | |
758 while (cnode) { | |
759 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
760 bnode = cnode->child; | |
761 cnode = cnode->next; | |
762 while (bnode) { | |
763 GaimBuddy *buddy; | |
764 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { | |
765 GaimConversation *conv; | |
766 buddy = (GaimBuddy*)bnode; | |
767 bnode = bnode->next; | |
10246 | 768 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, |
769 buddy->name, | |
770 buddy->account); | |
9730 | 771 if (gaim_account_is_connected(buddy->account)) { |
772 serv_remove_buddy(buddy->account->gc, buddy, group); | |
773 gaim_blist_remove_buddy(buddy); | |
774 if (conv) | |
775 gaim_conversation_update(conv, | |
776 GAIM_CONV_UPDATE_REMOVE); | |
777 } | |
778 } else { | |
779 bnode = bnode->next; | |
780 } | |
781 } | |
782 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
783 GaimChat *chat = (GaimChat *)cnode; | |
784 cnode = cnode->next; | |
785 if (gaim_account_is_connected(chat->account)) | |
786 gaim_blist_remove_chat(chat); | |
787 } else { | |
788 cnode = cnode->next; | |
789 } | |
790 } | |
791 | |
792 gaim_blist_remove_group(group); | |
793 } | |
794 | |
795 void | |
796 gaim_gtkdialogs_remove_group(GaimGroup *group) | |
797 { | |
9753 | 798 gchar *text; |
799 | |
800 g_return_if_fail(group != NULL); | |
801 | |
802 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?"), | |
803 group->name); | |
9730 | 804 |
10222 | 805 gaim_request_action(group, NULL, _("Remove Group"), text, 0, group, 2, |
9753 | 806 _("Remove Group"), G_CALLBACK(gaim_gtkdialogs_remove_group_cb), |
9730 | 807 _("Cancel"), NULL); |
808 | |
809 g_free(text); | |
9709 | 810 } |
811 | |
10246 | 812 /* XXX - Some of this should be moved into the core, methinks. */ |
9709 | 813 static void |
9753 | 814 gaim_gtkdialogs_remove_buddy_cb(GaimBuddy *buddy) |
9709 | 815 { |
9730 | 816 GaimGroup *group; |
817 GaimConversation *conv; | |
818 gchar *name; | |
819 GaimAccount *account; | |
820 | |
821 group = gaim_find_buddys_group(buddy); | |
822 name = g_strdup(buddy->name); /* b->name is a crasher after remove_buddy */ | |
823 account = buddy->account; | |
824 | |
9753 | 825 gaim_debug_info("blist", "Removing '%s' from buddy list.\n", buddy->name); |
9991 | 826 /* TODO - Should remove from blist first... then call serv_remove_buddy()? */ |
9730 | 827 serv_remove_buddy(buddy->account->gc, buddy, group); |
828 gaim_blist_remove_buddy(buddy); | |
829 | |
10246 | 830 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); |
9730 | 831 if (conv != NULL) |
832 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
833 | |
834 g_free(name); | |
9709 | 835 } |
836 | |
837 void | |
9730 | 838 gaim_gtkdialogs_remove_buddy(GaimBuddy *buddy) |
9709 | 839 { |
9753 | 840 gchar *text; |
9730 | 841 |
9753 | 842 g_return_if_fail(buddy != NULL); |
9730 | 843 |
9753 | 844 text = g_strdup_printf(_("You are about to remove %s from your buddy list. Do you want to continue?"), |
845 buddy->name); | |
9730 | 846 |
10222 | 847 gaim_request_action(buddy, NULL, _("Remove Buddy"), text, 0, buddy, 2, |
9753 | 848 _("Remove Buddy"), G_CALLBACK(gaim_gtkdialogs_remove_buddy_cb), |
9730 | 849 _("Cancel"), NULL); |
850 | |
851 g_free(text); | |
852 } | |
9709 | 853 |
9730 | 854 static void |
9753 | 855 gaim_gtkdialogs_remove_chat_cb(GaimChat *chat) |
9730 | 856 { |
9918 | 857 char *name = NULL; |
10167 | 858 GaimAccount *account; |
9918 | 859 GaimConversation *conv = NULL; |
860 | |
10167 | 861 account = chat->account; |
862 | |
863 if (GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl)->get_chat_name != NULL) | |
864 name = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl)->get_chat_name(chat->components); | |
9918 | 865 |
9730 | 866 gaim_blist_remove_chat(chat); |
9918 | 867 |
868 if (name != NULL) { | |
10246 | 869 conv = gaim_find_conversation_with_account(GAIM_CONV_CHAT, name, account); |
9918 | 870 g_free(name); |
871 } | |
872 | |
873 if (conv != NULL) | |
874 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); | |
9730 | 875 } |
9709 | 876 |
9730 | 877 void |
878 gaim_gtkdialogs_remove_chat(GaimChat *chat) | |
879 { | |
9753 | 880 gchar *name = gaim_chat_get_display_name(chat); |
881 gchar *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name); | |
882 | |
883 g_return_if_fail(chat != NULL); | |
9730 | 884 |
10222 | 885 gaim_request_action(chat, NULL, _("Remove Chat"), text, 0, chat, 2, |
9753 | 886 _("Remove Chat"), G_CALLBACK(gaim_gtkdialogs_remove_chat_cb), |
9730 | 887 _("Cancel"), NULL); |
888 | |
889 g_free(name); | |
890 g_free(text); | |
9709 | 891 } |