comparison pidgin/gtkconv.c @ 26145:685c8f5f85c7

Separate PidginMedia from PidginConversation.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 30 Jan 2009 04:40:54 +0000
parents 2091094745d9
children d6e23439b77c
comparison
equal deleted inserted replaced
26144:2091094745d9 26145:685c8f5f85c7
46 #include "cmds.h" 46 #include "cmds.h"
47 #include "debug.h" 47 #include "debug.h"
48 #include "idle.h" 48 #include "idle.h"
49 #include "imgstore.h" 49 #include "imgstore.h"
50 #include "log.h" 50 #include "log.h"
51 #include "mediamanager.h"
52 #include "notify.h" 51 #include "notify.h"
53 #include "prpl.h" 52 #include "prpl.h"
54 #include "request.h" 53 #include "request.h"
55 #include "util.h" 54 #include "util.h"
56 #include "version.h" 55 #include "version.h"
61 #include "gtkconvwin.h" 60 #include "gtkconvwin.h"
62 #include "gtkdialogs.h" 61 #include "gtkdialogs.h"
63 #include "gtkimhtml.h" 62 #include "gtkimhtml.h"
64 #include "gtkimhtmltoolbar.h" 63 #include "gtkimhtmltoolbar.h"
65 #include "gtklog.h" 64 #include "gtklog.h"
66 #include "gtkmedia.h"
67 #include "gtkmenutray.h" 65 #include "gtkmenutray.h"
68 #include "gtkpounce.h" 66 #include "gtkpounce.h"
69 #include "gtkprefs.h" 67 #include "gtkprefs.h"
70 #include "gtkprivacy.h" 68 #include "gtkprivacy.h"
71 #include "gtkthemes.h" 69 #include "gtkthemes.h"
4816 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); 4814 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT);
4817 GtkPolicyType imhtml_sw_hscroll; 4815 GtkPolicyType imhtml_sw_hscroll;
4818 int buddyicon_size = 0; 4816 int buddyicon_size = 0;
4819 4817
4820 /* Setup the top part of the pane */ 4818 /* Setup the top part of the pane */
4821 gtkconv->tophbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4822 gtk_widget_show(gtkconv->tophbox);
4823 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 4819 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4824 gtk_box_pack_start(GTK_BOX(gtkconv->tophbox), vbox, TRUE, TRUE, 0);
4825 gtk_widget_show(vbox); 4820 gtk_widget_show(vbox);
4826 4821
4827 /* Setup the info pane */ 4822 /* Setup the info pane */
4828 event_box = gtk_event_box_new(); 4823 event_box = gtk_event_box_new();
4829 #if GTK_CHECK_VERSION(2,4,0) 4824 #if GTK_CHECK_VERSION(2,4,0)
4968 G_CALLBACK(resize_imhtml_cb), gtkconv); 4963 G_CALLBACK(resize_imhtml_cb), gtkconv);
4969 4964
4970 default_formatize(gtkconv); 4965 default_formatize(gtkconv);
4971 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", 4966 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear",
4972 G_CALLBACK(clear_formatting_cb), gtkconv); 4967 G_CALLBACK(clear_formatting_cb), gtkconv);
4973 return gtkconv->tophbox; 4968 return vbox;
4974 } 4969 }
4975 4970
4976 static void 4971 static void
4977 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, 4972 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
4978 GtkSelectionData *sd, guint info, guint t, 4973 GtkSelectionData *sd, guint info, guint t,
6448 6443
6449 #ifdef USE_VV 6444 #ifdef USE_VV
6450 /* check if account support voice calls, and if the current buddy 6445 /* check if account support voice calls, and if the current buddy
6451 supports it */ 6446 supports it */
6452 if (account != NULL && purple_conversation_get_type(conv) 6447 if (account != NULL && purple_conversation_get_type(conv)
6453 == PURPLE_CONV_TYPE_IM 6448 == PURPLE_CONV_TYPE_IM) {
6454 && gtkconv->gtkmedia == NULL) {
6455 gboolean audio = purple_prpl_can_do_media(account, 6449 gboolean audio = purple_prpl_can_do_media(account,
6456 purple_conversation_get_name(conv), 6450 purple_conversation_get_name(conv),
6457 PURPLE_MEDIA_AUDIO); 6451 PURPLE_MEDIA_AUDIO);
6458 gboolean video = purple_prpl_can_do_media(account, 6452 gboolean video = purple_prpl_can_do_media(account,
6459 purple_conversation_get_name(conv), 6453 purple_conversation_get_name(conv),
7751 } 7745 }
7752 7746
7753 return TRUE; 7747 return TRUE;
7754 } 7748 }
7755 7749
7756
7757 #ifdef USE_VV
7758
7759 static void
7760 pidgin_gtkmedia_message_cb(PidginMedia *media, const char *msg, PurpleConversation *conv)
7761 {
7762 purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
7763 }
7764
7765 static void
7766 pidgin_gtkmedia_error_cb(PidginMedia *media, const char *msg, PurpleConversation *conv)
7767 {
7768 purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, msg, PURPLE_MESSAGE_ERROR, time(NULL));
7769 }
7770
7771 static void
7772 pidgin_conv_gtkmedia_destroyed(GtkWidget *widget, PidginConversation *gtkconv)
7773 {
7774 gtk_widget_destroyed(widget, &(gtkconv->gtkmedia));
7775 pidgin_conv_update_buttons_by_protocol(gtkconv->active_conv);
7776 }
7777
7778 static gboolean
7779 pidgin_conv_new_media_cb(PurpleMediaManager *manager, PurpleMedia *media,
7780 PurpleConnection *gc, gchar *screenname, gpointer nul)
7781 {
7782 GtkWidget *gtkmedia;
7783 PurpleConversation *conv;
7784 PidginConversation *gtkconv;
7785
7786 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
7787 purple_connection_get_account(gc), screenname);
7788
7789 gtkconv = PIDGIN_CONVERSATION(conv);
7790
7791 if (gtkconv->gtkmedia) {
7792 purple_debug_info("gtkconv", "Media session exists for this conversation.\n");
7793 return FALSE;
7794 }
7795
7796 gtkmedia = pidgin_media_new(media, screenname);
7797 g_object_unref(media);
7798
7799 gtk_box_pack_start(GTK_BOX(gtkconv->tophbox), gtkmedia, FALSE, FALSE, 0);
7800 gtk_widget_show(gtkmedia);
7801 g_signal_connect(G_OBJECT(gtkmedia), "message", G_CALLBACK(pidgin_gtkmedia_message_cb), conv);
7802 g_signal_connect(G_OBJECT(gtkmedia), "error", G_CALLBACK(pidgin_gtkmedia_error_cb), conv);
7803
7804 gtkconv->gtkmedia = gtkmedia;
7805 g_signal_connect(G_OBJECT(gtkmedia), "destroy", G_CALLBACK(
7806 pidgin_conv_gtkmedia_destroyed), gtkconv);
7807
7808 pidgin_conv_update_buttons_by_protocol(conv);
7809 return TRUE;
7810 }
7811
7812 #endif
7813
7814 void * 7750 void *
7815 pidgin_conversations_get_handle(void) 7751 pidgin_conversations_get_handle(void)
7816 { 7752 {
7817 static int handle; 7753 static int handle;
7818 7754
7909 show_buddy_icons_pref_cb, NULL); 7845 show_buddy_icons_pref_cb, NULL);
7910 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/blist/show_protocol_icons", 7846 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/blist/show_protocol_icons",
7911 show_protocol_icons_pref_cb, NULL); 7847 show_protocol_icons_pref_cb, NULL);
7912 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/im/hide_new", 7848 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/im/hide_new",
7913 hide_new_pref_cb, NULL); 7849 hide_new_pref_cb, NULL);
7914 #ifdef USE_VV
7915 g_signal_connect(G_OBJECT(purple_media_manager_get()), "init-media",
7916 G_CALLBACK(pidgin_conv_new_media_cb), NULL);
7917 #endif
7918 7850
7919 7851
7920 /********************************************************************** 7852 /**********************************************************************
7921 * Register signals 7853 * Register signals
7922 **********************************************************************/ 7854 **********************************************************************/