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 */
|
|
22 #include "gtkinternal.h"
|
|
23
|
|
24 #include "debug.h"
|
|
25 #include "notify.h"
|
|
26 #include "prefs.h"
|
|
27 #include "prpl.h"
|
|
28 #include "request.h"
|
|
29 #include "status.h"
|
|
30 #include "util.h"
|
|
31
|
|
32 #include "gtkdialogs.h"
|
|
33 #include "gtkimhtml.h"
|
|
34 #include "gtkimhtmltoolbar.h"
|
|
35 #include "gtklog.h"
|
|
36 #include "gtkutils.h"
|
|
37 #include "stock.h"
|
|
38
|
|
39 /* XXX */
|
|
40 #include "gaim.h"
|
|
41
|
|
42 static GList *dialogwindows = NULL;
|
|
43
|
|
44 struct confirm_del {
|
|
45 GtkWidget *window;
|
|
46 GtkWidget *label;
|
|
47 GtkWidget *ok;
|
|
48 GtkWidget *cancel;
|
|
49 char name[1024];
|
|
50 GaimConnection *gc;
|
|
51 };
|
|
52
|
|
53 struct create_away {
|
|
54 GtkWidget *window;
|
|
55 GtkWidget *toolbar;
|
|
56 GtkWidget *entry;
|
|
57 GtkWidget *text;
|
|
58 struct away_message *mess;
|
|
59 };
|
|
60
|
|
61 struct warning {
|
|
62 GtkWidget *window;
|
|
63 GtkWidget *anon;
|
|
64 char *who;
|
|
65 GaimConnection *gc;
|
|
66 };
|
|
67
|
|
68 struct getuserinfo {
|
|
69 GtkWidget *window;
|
|
70 GtkWidget *entry;
|
|
71 GtkWidget *account;
|
|
72 GaimConnection *gc;
|
|
73 };
|
|
74
|
|
75 struct view_log {
|
|
76 long offset;
|
|
77 int options;
|
|
78 char *name;
|
|
79 GtkWidget *bbox;
|
|
80 GtkWidget *window;
|
|
81 GtkWidget *layout;
|
|
82 void *clear_handle;
|
|
83 };
|
|
84
|
|
85 /* Wrapper to get all the text from a GtkTextView */
|
|
86 gchar* gtk_text_view_get_text(GtkTextView *text, gboolean include_hidden_chars)
|
|
87 {
|
|
88 GtkTextBuffer *buffer;
|
|
89 GtkTextIter start, end;
|
|
90
|
|
91 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
|
|
92 gtk_text_buffer_get_start_iter(buffer, &start);
|
|
93 gtk_text_buffer_get_end_iter(buffer, &end);
|
|
94
|
|
95 return gtk_text_buffer_get_text(buffer, &start, &end, include_hidden_chars);
|
|
96 }
|
|
97
|
|
98 /*------------------------------------------------------------------------*/
|
|
99 /* Destroys */
|
|
100 /*------------------------------------------------------------------------*/
|
|
101
|
|
102 static void destroy_dialog(GtkWidget *w, GtkWidget *w2)
|
|
103 {
|
|
104 GtkWidget *dest;
|
|
105
|
|
106 if (!GTK_IS_WIDGET(w2))
|
|
107 dest = w;
|
|
108 else
|
|
109 dest = w2;
|
|
110
|
|
111 dialogwindows = g_list_remove(dialogwindows, dest);
|
|
112 gtk_widget_destroy(dest);
|
|
113 }
|
|
114
|
|
115 void destroy_all_dialogs()
|
|
116 {
|
|
117 while (dialogwindows)
|
|
118 destroy_dialog(NULL, dialogwindows->data);
|
|
119
|
|
120 if (awaymessage)
|
|
121 do_im_back(NULL, NULL);
|
|
122 }
|
|
123
|
|
124 static void do_warn(GtkWidget *widget, gint resp, struct warning *w)
|
|
125 {
|
|
126 if (resp == GTK_RESPONSE_OK)
|
|
127 serv_warn(w->gc, w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? 1 : 0);
|
|
128
|
|
129 destroy_dialog(NULL, w->window);
|
|
130 g_free(w->who);
|
|
131 g_free(w);
|
|
132 }
|
|
133
|
9714
|
134 void gaim_gtkdialogs_warn(GaimConnection *gc, const char *who)
|
9709
|
135 {
|
|
136 char *labeltext;
|
|
137 GtkWidget *hbox, *vbox;
|
|
138 GtkWidget *label;
|
|
139 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
|
|
140 GaimConversation *c = gaim_find_conversation_with_account(who, gc->account);
|
|
141
|
|
142 struct warning *w = g_new0(struct warning, 1);
|
|
143 w->who = g_strdup(who);
|
|
144 w->gc = gc;
|
|
145
|
|
146 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
|
|
147
|
|
148 w->window = gtk_dialog_new_with_buttons(_("Warn User"),
|
|
149 GTK_WINDOW(GAIM_GTK_WINDOW(c->window)->window), 0,
|
|
150 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
151 GAIM_STOCK_WARN, GTK_RESPONSE_OK, NULL);
|
|
152 gtk_dialog_set_default_response (GTK_DIALOG(w->window), GTK_RESPONSE_OK);
|
|
153 g_signal_connect(G_OBJECT(w->window), "response", G_CALLBACK(do_warn), w);
|
|
154
|
|
155 gtk_container_set_border_width (GTK_CONTAINER(w->window), 6);
|
|
156 gtk_window_set_resizable(GTK_WINDOW(w->window), FALSE);
|
|
157 gtk_dialog_set_has_separator(GTK_DIALOG(w->window), FALSE);
|
|
158 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(w->window)->vbox), 12);
|
|
159 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), 6);
|
|
160
|
|
161 hbox = gtk_hbox_new(FALSE, 12);
|
|
162 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), hbox);
|
|
163 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
|
|
164
|
|
165 vbox = gtk_vbox_new(FALSE, 0);
|
|
166 gtk_container_add(GTK_CONTAINER(hbox), vbox);
|
|
167 labeltext = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">Warn %s?</span>\n\n"
|
|
168 "This will increase %s's warning level and he or she will be subject to harsher rate limiting.\n"), who, who);
|
|
169 label = gtk_label_new(NULL);
|
|
170 gtk_label_set_markup(GTK_LABEL(label), labeltext);
|
|
171 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
|
172 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
173 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
174 g_free(labeltext);
|
|
175
|
|
176 w->anon = gtk_check_button_new_with_mnemonic(_("Warn _anonymously?"));
|
|
177 gtk_box_pack_start(GTK_BOX(vbox), w->anon, FALSE, FALSE, 0);
|
|
178
|
|
179 hbox = gtk_hbox_new(FALSE, 6);
|
|
180 gtk_container_add(GTK_CONTAINER(vbox), hbox);
|
|
181 img = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU);
|
|
182 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
|
|
183 labeltext = _("<b>Anonymous warnings are less severe.</b>");
|
|
184 label = gtk_label_new(NULL);
|
|
185 gtk_label_set_markup(GTK_LABEL(label), labeltext);
|
|
186 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
|
187 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
188
|
|
189 dialogwindows = g_list_prepend(dialogwindows, w->window);
|
|
190 gtk_widget_show_all(w->window);
|
|
191 }
|
|
192
|
|
193 static void
|
|
194 do_remove_chat(GaimChat *chat)
|
|
195 {
|
|
196 gaim_blist_remove_chat(chat);
|
|
197 }
|
|
198
|
|
199 static void
|
|
200 do_remove_buddy(GaimBuddy *buddy)
|
|
201 {
|
|
202 GaimGroup *group;
|
|
203 GaimConversation *conv;
|
|
204 gchar *name;
|
|
205 GaimAccount *account;
|
|
206
|
|
207 if (!buddy)
|
|
208 return;
|
|
209
|
|
210 group = gaim_find_buddys_group(buddy);
|
|
211 name = g_strdup(buddy->name); /* b->name is a crasher after remove_buddy */
|
|
212 account = buddy->account;
|
|
213
|
|
214 gaim_debug(GAIM_DEBUG_INFO, "blist",
|
|
215 "Removing '%s' from buddy list.\n", buddy->name);
|
|
216 /* XXX - Should remove from blist first... then call serv_remove_buddy()? */
|
|
217 serv_remove_buddy(buddy->account->gc, buddy, group);
|
|
218 gaim_blist_remove_buddy(buddy);
|
|
219
|
|
220 conv = gaim_find_conversation_with_account(name, account);
|
|
221
|
|
222 if (conv != NULL)
|
|
223 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE);
|
|
224
|
|
225 g_free(name);
|
|
226 }
|
|
227
|
|
228 static void do_remove_contact(GaimContact *contact)
|
|
229 {
|
|
230 GaimBlistNode *bnode, *cnode;
|
|
231 GaimGroup *group;
|
|
232
|
|
233 if (!contact)
|
|
234 return;
|
|
235
|
|
236 cnode = (GaimBlistNode *)contact;
|
|
237 group = (GaimGroup*)cnode->parent;
|
|
238 for (bnode = cnode->child; bnode; bnode = bnode->next) {
|
|
239 GaimBuddy *buddy = (GaimBuddy*)bnode;
|
|
240 if (gaim_account_is_connected(buddy->account))
|
|
241 serv_remove_buddy(buddy->account->gc, buddy, group);
|
|
242 }
|
|
243 gaim_blist_remove_contact(contact);
|
|
244 }
|
|
245
|
|
246 void do_remove_group(GaimGroup *group)
|
|
247 {
|
|
248 GaimBlistNode *cnode, *bnode;
|
|
249
|
|
250 cnode = ((GaimBlistNode*)group)->child;
|
|
251
|
|
252 while (cnode) {
|
|
253 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) {
|
|
254 bnode = cnode->child;
|
|
255 cnode = cnode->next;
|
|
256 while (bnode) {
|
|
257 GaimBuddy *buddy;
|
|
258 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) {
|
|
259 GaimConversation *conv;
|
|
260 buddy = (GaimBuddy*)bnode;
|
|
261 bnode = bnode->next;
|
|
262 conv = gaim_find_conversation_with_account(buddy->name, buddy->account);
|
|
263 if (gaim_account_is_connected(buddy->account)) {
|
|
264 serv_remove_buddy(buddy->account->gc, buddy, group);
|
|
265 gaim_blist_remove_buddy(buddy);
|
|
266 if (conv)
|
|
267 gaim_conversation_update(conv,
|
|
268 GAIM_CONV_UPDATE_REMOVE);
|
|
269 }
|
|
270 } else {
|
|
271 bnode = bnode->next;
|
|
272 }
|
|
273 }
|
|
274 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) {
|
|
275 GaimChat *chat = (GaimChat *)cnode;
|
|
276 cnode = cnode->next;
|
|
277 if (gaim_account_is_connected(chat->account))
|
|
278 gaim_blist_remove_chat(chat);
|
|
279 } else {
|
|
280 cnode = cnode->next;
|
|
281 }
|
|
282 }
|
|
283
|
|
284 gaim_blist_remove_group(group);
|
|
285 }
|
|
286
|
|
287 void show_confirm_del(GaimBuddy *buddy)
|
|
288 {
|
|
289 char *text;
|
|
290
|
|
291 if (!buddy)
|
|
292 return;
|
|
293
|
|
294 text = g_strdup_printf(_("You are about to remove %s from your buddy list. Do you want to continue?"), buddy->name);
|
|
295
|
|
296 gaim_request_action(NULL, NULL, _("Remove Buddy"), text, -1, buddy, 2,
|
|
297 _("Remove Buddy"), G_CALLBACK(do_remove_buddy),
|
|
298 _("Cancel"), NULL);
|
|
299
|
|
300 g_free(text);
|
|
301 }
|
|
302
|
|
303 void show_confirm_del_blist_chat(GaimChat *chat)
|
|
304 {
|
|
305 char *name = gaim_chat_get_display_name(chat);
|
|
306 char *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name);
|
|
307
|
|
308 gaim_request_action(NULL, NULL, _("Remove Chat"), text, -1, chat, 2,
|
|
309 _("Remove Chat"), G_CALLBACK(do_remove_chat),
|
|
310 _("Cancel"), NULL);
|
|
311
|
|
312 g_free(name);
|
|
313 g_free(text);
|
|
314 }
|
|
315
|
|
316 void show_confirm_del_group(GaimGroup *group)
|
|
317 {
|
|
318 char *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?"),
|
|
319 group->name);
|
|
320
|
|
321 gaim_request_action(NULL, NULL, _("Remove Group"), text, -1, group, 2,
|
|
322 _("Remove Group"), G_CALLBACK(do_remove_group),
|
|
323 _("Cancel"), NULL);
|
|
324
|
|
325 g_free(text);
|
|
326 }
|
|
327
|
|
328 void show_confirm_del_contact(GaimContact *contact)
|
|
329 {
|
|
330 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact);
|
|
331
|
|
332 if (!buddy)
|
|
333 return;
|
|
334
|
|
335 if (((GaimBlistNode*)contact)->child == (GaimBlistNode*)buddy &&
|
|
336 !((GaimBlistNode*)buddy)->next) {
|
|
337 show_confirm_del(buddy);
|
|
338 } else {
|
|
339 char *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?"),
|
|
340 buddy->name, contact->totalsize - 1);
|
|
341
|
|
342 gaim_request_action(NULL, NULL, _("Remove Contact"), text, -1, contact, 2,
|
|
343 _("Remove Contact"), G_CALLBACK(do_remove_contact),
|
|
344 _("Cancel"), NULL);
|
|
345
|
|
346 g_free(text);
|
|
347 }
|
|
348 }
|
|
349
|
|
350 static gboolean show_ee_dialog(const char *ee)
|
|
351 {
|
|
352 GtkWidget *window;
|
|
353 GtkWidget *hbox;
|
|
354 GtkWidget *label;
|
|
355 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_COOL, GTK_ICON_SIZE_DIALOG);
|
|
356 gchar *norm = gaim_strreplace(ee, "rocksmyworld", "");
|
|
357
|
|
358 label = gtk_label_new(NULL);
|
|
359 if (!strcmp(norm, "zilding"))
|
|
360 gtk_label_set_markup(GTK_LABEL(label),
|
|
361 "<span weight=\"bold\" size=\"large\" foreground=\"purple\">Amazing! Simply Amazing!</span>");
|
|
362 else if (!strcmp(norm, "robflynn"))
|
|
363 gtk_label_set_markup(GTK_LABEL(label),
|
|
364 "<span weight=\"bold\" size=\"large\" foreground=\"#1f6bad\">Pimpin\' Penguin Style! *Waddle Waddle*</span>");
|
|
365 else if (!strcmp(norm, "flynorange"))
|
|
366 gtk_label_set_markup(GTK_LABEL(label),
|
|
367 "<span weight=\"bold\" size=\"large\" foreground=\"blue\">You should be me. I'm so cute!</span>");
|
|
368 else if (!strcmp(norm, "ewarmenhoven"))
|
|
369 gtk_label_set_markup(GTK_LABEL(label),
|
|
370 "<span weight=\"bold\" size=\"large\" foreground=\"orange\">Now that's what I like!</span>");
|
|
371 else if (!strcmp(norm, "markster97"))
|
|
372 gtk_label_set_markup(GTK_LABEL(label),
|
|
373 "<span weight=\"bold\" size=\"large\" foreground=\"brown\">Ahh, and excellent choice!</span>");
|
|
374 else if (!strcmp(norm, "seanegn"))
|
|
375 gtk_label_set_markup(GTK_LABEL(label),
|
|
376 "<span weight=\"bold\" size=\"large\" foreground=\"#009900\">Everytime you click my name, an angel gets its wings.</span>");
|
|
377 else if (!strcmp(norm, "chipx86"))
|
|
378 gtk_label_set_markup(GTK_LABEL(label),
|
|
379 "<span weight=\"bold\" size=\"large\" foreground=\"red\">This sunflower seed taste like pizza.</span>");
|
|
380 else if (!strcmp(norm, "markdoliner"))
|
|
381 gtk_label_set_markup(GTK_LABEL(label),
|
|
382 "<span weight=\"bold\" size=\"large\" foreground=\"#6364B1\">Hey! I was in that tumbleweed!</span>");
|
|
383 else if (!strcmp(norm, "lschiere"))
|
|
384 gtk_label_set_markup(GTK_LABEL(label),
|
|
385 "<span weight=\"bold\" size=\"large\" foreground=\"gray\">I'm not anything.</span>");
|
|
386 g_free(norm);
|
|
387
|
|
388 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0)
|
|
389 return FALSE;
|
|
390
|
|
391 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
|
|
392 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK);
|
|
393 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL);
|
|
394
|
|
395 gtk_container_set_border_width (GTK_CONTAINER(window), 6);
|
|
396 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
|
|
397 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE);
|
|
398 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12);
|
|
399 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6);
|
|
400
|
|
401 hbox = gtk_hbox_new(FALSE, 12);
|
|
402 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox);
|
|
403 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
|
|
404
|
|
405 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
|
406 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
407 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
408
|
|
409 gtk_widget_show_all(window);
|
|
410 return TRUE;
|
|
411 }
|
|
412
|
|
413 void
|
9728
|
414 gaim_gtkdialogs_im_with_user(GaimAccount *account, const char *username)
|
9709
|
415 {
|
|
416 GaimConversation *conv;
|
|
417 GaimConvWindow *win;
|
9728
|
418 GaimGtkWindow *gtkwin;
|
9709
|
419
|
|
420 conv = gaim_find_conversation_with_account(username, account);
|
|
421
|
|
422 if (conv == NULL)
|
|
423 conv = gaim_conversation_new(GAIM_CONV_IM, account, username);
|
|
424
|
|
425 win = gaim_conversation_get_window(conv);
|
9728
|
426 gtkwin = GAIM_GTK_WINDOW(win);
|
9709
|
427
|
9728
|
428 gtk_window_present(GTK_WINDOW(gtkwin->window));
|
9709
|
429 gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv));
|
|
430 }
|
|
431
|
|
432 static void
|
|
433 new_im_cb(gpointer data, GaimRequestFields *fields)
|
|
434 {
|
|
435 GaimAccount *account;
|
|
436 const char *username;
|
|
437
|
|
438 account = gaim_request_fields_get_account(fields, "account");
|
|
439 username = gaim_request_fields_get_string(fields, "screenname");
|
|
440
|
9728
|
441 gaim_gtkdialogs_im_with_user(account, username);
|
9709
|
442 }
|
|
443
|
|
444 void
|
9714
|
445 gaim_gtkdialogs_im(void)
|
9709
|
446 {
|
|
447 GaimRequestFields *fields;
|
|
448 GaimRequestFieldGroup *group;
|
|
449 GaimRequestField *field;
|
|
450
|
|
451 fields = gaim_request_fields_new();
|
|
452
|
|
453 group = gaim_request_field_group_new(NULL);
|
|
454 gaim_request_fields_add_group(fields, group);
|
|
455
|
|
456 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
457 NULL, FALSE);
|
|
458 gaim_request_field_set_required(field, TRUE);
|
|
459 gaim_request_field_set_type_hint(field, "screenname");
|
|
460 gaim_request_field_group_add_field(group, field);
|
|
461
|
|
462 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
463 gaim_request_field_set_visible(field,
|
|
464 (gaim_connections_get_all() != NULL &&
|
|
465 gaim_connections_get_all()->next != NULL));
|
|
466 gaim_request_field_set_required(field, TRUE);
|
|
467 gaim_request_field_group_add_field(group, field);
|
|
468
|
|
469 gaim_request_fields(gaim_get_blist(), _("New Instant Message"),
|
|
470 NULL,
|
|
471 _("Please enter the screen name of the person you "
|
|
472 "would like to IM."),
|
|
473 fields,
|
|
474 _("OK"), G_CALLBACK(new_im_cb),
|
|
475 _("Cancel"), NULL,
|
|
476 NULL);
|
|
477 }
|
|
478
|
|
479 static void
|
|
480 get_info_cb(gpointer data, GaimRequestFields *fields)
|
|
481 {
|
|
482 char *username;
|
|
483 gboolean found = FALSE;
|
|
484 GaimAccount *account;
|
|
485
|
|
486 account = gaim_request_fields_get_account(fields, "account");
|
|
487
|
|
488 username = g_strdup(gaim_normalize(account,
|
|
489 gaim_request_fields_get_string(fields, "screenname")));
|
|
490
|
|
491 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld"))
|
|
492 found = show_ee_dialog(username);
|
|
493
|
|
494 if (!found && username != NULL && *username != '\0' && account != NULL)
|
|
495 serv_get_info(gaim_account_get_connection(account), username);
|
|
496
|
|
497 g_free(username);
|
|
498 }
|
|
499
|
|
500 void
|
9714
|
501 gaim_gtkdialogs_info(void)
|
9709
|
502 {
|
|
503 GaimRequestFields *fields;
|
|
504 GaimRequestFieldGroup *group;
|
|
505 GaimRequestField *field;
|
|
506
|
|
507 fields = gaim_request_fields_new();
|
|
508
|
|
509 group = gaim_request_field_group_new(NULL);
|
|
510 gaim_request_fields_add_group(fields, group);
|
|
511
|
|
512 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
513 NULL, FALSE);
|
|
514 gaim_request_field_set_type_hint(field, "screenname");
|
|
515 gaim_request_field_set_required(field, TRUE);
|
|
516 gaim_request_field_group_add_field(group, field);
|
|
517
|
|
518 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
519 gaim_request_field_set_visible(field,
|
|
520 (gaim_connections_get_all() != NULL &&
|
|
521 gaim_connections_get_all()->next != NULL));
|
|
522 gaim_request_field_set_required(field, TRUE);
|
|
523 gaim_request_field_group_add_field(group, field);
|
|
524
|
|
525 gaim_request_fields(gaim_get_blist(), _("Get User Info"),
|
|
526 NULL,
|
|
527 _("Please enter the screen name of the person whose "
|
|
528 "info you would like to view."),
|
|
529 fields,
|
|
530 _("OK"), G_CALLBACK(get_info_cb),
|
|
531 _("Cancel"), NULL,
|
|
532 NULL);
|
|
533 }
|
|
534
|
|
535 static void
|
|
536 get_log_cb(gpointer data, GaimRequestFields *fields)
|
|
537 {
|
|
538 char *username;
|
|
539 GaimAccount *account;
|
|
540
|
|
541 account = gaim_request_fields_get_account(fields, "account");
|
|
542
|
|
543 username = g_strdup(gaim_normalize(account,
|
|
544 gaim_request_fields_get_string(fields, "screenname")));
|
|
545
|
|
546 if( username != NULL && *username != '\0' && account != NULL )
|
|
547 gaim_gtk_log_show( username, account );
|
|
548
|
|
549 g_free(username);
|
|
550 }
|
|
551
|
|
552 void
|
9714
|
553 gaim_gtkdialogs_log(void)
|
9709
|
554 {
|
|
555 GaimRequestFields *fields;
|
|
556 GaimRequestFieldGroup *group;
|
|
557 GaimRequestField *field;
|
|
558
|
|
559 fields = gaim_request_fields_new();
|
|
560
|
|
561 group = gaim_request_field_group_new(NULL);
|
|
562 gaim_request_fields_add_group(fields, group);
|
|
563
|
|
564 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
565 NULL, FALSE);
|
|
566 gaim_request_field_set_type_hint(field, "screenname");
|
|
567 gaim_request_field_set_required(field, TRUE);
|
|
568 gaim_request_field_group_add_field(group, field);
|
|
569
|
|
570 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
571 gaim_request_field_account_set_show_all(field, TRUE);
|
|
572 gaim_request_field_set_visible(field,
|
|
573 (gaim_accounts_get_all() != NULL &&
|
|
574 gaim_accounts_get_all()->next != NULL));
|
|
575 gaim_request_field_set_required(field, TRUE);
|
|
576 gaim_request_field_group_add_field(group, field);
|
|
577
|
|
578 gaim_request_fields(gaim_get_blist(), _("Get User Log"),
|
|
579 NULL,
|
|
580 _("Please enter the screen name of the person whose "
|
|
581 "log you would like to view."),
|
|
582 fields,
|
|
583 _("OK"), G_CALLBACK(get_log_cb),
|
|
584 _("Cancel"), NULL,
|
|
585 NULL);
|
|
586 }
|
|
587
|
|
588 /*------------------------------------------------------------------------*/
|
|
589 /* The dialog for new away messages */
|
|
590 /*------------------------------------------------------------------------*/
|
|
591
|
|
592 static void away_mess_destroy(GtkWidget *widget, struct create_away *ca)
|
|
593 {
|
|
594 destroy_dialog(NULL, ca->window);
|
|
595 g_free(ca);
|
|
596 }
|
|
597
|
|
598 static void away_mess_destroy_ca(GtkWidget *widget, GdkEvent *event, struct create_away *ca)
|
|
599 {
|
|
600 away_mess_destroy(NULL, ca);
|
|
601 }
|
|
602
|
|
603 static gint sort_awaymsg_list(gconstpointer a, gconstpointer b)
|
|
604 {
|
|
605 struct away_message *msg_a;
|
|
606 struct away_message *msg_b;
|
|
607
|
|
608 msg_a = (struct away_message *)a;
|
|
609 msg_b = (struct away_message *)b;
|
|
610
|
|
611 return (strcmp(msg_a->name, msg_b->name));
|
|
612 }
|
|
613
|
|
614 static struct away_message *save_away_message(struct create_away *ca)
|
|
615 {
|
|
616 struct away_message *am;
|
|
617 gchar *away_message;
|
|
618
|
|
619 if (!ca->mess)
|
|
620 am = g_new0(struct away_message, 1);
|
|
621 else {
|
|
622 am = ca->mess;
|
|
623 }
|
|
624
|
|
625 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
|
|
626 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text));
|
|
627
|
|
628 g_snprintf(am->message, sizeof(am->message), "%s", away_message);
|
|
629 g_free(away_message);
|
|
630
|
|
631 if (!ca->mess)
|
|
632 away_messages = g_slist_insert_sorted(away_messages, am, sort_awaymsg_list);
|
|
633
|
|
634 do_away_menu(NULL);
|
|
635 gaim_status_sync();
|
|
636
|
|
637 return am;
|
|
638 }
|
|
639
|
|
640 int check_away_mess(struct create_away *ca, int type)
|
|
641 {
|
|
642 gchar *msg;
|
|
643 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) {
|
|
644 /* We shouldn't allow a blank title */
|
|
645 gaim_notify_error(NULL, NULL,
|
|
646 _("You cannot save an away message with a "
|
|
647 "blank title"),
|
|
648 _("Please give the message a title, or choose "
|
|
649 "\"Use\" to use without saving."));
|
|
650 return 0;
|
|
651 }
|
|
652
|
|
653 msg = gtk_imhtml_get_text(GTK_IMHTML(ca->text), NULL, NULL);
|
|
654
|
|
655 if ((type <= 1) && ((msg == NULL) || (*msg == '\0'))) {
|
|
656 /* We shouldn't allow a blank message */
|
|
657 gaim_notify_error(NULL, NULL,
|
|
658 _("You cannot create an empty away message"), NULL);
|
|
659 return 0;
|
|
660 }
|
|
661
|
|
662 g_free(msg);
|
|
663
|
|
664 return 1;
|
|
665 }
|
|
666
|
|
667 void save_away_mess(GtkWidget *widget, struct create_away *ca)
|
|
668 {
|
|
669 if (!check_away_mess(ca, 1))
|
|
670 return;
|
|
671
|
|
672 save_away_message(ca);
|
|
673
|
|
674 away_mess_destroy(NULL, ca);
|
|
675 }
|
|
676
|
|
677 void use_away_mess(GtkWidget *widget, struct create_away *ca)
|
|
678 {
|
|
679 static struct away_message am;
|
|
680 gchar *away_message;
|
|
681
|
|
682 if (!check_away_mess(ca, 0))
|
|
683 return;
|
|
684
|
|
685 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
|
|
686 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text));
|
|
687
|
|
688 g_snprintf(am.message, sizeof(am.message), "%s", away_message);
|
|
689 g_free(away_message);
|
|
690
|
|
691 do_away_message(NULL, &am);
|
|
692
|
|
693 away_mess_destroy(NULL, ca);
|
|
694 }
|
|
695
|
|
696 void su_away_mess(GtkWidget *widget, struct create_away *ca)
|
|
697 {
|
|
698 if (!check_away_mess(ca, 1))
|
|
699 return;
|
|
700
|
|
701 do_away_message(NULL, save_away_message(ca));
|
|
702
|
|
703 away_mess_destroy(NULL, ca);
|
|
704 }
|
|
705
|
|
706 void create_away_mess(GtkWidget *widget, void *dummy)
|
|
707 {
|
|
708 GtkWidget *vbox, *hbox;
|
|
709 GtkWidget *label;
|
|
710 GtkWidget *sw;
|
|
711 GtkWidget *button;
|
|
712 GList *focus_chain = NULL;
|
|
713 struct create_away *ca = g_new0(struct create_away, 1);
|
|
714
|
|
715 /* Set up window */
|
|
716 GAIM_DIALOG(ca->window);
|
|
717 gtk_widget_set_size_request(ca->window, -1, 250);
|
|
718 gtk_window_set_role(GTK_WINDOW(ca->window), "away_mess");
|
|
719 gtk_window_set_title(GTK_WINDOW(ca->window), _("New away message"));
|
|
720 g_signal_connect(G_OBJECT(ca->window), "delete_event",
|
|
721 G_CALLBACK(away_mess_destroy_ca), ca);
|
|
722
|
|
723 hbox = gtk_hbox_new(FALSE, 12);
|
|
724 gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
|
|
725 gtk_container_add(GTK_CONTAINER(ca->window), hbox);
|
|
726
|
|
727 vbox = gtk_vbox_new(FALSE, 12);
|
|
728 gtk_container_add(GTK_CONTAINER(hbox), vbox);
|
|
729
|
|
730 /* Away message title */
|
|
731 hbox = gtk_hbox_new(FALSE, 0);
|
|
732 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
733
|
|
734 label = gtk_label_new(_("Away title: "));
|
|
735 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
736
|
|
737 ca->entry = gtk_entry_new();
|
|
738 gtk_box_pack_start(GTK_BOX(hbox), ca->entry, TRUE, TRUE, 0);
|
|
739 gaim_set_accessible_label (ca->entry, label);
|
|
740 focus_chain = g_list_append(focus_chain, hbox);
|
|
741
|
|
742 /* Toolbar */
|
|
743 ca->toolbar = gtk_imhtmltoolbar_new();
|
|
744 gtk_box_pack_start(GTK_BOX(vbox), ca->toolbar, FALSE, FALSE, 0);
|
|
745
|
|
746 /* Away message text */
|
|
747 sw = gtk_scrolled_window_new(NULL, NULL);
|
|
748 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
|
|
749 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
750 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
|
|
751 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
|
|
752
|
|
753 ca->text = gtk_imhtml_new(NULL, NULL);
|
|
754 gtk_imhtml_set_editable(GTK_IMHTML(ca->text), TRUE);
|
|
755 gtk_imhtml_set_format_functions(GTK_IMHTML(ca->text), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE);
|
|
756 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(ca->text), GTK_WRAP_WORD_CHAR);
|
|
757
|
|
758 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(ca->text),
|
|
759 gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts"));
|
|
760 gtk_imhtml_html_shortcuts(GTK_IMHTML(ca->text),
|
|
761 gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts"));
|
|
762 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck"))
|
|
763 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(ca->text));
|
|
764 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(ca->toolbar), ca->text);
|
|
765 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(ca->toolbar), "default");
|
|
766 gaim_setup_imhtml(ca->text);
|
|
767
|
|
768 gtk_container_add(GTK_CONTAINER(sw), ca->text);
|
|
769 focus_chain = g_list_append(focus_chain, sw);
|
|
770
|
|
771 if (dummy) {
|
|
772 struct away_message *amt;
|
|
773 GtkTreeIter iter;
|
|
774 GtkListStore *ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dummy)));
|
|
775 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dummy));
|
|
776 GValue val = { 0, };
|
|
777
|
|
778 if (! gtk_tree_selection_get_selected (sel, (GtkTreeModel**)&ls, &iter))
|
|
779 return;
|
|
780 gtk_tree_model_get_value (GTK_TREE_MODEL(ls), &iter, 1, &val);
|
|
781 amt = g_value_get_pointer (&val);
|
|
782 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name);
|
|
783 gtk_imhtml_append_text_with_images(GTK_IMHTML(ca->text), amt->message, 0, NULL);
|
|
784 ca->mess = amt;
|
|
785 }
|
|
786
|
|
787 hbox = gtk_hbox_new(FALSE, 5);
|
|
788 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
789
|
|
790 button = gaim_pixbuf_button_from_stock(_("_Save"), GTK_STOCK_SAVE, GAIM_BUTTON_HORIZONTAL);
|
|
791 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(save_away_mess), ca);
|
|
792 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
793
|
|
794 button = gaim_pixbuf_button_from_stock(_("Sa_ve & Use"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL);
|
|
795 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(su_away_mess), ca);
|
|
796 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
797
|
|
798 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE, GAIM_BUTTON_HORIZONTAL);
|
|
799 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(use_away_mess), ca);
|
|
800 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
801
|
|
802 button = gaim_pixbuf_button_from_stock(_("_Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL);
|
|
803 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(away_mess_destroy), ca);
|
|
804 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
805 focus_chain = g_list_prepend(focus_chain, hbox);
|
|
806
|
|
807 gtk_widget_show_all(ca->window);
|
|
808 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain);
|
|
809 }
|
|
810
|
|
811 static void
|
|
812 alias_chat_cb(GaimChat *chat, const char *new_alias)
|
|
813 {
|
|
814 gaim_blist_alias_chat(chat, new_alias);
|
|
815 }
|
|
816
|
|
817 void
|
|
818 alias_dialog_blist_chat(GaimChat *chat)
|
|
819 {
|
|
820 gaim_request_input(NULL, _("Alias Chat"), NULL,
|
|
821 _("Enter an alias for this chat."),
|
|
822 chat->alias, FALSE, FALSE, NULL,
|
|
823 _("Alias"), G_CALLBACK(alias_chat_cb),
|
|
824 _("Cancel"), NULL, chat);
|
|
825 }
|
|
826
|
|
827 static void
|
|
828 alias_contact_cb(GaimContact *contact, const char *new_alias)
|
|
829 {
|
|
830 gaim_contact_set_alias(contact, new_alias);
|
|
831 }
|
|
832
|
|
833 void
|
|
834 alias_dialog_contact(GaimContact *contact)
|
|
835 {
|
|
836 gaim_request_input(NULL, _("Alias Contact"), NULL,
|
|
837 _("Enter an alias for this contact."),
|
|
838 contact->alias, FALSE, FALSE, NULL,
|
|
839 _("Alias"), G_CALLBACK(alias_contact_cb),
|
|
840 _("Cancel"), NULL, contact);
|
|
841 }
|
|
842
|
|
843 static void
|
|
844 alias_buddy_cb(GaimBuddy *buddy, const char *alias)
|
|
845 {
|
|
846 gaim_blist_alias_buddy(buddy, (alias != NULL && *alias != '\0') ? alias : NULL);
|
|
847 serv_alias_buddy(buddy);
|
|
848 }
|
|
849
|
|
850 void
|
|
851 alias_dialog_bud(GaimBuddy *b)
|
|
852 {
|
|
853 char *secondary = g_strdup_printf(_("Enter an alias for %s."), b->name);
|
|
854
|
|
855 gaim_request_input(NULL, _("Alias Buddy"), NULL,
|
|
856 secondary, b->alias, FALSE, FALSE, NULL,
|
|
857 _("Alias"), G_CALLBACK(alias_buddy_cb),
|
|
858 _("Cancel"), NULL, b);
|
|
859
|
|
860 g_free(secondary);
|
|
861 }
|