pidgin/gtkpounce.c

changeset 33194
e5258008e4d7
parent 33170
ce4447562d64
child 33195
fc0195d8a917
equal deleted inserted replaced
33193:8d687d033529 33194:e5258008e4d7
36 #include "sound.h" 36 #include "sound.h"
37 #include "util.h" 37 #include "util.h"
38 38
39 #include "gtkblist.h" 39 #include "gtkblist.h"
40 #include "gtkdialogs.h" 40 #include "gtkdialogs.h"
41 #include "gtkimhtml.h"
42 #include "gtkpounce.h" 41 #include "gtkpounce.h"
43 #include "gtknotify.h" 42 #include "gtknotify.h"
44 #include "pidginstock.h" 43 #include "pidginstock.h"
45 #include "gtkutils.h" 44 #include "gtkutils.h"
45 #include "gtkwebview.h"
46 46
47 /** 47 /**
48 * These are used for the GtkTreeView when you're scrolling through 48 * These are used for the GtkTreeView when you're scrolling through
49 * all your saved pounces. 49 * all your saved pounces.
50 */ 50 */
302 302
303 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->message_recv))) 303 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->message_recv)))
304 events |= PURPLE_POUNCE_MESSAGE_RECEIVED; 304 events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
305 305
306 /* Data fields */ 306 /* Data fields */
307 message = gtk_imhtml_get_markup(GTK_IMHTML(dialog->send_msg_entry)); 307 message = gtk_webview_get_body_html(GTK_WEBVIEW(dialog->send_msg_entry));
308 command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry)); 308 command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry));
309 sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry)); 309 sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry));
310 reason = gtk_entry_get_text(GTK_ENTRY(dialog->popup_entry)); 310 reason = gtk_entry_get_text(GTK_ENTRY(dialog->popup_entry));
311 311
312 if (*reason == '\0') reason = NULL; 312 if (*reason == '\0') reason = NULL;
374 374
375 update_pounces(); 375 update_pounces();
376 g_free(message); 376 g_free(message);
377 377
378 delete_win_cb(NULL, NULL, dialog); 378 delete_win_cb(NULL, NULL, dialog);
379 }
380
381 static gboolean
382 entry_key_press_cb(GtkWidget *widget, GdkEventKey *event,
383 PidginPounceDialog *dialog)
384 {
385 if ((event->keyval == GDK_KEY_Return)
386 || (event->keyval == GDK_KEY_KP_Enter)) {
387 save_pounce_cb(widget, dialog);
388 return TRUE;
389 }
390
391 return FALSE;
379 } 392 }
380 393
381 static void 394 static void
382 pounce_choose_cb(GtkWidget *item, PurpleAccount *account, 395 pounce_choose_cb(GtkWidget *item, PurpleAccount *account,
383 PidginPounceDialog *dialog) 396 PidginPounceDialog *dialog)
475 488
476 static void 489 static void
477 reset_send_msg_entry(PidginPounceDialog *dialog, GtkWidget *dontcare) 490 reset_send_msg_entry(PidginPounceDialog *dialog, GtkWidget *dontcare)
478 { 491 {
479 PurpleAccount *account = pidgin_account_option_menu_get_selected(dialog->account_menu); 492 PurpleAccount *account = pidgin_account_option_menu_get_selected(dialog->account_menu);
480 gtk_imhtml_setup_entry(GTK_IMHTML(dialog->send_msg_entry), 493 gtk_webview_setup_entry(GTK_WEBVIEW(dialog->send_msg_entry),
481 (account && purple_account_get_connection(account)) ? purple_connection_get_flags(purple_account_get_connection(account)) : PURPLE_CONNECTION_HTML); 494 (account && purple_account_get_connection(account)) ? purple_connection_get_flags(purple_account_get_connection(account)) : PURPLE_CONNECTION_HTML);
482 } 495 }
483 496
484 void 497 void
485 pidgin_pounce_editor_show(PurpleAccount *account, const char *name, 498 pidgin_pounce_editor_show(PurpleAccount *account, const char *name,
494 GtkWidget *frame; 507 GtkWidget *frame;
495 GtkWidget *table; 508 GtkWidget *table;
496 GtkSizeGroup *sg; 509 GtkSizeGroup *sg;
497 GPtrArray *sound_widgets; 510 GPtrArray *sound_widgets;
498 GPtrArray *exec_widgets; 511 GPtrArray *exec_widgets;
499 GtkWidget *send_msg_imhtml; 512 GtkWidget *send_msg_webview;
500 513
501 g_return_if_fail((cur_pounce != NULL) || 514 g_return_if_fail((cur_pounce != NULL) ||
502 (account != NULL) || 515 (account != NULL) ||
503 (purple_accounts_get_all() != NULL)); 516 (purple_accounts_get_all() != NULL));
504 517
681 dialog->exec_cmd 694 dialog->exec_cmd
682 = gtk_check_button_new_with_mnemonic(_("E_xecute a command")); 695 = gtk_check_button_new_with_mnemonic(_("E_xecute a command"));
683 dialog->play_sound 696 dialog->play_sound
684 = gtk_check_button_new_with_mnemonic(_("P_lay a sound")); 697 = gtk_check_button_new_with_mnemonic(_("P_lay a sound"));
685 698
686 send_msg_imhtml = pidgin_create_imhtml(TRUE, &dialog->send_msg_entry, NULL, NULL); 699 send_msg_webview = pidgin_create_webview(TRUE, &dialog->send_msg_entry, NULL, NULL);
687 reset_send_msg_entry(dialog, NULL); 700 reset_send_msg_entry(dialog, NULL);
688 dialog->exec_cmd_entry = gtk_entry_new(); 701 dialog->exec_cmd_entry = gtk_entry_new();
689 dialog->popup_entry = gtk_entry_new(); 702 dialog->popup_entry = gtk_entry_new();
690 dialog->exec_cmd_browse = gtk_button_new_with_mnemonic(_("Brows_e...")); 703 dialog->exec_cmd_browse = gtk_button_new_with_mnemonic(_("Brows_e..."));
691 dialog->play_sound_entry = gtk_entry_new(); 704 dialog->play_sound_entry = gtk_entry_new();
693 gtk_editable_set_editable(GTK_EDITABLE(dialog->play_sound_entry), FALSE); 706 gtk_editable_set_editable(GTK_EDITABLE(dialog->play_sound_entry), FALSE);
694 dialog->play_sound_browse = gtk_button_new_with_mnemonic(_("Br_owse...")); 707 dialog->play_sound_browse = gtk_button_new_with_mnemonic(_("Br_owse..."));
695 dialog->play_sound_test = gtk_button_new_with_mnemonic(_("Pre_view")); 708 dialog->play_sound_test = gtk_button_new_with_mnemonic(_("Pre_view"));
696 dialog->play_sound_reset = gtk_button_new_with_mnemonic(_("Reset")); 709 dialog->play_sound_reset = gtk_button_new_with_mnemonic(_("Reset"));
697 710
698 gtk_widget_set_sensitive(send_msg_imhtml, FALSE); 711 gtk_widget_set_sensitive(send_msg_webview, FALSE);
699 gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE); 712 gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE);
700 gtk_widget_set_sensitive(dialog->popup_entry, FALSE); 713 gtk_widget_set_sensitive(dialog->popup_entry, FALSE);
701 gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE); 714 gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE);
702 gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE); 715 gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE);
703 gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE); 716 gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE);
728 GTK_FILL, 0, 0, 0); 741 GTK_FILL, 0, 0, 0);
729 gtk_table_attach(GTK_TABLE(table), dialog->popup_entry, 1, 5, 1, 2, 742 gtk_table_attach(GTK_TABLE(table), dialog->popup_entry, 1, 5, 1, 2,
730 GTK_FILL, 0, 0, 0); 743 GTK_FILL, 0, 0, 0);
731 gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 5, 2, 3, 744 gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 5, 2, 3,
732 GTK_FILL, 0, 0, 0); 745 GTK_FILL, 0, 0, 0);
733 gtk_table_attach(GTK_TABLE(table), send_msg_imhtml, 0, 5, 3, 4, 746 gtk_table_attach(GTK_TABLE(table), send_msg_webview, 0, 5, 3, 4,
734 GTK_FILL, 0, 0, 0); 747 GTK_FILL, 0, 0, 0);
735 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 4, 5, 748 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 4, 5,
736 GTK_FILL, 0, 0, 0); 749 GTK_FILL, 0, 0, 0);
737 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_entry, 1, 2, 4, 5, 750 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_entry, 1, 2, 4, 5,
738 GTK_FILL, 0, 0, 0); 751 GTK_FILL, 0, 0, 0);
753 766
754 gtk_widget_show(dialog->open_win); 767 gtk_widget_show(dialog->open_win);
755 gtk_widget_show(dialog->popup); 768 gtk_widget_show(dialog->popup);
756 gtk_widget_show(dialog->popup_entry); 769 gtk_widget_show(dialog->popup_entry);
757 gtk_widget_show(dialog->send_msg); 770 gtk_widget_show(dialog->send_msg);
758 gtk_widget_show(send_msg_imhtml); 771 gtk_widget_show(send_msg_webview);
759 gtk_widget_show(dialog->exec_cmd); 772 gtk_widget_show(dialog->exec_cmd);
760 gtk_widget_show(dialog->exec_cmd_entry); 773 gtk_widget_show(dialog->exec_cmd_entry);
761 gtk_widget_show(dialog->exec_cmd_browse); 774 gtk_widget_show(dialog->exec_cmd_browse);
762 gtk_widget_show(dialog->play_sound); 775 gtk_widget_show(dialog->play_sound);
763 gtk_widget_show(dialog->play_sound_entry); 776 gtk_widget_show(dialog->play_sound_entry);
769 G_CALLBACK(message_recv_toggle), 782 G_CALLBACK(message_recv_toggle),
770 dialog->send_msg); 783 dialog->send_msg);
771 784
772 g_signal_connect(G_OBJECT(dialog->send_msg), "clicked", 785 g_signal_connect(G_OBJECT(dialog->send_msg), "clicked",
773 G_CALLBACK(pidgin_toggle_sensitive), 786 G_CALLBACK(pidgin_toggle_sensitive),
774 send_msg_imhtml); 787 send_msg_webview);
775 788
776 g_signal_connect(G_OBJECT(dialog->popup), "clicked", 789 g_signal_connect(G_OBJECT(dialog->popup), "clicked",
777 G_CALLBACK(pidgin_toggle_sensitive), 790 G_CALLBACK(pidgin_toggle_sensitive),
778 dialog->popup_entry); 791 dialog->popup_entry);
779 792
809 G_CALLBACK(pounce_reset_sound), 822 G_CALLBACK(pounce_reset_sound),
810 dialog->play_sound_entry); 823 dialog->play_sound_entry);
811 g_object_set_data_full(G_OBJECT(dialog->window), "sound-widgets", 824 g_object_set_data_full(G_OBJECT(dialog->window), "sound-widgets",
812 sound_widgets, (GDestroyNotify)g_ptr_array_free); 825 sound_widgets, (GDestroyNotify)g_ptr_array_free);
813 826
814 g_signal_connect_swapped(G_OBJECT(dialog->send_msg_entry), "format_function_clear", 827 g_signal_connect_swapped(G_OBJECT(dialog->send_msg_entry), "format-cleared",
815 G_CALLBACK(reset_send_msg_entry), dialog); 828 G_CALLBACK(reset_send_msg_entry), dialog);
816 g_signal_connect_swapped(G_OBJECT(dialog->account_menu), "changed", 829 g_signal_connect_swapped(G_OBJECT(dialog->account_menu), "changed",
817 G_CALLBACK(reset_send_msg_entry), dialog); 830 G_CALLBACK(reset_send_msg_entry), dialog);
818 831
819 g_signal_connect(G_OBJECT(dialog->send_msg_entry), "message_send", 832 g_signal_connect(G_OBJECT(dialog->send_msg_entry), "key-press-event",
820 G_CALLBACK(save_pounce_cb), dialog); 833 G_CALLBACK(entry_key_press_cb), dialog);
821 g_signal_connect(G_OBJECT(dialog->popup_entry), "activate", 834 g_signal_connect(G_OBJECT(dialog->popup_entry), "activate",
822 G_CALLBACK(save_pounce_cb), dialog); 835 G_CALLBACK(save_pounce_cb), dialog);
823 g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate", 836 g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate",
824 G_CALLBACK(save_pounce_cb), dialog); 837 G_CALLBACK(save_pounce_cb), dialog);
825 838
928 941
929 if ((value = purple_pounce_action_get_attribute(cur_pounce, 942 if ((value = purple_pounce_action_get_attribute(cur_pounce,
930 "send-message", 943 "send-message",
931 "message")) != NULL) 944 "message")) != NULL)
932 { 945 {
933 gtk_imhtml_append_text(GTK_IMHTML(dialog->send_msg_entry), value, 0); 946 char *tmp = g_markup_escape_text(value, -1);
947 gtk_webview_append_html(GTK_WEBVIEW(dialog->send_msg_entry), value);
948 g_free(tmp);
934 } 949 }
935 950
936 if ((value = purple_pounce_action_get_attribute(cur_pounce, 951 if ((value = purple_pounce_action_get_attribute(cur_pounce,
937 "popup-notify", 952 "popup-notify",
938 "reason")) != NULL) 953 "reason")) != NULL)

mercurial