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