Mercurial > pidgin.yaz
comparison plugins/notify.c @ 3565:154c4a9d9b6d
[gaim-migrate @ 3660]
Now you can configure your plugins.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 28 Sep 2002 21:39:45 +0000 |
parents | 333551497ff8 |
children | 03ba413ca20b |
comparison
equal
deleted
inserted
replaced
3564:83a54877f1ae | 3565:154c4a9d9b6d |
---|---|
39 /* I really don't like this but I was having trouble getting any | 39 /* I really don't like this but I was having trouble getting any |
40 * other way of removing the signal callbacks to work and not crash gaim | 40 * other way of removing the signal callbacks to work and not crash gaim |
41 */ | 41 */ |
42 GtkWidget *really_evil_hack; | 42 GtkWidget *really_evil_hack; |
43 /* GHashTable *hash = NULL; */ | 43 /* GHashTable *hash = NULL; */ |
44 GtkWidget *Dialog = NULL; | 44 GtkWidget *Entry; |
45 GtkWidget *Click, *Focus, *Type, *InFocus; | |
46 GtkWidget *String, *Count, *Quote, *Urgent, *Entry; | |
47 gchar *title_string = "(*) "; | 45 gchar *title_string = "(*) "; |
48 | 46 |
49 /* predefine some functions, less warnings */ | 47 /* predefine some functions, less warnings */ |
50 void options(GtkWidget *widget, gpointer data); | 48 void options(GtkWidget *widget, gpointer data); |
51 void un_star(GtkWidget *widget, gpointer data); | 49 void un_star(GtkWidget *widget, gpointer data); |
317 method ^= METHOD_URGENT; | 315 method ^= METHOD_URGENT; |
318 else if (option == 5) | 316 else if (option == 5) |
319 choice ^= NOTIFY_IN_FOCUS; | 317 choice ^= NOTIFY_IN_FOCUS; |
320 else if (option == 6) | 318 else if (option == 6) |
321 method ^= METHOD_COUNT; | 319 method ^= METHOD_COUNT; |
322 } | |
323 | |
324 void setup_buttons() { | |
325 if (choice & NOTIFY_FOCUS) | |
326 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Focus), TRUE); | |
327 else | |
328 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Click), TRUE); | |
329 if (choice & NOTIFY_TYPE) | |
330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), TRUE); | |
331 else | |
332 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Type), FALSE); | |
333 | |
334 if (method & METHOD_STRING) | |
335 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(String), TRUE); | |
336 else | |
337 gtk_widget_set_sensitive(Entry, FALSE); | |
338 | |
339 if (method & METHOD_QUOTE) | |
340 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Quote), TRUE); | |
341 | |
342 if (method & METHOD_URGENT) | |
343 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Urgent), TRUE); | |
344 | |
345 if (choice & NOTIFY_IN_FOCUS) | |
346 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(InFocus), TRUE); | |
347 | |
348 if (method & METHOD_COUNT) | |
349 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Count), TRUE); | |
350 | |
351 return; | |
352 } | |
353 | |
354 void close_dialog(GtkWidget *widget, gpointer data) { | |
355 gint option = GPOINTER_TO_INT(data); | |
356 | |
357 if (option > 0) { | |
358 title_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(Entry))); | |
359 save_notify_prefs(); | |
360 } | |
361 else if (option < 0) | |
362 load_notify_prefs(); | |
363 | |
364 if (Dialog) | |
365 gtk_widget_destroy(Dialog); | |
366 Dialog = NULL; | |
367 } | 320 } |
368 | 321 |
369 char *gaim_plugin_init(GModule *hndl) { | 322 char *gaim_plugin_init(GModule *hndl) { |
370 handle = hndl; | 323 handle = hndl; |
371 | 324 |
423 char *description() { | 376 char *description() { |
424 return "Puts an asterisk in the title bar of all conversations" | 377 return "Puts an asterisk in the title bar of all conversations" |
425 " where you have not responded to a message yet."; | 378 " where you have not responded to a message yet."; |
426 } | 379 } |
427 | 380 |
428 void gaim_plugin_config() { | 381 GtkWidget *gaim_plugin_config_gtk() { |
429 GtkWidget *dialog_vbox; | 382 GtkWidget *ret; |
430 GtkWidget *button, *label; | 383 GtkWidget *vbox, *hbox; |
431 GtkWidget *box, *box2, *box3, *box4, *frame; | 384 GtkWidget *toggle; |
432 | 385 ret = gtk_vbox_new(FALSE, 18); |
433 if (Dialog) | 386 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); |
434 return; | 387 |
435 | 388 vbox = make_frame(ret, _("Notification Methods")); |
436 /* main config dialog */ | 389 hbox = gtk_hbox_new(FALSE, 18); |
437 Dialog = gtk_dialog_new(); | 390 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
438 gtk_window_set_title(GTK_WINDOW(Dialog), "Notify plugin configuration"); | 391 toggle = gtk_check_button_new_with_mnemonic(_("Prepend _string into window title:")); |
439 gtk_window_set_policy(GTK_WINDOW(Dialog), FALSE, FALSE, TRUE); | 392 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_STRING); |
440 gtk_signal_connect(GTK_OBJECT(Dialog), "destroy", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(-1)); | 393 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(2)); |
441 | 394 gtk_box_pack_start(GTK_BOX(hbox), toggle, FALSE, FALSE, 0); |
442 dialog_vbox = GTK_DIALOG(Dialog)->vbox; | |
443 | |
444 /* Ok and Cancel buttons */ | |
445 box = gtk_hbox_new(FALSE, 8); | |
446 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(Dialog)->action_area), box); | |
447 | |
448 button = gtk_button_new_with_label(_("Cancel")); | |
449 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
450 gtk_widget_set_usize(button, 80, -2); | |
451 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(0)); | |
452 | |
453 button = gtk_button_new_with_label(_("Ok")); | |
454 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); | |
455 gtk_widget_set_usize(button, 80, -2); | |
456 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(close_dialog), GINT_TO_POINTER(1)); | |
457 | |
458 /* warning label */ | |
459 label = gtk_label_new(_("Changes in notification removal options take effect only on new conversation windows")); | |
460 gtk_box_pack_start(GTK_BOX(dialog_vbox), label, FALSE, FALSE, 1); | |
461 | |
462 /* main hbox */ | |
463 box = gtk_hbox_new(FALSE, 0); | |
464 gtk_box_pack_start(GTK_BOX(dialog_vbox), box, FALSE, FALSE, 0); | |
465 | |
466 box4 = gtk_vbox_new(FALSE, 0); | |
467 gtk_box_pack_start(GTK_BOX(box), box4, FALSE, FALSE, 0); | |
468 | |
469 /* un-notify choices */ | |
470 frame = gtk_frame_new(_("Remove notification when:")); | |
471 gtk_box_pack_start(GTK_BOX(box4), frame, FALSE, FALSE, 0); | |
472 | |
473 box2 = gtk_vbox_new(FALSE, 0); | |
474 gtk_container_add(GTK_CONTAINER(frame), box2); | |
475 | |
476 Focus = gtk_radio_button_new_with_label(NULL, _("Conversation window gains focus.")); | |
477 gtk_box_pack_start(GTK_BOX(box2), Focus, FALSE, FALSE, 2); | |
478 | |
479 Click = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(Focus), _("Conversation window gets clicked.")); | |
480 gtk_box_pack_start(GTK_BOX(box2), Click, FALSE, FALSE, 2); | |
481 | |
482 Type = gtk_check_button_new_with_label(_("Type in conversation window")); | |
483 gtk_box_pack_start(GTK_BOX(box2), Type, FALSE, FALSE, 2); | |
484 | |
485 /* notification method choices */ | |
486 /* do I need/want any other notification methods? */ | |
487 frame = gtk_frame_new(_("Notification method:")); | |
488 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0); | |
489 | |
490 box2 = gtk_vbox_new(FALSE, 0); | |
491 gtk_container_add(GTK_CONTAINER(frame), box2); | |
492 | |
493 box3 = gtk_hbox_new(FALSE, 0); | |
494 gtk_box_pack_start(GTK_BOX(box2), box3, FALSE, FALSE, 0); | |
495 | |
496 String = gtk_check_button_new_with_label(_("Insert string into window title:")); | |
497 gtk_box_pack_start(GTK_BOX(box3), String, FALSE, FALSE, 0); | |
498 | |
499 Entry = gtk_entry_new_with_max_length(7); | 395 Entry = gtk_entry_new_with_max_length(7); |
500 gtk_box_pack_start(GTK_BOX(box3), Entry, FALSE, FALSE, 0); | 396 gtk_widget_set_sensitive(GTK_WIDGET(Entry), method & METHOD_STRING); |
397 gtk_box_pack_start(GTK_BOX(hbox), Entry, FALSE, FALSE, 0); | |
501 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); | 398 gtk_entry_set_text(GTK_ENTRY(Entry), title_string); |
502 | 399 |
503 Quote = gtk_check_button_new_with_label(_("Quote window title.")); | 400 toggle = gtk_check_button_new_with_mnemonic(_("_Quote window title.")); |
504 gtk_box_pack_start(GTK_BOX(box2), Quote, FALSE, FALSE, 0); | 401 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
505 | 402 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_QUOTE); |
506 Urgent = gtk_check_button_new_with_label(_("Send URGENT to window manager.")); | 403 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(3)); |
507 gtk_box_pack_start(GTK_BOX(box2), Urgent, FALSE, FALSE, 0); | 404 |
508 | 405 toggle = gtk_check_button_new_with_mnemonic(_("Set Window Manager \"_URGENT\" Hint")); |
509 label = gtk_label_new(_("Function oddly with tabs:")); | 406 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
510 gtk_box_pack_start(GTK_BOX(box2), label, FALSE, FALSE, 0); | 407 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_URGENT); |
511 | 408 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(4)); |
512 Count = gtk_check_button_new_with_label(_("Insert count of new messages into window title")); | 409 |
513 gtk_box_pack_start(GTK_BOX(box2), Count, FALSE, FALSE, 0); | 410 toggle = gtk_check_button_new_with_mnemonic(_("Insert _count of new messages into window title")); |
514 | 411 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), method & METHOD_COUNT); |
515 /* general options */ | 412 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
516 frame = gtk_frame_new(_("General Options")); | 413 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(6)); |
517 gtk_box_pack_start(GTK_BOX(box4), frame, FALSE, FALSE, 0); | 414 |
518 | 415 toggle = gtk_check_button_new_with_mnemonic(_("_Notify even if conversation is in focus.")); |
519 box = gtk_vbox_new(FALSE, 0); | 416 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_IN_FOCUS); |
520 gtk_container_add(GTK_CONTAINER(frame), box); | 417 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
521 | 418 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(5)); |
522 InFocus = gtk_check_button_new_with_label(_("Notify even when window is in focus")); | 419 |
523 gtk_box_pack_start(GTK_BOX(box), InFocus, FALSE, FALSE, 0); | 420 /*--------------*/ |
524 | 421 vbox = make_frame(ret, _("Notification Removal")); |
525 /* setup buttons, then attach signals */ | 422 toggle = gtk_check_button_new_with_mnemonic(_("Remove when conversation window gains _focus.")); |
526 setup_buttons(); | 423 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
527 gtk_signal_connect(GTK_OBJECT(Focus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(0)); | 424 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_FOCUS); |
528 gtk_signal_connect(GTK_OBJECT(Type), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(1)); | 425 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(0)); |
529 gtk_signal_connect(GTK_OBJECT(String), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(2)); | 426 |
530 gtk_signal_connect(GTK_OBJECT(Quote), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(3)); | 427 toggle = gtk_check_button_new_with_mnemonic(_("Remove when _typing in conversation window")); |
531 gtk_signal_connect(GTK_OBJECT(Urgent), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(4)); | 428 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
532 gtk_signal_connect(GTK_OBJECT(InFocus), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(5)); | 429 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), choice & NOTIFY_TYPE); |
533 gtk_signal_connect(GTK_OBJECT(Count), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(6)); | 430 gtk_signal_connect(GTK_OBJECT(toggle), "toggled", GTK_SIGNAL_FUNC(options), GINT_TO_POINTER(1)); |
534 | 431 |
535 gtk_widget_show_all(Dialog); | 432 gtk_widget_show_all(ret); |
536 } | 433 return ret; |
434 } |