4687
|
1 /*
|
|
2 * gaim
|
|
3 *
|
|
4 * Copyright (C) 1998-2003, 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 #include <stdlib.h>
|
|
23 #include <string.h>
|
|
24 #include <sys/types.h>
|
|
25 #include <unistd.h>
|
|
26
|
|
27 #include "gaim.h"
|
|
28 #include "prpl.h"
|
|
29 #include "pounce.h"
|
|
30
|
|
31 GtkWidget *bpmenu = NULL;
|
|
32
|
|
33 void rem_bp(GtkWidget *w, struct buddy_pounce *b)
|
|
34 {
|
|
35 buddy_pounces = g_list_remove(buddy_pounces, b);
|
4696
|
36 do_bp_menu();
|
4687
|
37 save_prefs();
|
|
38 }
|
|
39
|
|
40 void do_pounce(struct gaim_connection *gc, char *name, int when)
|
|
41 {
|
|
42 char *who;
|
|
43
|
|
44 struct buddy_pounce *b;
|
|
45 struct gaim_conversation *c;
|
|
46 struct gaim_account *account;
|
|
47
|
|
48 GList *bp = buddy_pounces;
|
|
49
|
|
50 who = g_strdup(normalize (name));
|
|
51
|
|
52 while (bp) {
|
|
53 b = (struct buddy_pounce *)bp->data;
|
|
54 bp = bp->next; /* increment the list here because rem_bp can make our handle bad */
|
|
55
|
|
56 if (!(b->options & when))
|
|
57 continue;
|
|
58
|
|
59 account = gaim_account_find(b->pouncer, b->protocol); /* find our user */
|
|
60 if (account == NULL)
|
|
61 continue;
|
|
62
|
|
63 /* check and see if we're signed on as the pouncer */
|
|
64 if (account->gc != gc)
|
|
65 continue;
|
|
66
|
4793
|
67 if (!gaim_utf8_strcasecmp(who, normalize (b->name))) { /* find someone to pounce */
|
4687
|
68 if (b->options & OPT_POUNCE_POPUP) {
|
|
69 c = gaim_find_conversation(name);
|
|
70
|
|
71 if (c == NULL)
|
|
72 c = gaim_conversation_new(GAIM_CONV_IM, account, name);
|
|
73 else
|
|
74 gaim_conversation_set_account(c, account);
|
|
75 }
|
|
76 if (b->options & OPT_POUNCE_NOTIFY) {
|
|
77 char tmp[1024];
|
|
78
|
|
79 /* I know the line below is really ugly. I only did it this way
|
|
80 * because I thought it'd be funny :-) */
|
|
81
|
|
82 g_snprintf(tmp, sizeof(tmp),
|
|
83 (when & OPT_POUNCE_TYPING) ? _("%s has started typing to you") :
|
|
84 (when & OPT_POUNCE_SIGNON) ? _("%s has signed on") :
|
|
85 (when & OPT_POUNCE_UNIDLE) ? _("%s has returned from being idle") :
|
|
86 _("%s has returned from being away"), name);
|
|
87
|
|
88 do_error_dialog(tmp, NULL, GAIM_INFO);
|
|
89 }
|
|
90 if (b->options & OPT_POUNCE_SEND_IM) {
|
|
91 if (strlen(b->message) > 0) {
|
|
92 c = gaim_find_conversation(name);
|
|
93
|
|
94 if (c == NULL)
|
|
95 c = gaim_conversation_new(GAIM_CONV_IM, account, name);
|
|
96 else
|
|
97 gaim_conversation_set_account(c, account);
|
|
98
|
|
99 gaim_conversation_write(c, NULL, b->message, -1,
|
|
100 WFLAG_SEND, time(NULL));
|
|
101
|
|
102 serv_send_im(account->gc, name, b->message, -1, 0);
|
|
103 }
|
|
104 }
|
|
105 if (b->options & OPT_POUNCE_COMMAND) {
|
|
106 #ifndef _WIN32
|
|
107 int pid = fork();
|
|
108
|
|
109 if (pid == 0) {
|
|
110 char *args[4];
|
|
111 args[0] = "sh";
|
|
112 args[1] = "-c";
|
|
113 args[2] = b->command;
|
|
114 args[3] = NULL;
|
|
115 execvp(args[0], args);
|
|
116 _exit(0);
|
|
117 }
|
|
118 #else
|
|
119 STARTUPINFO si;
|
|
120 PROCESS_INFORMATION pi;
|
|
121
|
|
122 ZeroMemory( &si, sizeof(si) );
|
|
123 si.cb = sizeof(si);
|
|
124 ZeroMemory( &pi, sizeof(pi) );
|
|
125
|
|
126 CreateProcess( NULL, b->command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
|
|
127 CloseHandle( pi.hProcess );
|
|
128 CloseHandle( pi.hThread );
|
|
129 #endif /*_WIN32*/
|
|
130 }
|
|
131 /* if (b->options & OPT_POUNCE_SOUND) {
|
|
132 if (strlen(b->sound))
|
|
133 play_file(b->sound);
|
|
134 else
|
|
135 play_sound(SND_POUNCE_DEFAULT);
|
|
136 }*/
|
|
137
|
|
138 if (!(b->options & OPT_POUNCE_SAVE))
|
|
139 rem_bp(NULL, b);
|
|
140
|
|
141 }
|
|
142 }
|
|
143 g_free(who);
|
|
144 }
|
|
145
|
|
146 static void new_bp_callback(GtkWidget *w, struct buddy *b)
|
|
147 {
|
|
148 if (b)
|
|
149 show_new_bp(b->name, b->account->gc, b->idle, b->uc & UC_UNAVAILABLE, NULL);
|
|
150 else
|
|
151 show_new_bp(NULL, NULL, 0, 0, NULL);
|
|
152 }
|
|
153
|
|
154 static void edit_bp_callback(GtkWidget *w, struct buddy_pounce *b)
|
|
155 {
|
|
156 show_new_bp(NULL, NULL, 0, 0, b);
|
|
157 }
|
|
158
|
4696
|
159 static GtkTooltips *bp_tooltip = NULL;
|
4687
|
160 void do_bp_menu()
|
|
161 {
|
|
162 GtkWidget *menuitem, *mess, *messmenu;
|
|
163 static GtkWidget *remmenu;
|
|
164 GtkWidget *remitem;
|
|
165 GtkWidget *sep;
|
|
166 GList *l;
|
|
167 struct buddy_pounce *b;
|
|
168 GList *bp = buddy_pounces;
|
|
169
|
4696
|
170 /* Tooltip for editing bp's */
|
4687
|
171 if(!bp_tooltip)
|
|
172 bp_tooltip = gtk_tooltips_new();
|
|
173
|
4696
|
174 l = gtk_container_get_children(GTK_CONTAINER(bpmenu));
|
4687
|
175
|
|
176 while (l) {
|
|
177 gtk_widget_destroy(GTK_WIDGET(l->data));
|
|
178 l = l->next;
|
|
179 }
|
|
180
|
|
181 remmenu = gtk_menu_new();
|
|
182
|
|
183 menuitem = gtk_menu_item_new_with_label(_("New Buddy Pounce"));
|
4696
|
184 gtk_menu_shell_append(GTK_MENU_SHELL(bpmenu), menuitem);
|
4687
|
185 gtk_widget_show(menuitem);
|
|
186 g_signal_connect(GTK_OBJECT(menuitem), "activate", G_CALLBACK(new_bp_callback), NULL);
|
|
187
|
|
188
|
|
189 while (bp) {
|
|
190
|
|
191 b = (struct buddy_pounce *)bp->data;
|
|
192 remitem = gtk_menu_item_new_with_label(b->name);
|
4696
|
193 gtk_menu_shell_append(GTK_MENU_SHELL(remmenu), remitem);
|
4687
|
194 gtk_widget_show(remitem);
|
|
195 g_signal_connect(GTK_OBJECT(remitem), "activate", G_CALLBACK(rem_bp), b);
|
|
196
|
|
197 bp = bp->next;
|
|
198
|
|
199 }
|
|
200
|
|
201 menuitem = gtk_menu_item_new_with_label(_("Remove Buddy Pounce"));
|
4696
|
202 gtk_menu_shell_append(GTK_MENU_SHELL(bpmenu), menuitem);
|
4687
|
203 gtk_widget_show(menuitem);
|
|
204 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), remmenu);
|
|
205 gtk_widget_show(remmenu);
|
|
206
|
|
207 sep = gtk_hseparator_new();
|
|
208 menuitem = gtk_menu_item_new();
|
4696
|
209 gtk_menu_shell_append(GTK_MENU_SHELL(bpmenu), menuitem);
|
4687
|
210 gtk_container_add(GTK_CONTAINER(menuitem), sep);
|
|
211 gtk_widget_set_sensitive(menuitem, FALSE);
|
|
212 gtk_widget_show(menuitem);
|
|
213 gtk_widget_show(sep);
|
|
214
|
|
215 bp = buddy_pounces;
|
|
216
|
|
217 while (bp) {
|
|
218
|
|
219 b = (struct buddy_pounce *)bp->data;
|
|
220
|
|
221 menuitem = gtk_menu_item_new_with_label(b->name);
|
4696
|
222 gtk_menu_shell_append(GTK_MENU_SHELL(bpmenu), menuitem);
|
4687
|
223 messmenu = gtk_menu_new();
|
|
224 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), messmenu);
|
|
225 gtk_widget_show(menuitem);
|
|
226
|
|
227 if (strlen(b->message))
|
|
228 mess = gtk_menu_item_new_with_label(b->message);
|
|
229 else
|
|
230 mess = gtk_menu_item_new_with_label(_("[no message]"));
|
4696
|
231 gtk_menu_shell_append(GTK_MENU_SHELL(messmenu), mess);
|
4687
|
232 gtk_tooltips_set_tip(bp_tooltip, GTK_WIDGET(mess), _("[Click to edit]"), NULL);
|
|
233 gtk_widget_show(mess);
|
|
234 g_signal_connect(GTK_OBJECT(mess), "activate", G_CALLBACK(edit_bp_callback), b);
|
|
235 bp = bp->next;
|
|
236
|
|
237 }
|
|
238
|
|
239 }
|
4696
|
240
|
4687
|
241 /*------------------------------------------------------------------------*/
|
|
242 /* The dialog for new buddy pounces */
|
|
243 /*------------------------------------------------------------------------*/
|
|
244
|
|
245
|
|
246 void do_new_bp(GtkWidget *w, struct addbp *b)
|
|
247 {
|
|
248 struct buddy_pounce *bp;
|
|
249
|
|
250 if (strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) {
|
|
251 do_error_dialog(_("Please enter a buddy to pounce."), NULL, GAIM_ERROR);
|
|
252 return;
|
|
253 }
|
|
254
|
|
255 if(!b->buddy_pounce)
|
|
256 bp = g_new0(struct buddy_pounce, 1);
|
|
257 else
|
|
258 bp = b->buddy_pounce;
|
|
259
|
|
260
|
|
261 g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry)));
|
|
262 g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry)));
|
|
263 g_snprintf(bp->command, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->commentry)));
|
|
264 g_snprintf(bp->sound, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->soundentry)));
|
|
265 g_snprintf(bp->pouncer, 80, "%s", b->account->username);
|
|
266
|
|
267 bp->protocol = b->account->protocol;
|
|
268
|
|
269 bp->options = 0;
|
|
270
|
|
271 if (GTK_TOGGLE_BUTTON(b->popupnotify)->active)
|
|
272 bp->options |= OPT_POUNCE_NOTIFY;
|
|
273
|
|
274 if (GTK_TOGGLE_BUTTON(b->openwindow)->active)
|
|
275 bp->options |= OPT_POUNCE_POPUP;
|
|
276
|
|
277 if (GTK_TOGGLE_BUTTON(b->sendim)->active)
|
|
278 bp->options |= OPT_POUNCE_SEND_IM;
|
|
279
|
|
280 if (GTK_TOGGLE_BUTTON(b->command)->active)
|
|
281 bp->options |= OPT_POUNCE_COMMAND;
|
|
282
|
|
283 if (GTK_TOGGLE_BUTTON(b->sound)->active)
|
|
284 bp->options |= OPT_POUNCE_SOUND;
|
|
285
|
|
286 if (GTK_TOGGLE_BUTTON(b->p_signon)->active)
|
|
287 bp->options |= OPT_POUNCE_SIGNON;
|
|
288
|
|
289 if (GTK_TOGGLE_BUTTON(b->p_unaway)->active)
|
|
290 bp->options |= OPT_POUNCE_UNAWAY;
|
|
291
|
|
292 if (GTK_TOGGLE_BUTTON(b->p_unidle)->active)
|
|
293 bp->options |= OPT_POUNCE_UNIDLE;
|
|
294
|
|
295 if (GTK_TOGGLE_BUTTON(b->p_typing)->active)
|
|
296 bp->options |= OPT_POUNCE_TYPING;
|
|
297
|
|
298 if (GTK_TOGGLE_BUTTON(b->save)->active)
|
|
299 bp->options |= OPT_POUNCE_SAVE;
|
|
300
|
|
301 if(!b->buddy_pounce)
|
|
302 buddy_pounces = g_list_append(buddy_pounces, bp);
|
|
303
|
4696
|
304 do_bp_menu();
|
4687
|
305
|
|
306 gtk_widget_destroy(b->window);
|
|
307
|
|
308 save_prefs();
|
|
309 g_free(b);
|
|
310 }
|
|
311
|
|
312 static void pounce_choose(GtkWidget *opt, struct addbp *b)
|
|
313 {
|
4729
|
314 struct gaim_account *account = g_object_get_data(G_OBJECT(opt), "gaim_account");
|
4687
|
315 b->account = account;
|
|
316 }
|
|
317
|
|
318 static GtkWidget *pounce_user_menu(struct addbp *b, struct gaim_connection *gc)
|
|
319 {
|
|
320 GtkWidget *optmenu;
|
|
321 GtkWidget *menu;
|
|
322 GtkWidget *opt;
|
|
323 GSList *u = gaim_accounts;
|
|
324 struct gaim_account *account;
|
|
325 struct prpl *p;
|
|
326 int count = 0;
|
|
327 int place = 0;
|
|
328 char buf[2048];
|
|
329
|
|
330
|
|
331 optmenu = gtk_option_menu_new();
|
|
332
|
|
333 menu = gtk_menu_new();
|
|
334
|
|
335 while (u) {
|
|
336 account = (struct gaim_account *)u->data;
|
|
337 p = (struct prpl *)find_prpl(account->protocol);
|
|
338 g_snprintf(buf, sizeof buf, "%s (%s)", account->username, (p && p->name)?p->name:_("Unknown"));
|
|
339 opt = gtk_menu_item_new_with_label(buf);
|
4729
|
340 g_object_set_data(G_OBJECT(opt), "gaim_account", account);
|
4687
|
341 g_signal_connect(GTK_OBJECT(opt), "activate", G_CALLBACK(pounce_choose), b);
|
4690
|
342 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
|
4687
|
343 gtk_widget_show(opt);
|
|
344
|
|
345 if (b->account == account) {
|
|
346 gtk_menu_item_activate(GTK_MENU_ITEM(opt));
|
|
347 place = count;
|
|
348 }
|
|
349
|
|
350 count++;
|
|
351
|
|
352 u = u->next;
|
|
353 }
|
|
354
|
|
355 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
|
|
356 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), place);
|
|
357
|
|
358 b->menu = optmenu;
|
|
359
|
|
360 return optmenu;
|
|
361 }
|
|
362
|
|
363
|
|
364 void show_new_bp(char *name, struct gaim_connection *gc, int idle, int away, struct buddy_pounce *edit_bp)
|
|
365 {
|
|
366 GtkWidget *label;
|
|
367 GtkWidget *bbox;
|
|
368 GtkWidget *vbox;
|
|
369 GtkWidget *button;
|
|
370 GtkWidget *frame;
|
|
371 GtkWidget *table;
|
|
372 GtkWidget *optmenu;
|
|
373 GtkWidget *sep;
|
|
374 GtkSizeGroup *sg;
|
|
375
|
|
376 struct addbp *b = g_new0(struct addbp, 1);
|
|
377
|
|
378 if(edit_bp) {
|
|
379 b->buddy_pounce = edit_bp;
|
|
380 b->account = gaim_account_find(edit_bp->pouncer, edit_bp->protocol);
|
|
381 } else {
|
|
382 b->account = gc ? gc->account : gaim_accounts->data;
|
|
383 b->buddy_pounce = NULL;
|
|
384 }
|
|
385
|
|
386 GAIM_DIALOG(b->window);
|
4690
|
387 gtk_window_set_resizable(GTK_WINDOW(b->window), TRUE);
|
4687
|
388 gtk_window_set_role(GTK_WINDOW(b->window), "new_bp");
|
4772
|
389 gtk_window_set_title(GTK_WINDOW(b->window), _("New Buddy Pounce"));
|
4687
|
390 g_signal_connect(GTK_OBJECT(b->window), "destroy", G_CALLBACK(gtk_widget_destroy), b->window);
|
|
391 gtk_widget_realize(b->window);
|
|
392
|
|
393 vbox = gtk_vbox_new(FALSE, 5);
|
|
394 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
|
|
395 gtk_container_add(GTK_CONTAINER(b->window), vbox);
|
|
396 gtk_widget_show(vbox);
|
|
397
|
|
398 /* <pounce type="who"> */
|
|
399 frame = gtk_frame_new(_("Pounce Who"));
|
|
400 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
|
|
401 gtk_widget_show(GTK_WIDGET(frame));
|
|
402
|
|
403 table = gtk_table_new(2, 2, FALSE);
|
|
404 gtk_container_add(GTK_CONTAINER(frame), table);
|
|
405 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
|
|
406 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
|
|
407 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
|
|
408 gtk_widget_show(table);
|
|
409
|
|
410 label = gtk_label_new(_("Account"));
|
|
411 gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
|
|
412 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
|
|
413 gtk_widget_show(label);
|
|
414
|
|
415 optmenu = pounce_user_menu(b, gc);
|
|
416 gtk_table_attach(GTK_TABLE(table), optmenu, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
|
|
417 gtk_widget_show(optmenu);
|
|
418
|
|
419 label = gtk_label_new(_("Buddy"));
|
|
420 gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
|
|
421 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
|
|
422 gtk_widget_show(label);
|
|
423
|
|
424 b->nameentry = gtk_entry_new();
|
|
425 gtk_table_attach(GTK_TABLE(table), b->nameentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
|
|
426 if (name !=NULL)
|
|
427 gtk_entry_set_text(GTK_ENTRY(b->nameentry), name);
|
|
428 else if(edit_bp)
|
|
429 gtk_entry_set_text(GTK_ENTRY(b->nameentry), edit_bp->name);
|
|
430 gtk_window_set_focus(GTK_WINDOW(b->window), b->nameentry);
|
|
431 gtk_widget_show(b->nameentry);
|
|
432 /* </pounce type="who"> */
|
|
433
|
|
434
|
|
435 /* <pounce type="when"> */
|
|
436 frame = gtk_frame_new(_("Pounce When"));
|
|
437 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
|
|
438 gtk_widget_show(GTK_WIDGET(frame));
|
|
439
|
|
440 table = gtk_table_new(2, 2, FALSE);
|
|
441 gtk_container_add(GTK_CONTAINER(frame), table);
|
|
442 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
|
|
443 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
|
|
444 gtk_widget_show(table);
|
|
445
|
|
446 b->p_signon = gtk_check_button_new_with_label(_("Pounce on sign on"));
|
|
447 if(edit_bp)
|
|
448 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->p_signon),
|
|
449 (edit_bp->options & OPT_POUNCE_SIGNON) ? TRUE : FALSE);
|
|
450 else
|
|
451 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->p_signon), TRUE);
|
|
452 gtk_table_attach(GTK_TABLE(table), b->p_signon, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
|
|
453 gtk_widget_show(b->p_signon);
|
|
454
|
|
455 b->p_unaway = gtk_check_button_new_with_label(_("Pounce on return from away"));
|
|
456 if (away)
|
|
457 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->p_unaway), TRUE);
|
|
458 else if(edit_bp)
|
|
459 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->p_unaway),
|
|
460 (edit_bp->options & OPT_POUNCE_UNAWAY) ? TRUE : FALSE);
|
|
461 gtk_table_attach(GTK_TABLE(table), b->p_unaway, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
|
|
462 gtk_widget_show(b->p_unaway);
|
|
463
|
|
464 b->p_unidle = gtk_check_button_new_with_label(_("Pounce on return from idle"));
|
|
465 if (idle)
|
|
466 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->p_unidle), TRUE);
|
|
467 else if(edit_bp)
|
|
468 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->p_unidle),
|
|
469 (edit_bp->options & OPT_POUNCE_UNIDLE) ? TRUE : FALSE);
|
|
470 gtk_table_attach(GTK_TABLE(table), b->p_unidle, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
|
|
471 gtk_widget_show(b->p_unidle);
|
|
472
|
|
473 b->p_typing = gtk_check_button_new_with_label(_("Pounce when buddy is typing to you"));
|
|
474 if (edit_bp)
|
|
475 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->p_typing),
|
|
476 (edit_bp->options & OPT_POUNCE_TYPING) ? TRUE : FALSE);
|
|
477 gtk_table_attach(GTK_TABLE(table), b->p_typing,1,2,1,2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
|
|
478 gtk_widget_show(b->p_typing);
|
|
479
|
|
480 /* </pounce type="when"> */
|
|
481
|
|
482 /* <pounce type="action"> */
|
|
483 frame = gtk_frame_new(_("Pounce Action"));
|
|
484 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
|
|
485 gtk_widget_show(GTK_WIDGET(frame));
|
|
486
|
|
487 table = gtk_table_new(4, 2, FALSE);
|
|
488 gtk_container_add(GTK_CONTAINER(frame), table);
|
|
489 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
|
|
490 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
|
|
491 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
|
|
492 gtk_widget_show(table);
|
|
493
|
|
494 b->openwindow = gtk_check_button_new_with_label(_("Open IM Window"));
|
|
495 if(edit_bp)
|
|
496 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->openwindow),
|
|
497 (edit_bp->options & OPT_POUNCE_POPUP) ? TRUE : FALSE);
|
|
498 else
|
|
499 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->openwindow), FALSE);
|
|
500 gtk_table_attach(GTK_TABLE(table), b->openwindow, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
|
|
501 gtk_widget_show(b->openwindow);
|
|
502
|
|
503 b->popupnotify = gtk_check_button_new_with_label(_("Popup Notification"));
|
|
504 if(edit_bp)
|
|
505 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->popupnotify),
|
|
506 (edit_bp->options & OPT_POUNCE_NOTIFY) ? TRUE : FALSE);
|
|
507 else
|
|
508 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->popupnotify), FALSE);
|
|
509 gtk_table_attach(GTK_TABLE(table), b->popupnotify, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
|
|
510 gtk_widget_show(b->popupnotify);
|
|
511
|
|
512 b->sendim = gtk_check_button_new_with_label(_("Send Message"));
|
|
513 if(edit_bp)
|
|
514 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->sendim),
|
|
515 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
|
|
516 else
|
|
517 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->sendim), TRUE);
|
|
518 gtk_table_attach(GTK_TABLE(table), b->sendim, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
|
|
519 gtk_widget_show(b->sendim);
|
|
520
|
|
521 b->messentry = gtk_entry_new();
|
|
522 gtk_table_attach(GTK_TABLE(table), b->messentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
|
|
523 g_signal_connect(GTK_OBJECT(b->messentry), "activate", G_CALLBACK(do_new_bp), b);
|
|
524 if(edit_bp) {
|
|
525 gtk_widget_set_sensitive(GTK_WIDGET(b->messentry),
|
|
526 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
|
|
527 gtk_entry_set_text(GTK_ENTRY(b->messentry), edit_bp->message);
|
|
528 }
|
|
529 gtk_widget_show(b->messentry);
|
|
530
|
|
531 g_signal_connect(GTK_OBJECT(b->sendim), "clicked",
|
|
532 G_CALLBACK(gaim_gtk_toggle_sensitive), b->messentry);
|
|
533
|
|
534 b->command = gtk_check_button_new_with_label(_("Execute command on pounce"));
|
|
535 gtk_table_attach(GTK_TABLE(table), b->command, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
|
|
536 if(edit_bp)
|
|
537 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->command),
|
|
538 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
|
|
539 else
|
|
540 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->command), FALSE);
|
|
541 gtk_widget_show(b->command);
|
|
542
|
|
543 b->commentry = gtk_entry_new();
|
|
544 gtk_table_attach(GTK_TABLE(table), b->commentry, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
|
|
545 g_signal_connect(GTK_OBJECT(b->commentry), "activate", G_CALLBACK(do_new_bp), b);
|
|
546 if(edit_bp) {
|
|
547 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry),
|
|
548 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
|
|
549 gtk_entry_set_text(GTK_ENTRY(b->commentry), edit_bp->command);
|
|
550 }
|
|
551 else
|
|
552 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry), FALSE);
|
|
553 gtk_widget_show(b->commentry);
|
|
554 g_signal_connect(GTK_OBJECT(b->command), "clicked",
|
|
555 G_CALLBACK(gaim_gtk_toggle_sensitive), b->commentry);
|
|
556
|
|
557 b->sound = gtk_check_button_new_with_label(_("Play sound on pounce"));
|
|
558 if(edit_bp)
|
|
559 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->sound),
|
|
560 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
|
|
561 else
|
|
562 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->sound), FALSE);
|
|
563 gtk_table_attach(GTK_TABLE(table), b->sound, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
|
|
564 gtk_widget_show(b->sound);
|
|
565
|
|
566 b->soundentry = gtk_entry_new();
|
|
567 gtk_table_attach(GTK_TABLE(table), b->soundentry, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
|
|
568 g_signal_connect(GTK_OBJECT(b->soundentry), "activate", G_CALLBACK(do_new_bp), b);
|
|
569 if(edit_bp) {
|
|
570 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry),
|
|
571 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
|
|
572 gtk_entry_set_text(GTK_ENTRY(b->soundentry), edit_bp->sound);
|
|
573 } else
|
|
574 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry), FALSE);
|
|
575 gtk_widget_show(b->soundentry);
|
|
576 g_signal_connect(GTK_OBJECT(b->sound), "clicked",
|
|
577 G_CALLBACK(gaim_gtk_toggle_sensitive), b->soundentry);
|
|
578 /* </pounce type="action"> */
|
|
579
|
|
580 b->save = gtk_check_button_new_with_label(_("Save this pounce after activation"));
|
|
581 gtk_container_set_border_width(GTK_CONTAINER(b->save), 7);
|
|
582 if(edit_bp)
|
|
583 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->save),
|
|
584 (edit_bp->options & OPT_POUNCE_SAVE) ? TRUE : FALSE);
|
|
585 else
|
|
586 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->save), FALSE);
|
|
587 gtk_box_pack_start(GTK_BOX(vbox), b->save, FALSE, FALSE, 0);
|
|
588 gtk_widget_show(b->save);
|
|
589
|
|
590 sep = gtk_hseparator_new();
|
|
591 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
|
|
592 gtk_widget_show(sep);
|
|
593
|
|
594 bbox = gtk_hbox_new(FALSE, 5);
|
|
595 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
596 gtk_widget_show(bbox);
|
|
597
|
|
598 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
|
|
599
|
|
600 button = gaim_pixbuf_button_from_stock(_("_Save"), "gtk-execute", GAIM_BUTTON_HORIZONTAL);
|
|
601 gtk_size_group_add_widget(sg, button);
|
|
602 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(do_new_bp), b);
|
|
603 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
|
|
604 gtk_widget_show(button);
|
|
605
|
|
606 button = gaim_pixbuf_button_from_stock(_("C_ancel"), "gtk-cancel", GAIM_BUTTON_HORIZONTAL);
|
|
607 gtk_size_group_add_widget(sg, button);
|
4696
|
608 g_signal_connect_swapped(GTK_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), b->window);
|
4687
|
609 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
|
|
610 gtk_widget_show(button);
|
|
611
|
|
612
|
|
613 gtk_widget_show(b->window);
|
|
614 }
|
|
615
|