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
|
|
414 gaim_gtkdialogs_new_im(GaimAccount *account, const char *username)
|
|
415 {
|
|
416 GaimConversation *conv;
|
|
417 GaimConvWindow *win;
|
|
418
|
|
419 conv = gaim_find_conversation_with_account(username, account);
|
|
420
|
|
421 if (conv == NULL)
|
|
422 conv = gaim_conversation_new(GAIM_CONV_IM, account, username);
|
|
423
|
|
424 win = gaim_conversation_get_window(conv);
|
|
425
|
|
426 gaim_conv_window_raise(win);
|
|
427 gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv));
|
|
428 }
|
|
429
|
|
430 static void
|
|
431 new_im_cb(gpointer data, GaimRequestFields *fields)
|
|
432 {
|
|
433 GaimAccount *account;
|
|
434 const char *username;
|
|
435
|
|
436 account = gaim_request_fields_get_account(fields, "account");
|
|
437 username = gaim_request_fields_get_string(fields, "screenname");
|
|
438
|
|
439 gaim_gtkdialogs_new_im(account, username);
|
|
440 }
|
|
441
|
|
442 void
|
9714
|
443 gaim_gtkdialogs_im(void)
|
9709
|
444 {
|
|
445 GaimRequestFields *fields;
|
|
446 GaimRequestFieldGroup *group;
|
|
447 GaimRequestField *field;
|
|
448
|
|
449 fields = gaim_request_fields_new();
|
|
450
|
|
451 group = gaim_request_field_group_new(NULL);
|
|
452 gaim_request_fields_add_group(fields, group);
|
|
453
|
|
454 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
455 NULL, FALSE);
|
|
456 gaim_request_field_set_required(field, TRUE);
|
|
457 gaim_request_field_set_type_hint(field, "screenname");
|
|
458 gaim_request_field_group_add_field(group, field);
|
|
459
|
|
460 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
461 gaim_request_field_set_visible(field,
|
|
462 (gaim_connections_get_all() != NULL &&
|
|
463 gaim_connections_get_all()->next != NULL));
|
|
464 gaim_request_field_set_required(field, TRUE);
|
|
465 gaim_request_field_group_add_field(group, field);
|
|
466
|
|
467 gaim_request_fields(gaim_get_blist(), _("New Instant Message"),
|
|
468 NULL,
|
|
469 _("Please enter the screen name of the person you "
|
|
470 "would like to IM."),
|
|
471 fields,
|
|
472 _("OK"), G_CALLBACK(new_im_cb),
|
|
473 _("Cancel"), NULL,
|
|
474 NULL);
|
|
475 }
|
|
476
|
|
477 static void
|
|
478 get_info_cb(gpointer data, GaimRequestFields *fields)
|
|
479 {
|
|
480 char *username;
|
|
481 gboolean found = FALSE;
|
|
482 GaimAccount *account;
|
|
483
|
|
484 account = gaim_request_fields_get_account(fields, "account");
|
|
485
|
|
486 username = g_strdup(gaim_normalize(account,
|
|
487 gaim_request_fields_get_string(fields, "screenname")));
|
|
488
|
|
489 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld"))
|
|
490 found = show_ee_dialog(username);
|
|
491
|
|
492 if (!found && username != NULL && *username != '\0' && account != NULL)
|
|
493 serv_get_info(gaim_account_get_connection(account), username);
|
|
494
|
|
495 g_free(username);
|
|
496 }
|
|
497
|
|
498 void
|
9714
|
499 gaim_gtkdialogs_info(void)
|
9709
|
500 {
|
|
501 GaimRequestFields *fields;
|
|
502 GaimRequestFieldGroup *group;
|
|
503 GaimRequestField *field;
|
|
504
|
|
505 fields = gaim_request_fields_new();
|
|
506
|
|
507 group = gaim_request_field_group_new(NULL);
|
|
508 gaim_request_fields_add_group(fields, group);
|
|
509
|
|
510 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
511 NULL, FALSE);
|
|
512 gaim_request_field_set_type_hint(field, "screenname");
|
|
513 gaim_request_field_set_required(field, TRUE);
|
|
514 gaim_request_field_group_add_field(group, field);
|
|
515
|
|
516 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
517 gaim_request_field_set_visible(field,
|
|
518 (gaim_connections_get_all() != NULL &&
|
|
519 gaim_connections_get_all()->next != NULL));
|
|
520 gaim_request_field_set_required(field, TRUE);
|
|
521 gaim_request_field_group_add_field(group, field);
|
|
522
|
|
523 gaim_request_fields(gaim_get_blist(), _("Get User Info"),
|
|
524 NULL,
|
|
525 _("Please enter the screen name of the person whose "
|
|
526 "info you would like to view."),
|
|
527 fields,
|
|
528 _("OK"), G_CALLBACK(get_info_cb),
|
|
529 _("Cancel"), NULL,
|
|
530 NULL);
|
|
531 }
|
|
532
|
|
533 static void
|
|
534 get_log_cb(gpointer data, GaimRequestFields *fields)
|
|
535 {
|
|
536 char *username;
|
|
537 GaimAccount *account;
|
|
538
|
|
539 account = gaim_request_fields_get_account(fields, "account");
|
|
540
|
|
541 username = g_strdup(gaim_normalize(account,
|
|
542 gaim_request_fields_get_string(fields, "screenname")));
|
|
543
|
|
544 if( username != NULL && *username != '\0' && account != NULL )
|
|
545 gaim_gtk_log_show( username, account );
|
|
546
|
|
547 g_free(username);
|
|
548 }
|
|
549
|
|
550 void
|
9714
|
551 gaim_gtkdialogs_log(void)
|
9709
|
552 {
|
|
553 GaimRequestFields *fields;
|
|
554 GaimRequestFieldGroup *group;
|
|
555 GaimRequestField *field;
|
|
556
|
|
557 fields = gaim_request_fields_new();
|
|
558
|
|
559 group = gaim_request_field_group_new(NULL);
|
|
560 gaim_request_fields_add_group(fields, group);
|
|
561
|
|
562 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
563 NULL, FALSE);
|
|
564 gaim_request_field_set_type_hint(field, "screenname");
|
|
565 gaim_request_field_set_required(field, TRUE);
|
|
566 gaim_request_field_group_add_field(group, field);
|
|
567
|
|
568 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
569 gaim_request_field_account_set_show_all(field, TRUE);
|
|
570 gaim_request_field_set_visible(field,
|
|
571 (gaim_accounts_get_all() != NULL &&
|
|
572 gaim_accounts_get_all()->next != NULL));
|
|
573 gaim_request_field_set_required(field, TRUE);
|
|
574 gaim_request_field_group_add_field(group, field);
|
|
575
|
|
576 gaim_request_fields(gaim_get_blist(), _("Get User Log"),
|
|
577 NULL,
|
|
578 _("Please enter the screen name of the person whose "
|
|
579 "log you would like to view."),
|
|
580 fields,
|
|
581 _("OK"), G_CALLBACK(get_log_cb),
|
|
582 _("Cancel"), NULL,
|
|
583 NULL);
|
|
584 }
|
|
585
|
|
586 /*------------------------------------------------------------------------*/
|
|
587 /* The dialog for new away messages */
|
|
588 /*------------------------------------------------------------------------*/
|
|
589
|
|
590 static void away_mess_destroy(GtkWidget *widget, struct create_away *ca)
|
|
591 {
|
|
592 destroy_dialog(NULL, ca->window);
|
|
593 g_free(ca);
|
|
594 }
|
|
595
|
|
596 static void away_mess_destroy_ca(GtkWidget *widget, GdkEvent *event, struct create_away *ca)
|
|
597 {
|
|
598 away_mess_destroy(NULL, ca);
|
|
599 }
|
|
600
|
|
601 static gint sort_awaymsg_list(gconstpointer a, gconstpointer b)
|
|
602 {
|
|
603 struct away_message *msg_a;
|
|
604 struct away_message *msg_b;
|
|
605
|
|
606 msg_a = (struct away_message *)a;
|
|
607 msg_b = (struct away_message *)b;
|
|
608
|
|
609 return (strcmp(msg_a->name, msg_b->name));
|
|
610 }
|
|
611
|
|
612 static struct away_message *save_away_message(struct create_away *ca)
|
|
613 {
|
|
614 struct away_message *am;
|
|
615 gchar *away_message;
|
|
616
|
|
617 if (!ca->mess)
|
|
618 am = g_new0(struct away_message, 1);
|
|
619 else {
|
|
620 am = ca->mess;
|
|
621 }
|
|
622
|
|
623 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
|
|
624 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text));
|
|
625
|
|
626 g_snprintf(am->message, sizeof(am->message), "%s", away_message);
|
|
627 g_free(away_message);
|
|
628
|
|
629 if (!ca->mess)
|
|
630 away_messages = g_slist_insert_sorted(away_messages, am, sort_awaymsg_list);
|
|
631
|
|
632 do_away_menu(NULL);
|
|
633 gaim_status_sync();
|
|
634
|
|
635 return am;
|
|
636 }
|
|
637
|
|
638 int check_away_mess(struct create_away *ca, int type)
|
|
639 {
|
|
640 gchar *msg;
|
|
641 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) {
|
|
642 /* We shouldn't allow a blank title */
|
|
643 gaim_notify_error(NULL, NULL,
|
|
644 _("You cannot save an away message with a "
|
|
645 "blank title"),
|
|
646 _("Please give the message a title, or choose "
|
|
647 "\"Use\" to use without saving."));
|
|
648 return 0;
|
|
649 }
|
|
650
|
|
651 msg = gtk_imhtml_get_text(GTK_IMHTML(ca->text), NULL, NULL);
|
|
652
|
|
653 if ((type <= 1) && ((msg == NULL) || (*msg == '\0'))) {
|
|
654 /* We shouldn't allow a blank message */
|
|
655 gaim_notify_error(NULL, NULL,
|
|
656 _("You cannot create an empty away message"), NULL);
|
|
657 return 0;
|
|
658 }
|
|
659
|
|
660 g_free(msg);
|
|
661
|
|
662 return 1;
|
|
663 }
|
|
664
|
|
665 void save_away_mess(GtkWidget *widget, struct create_away *ca)
|
|
666 {
|
|
667 if (!check_away_mess(ca, 1))
|
|
668 return;
|
|
669
|
|
670 save_away_message(ca);
|
|
671
|
|
672 away_mess_destroy(NULL, ca);
|
|
673 }
|
|
674
|
|
675 void use_away_mess(GtkWidget *widget, struct create_away *ca)
|
|
676 {
|
|
677 static struct away_message am;
|
|
678 gchar *away_message;
|
|
679
|
|
680 if (!check_away_mess(ca, 0))
|
|
681 return;
|
|
682
|
|
683 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
|
|
684 away_message = gtk_imhtml_get_markup(GTK_IMHTML(ca->text));
|
|
685
|
|
686 g_snprintf(am.message, sizeof(am.message), "%s", away_message);
|
|
687 g_free(away_message);
|
|
688
|
|
689 do_away_message(NULL, &am);
|
|
690
|
|
691 away_mess_destroy(NULL, ca);
|
|
692 }
|
|
693
|
|
694 void su_away_mess(GtkWidget *widget, struct create_away *ca)
|
|
695 {
|
|
696 if (!check_away_mess(ca, 1))
|
|
697 return;
|
|
698
|
|
699 do_away_message(NULL, save_away_message(ca));
|
|
700
|
|
701 away_mess_destroy(NULL, ca);
|
|
702 }
|
|
703
|
|
704 void create_away_mess(GtkWidget *widget, void *dummy)
|
|
705 {
|
|
706 GtkWidget *vbox, *hbox;
|
|
707 GtkWidget *label;
|
|
708 GtkWidget *sw;
|
|
709 GtkWidget *button;
|
|
710 GList *focus_chain = NULL;
|
|
711 struct create_away *ca = g_new0(struct create_away, 1);
|
|
712
|
|
713 /* Set up window */
|
|
714 GAIM_DIALOG(ca->window);
|
|
715 gtk_widget_set_size_request(ca->window, -1, 250);
|
|
716 gtk_window_set_role(GTK_WINDOW(ca->window), "away_mess");
|
|
717 gtk_window_set_title(GTK_WINDOW(ca->window), _("New away message"));
|
|
718 g_signal_connect(G_OBJECT(ca->window), "delete_event",
|
|
719 G_CALLBACK(away_mess_destroy_ca), ca);
|
|
720
|
|
721 hbox = gtk_hbox_new(FALSE, 12);
|
|
722 gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
|
|
723 gtk_container_add(GTK_CONTAINER(ca->window), hbox);
|
|
724
|
|
725 vbox = gtk_vbox_new(FALSE, 12);
|
|
726 gtk_container_add(GTK_CONTAINER(hbox), vbox);
|
|
727
|
|
728 /* Away message title */
|
|
729 hbox = gtk_hbox_new(FALSE, 0);
|
|
730 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
731
|
|
732 label = gtk_label_new(_("Away title: "));
|
|
733 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
734
|
|
735 ca->entry = gtk_entry_new();
|
|
736 gtk_box_pack_start(GTK_BOX(hbox), ca->entry, TRUE, TRUE, 0);
|
|
737 gaim_set_accessible_label (ca->entry, label);
|
|
738 focus_chain = g_list_append(focus_chain, hbox);
|
|
739
|
|
740 /* Toolbar */
|
|
741 ca->toolbar = gtk_imhtmltoolbar_new();
|
|
742 gtk_box_pack_start(GTK_BOX(vbox), ca->toolbar, FALSE, FALSE, 0);
|
|
743
|
|
744 /* Away message text */
|
|
745 sw = gtk_scrolled_window_new(NULL, NULL);
|
|
746 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
|
|
747 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
748 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
|
|
749 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
|
|
750
|
|
751 ca->text = gtk_imhtml_new(NULL, NULL);
|
|
752 gtk_imhtml_set_editable(GTK_IMHTML(ca->text), TRUE);
|
|
753 gtk_imhtml_set_format_functions(GTK_IMHTML(ca->text), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE);
|
|
754 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(ca->text), GTK_WRAP_WORD_CHAR);
|
|
755
|
|
756 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(ca->text),
|
|
757 gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts"));
|
|
758 gtk_imhtml_html_shortcuts(GTK_IMHTML(ca->text),
|
|
759 gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts"));
|
|
760 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck"))
|
|
761 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(ca->text));
|
|
762 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(ca->toolbar), ca->text);
|
|
763 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(ca->toolbar), "default");
|
|
764 gaim_setup_imhtml(ca->text);
|
|
765
|
|
766 gtk_container_add(GTK_CONTAINER(sw), ca->text);
|
|
767 focus_chain = g_list_append(focus_chain, sw);
|
|
768
|
|
769 if (dummy) {
|
|
770 struct away_message *amt;
|
|
771 GtkTreeIter iter;
|
|
772 GtkListStore *ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dummy)));
|
|
773 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dummy));
|
|
774 GValue val = { 0, };
|
|
775
|
|
776 if (! gtk_tree_selection_get_selected (sel, (GtkTreeModel**)&ls, &iter))
|
|
777 return;
|
|
778 gtk_tree_model_get_value (GTK_TREE_MODEL(ls), &iter, 1, &val);
|
|
779 amt = g_value_get_pointer (&val);
|
|
780 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name);
|
|
781 gtk_imhtml_append_text_with_images(GTK_IMHTML(ca->text), amt->message, 0, NULL);
|
|
782 ca->mess = amt;
|
|
783 }
|
|
784
|
|
785 hbox = gtk_hbox_new(FALSE, 5);
|
|
786 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
787
|
|
788 button = gaim_pixbuf_button_from_stock(_("_Save"), GTK_STOCK_SAVE, GAIM_BUTTON_HORIZONTAL);
|
|
789 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(save_away_mess), ca);
|
|
790 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
791
|
|
792 button = gaim_pixbuf_button_from_stock(_("Sa_ve & Use"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL);
|
|
793 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(su_away_mess), ca);
|
|
794 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
795
|
|
796 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE, GAIM_BUTTON_HORIZONTAL);
|
|
797 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(use_away_mess), ca);
|
|
798 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
799
|
|
800 button = gaim_pixbuf_button_from_stock(_("_Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL);
|
|
801 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(away_mess_destroy), ca);
|
|
802 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
|
803 focus_chain = g_list_prepend(focus_chain, hbox);
|
|
804
|
|
805 gtk_widget_show_all(ca->window);
|
|
806 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain);
|
|
807 }
|
|
808
|
|
809 static void
|
|
810 alias_chat_cb(GaimChat *chat, const char *new_alias)
|
|
811 {
|
|
812 gaim_blist_alias_chat(chat, new_alias);
|
|
813 }
|
|
814
|
|
815 void
|
|
816 alias_dialog_blist_chat(GaimChat *chat)
|
|
817 {
|
|
818 gaim_request_input(NULL, _("Alias Chat"), NULL,
|
|
819 _("Enter an alias for this chat."),
|
|
820 chat->alias, FALSE, FALSE, NULL,
|
|
821 _("Alias"), G_CALLBACK(alias_chat_cb),
|
|
822 _("Cancel"), NULL, chat);
|
|
823 }
|
|
824
|
|
825 static void
|
|
826 alias_contact_cb(GaimContact *contact, const char *new_alias)
|
|
827 {
|
|
828 gaim_contact_set_alias(contact, new_alias);
|
|
829 }
|
|
830
|
|
831 void
|
|
832 alias_dialog_contact(GaimContact *contact)
|
|
833 {
|
|
834 gaim_request_input(NULL, _("Alias Contact"), NULL,
|
|
835 _("Enter an alias for this contact."),
|
|
836 contact->alias, FALSE, FALSE, NULL,
|
|
837 _("Alias"), G_CALLBACK(alias_contact_cb),
|
|
838 _("Cancel"), NULL, contact);
|
|
839 }
|
|
840
|
|
841 static void
|
|
842 alias_buddy_cb(GaimBuddy *buddy, const char *alias)
|
|
843 {
|
|
844 gaim_blist_alias_buddy(buddy, (alias != NULL && *alias != '\0') ? alias : NULL);
|
|
845 serv_alias_buddy(buddy);
|
|
846 }
|
|
847
|
|
848 void
|
|
849 alias_dialog_bud(GaimBuddy *b)
|
|
850 {
|
|
851 char *secondary = g_strdup_printf(_("Enter an alias for %s."), b->name);
|
|
852
|
|
853 gaim_request_input(NULL, _("Alias Buddy"), NULL,
|
|
854 secondary, b->alias, FALSE, FALSE, NULL,
|
|
855 _("Alias"), G_CALLBACK(alias_buddy_cb),
|
|
856 _("Cancel"), NULL, b);
|
|
857
|
|
858 g_free(secondary);
|
|
859 }
|