comparison src/gtkconv.c @ 5205:fefad67de2c7

[gaim-migrate @ 5573] I had a damn good commit message, but it was eaten. Let's try it again. Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short. There are lots'a cool thingies here. Okay now, this isn't as cool as the previous message, but: 1) There's now a single entry function for all plugin types. It returns a detailed information structure on the plugin. This removes a lot of the ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so if you use it, well, you shouldn't have used it anyway, but now you can't! bwahahaha. Use AIM/ICQ. 2) There are now 3 types of plugins: Standard, Loader, and Protocol plugins. Standard plugins are, well, standard, compiled plugins. Loader plugins load other plugins. For example, the perl support is now a loader plugin. It loads perl scripts. In the future, we'll have Ruby and Python loader plugins. Protocol plugins are, well, protocol plugins... yeah... 3) Plugins have unique IDs, so they can be referred to or automatically updated from a plugin database in the future. Neat, huh? 4) Plugins will have dependency support in the future, and can be hidden, so if you have, say, a logging core plugin, it won't have to show up, but then you load the GTK+ logging plugin and it'll auto-load the core plugin. Core/UI split plugins! 5) There will eventually be custom plugin signals and RPC of some sort, for the core/ui split plugins. So, okay, back up .gaimrc. I'd like to thank my parents for their support, javabsp for helping convert a bunch of protocol plugins, and Etan for helping convert a bunch of standard plugins. Have fun. If you have any problems, please let me know, but you probably won't have anything major happen. You will have to convert your plugins, though, and I'm not guaranteeing that all perl scripts will still work. I'll end up changing the perl script API eventually, so I know they won't down the road. Don't worry, though. It'll be mass cool. faceprint wants me to just commit the damn code already. So, here we go!!! .. .. I need a massage. From a young, cute girl. Are there any young, cute girls in the audience? IM me plz k thx. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 25 Apr 2003 06:47:33 +0000
parents 44de70702205
children 0241d6b6702d
comparison
equal deleted inserted replaced
5204:44de70702205 5205:fefad67de2c7
633 } 633 }
634 634
635 static void 635 static void
636 menu_info_cb(GtkWidget *w, struct gaim_conversation *conv) 636 menu_info_cb(GtkWidget *w, struct gaim_conversation *conv)
637 { 637 {
638 GaimPluginProtocolInfo *prpl_info = NULL;
638 struct gaim_connection *gc; 639 struct gaim_connection *gc;
639 char *who; 640 char *who;
640 641
641 gc = gaim_conversation_get_gc(conv); 642 gc = gaim_conversation_get_gc(conv);
642 who = g_object_get_data(G_OBJECT(w), "user_data"); 643 who = g_object_get_data(G_OBJECT(w), "user_data");
643 644
644 if (gc != NULL) { 645 if (gc != NULL) {
646 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
647
645 /* 648 /*
646 * If there are special needs for getting info on users in 649 * If there are special needs for getting info on users in
647 * buddy chat "rooms"... 650 * buddy chat "rooms"...
648 */ 651 */
649 if (gc->prpl->get_cb_info != NULL) 652 if (prpl_info->get_cb_info != NULL)
650 gc->prpl->get_cb_info(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who); 653 prpl_info->get_cb_info(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who);
651 else 654 else
652 gc->prpl->get_info(gc, who); 655 prpl_info->get_info(gc, who);
653 } 656 }
654 } 657 }
655 658
656 static void 659 static void
657 menu_away_cb(GtkWidget *w, struct gaim_conversation *conv) 660 menu_away_cb(GtkWidget *w, struct gaim_conversation *conv)
658 { 661 {
662 GaimPluginProtocolInfo *prpl_info = NULL;
659 struct gaim_connection *gc; 663 struct gaim_connection *gc;
660 char *who; 664 char *who;
661 665
662 gc = gaim_conversation_get_gc(conv); 666 gc = gaim_conversation_get_gc(conv);
663 who = g_object_get_data(G_OBJECT(w), "user_data"); 667 who = g_object_get_data(G_OBJECT(w), "user_data");
664 668
665 if (gc != NULL) { 669 if (gc != NULL) {
670 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
671
666 /* 672 /*
667 * May want to expand this to work similarly to menu_info_cb? 673 * May want to expand this to work similarly to menu_info_cb?
668 */ 674 */
669 675
670 if (gc->prpl->get_cb_away != NULL) 676 if (prpl_info->get_cb_away != NULL)
671 gc->prpl->get_cb_away(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who); 677 prpl_info->get_cb_away(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who);
672 } 678 }
673 } 679 }
674 680
675 static void 681 static void
676 menu_add_cb(GtkWidget *w, struct gaim_conversation *conv) 682 menu_add_cb(GtkWidget *w, struct gaim_conversation *conv)
693 699
694 static gint 700 static gint
695 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, 701 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event,
696 struct gaim_conversation *conv) 702 struct gaim_conversation *conv)
697 { 703 {
704 GaimPluginProtocolInfo *prpl_info = NULL;
698 struct gaim_gtk_conversation *gtkconv; 705 struct gaim_gtk_conversation *gtkconv;
699 struct gaim_gtk_chat_pane *gtkchat; 706 struct gaim_gtk_chat_pane *gtkchat;
700 struct gaim_connection *gc; 707 struct gaim_connection *gc;
701 struct gaim_account *account; 708 struct gaim_account *account;
702 GtkTreePath *path; 709 GtkTreePath *path;
717 event->x, event->y, &path, &column, &x, &y); 724 event->x, event->y, &path, &column, &x, &y);
718 725
719 if (path == NULL) 726 if (path == NULL)
720 return FALSE; 727 return FALSE;
721 728
729 if (gc != NULL)
730 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
731
722 gtk_tree_selection_select_path(GTK_TREE_SELECTION( 732 gtk_tree_selection_select_path(GTK_TREE_SELECTION(
723 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); 733 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path);
724 734
725 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); 735 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path);
726 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &who, -1); 736 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &who, -1);
767 G_CALLBACK(ignore_cb), conv); 777 G_CALLBACK(ignore_cb), conv);
768 g_object_set_data(G_OBJECT(button), "user_data", who); 778 g_object_set_data(G_OBJECT(button), "user_data", who);
769 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); 779 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
770 gtk_widget_show(button); 780 gtk_widget_show(button);
771 781
772 if (gc && gc->prpl->get_info) { 782 if (gc && prpl_info->get_info) {
773 button = gtk_menu_item_new_with_label(_("Info")); 783 button = gtk_menu_item_new_with_label(_("Info"));
774 g_signal_connect(G_OBJECT(button), "activate", 784 g_signal_connect(G_OBJECT(button), "activate",
775 G_CALLBACK(menu_info_cb), conv); 785 G_CALLBACK(menu_info_cb), conv);
776 g_object_set_data(G_OBJECT(button), "user_data", who); 786 g_object_set_data(G_OBJECT(button), "user_data", who);
777 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); 787 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
778 gtk_widget_show(button); 788 gtk_widget_show(button);
779 } 789 }
780 790
781 if (gc && gc->prpl->get_cb_away) { 791 if (gc && prpl_info->get_cb_away) {
782 button = gtk_menu_item_new_with_label(_("Get Away Msg")); 792 button = gtk_menu_item_new_with_label(_("Get Away Msg"));
783 g_signal_connect(G_OBJECT(button), "activate", 793 g_signal_connect(G_OBJECT(button), "activate",
784 G_CALLBACK(menu_away_cb), conv); 794 G_CALLBACK(menu_away_cb), conv);
785 g_object_set_data(G_OBJECT(button), "user_data", who); 795 g_object_set_data(G_OBJECT(button), "user_data", who);
786 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); 796 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
1713 1723
1714 static void 1724 static void
1715 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, 1725 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
1716 gpointer user_data) 1726 gpointer user_data)
1717 { 1727 {
1728 GaimPluginProtocolInfo *prpl_info = NULL;
1718 struct gaim_window *win; 1729 struct gaim_window *win;
1719 struct gaim_conversation *conv; 1730 struct gaim_conversation *conv;
1720 struct gaim_gtk_conversation *gtkconv; 1731 struct gaim_gtk_conversation *gtkconv;
1721 struct gaim_gtk_window *gtkwin; 1732 struct gaim_gtk_window *gtkwin;
1722 struct gaim_connection *gc; 1733 struct gaim_connection *gc;
1734 1745
1735 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); 1746 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE);
1736 1747
1737 if (gc != NULL) { 1748 if (gc != NULL) {
1738 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); 1749 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE);
1750 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
1739 } 1751 }
1740 1752
1741 /* Update the menubar */ 1753 /* Update the menubar */
1742 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { 1754 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) {
1743 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE); 1755 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE);
1744 gtk_widget_set_sensitive(gtkwin->menu.insert_image, 1756 gtk_widget_set_sensitive(gtkwin->menu.insert_image,
1745 (gc && gc->prpl->options & OPT_PROTO_IM_IMAGE)); 1757 (gc && prpl_info->options & OPT_PROTO_IM_IMAGE));
1746 1758
1747 if (gtkwin->menu.send_as != NULL) 1759 if (gtkwin->menu.send_as != NULL)
1748 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); 1760 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win);
1749 } 1761 }
1750 else { 1762 else {
2920 } 2932 }
2921 2933
2922 static GtkWidget * 2934 static GtkWidget *
2923 setup_chat_pane(struct gaim_conversation *conv) 2935 setup_chat_pane(struct gaim_conversation *conv)
2924 { 2936 {
2937 GaimPluginProtocolInfo *prpl_info = NULL;
2925 struct gaim_gtk_conversation *gtkconv; 2938 struct gaim_gtk_conversation *gtkconv;
2926 struct gaim_gtk_chat_pane *gtkchat; 2939 struct gaim_gtk_chat_pane *gtkchat;
2927 struct gaim_connection *gc; 2940 struct gaim_connection *gc;
2928 GtkWidget *vpaned, *hpaned; 2941 GtkWidget *vpaned, *hpaned;
2929 GtkWidget *vbox, *hbox; 2942 GtkWidget *vbox, *hbox;
2948 /* Setup the top part of the pane. */ 2961 /* Setup the top part of the pane. */
2949 vbox = gtk_vbox_new(FALSE, 5); 2962 vbox = gtk_vbox_new(FALSE, 5);
2950 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, FALSE); 2963 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, FALSE);
2951 gtk_widget_show(vbox); 2964 gtk_widget_show(vbox);
2952 2965
2953 if (gc->prpl->options & OPT_PROTO_CHAT_TOPIC) 2966 if (gc != NULL)
2967 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
2968
2969 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC)
2954 { 2970 {
2955 hbox = gtk_hbox_new(FALSE, 0); 2971 hbox = gtk_hbox_new(FALSE, 0);
2956 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); 2972 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2957 gtk_widget_show(hbox); 2973 gtk_widget_show(hbox);
2958 2974
3744 }; 3760 };
3745 3761
3746 static void 3762 static void
3747 update_convo_add_button(struct gaim_conversation *conv) 3763 update_convo_add_button(struct gaim_conversation *conv)
3748 { 3764 {
3765 GaimPluginProtocolInfo *prpl_info = NULL;
3749 struct gaim_gtk_conversation *gtkconv; 3766 struct gaim_gtk_conversation *gtkconv;
3750 struct gaim_connection *gc; 3767 struct gaim_connection *gc;
3751 GaimConversationType type; 3768 GaimConversationType type;
3752 GtkWidget *parent; 3769 GtkWidget *parent;
3753 3770
3754 type = gaim_conversation_get_type(conv); 3771 type = gaim_conversation_get_type(conv);
3755 gc = gaim_conversation_get_gc(conv); 3772 gc = gaim_conversation_get_gc(conv);
3756 gtkconv = GAIM_GTK_CONVERSATION(conv); 3773 gtkconv = GAIM_GTK_CONVERSATION(conv);
3757 parent = gtk_widget_get_parent(gtkconv->u.im->add); 3774 parent = gtk_widget_get_parent(gtkconv->u.im->add);
3775
3776 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
3758 3777
3759 if (gaim_find_buddy(gc->account, gaim_conversation_get_name(conv))) { 3778 if (gaim_find_buddy(gc->account, gaim_conversation_get_name(conv))) {
3760 gtkconv->u.im->add = 3779 gtkconv->u.im->add =
3761 gaim_gtk_change_text(_("Remove"), gtkconv->u.im->add, 3780 gaim_gtk_change_text(_("Remove"), gtkconv->u.im->add,
3762 GTK_STOCK_REMOVE, type); 3781 GTK_STOCK_REMOVE, type);
3763 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, 3782 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add,
3764 _("Remove the user from your buddy list"), NULL); 3783 _("Remove the user from your buddy list"), NULL);
3765 3784
3766 gtk_widget_set_sensitive(gtkconv->u.im->add, 3785 gtk_widget_set_sensitive(gtkconv->u.im->add,
3767 (gc != NULL && gc->prpl->remove_buddy != NULL)); 3786 (gc != NULL && prpl_info->remove_buddy != NULL));
3768 } else { 3787 } else {
3769 gtkconv->u.im->add = 3788 gtkconv->u.im->add =
3770 gaim_gtk_change_text(_("Add"), gtkconv->u.im->add, 3789 gaim_gtk_change_text(_("Add"), gtkconv->u.im->add,
3771 GTK_STOCK_ADD, type); 3790 GTK_STOCK_ADD, type);
3772 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, 3791 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add,
3773 _("Add the user to your buddy list"), NULL); 3792 _("Add the user to your buddy list"), NULL);
3774 3793
3775 gtk_widget_set_sensitive(gtkconv->u.im->add, 3794 gtk_widget_set_sensitive(gtkconv->u.im->add,
3776 (gc != NULL && gc->prpl->add_buddy != NULL)); 3795 (gc != NULL && prpl_info->add_buddy != NULL));
3777 } 3796 }
3778 3797
3779 g_signal_connect(G_OBJECT(gtkconv->u.im->add), "clicked", 3798 g_signal_connect(G_OBJECT(gtkconv->u.im->add), "clicked",
3780 G_CALLBACK(add_cb), conv); 3799 G_CALLBACK(add_cb), conv);
3781 3800
3925 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); 3944 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime));
3926 else 3945 else
3927 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); 3946 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
3928 3947
3929 if(gc) 3948 if(gc)
3930 sml_attrib = g_strdup_printf("sml=\"%s\"", gc->prpl->name); 3949 sml_attrib = g_strdup_printf("sml=\"%s\"", gc->prpl->info->name);
3931 3950
3932 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS; 3951 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS;
3933 3952
3934 if (convo_options & OPT_CONVO_IGNORE_COLOUR) 3953 if (convo_options & OPT_CONVO_IGNORE_COLOUR)
3935 gtk_font_options ^= GTK_IMHTML_NO_COLOURS; 3954 gtk_font_options ^= GTK_IMHTML_NO_COLOURS;
5037 } 5056 }
5038 5057
5039 void 5058 void
5040 gaim_gtkconv_update_buttons_by_protocol(struct gaim_conversation *conv) 5059 gaim_gtkconv_update_buttons_by_protocol(struct gaim_conversation *conv)
5041 { 5060 {
5061 GaimPluginProtocolInfo *prpl_info = NULL;
5042 struct gaim_window *win; 5062 struct gaim_window *win;
5043 struct gaim_gtk_window *gtkwin = NULL; 5063 struct gaim_gtk_window *gtkwin = NULL;
5044 struct gaim_gtk_conversation *gtkconv; 5064 struct gaim_gtk_conversation *gtkconv;
5045 struct gaim_connection *gc; 5065 struct gaim_connection *gc;
5046 5066
5060 if (win != NULL && gaim_window_get_active_conversation(win) == conv) { 5080 if (win != NULL && gaim_window_get_active_conversation(win) == conv) {
5061 gtk_widget_set_sensitive(gtkwin->menu.insert_link, FALSE); 5081 gtk_widget_set_sensitive(gtkwin->menu.insert_link, FALSE);
5062 } 5082 }
5063 } 5083 }
5064 else { 5084 else {
5085 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
5086
5065 gtk_widget_set_sensitive(gtkconv->send, TRUE); 5087 gtk_widget_set_sensitive(gtkconv->send, TRUE);
5066 if (win != NULL) { 5088 if (win != NULL) {
5067 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); 5089 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE);
5068 } 5090 }
5069 } 5091 }
5083 5105
5084 return; 5106 return;
5085 } 5107 }
5086 5108
5087 gtk_widget_set_sensitive(gtkconv->info, 5109 gtk_widget_set_sensitive(gtkconv->info,
5088 (gc->prpl->get_info != NULL)); 5110 (prpl_info->get_info != NULL));
5089 5111
5090 gtk_widget_set_sensitive(gtkconv->toolbar.image, 5112 gtk_widget_set_sensitive(gtkconv->toolbar.image,
5091 (gc->prpl->options & OPT_PROTO_IM_IMAGE)); 5113 (prpl_info->options & OPT_PROTO_IM_IMAGE));
5092 5114
5093 if (win != NULL && gaim_window_get_active_conversation(win) == conv) { 5115 if (win != NULL && gaim_window_get_active_conversation(win) == conv) {
5094 gtk_widget_set_sensitive(gtkwin->menu.insert_image, 5116 gtk_widget_set_sensitive(gtkwin->menu.insert_image,
5095 (gc->prpl->options & OPT_PROTO_IM_IMAGE)); 5117 (prpl_info->options & OPT_PROTO_IM_IMAGE));
5096 } 5118 }
5097 5119
5098 gtk_widget_set_sensitive(gtkconv->u.im->warn, 5120 gtk_widget_set_sensitive(gtkconv->u.im->warn,
5099 (gc->prpl->warn != NULL)); 5121 (prpl_info->warn != NULL));
5100 5122
5101 gtk_widget_set_sensitive(gtkconv->u.im->block, 5123 gtk_widget_set_sensitive(gtkconv->u.im->block,
5102 (gc->prpl->add_permit != NULL)); 5124 (prpl_info->add_permit != NULL));
5103 5125
5104 update_convo_add_button(conv); 5126 update_convo_add_button(conv);
5105 } 5127 }
5106 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { 5128 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) {
5107 if (gc == NULL) { 5129 if (gc == NULL) {
5109 gtk_widget_set_sensitive(gtkconv->u.chat->invite, FALSE); 5131 gtk_widget_set_sensitive(gtkconv->u.chat->invite, FALSE);
5110 5132
5111 return; 5133 return;
5112 } 5134 }
5113 5135
5114 gtk_widget_set_sensitive(gtkconv->send, (gc->prpl->chat_send != NULL)); 5136 gtk_widget_set_sensitive(gtkconv->send, (prpl_info->chat_send != NULL));
5115 5137
5116 gtk_widget_set_sensitive(gtkconv->toolbar.image, FALSE); 5138 gtk_widget_set_sensitive(gtkconv->toolbar.image, FALSE);
5117 /* gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); */ 5139 /* gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); */
5118 5140
5119 gtk_widget_set_sensitive(gtkconv->u.chat->whisper, 5141 gtk_widget_set_sensitive(gtkconv->u.chat->whisper,
5120 (gc->prpl->chat_whisper != NULL)); 5142 (prpl_info->chat_whisper != NULL));
5121 5143
5122 gtk_widget_set_sensitive(gtkconv->u.chat->invite, 5144 gtk_widget_set_sensitive(gtkconv->u.chat->invite,
5123 (gc->prpl->chat_invite != NULL)); 5145 (prpl_info->chat_invite != NULL));
5124 } 5146 }
5125 } 5147 }
5126 5148
5127 struct gaim_window * 5149 struct gaim_window *
5128 gaim_gtkwin_get_at_xy(int x, int y) 5150 gaim_gtkwin_get_at_xy(int x, int y)