comparison pidgin/gtkconv.c @ 25635:efaecb71baad

propagate from branch 'im.pidgin.pidgin' (head 8ca6a80e2cd7fbbc59983f8ba370f7276e062db9) to branch 'im.pidgin.pidgin.vv' (head 3ed39e8792f4a2e92ef5a3c7f4fb14251c9dae11)
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 15 Mar 2008 07:39:15 +0000
parents f5bcb58bdf56 8802eddbfedc
children e4a4bc86c547
comparison
equal deleted inserted replaced
25634:741a702033e0 25635:efaecb71baad
238 const char *name = purple_conversation_get_name(conv); 238 const char *name = purple_conversation_get_name(conv);
239 239
240 switch (purple_conversation_get_type(conv)) { 240 switch (purple_conversation_get_type(conv)) {
241 case PURPLE_CONV_TYPE_IM: 241 case PURPLE_CONV_TYPE_IM:
242 { 242 {
243 hide_conv(gtkconv, TRUE); 243 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately"))
244 close_this_sucker(gtkconv);
245 else
246 hide_conv(gtkconv, TRUE);
244 break; 247 break;
245 } 248 }
246 case PURPLE_CONV_TYPE_CHAT: 249 case PURPLE_CONV_TYPE_CHAT:
247 { 250 {
248 PurpleChat *chat = purple_blist_find_chat(account, name); 251 PurpleChat *chat = purple_blist_find_chat(account, name);
2803 * End of the bunch of buddy icon functions 2806 * End of the bunch of buddy icon functions
2804 **************************************************************************/ 2807 **************************************************************************/
2805 void 2808 void
2806 pidgin_conv_present_conversation(PurpleConversation *conv) 2809 pidgin_conv_present_conversation(PurpleConversation *conv)
2807 { 2810 {
2808 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); 2811 PidginConversation *gtkconv;
2809 GdkModifierType state; 2812 GdkModifierType state;
2810 2813
2811 if (gtkconv == NULL) { 2814 pidgin_conv_attach_to_conversation(conv);
2812 pidgin_conv_attach_to_conversation(conv); 2815 gtkconv = PIDGIN_CONVERSATION(conv);
2813 gtkconv = PIDGIN_CONVERSATION(conv);
2814 } else if (gtkconv->win == hidden_convwin) {
2815 pidgin_conv_window_remove_gtkconv(hidden_convwin, gtkconv);
2816 pidgin_conv_placement_place(gtkconv);
2817 }
2818 2816
2819 pidgin_conv_switch_active_conversation(conv); 2817 pidgin_conv_switch_active_conversation(conv);
2820 /* Switch the tab only if the user initiated the event by pressing 2818 /* Switch the tab only if the user initiated the event by pressing
2821 * a button or hitting a key. */ 2819 * a button or hitting a key. */
2822 if (gtk_get_current_event_state(&state)) 2820 if (gtk_get_current_event_state(&state))
4579 PidginConversation *gtkconv = userdata; 4577 PidginConversation *gtkconv = userdata;
4580 4578
4581 conv = gtkconv->active_conv; 4579 conv = gtkconv->active_conv;
4582 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 4580 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
4583 node = (PurpleBlistNode*)(purple_blist_find_chat(conv->account, conv->name)); 4581 node = (PurpleBlistNode*)(purple_blist_find_chat(conv->account, conv->name));
4584 #if 0
4585 /* Using the transient blist nodes to show the tooltip doesn't quite work yet. */
4586 if (!node) 4582 if (!node)
4587 node = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_chat"); 4583 node = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_chat");
4588 #endif
4589 } else { 4584 } else {
4590 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, conv->name)); 4585 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, conv->name));
4591 #if 0 4586 #if 0
4587 /* Using the transient blist nodes to show the tooltip doesn't quite work yet. */
4592 if (!node) 4588 if (!node)
4593 node = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_buddy"); 4589 node = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_buddy");
4594 #endif 4590 #endif
4595 } 4591 }
4596 4592
4739 gtkconv->u.im->animate = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/animate_buddy_icons"); 4735 gtkconv->u.im->animate = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/animate_buddy_icons");
4740 gtkconv->u.im->show_icon = TRUE; 4736 gtkconv->u.im->show_icon = TRUE;
4741 } 4737 }
4742 4738
4743 g_signal_connect_swapped(G_OBJECT(gtkconv->entry_buffer), "changed", 4739 g_signal_connect_swapped(G_OBJECT(gtkconv->entry_buffer), "changed",
4740 G_CALLBACK(resize_imhtml_cb), gtkconv);
4741 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "realize",
4744 G_CALLBACK(resize_imhtml_cb), gtkconv); 4742 G_CALLBACK(resize_imhtml_cb), gtkconv);
4745 4743
4746 default_formatize(gtkconv); 4744 default_formatize(gtkconv);
4747 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", 4745 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear",
4748 G_CALLBACK(clear_formatting_cb), gtkconv); 4746 G_CALLBACK(clear_formatting_cb), gtkconv);
5016 5014
5017 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar")) 5015 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar"))
5018 gtk_widget_show(gtkconv->toolbar); 5016 gtk_widget_show(gtkconv->toolbar);
5019 else 5017 else
5020 gtk_widget_hide(gtkconv->toolbar); 5018 gtk_widget_hide(gtkconv->toolbar);
5021 g_idle_add((GSourceFunc)resize_imhtml_cb, gtkconv);
5022 5019
5023 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons")) 5020 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons"))
5024 gtk_widget_show(gtkconv->infopane_hbox); 5021 gtk_widget_show(gtkconv->infopane_hbox);
5025 else 5022 else
5026 gtk_widget_hide(gtkconv->infopane_hbox); 5023 gtk_widget_hide(gtkconv->infopane_hbox);
6495 } else { 6492 } else {
6496 markup = title; 6493 markup = title;
6497 } 6494 }
6498 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 6495 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
6499 const char *topic = gtkconv->u.chat->topic_text ? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text)) : NULL; 6496 const char *topic = gtkconv->u.chat->topic_text ? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text)) : NULL;
6500 char *esc = NULL; 6497 char *esc = NULL, *tmp;
6501 #if GTK_CHECK_VERSION(2,6,0) 6498 #if GTK_CHECK_VERSION(2,6,0)
6502 esc = topic ? g_markup_escape_text(topic, -1) : NULL; 6499 esc = topic ? g_markup_escape_text(topic, -1) : NULL;
6503 #else 6500 #else
6504 /* GTK < 2.6 doesn't have auto ellipsization, so we do a crude 6501 /* GTK < 2.6 doesn't have auto ellipsization, so we do a crude
6505 * trucation to prevent forcing the window to be as wide as the topic */ 6502 * trucation to prevent forcing the window to be as wide as the topic */
6506 int len = 0; 6503 int len = 0;
6507 char *c, *tmp = g_strdup(topic); 6504 char *c;
6505
6506 tmp = g_strdup(topic);
6508 c = tmp; 6507 c = tmp;
6509 while(*c && len < 72) { 6508 while(*c && len < 72) {
6510 c = g_utf8_next_char(c); 6509 c = g_utf8_next_char(c);
6511 len++; 6510 len++;
6512 } 6511 }
6517 tmp = c; 6516 tmp = c;
6518 } 6517 }
6519 esc = tmp ? g_markup_escape_text(tmp, -1) : NULL; 6518 esc = tmp ? g_markup_escape_text(tmp, -1) : NULL;
6520 g_free(tmp); 6519 g_free(tmp);
6521 #endif 6520 #endif
6521 tmp = g_markup_escape_text(purple_conversation_get_title(conv), -1);
6522 markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>", 6522 markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>",
6523 purple_conversation_get_title(conv), 6523 tmp, esc && *esc ? "\n" : "",
6524 esc && *esc ? "\n" : "",
6525 pidgin_get_dim_grey_string(gtkconv->infopane), 6524 pidgin_get_dim_grey_string(gtkconv->infopane),
6526 esc ? esc : ""); 6525 esc ? esc : "");
6526 g_free(tmp);
6527 g_free(esc); 6527 g_free(esc);
6528 } 6528 }
6529 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter), 6529 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter),
6530 CONV_TEXT_COLUMN, markup, -1); 6530 CONV_TEXT_COLUMN, markup, -1);
6531 /* XXX seanegan Why do I have to do this? */ 6531 /* XXX seanegan Why do I have to do this? */
7693 7693
7694 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", 54); 7694 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", 54);
7695 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", TRUE); 7695 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", TRUE);
7696 7696
7697 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "never"); 7697 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "never");
7698 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately", TRUE);
7698 7699
7699 #ifdef _WIN32 7700 #ifdef _WIN32
7700 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/win32/minimize_new_convs", FALSE); 7701 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/win32/minimize_new_convs", FALSE);
7701 #endif 7702 #endif
7702 7703