Mercurial > pidgin.yaz
annotate src/buddy.c @ 91:308d0896d979
[gaim-migrate @ 101]
Another test plugin showing yes, you can in fact do fun things with plugins
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 07 Apr 2000 19:53:11 +0000 |
parents | f5b305c0d974 |
children | 9f6ce50ffb78 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 #ifdef USE_APPLET | |
23 #include <gnome.h> | |
24 #include <applet-widget.h> | |
84 | 25 #include "gnome_applet_mgr.h" |
1 | 26 #endif /* USE_APPLET */ |
27 #include <string.h> | |
28 #include <stdio.h> | |
29 #include <stdlib.h> | |
30 #include <math.h> | |
31 #include <time.h> | |
32 | |
33 #include <gtk/gtk.h> | |
34 #include <gdk/gdkx.h> | |
35 #include "gaim.h" | |
36 #include "pixmaps/admin_icon.xpm" | |
37 #include "pixmaps/aol_icon.xpm" | |
38 #include "pixmaps/free_icon.xpm" | |
39 #include "pixmaps/dt_icon.xpm" | |
40 #include "pixmaps/no_icon.xpm" | |
41 #include "pixmaps/login_icon.xpm" | |
42 #include "pixmaps/logout_icon.xpm" | |
43 | |
44 #include "pixmaps/buddyadd.xpm" | |
45 #include "pixmaps/buddydel.xpm" | |
46 #include "pixmaps/buddychat.xpm" | |
47 #include "pixmaps/im.xpm" | |
48 #include "pixmaps/info.xpm" | |
49 #include "pixmaps/permadd.xpm" | |
50 #include "pixmaps/permdel.xpm" | |
51 #include "pixmaps/away_icon.xpm" | |
52 | |
53 static GtkTooltips *tips; | |
54 static GtkWidget *editpane; | |
55 static GtkWidget *buddypane; | |
56 static GtkWidget *permitpane; | |
57 static GtkWidget *edittree; | |
58 static GtkWidget *permtree; | |
59 static GtkWidget *imbutton, *infobutton, *chatbutton; | |
60 static GtkWidget *addbutton, *rembutton; | |
61 static GtkWidget *addpermbutton, *rempermbutton; | |
62 static GtkWidget *lagometer = NULL; | |
63 static GtkWidget *lagometer_box = NULL; | |
64 | |
65 static int last_lag_us; | |
66 | |
67 | |
68 GtkWidget *blist = NULL; | |
69 GtkWidget *bpmenu; | |
70 GtkWidget *buddies; | |
71 int permdeny; | |
72 | |
73 | |
74 /* Predefine some functions */ | |
75 static void new_bp_callback(GtkWidget *w, char *name); | |
76 static void log_callback(GtkWidget *w, char *name); | |
77 | |
78 | |
79 void destroy_buddy() | |
80 { | |
81 if (blist) | |
82 gtk_widget_destroy(blist); | |
83 blist=NULL; | |
10 | 84 #ifdef USE_APPLET |
85 buddy_created = FALSE; | |
86 #endif | |
1 | 87 } |
88 | |
89 void update_num_groups() | |
90 { | |
91 GList *grp = groups; | |
92 GList *mem; | |
93 struct buddy *b; | |
94 struct group *g; | |
95 int pres, total; | |
96 char buf[BUF_LONG]; | |
97 | |
98 if (!(display_options & OPT_DISP_SHOW_GRPNUM)) | |
99 return; | |
100 | |
101 while(grp) { | |
102 g = (struct group *)grp->data; | |
103 mem = g->members; | |
104 pres = 0; | |
105 total = 0; | |
106 while(mem) { | |
107 b = (struct buddy *)mem->data; | |
108 if (b->present) | |
109 pres++; | |
110 total++; | |
111 | |
112 | |
113 mem = mem->next; | |
114 } | |
115 | |
116 g_snprintf(buf, sizeof(buf), "%s (%d/%d)", g->name, pres, total); | |
117 | |
118 gtk_label_set(GTK_LABEL(g->label), buf); | |
119 grp = grp->next; | |
120 } | |
121 | |
122 } | |
123 | |
124 void update_show_idlepix() | |
125 { | |
126 GList *grp = groups; | |
127 GList *mem; | |
128 struct group *g; | |
129 struct buddy *b; | |
130 | |
131 while (grp) { | |
132 g = (struct group *)grp->data; | |
133 mem = g->members; | |
134 | |
135 while(mem) { | |
136 b = (struct buddy *)mem->data; | |
137 | |
138 if (display_options & OPT_DISP_SHOW_IDLETIME) | |
139 gtk_widget_show(b->idletime); | |
140 else | |
141 gtk_widget_hide(b->idletime); | |
142 | |
143 if (display_options & OPT_DISP_SHOW_PIXMAPS) | |
144 gtk_widget_show(b->pix); | |
145 else | |
146 gtk_widget_hide(b->pix); | |
147 mem = mem->next; | |
148 } | |
149 grp = grp->next; | |
150 } | |
151 } | |
152 | |
153 void update_all_buddies() | |
154 { | |
155 GList *grp = groups; | |
156 GList *mem; | |
157 struct buddy *b; | |
158 struct group *g; | |
159 | |
160 while(grp) { | |
161 g = (struct group *)grp->data; | |
162 mem = g->members; | |
163 while(mem) { | |
164 b = (struct buddy *)mem->data; | |
165 | |
59 | 166 if (b->present || !GTK_WIDGET_VISIBLE(b->item)) |
167 set_buddy(b); | |
1 | 168 |
169 mem = mem->next; | |
170 } | |
171 grp = grp->next; | |
172 } | |
173 | |
174 | |
175 } | |
176 | |
177 void update_lagometer(int us) | |
178 { | |
179 double pct; | |
180 | |
181 | |
182 | |
183 if (us != -1) | |
184 last_lag_us = us; | |
185 | |
186 | |
187 if (lagometer_box == NULL) | |
188 return; | |
189 | |
190 | |
191 if (!(general_options & OPT_GEN_SHOW_LAGMETER)) | |
192 gtk_widget_hide(lagometer_box); | |
193 else | |
194 gtk_widget_show(lagometer_box); | |
195 | |
196 | |
197 pct = last_lag_us/100000; | |
6 | 198 |
199 if (pct > 0) | |
200 pct = 25 * log(pct); | |
1 | 201 |
202 if (pct < 0) | |
203 pct = 0; | |
204 | |
205 if (pct > 100) | |
206 pct = 100; | |
207 | |
208 | |
209 pct /= 100; | |
210 | |
211 | |
212 gtk_progress_bar_update(GTK_PROGRESS_BAR(lagometer), pct); | |
213 } | |
214 | |
215 static void adjust_pic(GtkWidget *button, const char *c, gchar **xpm) | |
216 { | |
217 GdkPixmap *pm; | |
218 GdkBitmap *bm; | |
219 GtkWidget *pic; | |
220 GtkWidget *label; | |
221 | |
222 /*if the user had opted to put pictures on the buttons*/ | |
223 if (display_options & OPT_DISP_SHOW_BUTTON_XPM) { | |
224 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
225 NULL, xpm); | |
226 pic = gtk_pixmap_new(pm, bm); | |
227 gtk_widget_show(pic); | |
228 label = GTK_BIN(button)->child; | |
229 gtk_container_remove(GTK_CONTAINER(button), label); | |
230 gtk_container_add(GTK_CONTAINER(button), pic); | |
231 } else { | |
232 label = gtk_label_new(c); | |
233 gtk_widget_show(label); | |
234 pic = GTK_BIN(button)->child; | |
235 gtk_container_remove(GTK_CONTAINER(button), pic); | |
236 gtk_container_add(GTK_CONTAINER(button), label); | |
237 } | |
238 | |
239 } | |
240 | |
241 | |
242 void update_button_pix() | |
243 { | |
244 | |
245 adjust_pic(addbutton, "Add", (gchar **)buddyadd_xpm); | |
246 adjust_pic(rembutton, "Remove", (gchar **)buddydel_xpm); | |
247 adjust_pic(chatbutton, "Chat", (gchar **)buddychat_xpm); | |
248 adjust_pic(imbutton, "IM", (gchar **)im_xpm); | |
249 adjust_pic(infobutton, "Info", (gchar **)info_xpm); | |
250 adjust_pic(addpermbutton, "Add", (gchar **)permadd_xpm); | |
251 adjust_pic(rempermbutton, "Remove", (gchar **)permdel_xpm); | |
252 | |
253 } | |
254 | |
255 | |
256 | |
257 #ifdef USE_APPLET | |
258 gint applet_destroy_buddy( GtkWidget *widget, GdkEvent *event,gpointer *data ) { | |
259 GList *mem; | |
260 set_applet_draw_closed(); | |
261 | |
262 /****NO LONGER NEEDED | |
263 while(groups) { | |
264 mem = ((struct group *)groups->data)->members; | |
265 while(mem) { | |
266 g_free(mem->data); | |
267 mem = g_list_remove(mem, mem->data); | |
268 } | |
269 g_free(groups->data); | |
270 groups = g_list_remove(groups, groups->data); | |
271 } | |
272 | |
273 destroy_buddy(); | |
274 */ | |
275 gnome_buddy_hide(); | |
276 applet_widget_register_callback(APPLET_WIDGET(applet), | |
277 "buddy", | |
278 _("Buddy List"), | |
279 (AppletCallbackFunc)make_buddy, | |
280 NULL); | |
281 return (TRUE); | |
282 } | |
283 | |
284 void gnome_buddy_show(){ | |
285 gtk_widget_show( blist ); | |
286 } | |
287 | |
288 void gnome_buddy_hide(){ | |
289 gtk_widget_hide( blist ); | |
290 } | |
291 | |
292 void gnome_buddy_set_pos( gint x, gint y ){ | |
293 gtk_widget_set_uposition ( blist, x, y ); | |
294 } | |
295 | |
296 GtkRequisition gnome_buddy_get_dimentions(){ | |
297 return blist->requisition; | |
298 } | |
299 | |
300 #endif | |
301 | |
302 | |
84 | 303 extern enum gaim_user_states MRI_user_status; |
1 | 304 void signoff() |
305 { | |
306 GList *mem; | |
307 while(groups) { | |
308 mem = ((struct group *)groups->data)->members; | |
309 while(mem) { | |
310 g_free(mem->data); | |
311 mem = g_list_remove(mem, mem->data); | |
312 } | |
313 g_free(groups->data); | |
314 groups = g_list_remove(groups, groups->data); | |
315 } | |
316 | |
317 serv_close(); | |
318 destroy_all_dialogs(); | |
319 destroy_buddy(); | |
320 hide_login_progress(""); | |
321 #ifdef USE_APPLET | |
84 | 322 MRI_user_status = offline; |
1 | 323 set_applet_draw_closed(); |
324 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signoff"); | |
18 | 325 remove_applet_away(); |
1 | 326 applet_widget_unregister_callback(APPLET_WIDGET(applet),"buddy"); |
327 applet_widget_register_callback(APPLET_WIDGET(applet), | |
328 "signon", | |
329 _("Signon"), | |
330 applet_show_login, | |
331 NULL); | |
332 #else | |
333 show_login(); | |
334 #endif /* USE_APPLET */ | |
335 } | |
336 | |
337 void handle_click_group(GtkWidget *widget, GdkEventButton *event, gpointer func_data) | |
338 { | |
339 if (event->type == GDK_2BUTTON_PRESS) { | |
340 if (GTK_TREE_ITEM(widget)->expanded) | |
341 gtk_tree_item_collapse(GTK_TREE_ITEM(widget)); | |
342 else | |
343 gtk_tree_item_expand(GTK_TREE_ITEM(widget)); | |
344 } else { | |
345 } | |
346 } | |
347 | |
348 void pressed_im(GtkWidget *widget, struct buddy *b) | |
349 { | |
350 struct conversation *c; | |
351 | |
352 c = find_conversation(b->name); | |
353 | |
354 if (c != NULL) { | |
87 | 355 gdk_window_show(c->window->window); |
1 | 356 } else { |
357 c = new_conversation(b->name); | |
358 } | |
359 } | |
360 | |
361 void pressed_info(GtkWidget *widget, struct buddy *b) | |
362 { | |
363 serv_get_info(b->name); | |
364 | |
365 } | |
366 | |
367 void pressed_dir_info(GtkWidget *widget, struct buddy *b) | |
368 { | |
369 serv_get_dir(b->name); | |
370 | |
371 } | |
372 | |
373 void handle_click_buddy(GtkWidget *widget, GdkEventButton *event, struct buddy *b) | |
374 { | |
375 if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { | |
376 struct conversation *c; | |
377 | |
378 c = find_conversation(b->name); | |
379 | |
380 if (c != NULL) { | |
87 | 381 gdk_window_show(c->window->window); |
1 | 382 } else { |
383 c = new_conversation(b->name); | |
384 } | |
385 } else if (event->type == GDK_BUTTON_PRESS && event->button == 3) { | |
386 GtkWidget *menu, *button; | |
387 /* We're gonna make us a menu right here */ | |
388 | |
389 menu = gtk_menu_new(); | |
390 | |
391 button = gtk_menu_item_new_with_label("IM"); | |
392 gtk_signal_connect(GTK_OBJECT(button), "activate", | |
393 GTK_SIGNAL_FUNC(pressed_im), b); | |
394 gtk_menu_append(GTK_MENU(menu), button); | |
395 gtk_widget_show(button); | |
396 | |
397 button = gtk_menu_item_new_with_label("Info"); | |
398 gtk_signal_connect(GTK_OBJECT(button), "activate", | |
399 GTK_SIGNAL_FUNC(pressed_info), b); | |
400 gtk_menu_append(GTK_MENU(menu), button); | |
401 gtk_widget_show(button); | |
402 | |
403 button = gtk_menu_item_new_with_label("Dir Info"); | |
404 gtk_signal_connect(GTK_OBJECT(button), "activate", | |
405 GTK_SIGNAL_FUNC(pressed_dir_info), b); | |
406 gtk_menu_append(GTK_MENU(menu), button); | |
407 gtk_widget_show(button); | |
408 | |
409 button = gtk_menu_item_new_with_label("Toggle Logging"); | |
410 gtk_signal_connect(GTK_OBJECT(button), "activate", | |
411 GTK_SIGNAL_FUNC(log_callback), b->name); | |
412 gtk_menu_append(GTK_MENU(menu), button); | |
413 gtk_widget_show(button); | |
414 | |
415 button = gtk_menu_item_new_with_label("Add Buddy Pounce"); | |
416 gtk_signal_connect(GTK_OBJECT(button), "activate", | |
417 GTK_SIGNAL_FUNC(new_bp_callback), b->name); | |
418 gtk_menu_append(GTK_MENU(menu), button); | |
419 gtk_widget_show(button); | |
420 | |
421 | |
422 | |
423 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, | |
424 event->button, event->time); | |
425 | |
426 } else if (event->type == GDK_3BUTTON_PRESS && event->button == 2) { | |
427 if (!strcasecmp("zilding", normalize(b->name))) | |
428 show_ee_dialog(0); | |
429 else if (!strcasecmp("robflynn", normalize(b->name))) | |
430 show_ee_dialog(1); | |
431 else if (!strcasecmp("flynorange", normalize(b->name))) | |
432 show_ee_dialog(2); | |
433 | |
434 } else { | |
435 | |
436 /* Anything for other buttons? :) */ | |
437 } | |
438 } | |
439 | |
440 | |
441 | |
442 void remove_buddy(struct group *rem_g, struct buddy *rem_b) | |
443 { | |
444 GList *grp; | |
445 GList *mem; | |
446 | |
447 struct group *delg; | |
448 struct buddy *delb; | |
449 | |
450 grp = g_list_find(groups, rem_g); | |
451 delg = (struct group *)grp->data; | |
452 mem = delg->members; | |
453 | |
454 mem = g_list_find(mem, rem_b); | |
455 delb = (struct buddy *)mem->data; | |
456 | |
457 gtk_tree_remove_items(GTK_TREE(delg->tree), g_list_append(NULL, delb->item)); | |
458 delg->members = g_list_remove(delg->members, delb); | |
459 serv_remove_buddy(delb->name); | |
460 g_free(delb); | |
461 | |
462 serv_save_config(); | |
463 | |
464 update_num_groups(); | |
465 | |
466 | |
467 } | |
468 | |
469 void remove_group(struct group *rem_g) | |
470 { | |
471 GList *grp; | |
472 GList *mem; | |
473 | |
474 struct group *delg; | |
475 struct buddy *delb; | |
476 | |
477 grp = g_list_find(groups, rem_g); | |
478 delg = (struct group *)grp->data; | |
479 mem = delg->members; | |
480 | |
481 while(delg->members) { | |
482 delb = (struct buddy *)delg->members->data; | |
483 gtk_tree_remove_items(GTK_TREE(delg->tree), g_list_append(NULL, delb->item)); | |
484 delg->members = g_list_remove(delg->members, delb); | |
485 serv_remove_buddy(delb->name); | |
486 g_free(delb); | |
487 } | |
488 | |
489 | |
490 gtk_tree_remove_items(GTK_TREE(buddies), g_list_append(NULL, delg->item)); | |
491 groups = g_list_remove(groups, delg); | |
492 g_free(delg); | |
493 | |
494 serv_save_config(); | |
495 } | |
496 | |
497 | |
498 | |
499 void build_permit_tree() | |
500 { | |
501 GtkWidget *ti; | |
502 GtkWidget *sub; | |
503 GList *plist = permit; | |
504 GList *dlist = deny; | |
505 | |
506 gtk_tree_clear_items(GTK_TREE(permtree), 0, -1); | |
507 | |
508 ti = gtk_tree_item_new_with_label("Permit"); | |
509 sub = gtk_tree_new(); | |
510 gtk_widget_show(ti); | |
511 gtk_widget_show(sub); | |
512 gtk_tree_prepend(GTK_TREE(permtree), ti); | |
513 gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), sub); | |
514 gtk_tree_item_expand(GTK_TREE_ITEM(ti)); | |
515 | |
516 while(plist) { | |
517 ti = gtk_tree_item_new_with_label((char *)plist->data); | |
518 gtk_widget_show(ti); | |
519 gtk_tree_prepend(GTK_TREE(sub), ti); | |
520 plist = plist->next; | |
521 } | |
522 | |
523 | |
524 ti = gtk_tree_item_new_with_label("Deny"); | |
525 sub = gtk_tree_new(); | |
526 gtk_widget_show(ti); | |
527 gtk_widget_show(sub); | |
528 gtk_tree_prepend(GTK_TREE(permtree), ti); | |
529 gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), sub); | |
530 gtk_tree_item_expand(GTK_TREE_ITEM(ti)); | |
531 | |
532 while(dlist) { | |
533 ti = gtk_tree_item_new_with_label((char *)dlist->data); | |
534 gtk_widget_show(ti); | |
535 gtk_tree_prepend(GTK_TREE(sub), ti); | |
536 dlist = dlist->next; | |
537 } | |
538 | |
539 | |
540 } | |
541 | |
542 | |
543 gboolean edit_drag_compare_func (GtkCTree *ctree, GtkCTreeNode *source_node, | |
544 GtkCTreeNode *new_parent, GtkCTreeNode *new_sibling) | |
545 { | |
546 gboolean leaf; | |
547 | |
548 gtk_ctree_get_node_info (ctree, source_node, NULL, | |
549 NULL, NULL, NULL, NULL, NULL, &leaf, NULL); | |
550 | |
551 | |
552 if (leaf) { | |
553 if (!new_parent) | |
554 return FALSE; | |
555 } else { | |
556 | |
557 if (new_parent) | |
558 return FALSE; | |
559 | |
560 } | |
561 | |
562 return TRUE; | |
563 } | |
564 | |
565 | |
566 | |
567 static void edit_tree_move (GtkCTree *ctree, GtkCTreeNode *child, GtkCTreeNode *parent, | |
568 GtkCTreeNode *sibling, gpointer data) | |
569 { | |
570 char *source; | |
571 char *target1; | |
572 char *target2; | |
573 | |
574 gtk_ctree_get_node_info (ctree, child, &source, | |
575 NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
576 if (parent) | |
577 gtk_ctree_get_node_info (ctree, parent, &target1, | |
578 NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
579 if (sibling) | |
580 gtk_ctree_get_node_info (ctree, sibling, &target2, | |
581 NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
582 | |
583 | |
584 if (!parent) { | |
585 GList *grps, *buds; | |
586 struct group *g, *g2; | |
587 GList *tmp; | |
588 int pos; | |
589 struct buddy *b; | |
590 /* Okay we've moved group order... */ | |
591 | |
592 g = find_group(source); | |
593 | |
594 gtk_widget_ref(g->tree); | |
595 | |
596 buds = g->members; | |
597 while(buds) { | |
598 b = (struct buddy *)buds->data; | |
599 gtk_widget_ref(b->item); | |
600 gtk_widget_ref(b->label); | |
601 gtk_widget_ref(b->idletime); | |
602 gtk_widget_ref(b->pix); | |
603 buds = buds->next; | |
604 } | |
605 | |
606 | |
607 | |
608 | |
609 pos = g_list_index(GTK_TREE(buddies)->children, g->item); | |
610 | |
611 tmp = g_list_append(NULL, g->item); | |
612 gtk_tree_remove_items(GTK_TREE(buddies), tmp); | |
613 g_list_free(tmp); | |
614 | |
615 groups = g_list_remove(groups, g); | |
616 | |
617 g->item = gtk_tree_item_new_with_label(g->name); | |
618 gtk_widget_show(g->item); | |
619 | |
620 if (sibling) { | |
621 g2 = find_group(target2); | |
622 pos = g_list_index(groups, g2); | |
623 if (pos == 0) { | |
624 groups = g_list_prepend(groups, g); | |
625 gtk_tree_prepend(GTK_TREE(buddies), g->item); | |
626 } else { | |
627 groups = g_list_insert(groups, g, pos); | |
628 gtk_tree_insert(GTK_TREE(buddies), g->item, pos); | |
629 } | |
630 | |
631 } else { | |
632 groups = g_list_append(groups, g); | |
633 gtk_tree_append(GTK_TREE(buddies), g->item); | |
634 | |
635 } | |
636 | |
637 gtk_tree_item_set_subtree (GTK_TREE_ITEM(g->item), g->tree); | |
638 gtk_tree_item_expand (GTK_TREE_ITEM(g->item)); | |
639 gtk_signal_connect(GTK_OBJECT(g->item), "button_press_event", | |
640 GTK_SIGNAL_FUNC(handle_click_group), | |
641 NULL); | |
642 gtk_object_set_user_data(GTK_OBJECT(g->item), NULL); | |
643 | |
644 gtk_widget_unref(g->tree); | |
645 | |
646 update_num_groups(); | |
647 | |
648 | |
649 buds = g->members; | |
650 | |
651 while(buds) { | |
652 b = (struct buddy *)buds->data; | |
653 set_buddy(b); | |
654 buds = buds->next; | |
655 } | |
656 | |
657 grps = groups; | |
658 while(grps) { | |
659 g = (struct group *)grps->data; | |
660 grps = grps->next; | |
661 } | |
662 | |
663 } else { | |
664 struct group *new_g, *old_g; | |
665 struct buddy *b, *s; | |
666 GtkWidget *gtree; | |
667 GtkWidget *owner; | |
668 GList *temp; | |
669 int pos; | |
670 | |
671 b = find_buddy(source); | |
672 new_g = find_group(target1); | |
673 old_g = find_group_by_buddy(source); | |
674 gtree = old_g->tree; | |
675 if (sibling) | |
676 s = find_buddy(target2); | |
677 else | |
678 s = NULL; | |
679 | |
680 old_g->members = g_list_remove(old_g->members, b); | |
681 | |
682 gtk_widget_ref(b->item); | |
683 gtk_widget_ref(b->label); | |
684 gtk_widget_ref(b->pix); | |
685 gtk_widget_ref(b->idletime); | |
686 gtk_widget_ref(gtree); | |
687 | |
688 owner = GTK_TREE(gtree)->tree_owner; | |
689 | |
690 temp = g_list_append(NULL, b->item); | |
691 gtk_tree_remove_items(GTK_TREE(old_g->tree), temp); | |
692 g_list_free(temp); | |
693 | |
694 if (gtree->parent == NULL){ | |
695 gtk_tree_item_set_subtree (GTK_TREE_ITEM(owner), gtree); | |
696 gtk_tree_item_expand (GTK_TREE_ITEM(owner)); | |
697 } | |
698 | |
699 if (!sibling) { | |
700 gtk_tree_append(GTK_TREE(new_g->tree), b->item); | |
701 new_g->members = g_list_append(new_g->members, b); | |
702 } else { | |
703 pos = g_list_index(new_g->members, s); | |
704 if (pos != 0) { | |
705 new_g->members = g_list_insert(new_g->members, b, pos); | |
706 gtk_tree_insert(GTK_TREE(new_g->tree), b->item, pos); | |
707 } else { | |
708 new_g->members = g_list_prepend(new_g->members, b); | |
709 gtk_tree_prepend(GTK_TREE(new_g->tree), b->item); | |
710 | |
711 } | |
712 } | |
713 | |
714 gtk_widget_unref(b->item); | |
715 gtk_widget_unref(b->label); | |
716 gtk_widget_unref(b->pix); | |
717 gtk_widget_unref(b->idletime); | |
718 gtk_widget_unref(gtree); | |
719 | |
720 gtk_ctree_expand(ctree, parent); | |
721 | |
722 update_num_groups(); | |
723 update_show_idlepix(); | |
724 set_buddy(b); | |
725 | |
726 | |
727 | |
728 | |
729 | |
730 } | |
731 | |
732 serv_save_config(); | |
733 } | |
734 | |
735 | |
736 | |
737 void build_edit_tree() | |
738 { | |
739 GtkCTreeNode *p = NULL, *n; | |
740 GList *grp = groups; | |
741 GList *mem; | |
742 struct group *g; | |
743 struct buddy *b; | |
744 char *text[1]; | |
745 | |
746 gtk_clist_freeze(GTK_CLIST(edittree)); | |
747 gtk_clist_clear(GTK_CLIST(edittree)); | |
748 | |
749 | |
750 while(grp) { | |
751 g = (struct group *)grp->data; | |
752 | |
753 text[0] = g->name; | |
754 | |
755 p = gtk_ctree_insert_node(GTK_CTREE(edittree), NULL, | |
756 NULL, text, 5, NULL, NULL, | |
757 NULL, NULL, 0, 1); | |
758 | |
759 n = NULL; | |
760 | |
761 mem = g->members; | |
762 | |
763 while(mem) { | |
764 b = (struct buddy *)mem->data; | |
765 | |
766 text[0] = b->name; | |
767 | |
768 n = gtk_ctree_insert_node(GTK_CTREE(edittree), | |
769 p, NULL, text, 5, | |
770 NULL, NULL, | |
771 NULL, NULL, 1, 1); | |
772 | |
773 mem = mem->next; | |
774 | |
775 } | |
776 grp = grp->next; | |
777 } | |
778 | |
779 gtk_clist_thaw(GTK_CLIST(edittree)); | |
780 | |
781 } | |
782 | |
783 struct buddy *add_buddy(char *group, char *buddy) | |
784 { | |
785 struct buddy *b; | |
786 struct group *g; | |
787 GdkPixmap *pm; | |
788 GdkBitmap *bm; | |
789 GtkWidget *box; | |
790 | |
791 | |
792 if ((b = find_buddy(buddy)) != NULL) | |
793 return b; | |
794 | |
795 g = find_group(group); | |
796 | |
797 if (g == NULL) | |
798 g = add_group(group); | |
799 | |
800 b = (struct buddy *)g_new0(struct buddy, 1); | |
801 | |
802 if (!b) | |
803 return NULL; | |
804 | |
805 b->present = 0; | |
806 b->item = gtk_tree_item_new(); | |
807 | |
808 g_snprintf(b->name, sizeof(b->name), "%s", buddy); | |
809 g->members = g_list_append(g->members, b); | |
810 | |
811 | |
812 if (blist == NULL) | |
813 return b; | |
814 | |
815 box = gtk_hbox_new(FALSE, 1); | |
816 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
817 NULL, (gchar **)login_icon_xpm); | |
818 b->pix = gtk_pixmap_new(pm, bm); | |
819 | |
820 b->idle = 0; | |
821 | |
822 gtk_widget_show(b->pix); | |
823 | |
824 b->label = gtk_label_new(buddy); | |
825 gtk_misc_set_alignment(GTK_MISC(b->label), 0.0, 0.5); | |
826 | |
827 b->idletime = gtk_label_new(""); | |
828 | |
829 gtk_tree_append(GTK_TREE(g->tree),b->item); | |
830 gtk_container_add(GTK_CONTAINER(b->item), box); | |
831 | |
832 gtk_box_pack_start(GTK_BOX(box), b->pix, FALSE, FALSE, 1); | |
833 gtk_box_pack_start(GTK_BOX(box), b->label, TRUE, TRUE, 1); | |
834 gtk_box_pack_start(GTK_BOX(box), b->idletime, FALSE, FALSE, 1); | |
835 | |
836 gtk_widget_show(b->label); | |
837 gtk_widget_show(box); | |
838 | |
839 gtk_object_set_user_data(GTK_OBJECT(b->item), b); | |
840 | |
841 gtk_signal_connect(GTK_OBJECT(b->item), "button_press_event", | |
842 GTK_SIGNAL_FUNC(handle_click_buddy), b); | |
843 | |
844 return b; | |
845 } | |
846 | |
847 | |
848 struct group *add_group(char *group) | |
849 { | |
850 struct group *g; | |
851 g = (struct group *)g_new0(struct group, 1); | |
852 if (!g) | |
853 return NULL; | |
854 | |
855 strncpy(g->name, group, sizeof(g->name)); | |
856 groups = g_list_append(groups, g); | |
857 | |
858 if (blist == NULL) | |
859 return g; | |
860 | |
861 g->item = gtk_tree_item_new(); | |
862 g->label = gtk_label_new(g->name); | |
863 gtk_misc_set_alignment(GTK_MISC(g->label), 0.0, 0.5); | |
864 gtk_widget_show(g->label); | |
865 gtk_container_add(GTK_CONTAINER(g->item), g->label); | |
866 g->tree = gtk_tree_new(); | |
867 gtk_widget_show(g->item); | |
868 gtk_widget_show(g->tree); | |
869 gtk_tree_append(GTK_TREE(buddies), g->item); | |
870 gtk_tree_item_set_subtree(GTK_TREE_ITEM(g->item), g->tree); | |
871 gtk_tree_item_expand(GTK_TREE_ITEM(g->item)); | |
872 gtk_signal_connect(GTK_OBJECT(g->item), "button_press_event", | |
873 GTK_SIGNAL_FUNC(handle_click_group), | |
874 NULL); | |
875 gtk_object_set_user_data(GTK_OBJECT(g->item), NULL); | |
876 g->members = NULL; | |
877 | |
878 | |
879 build_edit_tree(); | |
880 | |
881 return g; | |
882 | |
883 } | |
884 | |
885 | |
886 static void do_del_buddy(GtkWidget *w, GtkCTree *ctree) | |
887 { | |
888 GtkCTreeNode *node; | |
889 char *bud, *grp; | |
890 struct buddy *b; | |
891 struct group *g; | |
892 GList *i; | |
893 | |
894 i = GTK_CLIST(edittree)->selection; | |
895 if (i) { | |
896 node = i->data; | |
897 | |
898 if (GTK_CTREE_ROW(node)->is_leaf) { | |
899 gtk_ctree_get_node_info (GTK_CTREE(edittree), node, &bud, | |
900 NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
901 | |
902 b = find_buddy(bud); | |
903 g = find_group_by_buddy(bud); | |
904 remove_buddy(g, b); | |
905 } else { | |
906 gtk_ctree_get_node_info (ctree, node, &grp, | |
907 NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
908 g = find_group(grp); | |
909 remove_group(g); | |
910 } | |
911 | |
912 build_edit_tree(); | |
913 serv_save_config(); | |
914 } else { | |
915 /* Nothing selected. */ | |
916 } | |
917 update_num_groups(); | |
918 } | |
919 | |
920 static void do_del_perm(GtkWidget *w, GtkTree *permtree) | |
921 { | |
922 GtkLabel *label, *plabel; | |
923 GtkWidget *item, *pitem; | |
924 char *c, *d; | |
925 GList *i; | |
926 | |
927 GList *plist; | |
928 GList *dlist; | |
929 int level; | |
930 | |
931 plist = permit; | |
932 dlist = deny; | |
933 | |
934 i = GTK_TREE_SELECTION(permtree); | |
935 if (i) { | |
936 item = GTK_WIDGET(i->data); | |
937 gtk_tree_unselect_child(GTK_TREE(permtree), item); | |
938 label = GTK_LABEL(GTK_BIN(item)->child); | |
939 gtk_label_get(label, &c); | |
940 level = GTK_TREE(item->parent)->level; | |
941 if (level > 0) { | |
942 pitem = GTK_WIDGET(GTK_TREE(item->parent)->tree_owner); | |
943 plabel = GTK_LABEL(GTK_BIN(pitem)->child); | |
944 gtk_label_get(plabel, &d); | |
945 if (!strcasecmp(d, "Permit")) { | |
946 while(plist) { | |
947 if (!strcasecmp((char *)(plist->data), c)) { | |
948 permit = g_list_remove(permit, plist->data); | |
949 break; | |
950 } | |
951 | |
952 plist = plist->next; | |
953 } | |
954 | |
955 } else { | |
956 while(dlist) { | |
957 if (!strcasecmp((char *)(dlist->data), c)) { | |
958 deny = g_list_remove(deny, dlist->data); | |
959 | |
960 break; | |
961 } | |
962 dlist = dlist->next; | |
963 } | |
964 | |
965 } | |
966 | |
967 | |
968 } else { | |
969 /* Can't delete groups here! :) */ | |
970 return; | |
971 } | |
972 serv_set_permit_deny(); | |
973 gtk_tree_clear_items(GTK_TREE(permtree), 0, -1); | |
974 build_permit_tree(); | |
975 serv_save_config(); | |
976 } | |
977 } | |
978 | |
979 | |
980 | |
981 void gaimreg_callback(GtkWidget *widget) | |
982 { | |
983 show_register_dialog(); | |
984 } | |
985 | |
986 void import_callback(GtkWidget *widget, void *null) | |
987 { | |
988 show_import_dialog(); | |
989 } | |
990 | |
991 void export_callback(GtkWidget *widget, void *null) | |
992 { | |
993 show_export_dialog(); | |
994 } | |
995 | |
996 | |
997 | |
998 void do_quit() | |
999 { | |
1000 exit(0); | |
1001 } | |
1002 | |
1003 void add_buddy_callback(GtkWidget *widget, void *dummy) | |
1004 { | |
1005 char *grp = NULL; | |
1006 GtkCTreeNode *node; | |
1007 GList *i; | |
1008 | |
1009 i = GTK_CLIST(edittree)->selection; | |
1010 if (i) { | |
1011 node = i->data; | |
1012 | |
1013 if (GTK_CTREE_ROW(node)->is_leaf) { | |
1014 node = GTK_CTREE_ROW(node)->parent; | |
1015 } | |
1016 | |
1017 gtk_ctree_get_node_info (GTK_CTREE(edittree), node, &grp, | |
1018 NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
1019 } | |
1020 show_add_buddy(NULL, grp); | |
1021 | |
1022 } | |
1023 | |
1024 void add_perm_callback(GtkWidget *widget, void *dummy) | |
1025 { | |
1026 show_add_perm(NULL); | |
1027 } | |
1028 | |
1029 | |
1030 static void info_callback(GtkWidget *widget, GtkTree *tree) | |
1031 { | |
1032 GList *i; | |
1033 struct buddy *b = NULL; | |
1034 i = GTK_TREE_SELECTION(tree); | |
1035 if (i) { | |
1036 b = gtk_object_get_user_data(GTK_OBJECT(i->data)); | |
1037 } else { | |
1038 return; | |
1039 } | |
1040 if (!b->name) | |
1041 return; | |
1042 serv_get_info(b->name); | |
1043 } | |
1044 | |
1045 | |
1046 void chat_callback(GtkWidget *widget, GtkTree *tree) | |
1047 { | |
1048 join_chat(); | |
1049 } | |
1050 | |
1051 struct group *find_group(char *group) | |
1052 { | |
1053 struct group *g; | |
1054 GList *grp = groups; | |
1055 char *grpname = g_malloc(strlen(group) + 1); | |
1056 | |
1057 strcpy(grpname, normalize(group)); | |
1058 while (grp) { | |
1059 g = (struct group *)grp->data; | |
1060 if (!strcasecmp(normalize(g->name), grpname)) { | |
1061 g_free(grpname); | |
1062 return g; | |
1063 } | |
1064 grp = grp->next; | |
1065 } | |
1066 | |
1067 g_free(grpname); | |
1068 return NULL; | |
1069 | |
1070 } | |
1071 | |
1072 | |
1073 struct group *find_group_by_buddy(char *who) | |
1074 { | |
1075 struct group *g; | |
1076 struct buddy *b; | |
1077 GList *grp = groups; | |
1078 GList *mem; | |
1079 char *whoname = g_malloc(strlen(who) + 1); | |
1080 | |
1081 strcpy(whoname, normalize(who)); | |
1082 | |
1083 while(grp) { | |
1084 g = (struct group *)grp->data; | |
1085 | |
1086 mem = g->members; | |
1087 while(mem) { | |
1088 b = (struct buddy *)mem->data; | |
1089 if (!strcasecmp(normalize(b->name), whoname)) { | |
1090 g_free(whoname); | |
1091 return g; | |
1092 } | |
1093 mem = mem->next; | |
1094 } | |
1095 grp = grp->next; | |
1096 } | |
1097 g_free(whoname); | |
1098 return NULL; | |
1099 } | |
1100 | |
1101 | |
1102 struct buddy *find_buddy(char *who) | |
1103 { | |
1104 struct group *g; | |
1105 struct buddy *b; | |
1106 GList *grp = groups; | |
1107 GList *mem; | |
1108 char *whoname = g_malloc(strlen(who) + 1); | |
1109 | |
1110 strcpy(whoname, normalize(who)); | |
1111 | |
1112 while(grp) { | |
1113 g = (struct group *)grp->data; | |
1114 | |
1115 mem = g->members; | |
1116 while(mem) { | |
1117 b = (struct buddy *)mem->data; | |
1118 if (!strcasecmp(normalize(b->name), whoname)) { | |
1119 g_free(whoname); | |
1120 return b; | |
1121 } | |
1122 mem = mem->next; | |
1123 } | |
1124 grp = grp->next; | |
1125 } | |
1126 g_free(whoname); | |
1127 return NULL; | |
1128 } | |
1129 | |
1130 | |
1131 void rem_bp(GtkWidget *w, struct buddy_pounce *b) | |
1132 { | |
1133 buddy_pounces = g_list_remove(buddy_pounces, b); | |
1134 } | |
1135 | |
1136 void do_pounce(char *name) | |
1137 { | |
26 | 1138 char *who; |
1 | 1139 |
1140 struct buddy_pounce *b; | |
1141 struct conversation *c; | |
1142 | |
1143 GList *bp = buddy_pounces; | |
1144 | |
26 | 1145 who = g_strdup(normalize(name)); |
1 | 1146 |
1147 while(bp) { | |
1148 b = (struct buddy_pounce *)bp->data;; | |
26 | 1149 bp = bp->next; /* increment the list here because rem_bp can make our handle bad */ |
1150 | |
1 | 1151 if (!strcasecmp(who, normalize(b->name))) { |
1152 if (b->popup == 1) | |
1153 { | |
1154 c = find_conversation(name); | |
1155 if (c == NULL) | |
1156 c = new_conversation(name); | |
1157 } | |
1158 if (b->sendim == 1) | |
1159 { | |
1160 c = find_conversation(name); | |
1161 if (c == NULL) | |
1162 c = new_conversation(name); | |
1163 | |
1164 write_to_conv(c, b->message, WFLAG_SEND); | |
1165 | |
1166 escape_text(b->message); | |
1167 | |
1168 serv_send_im(name, b->message, 0); | |
1169 } | |
1170 | |
1171 rem_bp(NULL, b); | |
1172 | |
1173 } | |
1174 } | |
1175 g_free(who); | |
1176 } | |
1177 | |
1178 static void new_bp_callback(GtkWidget *w, char *name) | |
1179 { | |
1180 show_new_bp(name); | |
1181 } | |
1182 | |
1183 static void log_callback(GtkWidget *w, char *name) | |
1184 { | |
1185 struct conversation *c = find_conversation(name); | |
1186 | |
1187 if (find_log_info(name)) | |
1188 { | |
1189 if (c) { | |
1190 set_state_lock(1); | |
1191 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->log_button), FALSE); | |
1192 set_state_lock(0); | |
1193 } | |
1194 rm_log(find_log_info(name)); | |
1195 } | |
1196 else | |
1197 { | |
1198 show_log_dialog(name); | |
1199 if (c) { | |
1200 set_state_lock(1); | |
1201 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->log_button), TRUE); | |
1202 set_state_lock(0); | |
1203 } | |
1204 } | |
1205 } | |
1206 | |
1207 void do_bp_menu() | |
1208 { | |
1209 GtkWidget *menuitem, *mess, *messmenu; | |
1210 static GtkWidget *remmenu; | |
1211 GtkWidget *remitem; | |
1212 GtkWidget *sep; | |
1213 GList *l; | |
1214 struct buddy_pounce *b; | |
1215 GList *bp = buddy_pounces; | |
1216 | |
1217 l = gtk_container_children(GTK_CONTAINER(bpmenu)); | |
1218 | |
1219 while(l) { | |
1220 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
1221 l = l->next; | |
1222 } | |
1223 | |
1224 remmenu = gtk_menu_new(); | |
1225 | |
1226 menuitem = gtk_menu_item_new_with_label("New Buddy Pounce"); | |
1227 gtk_menu_append(GTK_MENU(bpmenu), menuitem); | |
1228 gtk_widget_show(menuitem); | |
1229 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(new_bp_callback), NULL); | |
1230 | |
1231 | |
1232 while(bp) { | |
1233 | |
1234 b = (struct buddy_pounce *)bp->data; | |
1235 remitem = gtk_menu_item_new_with_label(b->name); | |
1236 gtk_menu_append(GTK_MENU(remmenu), remitem); | |
1237 gtk_widget_show(remitem); | |
1238 gtk_signal_connect(GTK_OBJECT(remitem), "activate", GTK_SIGNAL_FUNC(rem_bp), b); | |
1239 | |
1240 bp = bp->next; | |
1241 | |
1242 } | |
1243 | |
1244 menuitem = gtk_menu_item_new_with_label("Remove Buddy Pounce"); | |
1245 gtk_menu_append(GTK_MENU(bpmenu), menuitem); | |
1246 gtk_widget_show(menuitem); | |
1247 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu); | |
1248 gtk_widget_show(remmenu); | |
1249 | |
1250 | |
1251 sep = gtk_hseparator_new(); | |
1252 menuitem = gtk_menu_item_new(); | |
1253 gtk_menu_append(GTK_MENU(bpmenu), menuitem); | |
1254 gtk_container_add(GTK_CONTAINER(menuitem), sep); | |
1255 gtk_widget_set_sensitive(menuitem, FALSE); | |
1256 gtk_widget_show(menuitem); | |
1257 gtk_widget_show(sep); | |
1258 | |
1259 bp = buddy_pounces;; | |
1260 | |
1261 while(bp) { | |
1262 | |
1263 b = (struct buddy_pounce *)bp->data; | |
1264 | |
1265 menuitem = gtk_menu_item_new_with_label(b->name); | |
1266 gtk_menu_append(GTK_MENU(bpmenu), menuitem); | |
1267 messmenu = gtk_menu_new(); | |
1268 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), messmenu); | |
1269 gtk_widget_show(menuitem); | |
1270 | |
1271 | |
1272 | |
1273 mess = gtk_menu_item_new_with_label(b->message); | |
1274 gtk_menu_append(GTK_MENU(messmenu), mess); | |
1275 gtk_widget_show(mess); | |
1276 | |
1277 bp = bp->next; | |
1278 | |
1279 } | |
1280 | |
1281 } | |
1282 | |
1283 | |
1284 gint log_timeout(char *name) | |
1285 { | |
1286 struct buddy *b; | |
1287 | |
1288 b = find_buddy(name); | |
1289 | |
1290 if(!b) | |
1291 return FALSE; | |
1292 | |
1293 b->log_timer = 0; | |
1294 | |
1295 if (!b->present) | |
1296 gtk_widget_hide(b->item); | |
1297 else | |
1298 set_buddy(b); | |
1299 | |
1300 return FALSE; | |
1301 } | |
1302 | |
1303 | |
1304 void set_buddy(struct buddy *b) | |
1305 { | |
1306 char infotip[256]; | |
1307 char idlet[16]; | |
1308 char warn[256]; | |
70 | 1309 char *who; |
1 | 1310 int i; |
1311 int ihrs, imin; | |
1312 time_t t; | |
1313 GdkPixmap *pm; | |
1314 GdkBitmap *bm; | |
1315 char *itime, *sotime; | |
1316 | |
1317 if (b->present) { | |
1318 time(&t); | |
1319 | |
1320 ihrs = (t - b->idle) / 3600; | |
1321 imin = ((t - b->idle) / 60) % 60; | |
1322 | |
1323 if (ihrs) | |
1324 g_snprintf(idlet, sizeof(idlet), "(%d:%02d)", ihrs, imin); | |
1325 else | |
1326 g_snprintf(idlet, sizeof(idlet), "(%02d)", imin); | |
1327 | |
1328 gtk_widget_hide(b->idletime); | |
1329 | |
1330 if (b->idle) | |
1331 gtk_label_set(GTK_LABEL(b->idletime), idlet); | |
1332 else | |
1333 gtk_label_set(GTK_LABEL(b->idletime), ""); | |
1334 if (display_options & OPT_DISP_SHOW_IDLETIME) | |
1335 gtk_widget_show(b->idletime); | |
1336 | |
1337 | |
1338 sotime = sec_to_text(t - b->signon + correction_time); | |
1339 if (b->idle) { | |
1340 itime = sec_to_text(t - b->idle); | |
1341 } else { | |
1342 itime = g_malloc(1); | |
1343 itime[0] = 0; | |
1344 } | |
1345 | |
1346 if (b->evil) { | |
1347 g_snprintf(warn, sizeof(warn), "Warnings: %d%%\n", b->evil); | |
1348 | |
1349 } else | |
1350 warn[0] = '\0'; | |
1351 | |
1352 i = g_snprintf(infotip, sizeof(infotip), "Name: %s \nLogged in: %s\n%s%s%s", b->name, sotime, warn, ((b->idle) ? "Idle: " : ""), itime); | |
1353 | |
1354 gtk_tooltips_set_tip(tips, GTK_WIDGET(b->item), infotip, ""); | |
1355 | |
1356 g_free(sotime); | |
1357 g_free(itime); | |
1358 | |
1359 | |
1360 | |
1361 if (!GTK_WIDGET_VISIBLE(b->item)) { | |
1362 | |
1363 play_sound(BUDDY_ARRIVE); | |
1364 | |
70 | 1365 who = g_malloc(sizeof(b->name) + 10); |
1366 strcpy(who, b->name); | |
1367 gtk_label_set(GTK_LABEL(b->label), who); | |
1368 g_free(who); | |
1369 | |
1 | 1370 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, |
1371 NULL, (gchar **)login_icon_xpm); | |
1372 gtk_widget_hide(b->pix); | |
1373 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1374 if (display_options & OPT_DISP_SHOW_PIXMAPS) | |
1375 gtk_widget_show(b->pix); | |
1376 | |
1377 if (display_options & OPT_DISP_SHOW_LOGON) { | |
1378 struct conversation *c = find_conversation(b->name); | |
1379 if (c) { | |
1380 char tmp[1024]; | |
1381 | |
1382 | |
1383 g_snprintf(tmp, sizeof(tmp), "<HR><B>%s logged in%s%s.</B><BR><HR>", b->name, | |
1384 ((display_options & OPT_DISP_SHOW_TIME) ? " @ " : ""), | |
1385 ((display_options & OPT_DISP_SHOW_TIME) ? date() : "")); | |
1386 | |
1387 | |
1388 write_to_conv(c, tmp, WFLAG_SYSTEM); | |
1389 | |
1390 } | |
1391 } | |
1392 | |
1393 | |
1394 gtk_widget_show(b->item); | |
1395 gtk_widget_show(b->label); | |
58 | 1396 b->log_timer = gtk_timeout_add(10000, (GtkFunction) log_timeout, b->name); |
1 | 1397 update_num_groups(); |
1398 update_show_idlepix(); | |
1399 setup_buddy_chats(); | |
1400 return; | |
1401 } | |
1402 | |
1403 | |
1404 | |
1405 if (!b->log_timer) { | |
1406 gtk_widget_hide(b->pix); | |
1407 if (b->uc & UC_UNAVAILABLE) { | |
1408 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1409 NULL, (gchar **)away_icon_xpm); | |
1410 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1411 } else if (b->uc & UC_AOL) { | |
1412 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1413 NULL, (gchar **)aol_icon_xpm); | |
1414 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1415 } else if (b->uc & UC_NORMAL) { | |
1416 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1417 NULL, (gchar **)free_icon_xpm); | |
1418 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1419 } else if (b->uc & UC_ADMIN) { | |
1420 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1421 NULL, (gchar **)admin_icon_xpm); | |
1422 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1423 } else if (b->uc & UC_UNCONFIRMED) { | |
1424 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1425 NULL, (gchar **)dt_icon_xpm); | |
1426 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1427 } else { | |
1428 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1429 NULL, (gchar **)no_icon_xpm); | |
1430 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1431 } | |
1432 if (display_options & OPT_DISP_SHOW_PIXMAPS) | |
1433 gtk_widget_show(b->pix); | |
1434 } | |
1435 | |
1436 | |
1437 | |
1438 } else { | |
59 | 1439 if (GTK_WIDGET_VISIBLE(b->item)) { |
1 | 1440 play_sound(BUDDY_LEAVE); |
1441 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1442 NULL, (gchar **)logout_icon_xpm); | |
1443 gtk_widget_hide(b->pix); | |
1444 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1445 if (display_options & OPT_DISP_SHOW_PIXMAPS) | |
1446 gtk_widget_show(b->pix); | |
1447 if (display_options & OPT_DISP_SHOW_LOGON) { | |
1448 struct conversation *c = find_conversation(b->name); | |
1449 if (c) { | |
1450 char tmp[1024]; | |
1451 | |
1452 | |
1453 g_snprintf(tmp, sizeof(tmp), "<HR><B>%s logged out%s%s.</B><BR><HR>", b->name, | |
1454 ((display_options & OPT_DISP_SHOW_TIME) ? " @ " : ""), | |
1455 ((display_options & OPT_DISP_SHOW_TIME) ? date() : "")); | |
1456 | |
1457 | |
1458 write_to_conv(c, tmp, WFLAG_SYSTEM); | |
1459 | |
1460 } | |
1461 } | |
58 | 1462 b->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, b->name); |
1 | 1463 update_num_groups(); |
1464 update_show_idlepix(); | |
1465 } | |
1466 } | |
1467 setup_buddy_chats(); | |
1468 } | |
1469 | |
1470 | |
1471 static void set_permit(GtkWidget *w, int *data) | |
1472 { | |
1473 permdeny = (int)data; | |
1474 /* printf("BLAH BLAH %d %d", permdeny, (int) data); */ | |
1475 /* We don't save this 'at home', it's on the server. | |
1476 * So, we gotta resend the config to the server. */ | |
1477 serv_save_config(); | |
1478 } | |
1479 | |
1480 | |
1481 static void move_blist_window(GtkWidget *w, GdkEventConfigure *e, void *dummy) | |
1482 { | |
1483 int x, y, width, height; | |
1484 int save = 0; | |
1485 gdk_window_get_position(blist->window, &x, &y); | |
1486 gdk_window_get_size(blist->window, &width, &height); | |
1487 | |
1488 if(e->send_event) { /* Is a position event */ | |
1489 if (blist_pos.x != x || blist_pos.y != y) | |
1490 save = 1; | |
1491 blist_pos.x = x; | |
1492 blist_pos.y = y; | |
1493 } else { /* Is a size event */ | |
1494 if (blist_pos.xoff != x || blist_pos.yoff != y || | |
1495 blist_pos.width != width || blist_pos.width != width) | |
1496 save = 1; | |
1497 | |
1498 blist_pos.width = width; | |
1499 blist_pos.height = height; | |
1500 blist_pos.xoff = x; | |
1501 blist_pos.yoff = y; | |
1502 } | |
1503 | |
1504 if (save) | |
1505 save_prefs(); | |
1506 | |
1507 } | |
1508 | |
1509 | |
1510 /******************************************************************* | |
1511 * | |
1512 * Helper funs for making the menu | |
1513 * | |
1514 *******************************************************************/ | |
1515 | |
1516 void gaim_seperator(GtkWidget *menu) | |
1517 { | |
1518 GtkWidget *sep, *menuitem; | |
1519 sep = gtk_hseparator_new(); | |
1520 menuitem = gtk_menu_item_new(); | |
1521 gtk_menu_append(GTK_MENU(menu), menuitem); | |
1522 gtk_container_add(GTK_CONTAINER(menuitem), sep); | |
1523 gtk_widget_set_sensitive(menuitem, FALSE); | |
1524 gtk_widget_show(menuitem); | |
1525 gtk_widget_show(sep); | |
1526 } | |
1527 | |
1528 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str, GtkSignalFunc sf) | |
1529 { | |
1530 GtkWidget *menuitem; | |
1531 menuitem = gtk_menu_item_new_with_label(str); | |
1532 if (menu) | |
1533 gtk_menu_append(GTK_MENU(menu), menuitem); | |
1534 gtk_widget_show(menuitem); | |
1535 if (sf) | |
1536 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, NULL); | |
1537 return menuitem; | |
1538 } | |
1539 | |
1540 | |
1541 | |
1542 | |
1543 | |
1544 void show_buddy_list() | |
1545 { | |
1546 | |
1547 /* Build the buddy list, based on *config */ | |
1548 | |
1549 GtkWidget *sw; | |
1550 GtkWidget *menu; | |
1551 GtkWidget *findmenu; | |
1552 GtkWidget *setmenu; | |
1553 GtkWidget *menubar; | |
1554 GtkWidget *vbox; | |
1555 GtkWidget *hbox; | |
1556 GtkWidget *menuitem; | |
1557 GtkWidget *notebook; | |
1558 GtkWidget *label; | |
1559 GtkWidget *bbox; | |
1560 GtkWidget *permopt; | |
1561 GtkWidget *tbox; | |
1562 GtkWidget *xbox; | |
1563 GtkWidget *pbox; | |
1564 | |
1565 | |
1566 #ifdef USE_APPLET | |
1567 blist = gtk_window_new(GTK_WINDOW_DIALOG); | |
1568 #else | |
1569 blist = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1570 #endif | |
1571 | |
1572 gtk_widget_realize(blist); | |
1573 aol_icon(blist->window); | |
1574 | |
1575 gtk_window_set_policy(GTK_WINDOW(blist), TRUE, TRUE, TRUE); | |
1576 | |
1577 menubar = gtk_menu_bar_new(); | |
1578 | |
1579 menu = gtk_menu_new(); | |
1580 | |
1581 | |
1582 menuitem = gaim_new_item(NULL, "File", NULL); | |
1583 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); | |
1584 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); | |
1585 | |
1586 gaim_new_item(menu, "Add A Buddy", GTK_SIGNAL_FUNC(add_buddy_callback)); | |
1587 gaim_seperator(menu); | |
1588 gaim_new_item(menu, "Import Buddy List", GTK_SIGNAL_FUNC(import_callback)); | |
1589 gaim_new_item(menu, "Export Buddy List", GTK_SIGNAL_FUNC(export_callback)); | |
1590 if (!(general_options & OPT_GEN_REGISTERED)) | |
1591 { | |
1592 gaim_seperator(menu); | |
1593 gaim_new_item(menu, "Register", GTK_SIGNAL_FUNC(gaimreg_callback)); | |
1594 } | |
1595 gaim_seperator(menu); | |
1596 gaim_new_item(menu, "Signoff", GTK_SIGNAL_FUNC(signoff)); | |
1597 | |
1598 #ifndef USE_APPLET | |
1599 gaim_new_item(menu, "Quit", GTK_SIGNAL_FUNC(do_quit)); | |
1600 #else | |
1601 gaim_new_item(menu, "Close", GTK_SIGNAL_FUNC(applet_destroy_buddy)); | |
1602 #endif | |
1603 | |
1604 menu = gtk_menu_new(); | |
1605 | |
1606 menuitem = gaim_new_item(NULL, "Tools", NULL); | |
1607 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); | |
1608 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); | |
1609 | |
1610 awaymenu = gtk_menu_new(); | |
1611 menuitem = gaim_new_item(menu, "Away", NULL); | |
1612 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), awaymenu); | |
1613 do_away_menu(); | |
1614 | |
1615 bpmenu = gtk_menu_new(); | |
1616 menuitem = gaim_new_item(menu, "Buddy Pounce", NULL); | |
1617 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), bpmenu); | |
1618 do_bp_menu(); | |
1619 | |
1620 gaim_seperator(menu); | |
1621 | |
1622 findmenu = gtk_menu_new(); | |
1623 gtk_widget_show(findmenu); | |
1624 menuitem = gaim_new_item(menu, "Search for Buddy", NULL); | |
1625 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), findmenu); | |
1626 gtk_widget_show(menuitem); | |
1627 menuitem = gtk_menu_item_new_with_label("by Email"); | |
1628 gtk_menu_append(GTK_MENU(findmenu), menuitem); | |
1629 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_find_email), NULL); | |
1630 gtk_widget_show(menuitem); | |
1631 menuitem = gtk_menu_item_new_with_label("by Dir Info"); | |
1632 gtk_menu_append(GTK_MENU(findmenu), menuitem); | |
1633 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_find_info), NULL); | |
1634 gtk_widget_show(menuitem); | |
1635 | |
1636 setmenu = gtk_menu_new(); | |
1637 gtk_widget_show(setmenu); | |
1638 menuitem = gaim_new_item(menu, "Settings", NULL); | |
1639 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), setmenu); | |
1640 gtk_widget_show(menuitem); | |
1641 menuitem = gtk_menu_item_new_with_label("User Info"); | |
1642 gtk_menu_append(GTK_MENU(setmenu), menuitem); | |
1643 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_set_info), NULL); | |
1644 gtk_widget_show(menuitem); | |
1645 menuitem = gtk_menu_item_new_with_label("Directory Info"); | |
1646 gtk_menu_append(GTK_MENU(setmenu), menuitem); | |
1647 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_set_dir), NULL); | |
1648 gtk_widget_show(menuitem); | |
1649 | |
1650 gaim_seperator(menu); | |
1651 | |
1652 gaim_new_item(menu, "Preferences", GTK_SIGNAL_FUNC(show_prefs)); | |
90
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1653 |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1654 #ifdef GAIM_PLUGINS |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1655 menu = gtk_menu_new(); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1656 |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1657 menuitem = gaim_new_item(NULL, "Plugins", NULL); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1658 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1659 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1660 |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1661 gaim_new_item(menu, "Load Plugin", GTK_SIGNAL_FUNC(load_plugin)); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1662 /* FIXME */ |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1663 gaim_new_item(menu, "Remove Plugin", GTK_SIGNAL_FUNC(show_plugins)); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1664 gaim_new_item(menu, "Show Plugins", GTK_SIGNAL_FUNC(show_plugins)); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1665 #endif |
1 | 1666 |
1667 menu = gtk_menu_new(); | |
1668 | |
1669 menuitem = gaim_new_item(NULL, "Help", NULL); | |
1670 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); | |
1671 gtk_menu_item_right_justify(GTK_MENU_ITEM(menuitem)); | |
1672 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); | |
1673 | |
1674 gaim_new_item(menu, "About", show_about); | |
1675 | |
1676 gtk_widget_show(menubar); | |
1677 | |
1678 lagometer_box = gtk_hbox_new(FALSE, 0); | |
1679 | |
1680 | |
1681 lagometer = gtk_progress_bar_new(); | |
1682 gtk_widget_show(lagometer); | |
1683 | |
1684 label = gtk_label_new("Lag-O-Meter: "); | |
1685 gtk_widget_show(label); | |
1686 | |
1687 gtk_box_pack_start(GTK_BOX(lagometer_box), label, FALSE, FALSE, 5); | |
1688 gtk_box_pack_start(GTK_BOX(lagometer_box), lagometer, TRUE, TRUE, 5); | |
1689 | |
1690 gtk_widget_set_usize(lagometer, 5, 5); | |
1691 | |
1692 | |
1693 if ((general_options & OPT_GEN_SHOW_LAGMETER)) | |
1694 gtk_widget_show(lagometer_box); | |
1695 | |
1696 | |
1697 vbox = gtk_vbox_new(FALSE, 10); | |
1698 | |
1699 notebook = gtk_notebook_new(); | |
1700 | |
1701 | |
1702 | |
1703 | |
1704 /* Do buddy list stuff */ | |
1705 | |
1706 buddypane = gtk_vbox_new(FALSE, 0); | |
1707 | |
1708 imbutton = gtk_button_new_with_label("Im"); | |
1709 infobutton = gtk_button_new_with_label("Info"); | |
1710 chatbutton = gtk_button_new_with_label("Chat"); | |
1711 | |
1712 hbox = gtk_hbox_new(TRUE, 10); | |
1713 | |
1714 buddies = gtk_tree_new(); | |
1715 sw = gtk_scrolled_window_new(NULL, NULL); | |
1716 | |
1717 | |
1718 | |
1719 | |
1720 | |
1721 tips = gtk_tooltips_new(); | |
1722 gtk_object_set_data(GTK_OBJECT(blist), "Buddy List", tips); | |
1723 | |
1724 | |
1725 | |
1726 /* Now the buddy list */ | |
1727 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw),buddies); | |
1728 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
1729 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
1730 gtk_widget_set_usize(sw,200,200); | |
1731 gtk_widget_show(buddies); | |
1732 gtk_widget_show(sw); | |
1733 | |
1734 /* Put the buttons in the hbox */ | |
1735 gtk_widget_show(imbutton); | |
1736 gtk_widget_show(chatbutton); | |
1737 gtk_widget_show(infobutton); | |
1738 | |
1739 gtk_box_pack_start(GTK_BOX(hbox), imbutton, TRUE, TRUE, 0); | |
1740 gtk_box_pack_start(GTK_BOX(hbox), infobutton, TRUE, TRUE, 0); | |
1741 gtk_box_pack_start(GTK_BOX(hbox), chatbutton, TRUE, TRUE, 0); | |
1742 gtk_container_border_width(GTK_CONTAINER(hbox), 10); | |
1743 | |
1744 | |
1745 gtk_tooltips_set_tip(tips,infobutton, "Information on selected Buddy", "Penguin"); | |
1746 gtk_tooltips_set_tip(tips,imbutton, "Send Instant Message", "Penguin"); | |
1747 gtk_tooltips_set_tip(tips,chatbutton, "Start/join a Buddy Chat", "Penguin"); | |
1748 | |
1749 gtk_box_pack_start(GTK_BOX(buddypane), sw, TRUE, TRUE, 0); | |
1750 gtk_box_pack_start(GTK_BOX(buddypane), hbox, FALSE, FALSE, 0); | |
1751 | |
1752 gtk_widget_show(hbox); | |
1753 gtk_widget_show(buddypane); | |
1754 | |
1755 | |
1756 | |
1757 /* Swing the edit buddy */ | |
1758 editpane = gtk_vbox_new(FALSE, 0); | |
1759 | |
1760 | |
1761 addbutton = gtk_button_new_with_label("Add"); | |
1762 rembutton = gtk_button_new_with_label("Remove"); | |
1763 edittree = gtk_ctree_new(1, 0); | |
1764 gtk_ctree_set_line_style (GTK_CTREE(edittree), GTK_CTREE_LINES_SOLID); | |
1765 gtk_ctree_set_expander_style(GTK_CTREE(edittree), GTK_CTREE_EXPANDER_SQUARE); | |
1766 gtk_clist_set_reorderable(GTK_CLIST(edittree), TRUE); | |
1767 | |
1768 gtk_ctree_set_drag_compare_func (GTK_CTREE(edittree), | |
1769 (GtkCTreeCompareDragFunc)edit_drag_compare_func); | |
1770 | |
1771 | |
1772 gtk_signal_connect_after (GTK_OBJECT (edittree), "tree_move", | |
1773 GTK_SIGNAL_FUNC (edit_tree_move), NULL); | |
1774 | |
1775 | |
1776 bbox = gtk_hbox_new(TRUE, 10); | |
1777 tbox = gtk_scrolled_window_new(NULL, NULL); | |
1778 /* Put the buttons in the box */ | |
1779 gtk_box_pack_start(GTK_BOX(bbox), addbutton, TRUE, TRUE, 10); | |
1780 gtk_box_pack_start(GTK_BOX(bbox), rembutton, TRUE, TRUE, 10); | |
1781 | |
1782 gtk_tooltips_set_tip(tips, addbutton, "Add a new Buddy", "Penguin"); | |
1783 gtk_tooltips_set_tip(tips, rembutton, "Remove selected Buddy", "Penguin"); | |
1784 | |
1785 /* And the boxes in the box */ | |
1786 gtk_box_pack_start(GTK_BOX(editpane), tbox, TRUE, TRUE, 5); | |
1787 gtk_box_pack_start(GTK_BOX(editpane), bbox, FALSE, FALSE, 5); | |
1788 | |
1789 /* Handle closes right */ | |
1790 | |
1791 | |
1792 | |
1793 /* Finish up */ | |
1794 gtk_widget_show(addbutton); | |
1795 gtk_widget_show(rembutton); | |
1796 gtk_widget_show(edittree); | |
1797 gtk_widget_show(tbox); | |
1798 gtk_widget_show(bbox); | |
1799 gtk_widget_show(editpane); | |
1800 | |
1801 | |
1802 /* Permit/Deny */ | |
1803 | |
1804 permitpane = gtk_vbox_new(FALSE, 0); | |
1805 | |
1806 permopt = gtk_radio_button_new_with_label(NULL, "Allow anyone"); | |
1807 gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0); | |
1808 gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)1); | |
1809 gtk_widget_show(permopt); | |
1810 if (permdeny == 1) | |
1811 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE); | |
1812 | |
1813 permopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(permopt)), "Permit some"); | |
1814 gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0); | |
1815 gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)3); | |
1816 gtk_widget_show(permopt); | |
1817 if (permdeny == 3) | |
1818 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE); | |
1819 | |
1820 | |
1821 permopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(permopt)), "Deny some"); | |
1822 gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0); | |
1823 gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)4); | |
1824 gtk_widget_show(permopt); | |
1825 if (permdeny == 4) | |
1826 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE); | |
1827 | |
1828 | |
1829 | |
1830 addpermbutton = gtk_button_new_with_label("Add"); | |
1831 rempermbutton = gtk_button_new_with_label("Remove"); | |
1832 | |
1833 permtree = gtk_tree_new(); | |
1834 pbox = gtk_hbox_new(TRUE, 10); | |
1835 xbox = gtk_scrolled_window_new(NULL, NULL); | |
1836 /* Put the buttons in the box */ | |
1837 gtk_box_pack_start(GTK_BOX(pbox), addpermbutton, TRUE, TRUE, 10); | |
1838 gtk_box_pack_start(GTK_BOX(pbox), rempermbutton, TRUE, TRUE, 10); | |
1839 | |
1840 | |
1841 gtk_tooltips_set_tip(tips, addpermbutton, "Add buddy to permit/deny", "Penguin"); | |
1842 gtk_tooltips_set_tip(tips, rempermbutton, "Remove buddy from permit/deny", "Penguin"); | |
1843 /* And the boxes in the box */ | |
1844 gtk_box_pack_start(GTK_BOX(permitpane), xbox, TRUE, TRUE, 5); | |
1845 gtk_box_pack_start(GTK_BOX(permitpane), pbox, FALSE, FALSE, 5); | |
1846 | |
1847 /* Handle closes right */ | |
1848 | |
1849 | |
1850 | |
1851 /* Finish up */ | |
1852 gtk_widget_show(addpermbutton); | |
1853 gtk_widget_show(rempermbutton); | |
1854 gtk_widget_show(permtree); | |
1855 gtk_widget_show(xbox); | |
1856 gtk_widget_show(pbox); | |
1857 gtk_widget_show(permitpane); | |
1858 | |
1859 | |
1860 | |
1861 label = gtk_label_new("Online"); | |
1862 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), buddypane, label); | |
1863 label = gtk_label_new("Edit Buddies"); | |
1864 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), editpane, label); | |
1865 label = gtk_label_new("Permit"); | |
1866 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), permitpane, label); | |
1867 | |
1868 gtk_widget_show_all(notebook); | |
1869 | |
1870 /* Pack things in the vbox */ | |
1871 gtk_widget_show(vbox); | |
1872 | |
1873 | |
1874 gtk_widget_show(notebook); | |
1875 | |
1876 /* Enable buttons */ | |
1877 | |
1878 gtk_signal_connect(GTK_OBJECT(imbutton), "clicked", GTK_SIGNAL_FUNC(show_im_dialog), buddies); | |
1879 gtk_signal_connect(GTK_OBJECT(infobutton), "clicked", GTK_SIGNAL_FUNC(info_callback), buddies); | |
1880 gtk_signal_connect(GTK_OBJECT(chatbutton), "clicked", GTK_SIGNAL_FUNC(chat_callback), buddies); | |
1881 gtk_signal_connect(GTK_OBJECT(rembutton), "clicked", GTK_SIGNAL_FUNC(do_del_buddy), edittree); | |
1882 gtk_signal_connect(GTK_OBJECT(addbutton), "clicked", GTK_SIGNAL_FUNC(add_buddy_callback), NULL); | |
1883 gtk_signal_connect(GTK_OBJECT(addpermbutton), "clicked", GTK_SIGNAL_FUNC(add_perm_callback), NULL); | |
1884 gtk_signal_connect(GTK_OBJECT(rempermbutton), "clicked", GTK_SIGNAL_FUNC(do_del_perm), permtree); | |
1885 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0); | |
1886 gtk_box_pack_start(GTK_BOX(vbox), lagometer_box, FALSE, TRUE, 0); | |
1887 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); | |
1888 | |
1889 gtk_container_add(GTK_CONTAINER(blist), vbox); | |
1890 | |
1891 #ifndef USE_APPLET | |
1892 gtk_signal_connect(GTK_OBJECT(blist), "delete_event", GTK_SIGNAL_FUNC(do_quit), blist); | |
1893 #else | |
1894 gtk_signal_connect(GTK_OBJECT(blist), "delete_event", GTK_SIGNAL_FUNC(applet_destroy_buddy), NULL); | |
1895 #endif | |
1896 | |
1897 gtk_signal_connect(GTK_OBJECT(blist), "configure_event", GTK_SIGNAL_FUNC(move_blist_window), NULL); | |
1898 | |
1899 | |
1900 | |
1901 /* The edit tree */ | |
1902 gtk_container_add(GTK_CONTAINER(tbox), edittree); | |
1903 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tbox), | |
1904 GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC); | |
1905 | |
1906 | |
1907 /* The permit tree */ | |
1908 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(xbox), permtree); | |
1909 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(xbox), | |
1910 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
1911 | |
1912 gtk_window_set_title(GTK_WINDOW(blist), "Gaim - Buddy List"); | |
1913 | |
1914 if (general_options & OPT_GEN_SAVED_WINDOWS) { | |
1915 if (blist_pos.width != 0) { /* Sanity check! */ | |
1916 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, blist_pos.y - blist_pos.yoff); | |
1917 gtk_widget_set_usize(blist, blist_pos.width, blist_pos.height); | |
1918 } | |
1919 } | |
1920 } | |
1921 | |
1922 void refresh_buddy_window() | |
1923 { | |
1924 setup_buddy_chats(); | |
1925 | |
1926 build_edit_tree(); | |
1927 build_permit_tree(); | |
1928 | |
1929 update_button_pix(); | |
1930 gtk_widget_show(blist); | |
1931 | |
1932 | |
1933 } | |
1934 |