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