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