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