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