Mercurial > pidgin
annotate src/buddy.c @ 120:991d5f0c6c90
[gaim-migrate @ 130]
Whoops, shouldn't expand if wasn't expanded.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 15 Apr 2000 23:29:33 +0000 |
parents | 66ec3865bd46 |
children | 3571b593f423 |
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 | |
1389 if (!GTK_WIDGET_VISIBLE(b->item)) { | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1390 #ifdef GAIM_PLUGINS |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1391 GList *c = callbacks; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1392 struct gaim_callback *g; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1393 void (*function)(char *, void *); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1394 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1395 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1396 if (g->event == event_buddy_signon && |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1397 g->function != NULL) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1398 function = g->function; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1399 (*function)(b->name, g->data); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1400 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1401 c = c->next; |
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 #endif |
1 | 1404 |
1405 play_sound(BUDDY_ARRIVE); | |
1406 | |
70 | 1407 who = g_malloc(sizeof(b->name) + 10); |
1408 strcpy(who, b->name); | |
1409 gtk_label_set(GTK_LABEL(b->label), who); | |
1410 g_free(who); | |
1411 | |
1 | 1412 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, |
1413 NULL, (gchar **)login_icon_xpm); | |
1414 gtk_widget_hide(b->pix); | |
1415 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1416 if (display_options & OPT_DISP_SHOW_PIXMAPS) | |
1417 gtk_widget_show(b->pix); | |
1418 | |
1419 if (display_options & OPT_DISP_SHOW_LOGON) { | |
1420 struct conversation *c = find_conversation(b->name); | |
1421 if (c) { | |
1422 char tmp[1024]; | |
1423 | |
1424 | |
1425 g_snprintf(tmp, sizeof(tmp), "<HR><B>%s logged in%s%s.</B><BR><HR>", b->name, | |
1426 ((display_options & OPT_DISP_SHOW_TIME) ? " @ " : ""), | |
1427 ((display_options & OPT_DISP_SHOW_TIME) ? date() : "")); | |
1428 | |
1429 | |
1430 write_to_conv(c, tmp, WFLAG_SYSTEM); | |
1431 | |
1432 } | |
1433 } | |
1434 | |
1435 | |
1436 gtk_widget_show(b->item); | |
1437 gtk_widget_show(b->label); | |
58 | 1438 b->log_timer = gtk_timeout_add(10000, (GtkFunction) log_timeout, b->name); |
1 | 1439 update_num_groups(); |
1440 update_show_idlepix(); | |
1441 setup_buddy_chats(); | |
1442 return; | |
1443 } | |
1444 | |
1445 | |
1446 | |
1447 if (!b->log_timer) { | |
1448 gtk_widget_hide(b->pix); | |
1449 if (b->uc & UC_UNAVAILABLE) { | |
1450 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1451 NULL, (gchar **)away_icon_xpm); | |
1452 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1453 } else if (b->uc & UC_AOL) { | |
1454 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1455 NULL, (gchar **)aol_icon_xpm); | |
1456 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1457 } else if (b->uc & UC_NORMAL) { | |
1458 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1459 NULL, (gchar **)free_icon_xpm); | |
1460 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1461 } else if (b->uc & UC_ADMIN) { | |
1462 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1463 NULL, (gchar **)admin_icon_xpm); | |
1464 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1465 } else if (b->uc & UC_UNCONFIRMED) { | |
1466 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1467 NULL, (gchar **)dt_icon_xpm); | |
1468 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1469 } else { | |
1470 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1471 NULL, (gchar **)no_icon_xpm); | |
1472 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1473 } | |
1474 if (display_options & OPT_DISP_SHOW_PIXMAPS) | |
1475 gtk_widget_show(b->pix); | |
1476 } | |
1477 | |
1478 | |
1479 | |
1480 } else { | |
59 | 1481 if (GTK_WIDGET_VISIBLE(b->item)) { |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1482 #ifdef GAIM_PLUGINS |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1483 GList *c = callbacks; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1484 struct gaim_callback *g; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1485 void (*function)(char *, void *); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1486 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1487 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1488 if (g->event == event_buddy_signoff && |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1489 g->function != NULL) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1490 function = g->function; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1491 (*function)(b->name, g->data); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1492 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1493 c = c->next; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1494 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
90
diff
changeset
|
1495 #endif |
1 | 1496 play_sound(BUDDY_LEAVE); |
1497 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, | |
1498 NULL, (gchar **)logout_icon_xpm); | |
1499 gtk_widget_hide(b->pix); | |
1500 gtk_pixmap_set(GTK_PIXMAP(b->pix), pm, bm); | |
1501 if (display_options & OPT_DISP_SHOW_PIXMAPS) | |
1502 gtk_widget_show(b->pix); | |
1503 if (display_options & OPT_DISP_SHOW_LOGON) { | |
1504 struct conversation *c = find_conversation(b->name); | |
1505 if (c) { | |
1506 char tmp[1024]; | |
1507 | |
1508 | |
1509 g_snprintf(tmp, sizeof(tmp), "<HR><B>%s logged out%s%s.</B><BR><HR>", b->name, | |
1510 ((display_options & OPT_DISP_SHOW_TIME) ? " @ " : ""), | |
1511 ((display_options & OPT_DISP_SHOW_TIME) ? date() : "")); | |
1512 | |
1513 | |
1514 write_to_conv(c, tmp, WFLAG_SYSTEM); | |
1515 | |
1516 } | |
1517 } | |
58 | 1518 b->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, b->name); |
1 | 1519 update_num_groups(); |
1520 update_show_idlepix(); | |
1521 } | |
1522 } | |
1523 setup_buddy_chats(); | |
1524 } | |
1525 | |
1526 | |
1527 static void set_permit(GtkWidget *w, int *data) | |
1528 { | |
1529 permdeny = (int)data; | |
1530 /* printf("BLAH BLAH %d %d", permdeny, (int) data); */ | |
1531 /* We don't save this 'at home', it's on the server. | |
1532 * So, we gotta resend the config to the server. */ | |
1533 serv_save_config(); | |
1534 } | |
1535 | |
1536 | |
1537 static void move_blist_window(GtkWidget *w, GdkEventConfigure *e, void *dummy) | |
1538 { | |
1539 int x, y, width, height; | |
1540 int save = 0; | |
1541 gdk_window_get_position(blist->window, &x, &y); | |
1542 gdk_window_get_size(blist->window, &width, &height); | |
1543 | |
1544 if(e->send_event) { /* Is a position event */ | |
1545 if (blist_pos.x != x || blist_pos.y != y) | |
1546 save = 1; | |
1547 blist_pos.x = x; | |
1548 blist_pos.y = y; | |
1549 } else { /* Is a size event */ | |
1550 if (blist_pos.xoff != x || blist_pos.yoff != y || | |
1551 blist_pos.width != width || blist_pos.width != width) | |
1552 save = 1; | |
1553 | |
1554 blist_pos.width = width; | |
1555 blist_pos.height = height; | |
1556 blist_pos.xoff = x; | |
1557 blist_pos.yoff = y; | |
1558 } | |
1559 | |
1560 if (save) | |
1561 save_prefs(); | |
1562 | |
1563 } | |
1564 | |
1565 | |
1566 /******************************************************************* | |
1567 * | |
1568 * Helper funs for making the menu | |
1569 * | |
1570 *******************************************************************/ | |
1571 | |
1572 void gaim_seperator(GtkWidget *menu) | |
1573 { | |
1574 GtkWidget *sep, *menuitem; | |
1575 sep = gtk_hseparator_new(); | |
1576 menuitem = gtk_menu_item_new(); | |
1577 gtk_menu_append(GTK_MENU(menu), menuitem); | |
1578 gtk_container_add(GTK_CONTAINER(menuitem), sep); | |
1579 gtk_widget_set_sensitive(menuitem, FALSE); | |
1580 gtk_widget_show(menuitem); | |
1581 gtk_widget_show(sep); | |
1582 } | |
1583 | |
1584 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str, GtkSignalFunc sf) | |
1585 { | |
1586 GtkWidget *menuitem; | |
1587 menuitem = gtk_menu_item_new_with_label(str); | |
1588 if (menu) | |
1589 gtk_menu_append(GTK_MENU(menu), menuitem); | |
1590 gtk_widget_show(menuitem); | |
1591 if (sf) | |
1592 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", sf, NULL); | |
1593 return menuitem; | |
1594 } | |
1595 | |
1596 | |
1597 | |
1598 | |
1599 | |
1600 void show_buddy_list() | |
1601 { | |
1602 | |
1603 /* Build the buddy list, based on *config */ | |
1604 | |
1605 GtkWidget *sw; | |
1606 GtkWidget *menu; | |
1607 GtkWidget *findmenu; | |
1608 GtkWidget *setmenu; | |
1609 GtkWidget *menubar; | |
1610 GtkWidget *vbox; | |
1611 GtkWidget *hbox; | |
1612 GtkWidget *menuitem; | |
1613 GtkWidget *notebook; | |
1614 GtkWidget *label; | |
1615 GtkWidget *bbox; | |
1616 GtkWidget *permopt; | |
1617 GtkWidget *tbox; | |
1618 GtkWidget *xbox; | |
1619 GtkWidget *pbox; | |
1620 | |
1621 | |
1622 #ifdef USE_APPLET | |
1623 blist = gtk_window_new(GTK_WINDOW_DIALOG); | |
1624 #else | |
1625 blist = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1626 #endif | |
1627 | |
1628 gtk_widget_realize(blist); | |
1629 aol_icon(blist->window); | |
1630 | |
1631 gtk_window_set_policy(GTK_WINDOW(blist), TRUE, TRUE, TRUE); | |
1632 | |
1633 menubar = gtk_menu_bar_new(); | |
1634 | |
1635 menu = gtk_menu_new(); | |
1636 | |
1637 | |
1638 menuitem = gaim_new_item(NULL, "File", NULL); | |
1639 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); | |
1640 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); | |
1641 | |
1642 gaim_new_item(menu, "Add A Buddy", GTK_SIGNAL_FUNC(add_buddy_callback)); | |
1643 gaim_seperator(menu); | |
1644 gaim_new_item(menu, "Import Buddy List", GTK_SIGNAL_FUNC(import_callback)); | |
1645 gaim_new_item(menu, "Export Buddy List", GTK_SIGNAL_FUNC(export_callback)); | |
1646 if (!(general_options & OPT_GEN_REGISTERED)) | |
1647 { | |
1648 gaim_seperator(menu); | |
1649 gaim_new_item(menu, "Register", GTK_SIGNAL_FUNC(gaimreg_callback)); | |
1650 } | |
1651 gaim_seperator(menu); | |
1652 gaim_new_item(menu, "Signoff", GTK_SIGNAL_FUNC(signoff)); | |
1653 | |
1654 #ifndef USE_APPLET | |
1655 gaim_new_item(menu, "Quit", GTK_SIGNAL_FUNC(do_quit)); | |
1656 #else | |
1657 gaim_new_item(menu, "Close", GTK_SIGNAL_FUNC(applet_destroy_buddy)); | |
1658 #endif | |
1659 | |
1660 menu = gtk_menu_new(); | |
1661 | |
1662 menuitem = gaim_new_item(NULL, "Tools", NULL); | |
1663 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); | |
1664 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); | |
1665 | |
1666 awaymenu = gtk_menu_new(); | |
1667 menuitem = gaim_new_item(menu, "Away", NULL); | |
1668 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), awaymenu); | |
1669 do_away_menu(); | |
1670 | |
1671 bpmenu = gtk_menu_new(); | |
1672 menuitem = gaim_new_item(menu, "Buddy Pounce", NULL); | |
1673 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), bpmenu); | |
1674 do_bp_menu(); | |
1675 | |
1676 gaim_seperator(menu); | |
1677 | |
1678 findmenu = gtk_menu_new(); | |
1679 gtk_widget_show(findmenu); | |
1680 menuitem = gaim_new_item(menu, "Search for Buddy", NULL); | |
1681 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), findmenu); | |
1682 gtk_widget_show(menuitem); | |
1683 menuitem = gtk_menu_item_new_with_label("by Email"); | |
1684 gtk_menu_append(GTK_MENU(findmenu), menuitem); | |
1685 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_find_email), NULL); | |
1686 gtk_widget_show(menuitem); | |
1687 menuitem = gtk_menu_item_new_with_label("by Dir Info"); | |
1688 gtk_menu_append(GTK_MENU(findmenu), menuitem); | |
1689 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_find_info), NULL); | |
1690 gtk_widget_show(menuitem); | |
1691 | |
1692 setmenu = gtk_menu_new(); | |
1693 gtk_widget_show(setmenu); | |
1694 menuitem = gaim_new_item(menu, "Settings", NULL); | |
1695 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), setmenu); | |
1696 gtk_widget_show(menuitem); | |
1697 menuitem = gtk_menu_item_new_with_label("User Info"); | |
1698 gtk_menu_append(GTK_MENU(setmenu), menuitem); | |
1699 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_set_info), NULL); | |
1700 gtk_widget_show(menuitem); | |
1701 menuitem = gtk_menu_item_new_with_label("Directory Info"); | |
1702 gtk_menu_append(GTK_MENU(setmenu), menuitem); | |
1703 gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(show_set_dir), NULL); | |
1704 gtk_widget_show(menuitem); | |
1705 | |
1706 gaim_seperator(menu); | |
1707 | |
1708 gaim_new_item(menu, "Preferences", GTK_SIGNAL_FUNC(show_prefs)); | |
90
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1709 |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1710 #ifdef GAIM_PLUGINS |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1711 menu = gtk_menu_new(); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1712 |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1713 menuitem = gaim_new_item(NULL, "Plugins", NULL); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1714 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1715 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1716 |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1717 gaim_new_item(menu, "Load Plugin", GTK_SIGNAL_FUNC(load_plugin)); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1718 /* FIXME */ |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1719 gaim_new_item(menu, "Remove Plugin", GTK_SIGNAL_FUNC(show_plugins)); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1720 gaim_new_item(menu, "Show Plugins", GTK_SIGNAL_FUNC(show_plugins)); |
f5b305c0d974
[gaim-migrate @ 100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
87
diff
changeset
|
1721 #endif |
1 | 1722 |
1723 menu = gtk_menu_new(); | |
1724 | |
1725 menuitem = gaim_new_item(NULL, "Help", NULL); | |
1726 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); | |
1727 gtk_menu_item_right_justify(GTK_MENU_ITEM(menuitem)); | |
1728 gtk_menu_bar_append(GTK_MENU_BAR(menubar), menuitem); | |
1729 | |
1730 gaim_new_item(menu, "About", show_about); | |
1731 | |
1732 gtk_widget_show(menubar); | |
1733 | |
1734 lagometer_box = gtk_hbox_new(FALSE, 0); | |
1735 | |
1736 | |
1737 lagometer = gtk_progress_bar_new(); | |
1738 gtk_widget_show(lagometer); | |
1739 | |
1740 label = gtk_label_new("Lag-O-Meter: "); | |
1741 gtk_widget_show(label); | |
1742 | |
1743 gtk_box_pack_start(GTK_BOX(lagometer_box), label, FALSE, FALSE, 5); | |
1744 gtk_box_pack_start(GTK_BOX(lagometer_box), lagometer, TRUE, TRUE, 5); | |
1745 | |
1746 gtk_widget_set_usize(lagometer, 5, 5); | |
1747 | |
1748 | |
1749 if ((general_options & OPT_GEN_SHOW_LAGMETER)) | |
1750 gtk_widget_show(lagometer_box); | |
1751 | |
1752 | |
1753 vbox = gtk_vbox_new(FALSE, 10); | |
1754 | |
1755 notebook = gtk_notebook_new(); | |
1756 | |
1757 | |
1758 | |
1759 | |
1760 /* Do buddy list stuff */ | |
1761 | |
1762 buddypane = gtk_vbox_new(FALSE, 0); | |
1763 | |
1764 imbutton = gtk_button_new_with_label("Im"); | |
1765 infobutton = gtk_button_new_with_label("Info"); | |
1766 chatbutton = gtk_button_new_with_label("Chat"); | |
1767 | |
1768 hbox = gtk_hbox_new(TRUE, 10); | |
1769 | |
1770 buddies = gtk_tree_new(); | |
1771 sw = gtk_scrolled_window_new(NULL, NULL); | |
1772 | |
1773 | |
1774 | |
1775 | |
1776 | |
1777 tips = gtk_tooltips_new(); | |
1778 gtk_object_set_data(GTK_OBJECT(blist), "Buddy List", tips); | |
1779 | |
1780 | |
1781 | |
1782 /* Now the buddy list */ | |
1783 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw),buddies); | |
1784 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
1785 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
1786 gtk_widget_set_usize(sw,200,200); | |
1787 gtk_widget_show(buddies); | |
1788 gtk_widget_show(sw); | |
1789 | |
1790 /* Put the buttons in the hbox */ | |
1791 gtk_widget_show(imbutton); | |
1792 gtk_widget_show(chatbutton); | |
1793 gtk_widget_show(infobutton); | |
1794 | |
1795 gtk_box_pack_start(GTK_BOX(hbox), imbutton, TRUE, TRUE, 0); | |
1796 gtk_box_pack_start(GTK_BOX(hbox), infobutton, TRUE, TRUE, 0); | |
1797 gtk_box_pack_start(GTK_BOX(hbox), chatbutton, TRUE, TRUE, 0); | |
1798 gtk_container_border_width(GTK_CONTAINER(hbox), 10); | |
1799 | |
1800 | |
1801 gtk_tooltips_set_tip(tips,infobutton, "Information on selected Buddy", "Penguin"); | |
1802 gtk_tooltips_set_tip(tips,imbutton, "Send Instant Message", "Penguin"); | |
1803 gtk_tooltips_set_tip(tips,chatbutton, "Start/join a Buddy Chat", "Penguin"); | |
1804 | |
1805 gtk_box_pack_start(GTK_BOX(buddypane), sw, TRUE, TRUE, 0); | |
1806 gtk_box_pack_start(GTK_BOX(buddypane), hbox, FALSE, FALSE, 0); | |
1807 | |
1808 gtk_widget_show(hbox); | |
1809 gtk_widget_show(buddypane); | |
1810 | |
1811 | |
1812 | |
1813 /* Swing the edit buddy */ | |
1814 editpane = gtk_vbox_new(FALSE, 0); | |
1815 | |
1816 | |
1817 addbutton = gtk_button_new_with_label("Add"); | |
1818 rembutton = gtk_button_new_with_label("Remove"); | |
1819 edittree = gtk_ctree_new(1, 0); | |
1820 gtk_ctree_set_line_style (GTK_CTREE(edittree), GTK_CTREE_LINES_SOLID); | |
1821 gtk_ctree_set_expander_style(GTK_CTREE(edittree), GTK_CTREE_EXPANDER_SQUARE); | |
1822 gtk_clist_set_reorderable(GTK_CLIST(edittree), TRUE); | |
1823 | |
1824 gtk_ctree_set_drag_compare_func (GTK_CTREE(edittree), | |
1825 (GtkCTreeCompareDragFunc)edit_drag_compare_func); | |
1826 | |
1827 | |
1828 gtk_signal_connect_after (GTK_OBJECT (edittree), "tree_move", | |
1829 GTK_SIGNAL_FUNC (edit_tree_move), NULL); | |
1830 | |
1831 | |
1832 bbox = gtk_hbox_new(TRUE, 10); | |
1833 tbox = gtk_scrolled_window_new(NULL, NULL); | |
1834 /* Put the buttons in the box */ | |
1835 gtk_box_pack_start(GTK_BOX(bbox), addbutton, TRUE, TRUE, 10); | |
1836 gtk_box_pack_start(GTK_BOX(bbox), rembutton, TRUE, TRUE, 10); | |
1837 | |
1838 gtk_tooltips_set_tip(tips, addbutton, "Add a new Buddy", "Penguin"); | |
1839 gtk_tooltips_set_tip(tips, rembutton, "Remove selected Buddy", "Penguin"); | |
1840 | |
1841 /* And the boxes in the box */ | |
1842 gtk_box_pack_start(GTK_BOX(editpane), tbox, TRUE, TRUE, 5); | |
1843 gtk_box_pack_start(GTK_BOX(editpane), bbox, FALSE, FALSE, 5); | |
1844 | |
1845 /* Handle closes right */ | |
1846 | |
1847 | |
1848 | |
1849 /* Finish up */ | |
1850 gtk_widget_show(addbutton); | |
1851 gtk_widget_show(rembutton); | |
1852 gtk_widget_show(edittree); | |
1853 gtk_widget_show(tbox); | |
1854 gtk_widget_show(bbox); | |
1855 gtk_widget_show(editpane); | |
1856 | |
1857 | |
1858 /* Permit/Deny */ | |
1859 | |
1860 permitpane = gtk_vbox_new(FALSE, 0); | |
1861 | |
1862 permopt = gtk_radio_button_new_with_label(NULL, "Allow anyone"); | |
1863 gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0); | |
1864 gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)1); | |
1865 gtk_widget_show(permopt); | |
1866 if (permdeny == 1) | |
1867 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE); | |
1868 | |
1869 permopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(permopt)), "Permit some"); | |
1870 gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0); | |
1871 gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)3); | |
1872 gtk_widget_show(permopt); | |
1873 if (permdeny == 3) | |
1874 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE); | |
1875 | |
1876 | |
1877 permopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(permopt)), "Deny some"); | |
1878 gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0); | |
1879 gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)4); | |
1880 gtk_widget_show(permopt); | |
1881 if (permdeny == 4) | |
1882 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE); | |
1883 | |
1884 | |
1885 | |
1886 addpermbutton = gtk_button_new_with_label("Add"); | |
1887 rempermbutton = gtk_button_new_with_label("Remove"); | |
1888 | |
1889 permtree = gtk_tree_new(); | |
1890 pbox = gtk_hbox_new(TRUE, 10); | |
1891 xbox = gtk_scrolled_window_new(NULL, NULL); | |
1892 /* Put the buttons in the box */ | |
1893 gtk_box_pack_start(GTK_BOX(pbox), addpermbutton, TRUE, TRUE, 10); | |
1894 gtk_box_pack_start(GTK_BOX(pbox), rempermbutton, TRUE, TRUE, 10); | |
1895 | |
1896 | |
1897 gtk_tooltips_set_tip(tips, addpermbutton, "Add buddy to permit/deny", "Penguin"); | |
1898 gtk_tooltips_set_tip(tips, rempermbutton, "Remove buddy from permit/deny", "Penguin"); | |
1899 /* And the boxes in the box */ | |
1900 gtk_box_pack_start(GTK_BOX(permitpane), xbox, TRUE, TRUE, 5); | |
1901 gtk_box_pack_start(GTK_BOX(permitpane), pbox, FALSE, FALSE, 5); | |
1902 | |
1903 /* Handle closes right */ | |
1904 | |
1905 | |
1906 | |
1907 /* Finish up */ | |
1908 gtk_widget_show(addpermbutton); | |
1909 gtk_widget_show(rempermbutton); | |
1910 gtk_widget_show(permtree); | |
1911 gtk_widget_show(xbox); | |
1912 gtk_widget_show(pbox); | |
1913 gtk_widget_show(permitpane); | |
1914 | |
1915 | |
1916 | |
1917 label = gtk_label_new("Online"); | |
1918 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), buddypane, label); | |
1919 label = gtk_label_new("Edit Buddies"); | |
1920 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), editpane, label); | |
1921 label = gtk_label_new("Permit"); | |
1922 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), permitpane, label); | |
1923 | |
1924 gtk_widget_show_all(notebook); | |
1925 | |
1926 /* Pack things in the vbox */ | |
1927 gtk_widget_show(vbox); | |
1928 | |
1929 | |
1930 gtk_widget_show(notebook); | |
1931 | |
1932 /* Enable buttons */ | |
1933 | |
1934 gtk_signal_connect(GTK_OBJECT(imbutton), "clicked", GTK_SIGNAL_FUNC(show_im_dialog), buddies); | |
1935 gtk_signal_connect(GTK_OBJECT(infobutton), "clicked", GTK_SIGNAL_FUNC(info_callback), buddies); | |
1936 gtk_signal_connect(GTK_OBJECT(chatbutton), "clicked", GTK_SIGNAL_FUNC(chat_callback), buddies); | |
1937 gtk_signal_connect(GTK_OBJECT(rembutton), "clicked", GTK_SIGNAL_FUNC(do_del_buddy), edittree); | |
1938 gtk_signal_connect(GTK_OBJECT(addbutton), "clicked", GTK_SIGNAL_FUNC(add_buddy_callback), NULL); | |
1939 gtk_signal_connect(GTK_OBJECT(addpermbutton), "clicked", GTK_SIGNAL_FUNC(add_perm_callback), NULL); | |
1940 gtk_signal_connect(GTK_OBJECT(rempermbutton), "clicked", GTK_SIGNAL_FUNC(do_del_perm), permtree); | |
1941 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0); | |
1942 gtk_box_pack_start(GTK_BOX(vbox), lagometer_box, FALSE, TRUE, 0); | |
1943 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); | |
1944 | |
1945 gtk_container_add(GTK_CONTAINER(blist), vbox); | |
1946 | |
1947 #ifndef USE_APPLET | |
1948 gtk_signal_connect(GTK_OBJECT(blist), "delete_event", GTK_SIGNAL_FUNC(do_quit), blist); | |
1949 #else | |
1950 gtk_signal_connect(GTK_OBJECT(blist), "delete_event", GTK_SIGNAL_FUNC(applet_destroy_buddy), NULL); | |
1951 #endif | |
1952 | |
1953 gtk_signal_connect(GTK_OBJECT(blist), "configure_event", GTK_SIGNAL_FUNC(move_blist_window), NULL); | |
1954 | |
1955 | |
1956 | |
1957 /* The edit tree */ | |
1958 gtk_container_add(GTK_CONTAINER(tbox), edittree); | |
1959 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tbox), | |
1960 GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC); | |
1961 | |
1962 | |
1963 /* The permit tree */ | |
1964 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(xbox), permtree); | |
1965 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(xbox), | |
1966 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); | |
1967 | |
1968 gtk_window_set_title(GTK_WINDOW(blist), "Gaim - Buddy List"); | |
1969 | |
1970 if (general_options & OPT_GEN_SAVED_WINDOWS) { | |
1971 if (blist_pos.width != 0) { /* Sanity check! */ | |
1972 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, blist_pos.y - blist_pos.yoff); | |
1973 gtk_widget_set_usize(blist, blist_pos.width, blist_pos.height); | |
1974 } | |
1975 } | |
1976 } | |
1977 | |
1978 void refresh_buddy_window() | |
1979 { | |
1980 setup_buddy_chats(); | |
1981 | |
1982 build_edit_tree(); | |
1983 build_permit_tree(); | |
1984 | |
1985 update_button_pix(); | |
1986 gtk_widget_show(blist); | |
1987 | |
1988 | |
1989 } | |
1990 |