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