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