Mercurial > pidgin.yaz
comparison src/gtkpounce.c @ 12934:c6a202e5823b
[gaim-migrate @ 15287]
SF Patch #1408623 from wbaz
"This patch lets the user add a note to pop up
notification pouncing"
I also fixed a bug where pounce pop-ups would show (null) as the name.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 19 Jan 2006 02:44:07 +0000 |
parents | ebed1bbedb04 |
children | 69b3d5cbd2b1 |
comparison
equal
deleted
inserted
replaced
12933:75ac13ab161f | 12934:c6a202e5823b |
---|---|
85 GtkWidget *message_recv; | 85 GtkWidget *message_recv; |
86 | 86 |
87 /* Action */ | 87 /* Action */ |
88 GtkWidget *open_win; | 88 GtkWidget *open_win; |
89 GtkWidget *popup; | 89 GtkWidget *popup; |
90 GtkWidget *popup_entry; | |
90 GtkWidget *send_msg; | 91 GtkWidget *send_msg; |
91 GtkWidget *send_msg_entry; | 92 GtkWidget *send_msg_entry; |
92 GtkWidget *exec_cmd; | 93 GtkWidget *exec_cmd; |
93 GtkWidget *exec_cmd_entry; | 94 GtkWidget *exec_cmd_entry; |
94 GtkWidget *exec_cmd_browse; | 95 GtkWidget *exec_cmd_browse; |
245 | 246 |
246 static void | 247 static void |
247 save_pounce_cb(GtkWidget *w, GaimGtkPounceDialog *dialog) | 248 save_pounce_cb(GtkWidget *w, GaimGtkPounceDialog *dialog) |
248 { | 249 { |
249 const char *name; | 250 const char *name; |
250 const char *message, *command, *sound; | 251 const char *message, *command, *sound, *reason; |
251 GaimPounceEvent events = GAIM_POUNCE_NONE; | 252 GaimPounceEvent events = GAIM_POUNCE_NONE; |
252 GaimPounceOption options = GAIM_POUNCE_OPTION_NONE; | 253 GaimPounceOption options = GAIM_POUNCE_OPTION_NONE; |
253 | 254 |
254 name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)); | 255 name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)); |
255 | 256 |
294 | 295 |
295 /* Data fields */ | 296 /* Data fields */ |
296 message = gtk_entry_get_text(GTK_ENTRY(dialog->send_msg_entry)); | 297 message = gtk_entry_get_text(GTK_ENTRY(dialog->send_msg_entry)); |
297 command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry)); | 298 command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry)); |
298 sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry)); | 299 sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry)); |
299 | 300 reason = gtk_entry_get_text(GTK_ENTRY(dialog->popup_entry)); |
301 | |
302 if (*reason == '\0') reason = NULL; | |
300 if (*message == '\0') message = NULL; | 303 if (*message == '\0') message = NULL; |
301 if (*command == '\0') command = NULL; | 304 if (*command == '\0') command = NULL; |
302 if (*sound == '\0') sound = NULL; | 305 if (*sound == '\0') sound = NULL; |
303 | 306 |
304 if (dialog->pounce == NULL) | 307 if (dialog->pounce == NULL) |
329 "message", message); | 332 "message", message); |
330 gaim_pounce_action_set_attribute(dialog->pounce, "execute-command", | 333 gaim_pounce_action_set_attribute(dialog->pounce, "execute-command", |
331 "command", command); | 334 "command", command); |
332 gaim_pounce_action_set_attribute(dialog->pounce, "play-sound", | 335 gaim_pounce_action_set_attribute(dialog->pounce, "play-sound", |
333 "filename", sound); | 336 "filename", sound); |
337 gaim_pounce_action_set_attribute(dialog->pounce, "popup-notify", | |
338 "reason", reason); | |
334 | 339 |
335 /* Set the defaults for next time. */ | 340 /* Set the defaults for next time. */ |
336 gaim_prefs_set_bool("/gaim/gtk/pounces/default_actions/open-window", | 341 gaim_prefs_set_bool("/gaim/gtk/pounces/default_actions/open-window", |
337 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win))); | 342 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win))); |
338 gaim_prefs_set_bool("/gaim/gtk/pounces/default_actions/popup-notify", | 343 gaim_prefs_set_bool("/gaim/gtk/pounces/default_actions/popup-notify", |
638 dialog->play_sound | 643 dialog->play_sound |
639 = gtk_check_button_new_with_mnemonic(_("P_lay a sound")); | 644 = gtk_check_button_new_with_mnemonic(_("P_lay a sound")); |
640 | 645 |
641 dialog->send_msg_entry = gtk_entry_new(); | 646 dialog->send_msg_entry = gtk_entry_new(); |
642 dialog->exec_cmd_entry = gtk_entry_new(); | 647 dialog->exec_cmd_entry = gtk_entry_new(); |
648 dialog->popup_entry = gtk_entry_new(); | |
643 dialog->exec_cmd_browse = gtk_button_new_with_mnemonic(_("Brows_e...")); | 649 dialog->exec_cmd_browse = gtk_button_new_with_mnemonic(_("Brows_e...")); |
644 dialog->play_sound_entry = gtk_entry_new(); | 650 dialog->play_sound_entry = gtk_entry_new(); |
645 dialog->play_sound_browse = gtk_button_new_with_mnemonic(_("Br_owse...")); | 651 dialog->play_sound_browse = gtk_button_new_with_mnemonic(_("Br_owse...")); |
646 dialog->play_sound_test = gtk_button_new_with_mnemonic(_("Pre_view")); | 652 dialog->play_sound_test = gtk_button_new_with_mnemonic(_("Pre_view")); |
647 | 653 |
648 gtk_widget_set_sensitive(dialog->send_msg_entry, FALSE); | 654 gtk_widget_set_sensitive(dialog->send_msg_entry, FALSE); |
649 gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE); | 655 gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE); |
656 gtk_widget_set_sensitive(dialog->popup_entry, FALSE); | |
650 gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE); | 657 gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE); |
651 gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE); | 658 gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE); |
652 gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE); | 659 gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE); |
653 gtk_widget_set_sensitive(dialog->play_sound_test, FALSE); | 660 gtk_widget_set_sensitive(dialog->play_sound_test, FALSE); |
654 | 661 |
655 sg = gtk_size_group_new(GTK_SIZE_GROUP_VERTICAL); | 662 sg = gtk_size_group_new(GTK_SIZE_GROUP_VERTICAL); |
656 gtk_size_group_add_widget(sg, dialog->open_win); | 663 gtk_size_group_add_widget(sg, dialog->open_win); |
657 gtk_size_group_add_widget(sg, dialog->popup); | 664 gtk_size_group_add_widget(sg, dialog->popup); |
665 gtk_size_group_add_widget(sg, dialog->popup_entry); | |
658 gtk_size_group_add_widget(sg, dialog->send_msg); | 666 gtk_size_group_add_widget(sg, dialog->send_msg); |
659 gtk_size_group_add_widget(sg, dialog->send_msg_entry); | 667 gtk_size_group_add_widget(sg, dialog->send_msg_entry); |
660 gtk_size_group_add_widget(sg, dialog->exec_cmd); | 668 gtk_size_group_add_widget(sg, dialog->exec_cmd); |
661 gtk_size_group_add_widget(sg, dialog->exec_cmd_entry); | 669 gtk_size_group_add_widget(sg, dialog->exec_cmd_entry); |
662 gtk_size_group_add_widget(sg, dialog->exec_cmd_browse); | 670 gtk_size_group_add_widget(sg, dialog->exec_cmd_browse); |
667 | 675 |
668 gtk_table_attach(GTK_TABLE(table), dialog->open_win, 0, 1, 0, 1, | 676 gtk_table_attach(GTK_TABLE(table), dialog->open_win, 0, 1, 0, 1, |
669 GTK_FILL, 0, 0, 0); | 677 GTK_FILL, 0, 0, 0); |
670 gtk_table_attach(GTK_TABLE(table), dialog->popup, 0, 1, 1, 2, | 678 gtk_table_attach(GTK_TABLE(table), dialog->popup, 0, 1, 1, 2, |
671 GTK_FILL, 0, 0, 0); | 679 GTK_FILL, 0, 0, 0); |
680 gtk_table_attach(GTK_TABLE(table), dialog->popup_entry, 1, 4, 1, 2, | |
681 GTK_FILL, 0, 0, 0); | |
672 gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 1, 2, 3, | 682 gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 1, 2, 3, |
673 GTK_FILL, 0, 0, 0); | 683 GTK_FILL, 0, 0, 0); |
674 gtk_table_attach(GTK_TABLE(table), dialog->send_msg_entry, 1, 4, 2, 3, | 684 gtk_table_attach(GTK_TABLE(table), dialog->send_msg_entry, 1, 4, 2, 3, |
675 GTK_FILL, 0, 0, 0); | 685 GTK_FILL, 0, 0, 0); |
676 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 3, 4, | 686 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 3, 4, |
690 | 700 |
691 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE / 2); | 701 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE / 2); |
692 | 702 |
693 gtk_widget_show(dialog->open_win); | 703 gtk_widget_show(dialog->open_win); |
694 gtk_widget_show(dialog->popup); | 704 gtk_widget_show(dialog->popup); |
705 gtk_widget_show(dialog->popup_entry); | |
695 gtk_widget_show(dialog->send_msg); | 706 gtk_widget_show(dialog->send_msg); |
696 gtk_widget_show(dialog->send_msg_entry); | 707 gtk_widget_show(dialog->send_msg_entry); |
697 gtk_widget_show(dialog->exec_cmd); | 708 gtk_widget_show(dialog->exec_cmd); |
698 gtk_widget_show(dialog->exec_cmd_entry); | 709 gtk_widget_show(dialog->exec_cmd_entry); |
699 gtk_widget_show(dialog->exec_cmd_browse); | 710 gtk_widget_show(dialog->exec_cmd_browse); |
708 | 719 |
709 g_signal_connect(G_OBJECT(dialog->send_msg), "clicked", | 720 g_signal_connect(G_OBJECT(dialog->send_msg), "clicked", |
710 G_CALLBACK(gaim_gtk_toggle_sensitive), | 721 G_CALLBACK(gaim_gtk_toggle_sensitive), |
711 dialog->send_msg_entry); | 722 dialog->send_msg_entry); |
712 | 723 |
724 g_signal_connect(G_OBJECT(dialog->popup), "clicked", | |
725 G_CALLBACK(gaim_gtk_toggle_sensitive), | |
726 dialog->popup_entry); | |
727 | |
713 exec_widgets = g_ptr_array_new(); | 728 exec_widgets = g_ptr_array_new(); |
714 g_ptr_array_add(exec_widgets,dialog->exec_cmd_entry); | 729 g_ptr_array_add(exec_widgets,dialog->exec_cmd_entry); |
715 g_ptr_array_add(exec_widgets,dialog->exec_cmd_browse); | 730 g_ptr_array_add(exec_widgets,dialog->exec_cmd_browse); |
716 | 731 |
717 g_signal_connect(G_OBJECT(dialog->exec_cmd), "clicked", | 732 g_signal_connect(G_OBJECT(dialog->exec_cmd), "clicked", |
735 g_signal_connect(G_OBJECT(dialog->play_sound_test), "clicked", | 750 g_signal_connect(G_OBJECT(dialog->play_sound_test), "clicked", |
736 G_CALLBACK(pounce_test_sound), | 751 G_CALLBACK(pounce_test_sound), |
737 dialog->play_sound_entry); | 752 dialog->play_sound_entry); |
738 | 753 |
739 g_signal_connect(G_OBJECT(dialog->send_msg_entry), "activate", | 754 g_signal_connect(G_OBJECT(dialog->send_msg_entry), "activate", |
755 G_CALLBACK(save_pounce_cb), dialog); | |
756 g_signal_connect(G_OBJECT(dialog->popup_entry), "activate", | |
740 G_CALLBACK(save_pounce_cb), dialog); | 757 G_CALLBACK(save_pounce_cb), dialog); |
741 g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate", | 758 g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate", |
742 G_CALLBACK(save_pounce_cb), dialog); | 759 G_CALLBACK(save_pounce_cb), dialog); |
743 g_signal_connect(G_OBJECT(dialog->play_sound_entry), "activate", | 760 g_signal_connect(G_OBJECT(dialog->play_sound_entry), "activate", |
744 G_CALLBACK(save_pounce_cb), dialog); | 761 G_CALLBACK(save_pounce_cb), dialog); |
871 { | 888 { |
872 gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry), value); | 889 gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry), value); |
873 } | 890 } |
874 | 891 |
875 if ((value = gaim_pounce_action_get_attribute(cur_pounce, | 892 if ((value = gaim_pounce_action_get_attribute(cur_pounce, |
893 "popup-notify", | |
894 "reason")) != NULL) | |
895 { | |
896 gtk_entry_set_text(GTK_ENTRY(dialog->popup_entry), value); | |
897 } | |
898 | |
899 if ((value = gaim_pounce_action_get_attribute(cur_pounce, | |
876 "execute-command", | 900 "execute-command", |
877 "command")) != NULL) | 901 "command")) != NULL) |
878 { | 902 { |
879 gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), value); | 903 gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), value); |
880 } | 904 } |
1387 | 1411 |
1388 pouncee = gaim_pounce_get_pouncee(pounce); | 1412 pouncee = gaim_pounce_get_pouncee(pounce); |
1389 account = gaim_pounce_get_pouncer(pounce); | 1413 account = gaim_pounce_get_pouncer(pounce); |
1390 | 1414 |
1391 buddy = gaim_find_buddy(account, pouncee); | 1415 buddy = gaim_find_buddy(account, pouncee); |
1392 | 1416 if (buddy != NULL) |
1393 alias = gaim_buddy_get_alias(buddy); | 1417 { |
1418 alias = gaim_buddy_get_alias(buddy); | |
1419 if (alias == NULL) | |
1420 alias = pouncee; | |
1421 } | |
1422 else | |
1423 alias = pouncee; | |
1394 | 1424 |
1395 if (gaim_pounce_action_is_enabled(pounce, "open-window")) | 1425 if (gaim_pounce_action_is_enabled(pounce, "open-window")) |
1396 { | 1426 { |
1397 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, pouncee, account); | 1427 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, pouncee, account); |
1398 | 1428 |
1400 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, pouncee); | 1430 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, pouncee); |
1401 } | 1431 } |
1402 | 1432 |
1403 if (gaim_pounce_action_is_enabled(pounce, "popup-notify")) | 1433 if (gaim_pounce_action_is_enabled(pounce, "popup-notify")) |
1404 { | 1434 { |
1405 char tmp[1024]; | 1435 char *tmp; |
1406 const char *name_shown; | 1436 const char *name_shown; |
1437 const char *reason; | |
1438 reason = gaim_pounce_action_get_attribute(pounce, "popup-notify", | |
1439 "reason"); | |
1407 | 1440 |
1408 /* | 1441 /* |
1409 * Here we place the protocol name in the pounce dialog to lessen | 1442 * Here we place the protocol name in the pounce dialog to lessen |
1410 * confusion about what protocol a pounce is for. | 1443 * confusion about what protocol a pounce is for. |
1411 */ | 1444 */ |
1412 g_snprintf(tmp, sizeof(tmp), | 1445 tmp = g_strdup_printf( |
1413 (events & GAIM_POUNCE_TYPING) ? | 1446 (events & GAIM_POUNCE_TYPING) ? |
1414 _("%s has started typing to you (%s)") : | 1447 _("%s has started typing to you (%s)") : |
1415 (events & GAIM_POUNCE_SIGNON) ? | 1448 (events & GAIM_POUNCE_SIGNON) ? |
1416 _("%s has signed on (%s)") : | 1449 _("%s has signed on (%s)") : |
1417 (events & GAIM_POUNCE_IDLE_RETURN) ? | 1450 (events & GAIM_POUNCE_IDLE_RETURN) ? |
1431 _("Unknown pounce event. Please report this!"), | 1464 _("Unknown pounce event. Please report this!"), |
1432 alias, gaim_account_get_protocol_name(account)); | 1465 alias, gaim_account_get_protocol_name(account)); |
1433 | 1466 |
1434 /* | 1467 /* |
1435 * Ok here is where I change the second argument, title, from | 1468 * Ok here is where I change the second argument, title, from |
1436 * NULL to the account name if that's all we have or the account | 1469 * NULL to the account alias if we have it or the account |
1437 * alias if we have that | 1470 * name if that's all we have |
1438 */ | 1471 */ |
1439 if ((name_shown = gaim_account_get_alias(account)) == NULL) | 1472 if ((name_shown = gaim_account_get_alias(account)) == NULL) |
1440 name_shown = gaim_account_get_username(account); | 1473 name_shown = gaim_account_get_username(account); |
1441 | 1474 |
1442 gaim_notify_info(NULL, name_shown, tmp, gaim_date_full()); | 1475 if (reason == NULL) |
1476 gaim_notify_info(NULL, name_shown, tmp, gaim_date_full()); | |
1477 else | |
1478 { | |
1479 char *tmp2 = g_strdup_printf("%s\n\n%s", reason, gaim_date_full()); | |
1480 gaim_notify_info(NULL, name_shown, tmp, tmp2); | |
1481 g_free(tmp2); | |
1482 } | |
1483 g_free(tmp); | |
1443 } | 1484 } |
1444 | 1485 |
1445 if (gaim_pounce_action_is_enabled(pounce, "send-message")) | 1486 if (gaim_pounce_action_is_enabled(pounce, "send-message")) |
1446 { | 1487 { |
1447 const char *message; | 1488 const char *message; |