pidgin/gtkconv.c

branch
cpw.qulogic.gtk3
changeset 32365
0c722056e496
parent 32362
8175436b817f
parent 28278
6539418cb140
child 32366
0472bc614998
equal deleted inserted replaced
32364:e98a5b6e56a4 32365:0c722056e496
960 #else 960 #else
961 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) 961 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget)
962 #endif 962 #endif
963 { 963 {
964 pidgin_dialogs_im(); 964 pidgin_dialogs_im();
965 }
966
967 static void
968 menu_join_chat_cb(gpointer data, guint action, GtkWidget *widget)
969 {
970 pidgin_blist_joinchat_show();
965 } 971 }
966 972
967 static void 973 static void
968 savelog_writefile_cb(void *user_data, const char *filename) 974 savelog_writefile_cb(void *user_data, const char *filename)
969 { 975 {
3343 /* Conversation menu */ 3349 /* Conversation menu */
3344 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL }, 3350 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL },
3345 3351
3346 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, 3352 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb,
3347 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW }, 3353 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW },
3354 { N_("/Conversation/Join a _Chat..."), "<CTL>C", menu_join_chat_cb,
3355 0, "<StockItem>", PIDGIN_STOCK_CHAT },
3348 3356
3349 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, 3357 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL },
3350 3358
3351 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, 3359 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0,
3352 "<StockItem>", GTK_STOCK_FIND }, 3360 "<StockItem>", GTK_STOCK_FIND },
3550 } 3558 }
3551 return ret; 3559 return ret;
3552 } 3560 }
3553 3561
3554 static void 3562 static void
3563 regenerate_media_items(PidginWindow *win)
3564 {
3565 #ifdef USE_VV
3566 PurpleAccount *account;
3567 PurpleConversation *conv;
3568
3569 conv = pidgin_conv_window_get_active_conversation(win);
3570
3571 if (conv == NULL) {
3572 purple_debug_error("gtkconv", "couldn't get active conversation"
3573 " when regenerating media items\n");
3574 return;
3575 }
3576
3577 account = purple_conversation_get_account(conv);
3578
3579 if (account == NULL) {
3580 purple_debug_error("gtkconv", "couldn't get account when"
3581 " regenerating media items\n");
3582 return;
3583 }
3584
3585 /*
3586 * Check if account support voice and/or calls, and
3587 * if the current buddy supports it.
3588 */
3589 if (account != NULL && purple_conversation_get_type(conv)
3590 == PURPLE_CONV_TYPE_IM) {
3591 PurpleMediaCaps caps =
3592 purple_prpl_get_media_caps(account,
3593 purple_conversation_get_name(conv));
3594
3595 gtk_widget_set_sensitive(win->audio_call,
3596 caps & PURPLE_MEDIA_CAPS_AUDIO
3597 ? TRUE : FALSE);
3598 gtk_widget_set_sensitive(win->video_call,
3599 caps & PURPLE_MEDIA_CAPS_VIDEO
3600 ? TRUE : FALSE);
3601 gtk_widget_set_sensitive(win->audio_video_call,
3602 caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO
3603 ? TRUE : FALSE);
3604 } else if (purple_conversation_get_type(conv)
3605 == PURPLE_CONV_TYPE_CHAT) {
3606 /* for now, don't care about chats... */
3607 gtk_widget_set_sensitive(win->audio_call, FALSE);
3608 gtk_widget_set_sensitive(win->video_call, FALSE);
3609 gtk_widget_set_sensitive(win->audio_video_call, FALSE);
3610 } else {
3611 gtk_widget_set_sensitive(win->audio_call, FALSE);
3612 gtk_widget_set_sensitive(win->video_call, FALSE);
3613 gtk_widget_set_sensitive(win->audio_video_call, FALSE);
3614 }
3615 #endif
3616 }
3617
3618 static void
3555 regenerate_options_items(PidginWindow *win) 3619 regenerate_options_items(PidginWindow *win)
3556 { 3620 {
3557 #if GTK_CHECK_VERSION(2,6,0) 3621 #if GTK_CHECK_VERSION(2,6,0)
3558 #else 3622 #else
3559 GtkWidget *menu; 3623 GtkWidget *menu;
3641 3705
3642 #if !GTK_CHECK_VERSION(2,6,0) 3706 #if !GTK_CHECK_VERSION(2,6,0)
3643 static void menubar_activated(GtkWidget *item, gpointer data) 3707 static void menubar_activated(GtkWidget *item, gpointer data)
3644 { 3708 {
3645 PidginWindow *win = data; 3709 PidginWindow *win = data;
3710 regenerate_media_items(win);
3646 regenerate_options_items(win); 3711 regenerate_options_items(win);
3647 regenerate_plugins_items(win); 3712 regenerate_plugins_items(win);
3648 3713
3649 /* The following are to make sure the 'More' submenu is not regenerated every time 3714 /* The following are to make sure the 'More' submenu is not regenerated every time
3650 * the focus shifts from 'Conversations' to some other menu and back. */ 3715 * the focus shifts from 'Conversations' to some other menu and back. */
4680 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ 4745 if(current_topic && !g_utf8_collate(new_topic, current_topic)){
4681 g_free(new_topic); 4746 g_free(new_topic);
4682 return; 4747 return;
4683 } 4748 }
4684 4749
4685 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); 4750 if (current_topic)
4751 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic);
4752 else
4753 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), "");
4754
4686 prpl_info->set_chat_topic(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), 4755 prpl_info->set_chat_topic(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)),
4687 new_topic); 4756 new_topic);
4688 4757
4689 g_free(new_topic); 4758 g_free(new_topic);
4690 } 4759 }
5750 received_im_msg_cb(PurpleAccount *account, char *sender, char *message, 5819 received_im_msg_cb(PurpleAccount *account, char *sender, char *message,
5751 PurpleConversation *conv, PurpleMessageFlags flags) 5820 PurpleConversation *conv, PurpleMessageFlags flags)
5752 { 5821 {
5753 PurpleConversationUiOps *ui_ops = pidgin_conversations_get_conv_ui_ops(); 5822 PurpleConversationUiOps *ui_ops = pidgin_conversations_get_conv_ui_ops();
5754 gboolean hide = FALSE; 5823 gboolean hide = FALSE;
5824 guint timer;
5755 5825
5756 /* create hidden conv if hide_new pref is always */ 5826 /* create hidden conv if hide_new pref is always */
5757 if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always") == 0) 5827 if (strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new"), "always") == 0)
5758 hide = TRUE; 5828 hide = TRUE;
5759 5829
5772 5842
5773 if (hide) { 5843 if (hide) {
5774 ui_ops->create_conversation = pidgin_conv_new_hidden; 5844 ui_ops->create_conversation = pidgin_conv_new_hidden;
5775 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); 5845 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender);
5776 ui_ops->create_conversation = pidgin_conv_new; 5846 ui_ops->create_conversation = pidgin_conv_new;
5847 }
5848
5849 /* Somebody wants to keep this conversation around, so don't time it out */
5850 timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer"));
5851 if (timer) {
5852 purple_timeout_remove(timer);
5853 purple_conversation_set_data(conv, "close-timer", GINT_TO_POINTER(0));
5777 } 5854 }
5778 } 5855 }
5779 5856
5780 static void 5857 static void
5781 pidgin_conv_destroy(PurpleConversation *conv) 5858 pidgin_conv_destroy(PurpleConversation *conv)
6870 6947
6871 if (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) 6948 if (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)
6872 buttons |= GTK_IMHTML_CUSTOM_SMILEY; 6949 buttons |= GTK_IMHTML_CUSTOM_SMILEY;
6873 else 6950 else
6874 buttons &= ~GTK_IMHTML_CUSTOM_SMILEY; 6951 buttons &= ~GTK_IMHTML_CUSTOM_SMILEY;
6875
6876 #ifdef USE_VV
6877 /* check if account support voice calls, and if the current buddy
6878 supports it */
6879 if (account != NULL && purple_conversation_get_type(conv)
6880 == PURPLE_CONV_TYPE_IM) {
6881 PurpleMediaCaps caps =
6882 purple_prpl_get_media_caps(account,
6883 purple_conversation_get_name(conv));
6884
6885 gtk_widget_set_sensitive(win->audio_call,
6886 caps & PURPLE_MEDIA_CAPS_AUDIO
6887 ? TRUE : FALSE);
6888 gtk_widget_set_sensitive(win->video_call,
6889 caps & PURPLE_MEDIA_CAPS_VIDEO
6890 ? TRUE : FALSE);
6891 gtk_widget_set_sensitive(win->audio_video_call,
6892 caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO
6893 ? TRUE : FALSE);
6894 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
6895 /* for now, don't care about chats... */
6896 gtk_widget_set_sensitive(win->audio_call, FALSE);
6897 gtk_widget_set_sensitive(win->video_call, FALSE);
6898 gtk_widget_set_sensitive(win->audio_video_call, FALSE);
6899 } else {
6900 gtk_widget_set_sensitive(win->audio_call, FALSE);
6901 gtk_widget_set_sensitive(win->video_call, FALSE);
6902 gtk_widget_set_sensitive(win->audio_video_call, FALSE);
6903 }
6904 #endif
6905 6952
6906 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); 6953 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons);
6907 if (account != NULL) 6954 if (account != NULL)
6908 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), purple_account_get_protocol_id(account)); 6955 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), purple_account_get_protocol_id(account));
6909 6956

mercurial