| 3899 |
3901 |
| 3900 tmp = g_utf8_casefold(alias, -1); |
3902 tmp = g_utf8_casefold(alias, -1); |
| 3901 alias_key = g_utf8_collate_key(tmp, -1); |
3903 alias_key = g_utf8_collate_key(tmp, -1); |
| 3902 g_free(tmp); |
3904 g_free(tmp); |
| 3903 |
3905 |
| 3904 if (is_me) |
3906 if (is_me) { |
| 3905 { |
3907 GtkTextTag *tag = gtk_text_tag_table_lookup( |
| 3906 GdkColor send_color; |
3908 gtk_text_buffer_get_tag_table(GTK_IMHTML(gtkconv->imhtml)->text_buffer), |
| 3907 gdk_color_parse(DEFAULT_SEND_COLOR, &send_color); |
3909 "send-name"); |
| |
3910 g_object_get(tag, "foreground-gdk", &color, NULL); |
| |
3911 } else { |
| |
3912 color = (GdkColor*)get_nick_color(gtkconv, name); |
| |
3913 } |
| 3908 |
3914 |
| 3909 #if GTK_CHECK_VERSION(2,6,0) |
3915 #if GTK_CHECK_VERSION(2,6,0) |
| 3910 gtk_list_store_insert_with_values(ls, &iter, |
3916 gtk_list_store_insert_with_values(ls, &iter, |
| 3911 /* |
3917 /* |
| 3912 * The GTK docs are mute about the effects of the "row" value for performance. |
3918 * The GTK docs are mute about the effects of the "row" value for performance. |
| 3913 * X-Chat hardcodes their value to 0 (prepend) and -1 (append), so we will too. |
3919 * X-Chat hardcodes their value to 0 (prepend) and -1 (append), so we will too. |
| 3914 * It *might* be faster to search the gtk_list_store and set row accurately, |
3920 * It *might* be faster to search the gtk_list_store and set row accurately, |
| 3915 * but no one in #gtk+ seems to know anything about it either. |
3921 * but no one in #gtk+ seems to know anything about it either. |
| 3916 * Inserting in the "wrong" location has no visible ill effects. - F.P. |
3922 * Inserting in the "wrong" location has no visible ill effects. - F.P. |
| 3917 */ |
3923 */ |
| 3918 -1, /* "row" */ |
3924 -1, /* "row" */ |
| 3919 CHAT_USERS_ICON_COLUMN, pixbuf, |
3925 CHAT_USERS_ICON_COLUMN, pixbuf, |
| 3920 CHAT_USERS_ALIAS_COLUMN, alias, |
3926 CHAT_USERS_ALIAS_COLUMN, alias, |
| 3921 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
3927 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
| 3922 CHAT_USERS_NAME_COLUMN, name, |
3928 CHAT_USERS_NAME_COLUMN, name, |
| 3923 CHAT_USERS_FLAGS_COLUMN, flags, |
3929 CHAT_USERS_FLAGS_COLUMN, flags, |
| 3924 CHAT_USERS_COLOR_COLUMN, &send_color, |
3930 CHAT_USERS_COLOR_COLUMN, color, |
| 3925 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, |
3931 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, |
| 3926 -1); |
3932 -1); |
| 3927 } |
|
| 3928 else |
|
| 3929 { |
|
| 3930 gtk_list_store_insert_with_values(ls, &iter, |
|
| 3931 -1, /* "row" */ |
|
| 3932 CHAT_USERS_ICON_COLUMN, pixbuf, |
|
| 3933 CHAT_USERS_ALIAS_COLUMN, alias, |
|
| 3934 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
|
| 3935 CHAT_USERS_NAME_COLUMN, name, |
|
| 3936 CHAT_USERS_FLAGS_COLUMN, flags, |
|
| 3937 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
|
| 3938 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, |
|
| 3939 -1); |
|
| 3940 #else |
3933 #else |
| 3941 gtk_list_store_append(ls, &iter); |
3934 gtk_list_store_append(ls, &iter); |
| 3942 gtk_list_store_set(ls, &iter, |
3935 gtk_list_store_set(ls, &iter, |
| 3943 CHAT_USERS_ICON_COLUMN, pixbuf, |
3936 CHAT_USERS_ICON_COLUMN, pixbuf, |
| 3944 CHAT_USERS_ALIAS_COLUMN, alias, |
3937 CHAT_USERS_ALIAS_COLUMN, alias, |
| 3945 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
3938 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
| 3946 CHAT_USERS_NAME_COLUMN, name, |
3939 CHAT_USERS_NAME_COLUMN, name, |
| 3947 CHAT_USERS_FLAGS_COLUMN, flags, |
3940 CHAT_USERS_FLAGS_COLUMN, flags, |
| 3948 CHAT_USERS_COLOR_COLUMN, &send_color, |
3941 CHAT_USERS_COLOR_COLUMN, color, |
| 3949 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, |
3942 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, |
| 3950 -1); |
3943 -1); |
| 3951 } |
|
| 3952 else |
|
| 3953 { |
|
| 3954 gtk_list_store_append(ls, &iter); |
|
| 3955 gtk_list_store_set(ls, &iter, |
|
| 3956 CHAT_USERS_ICON_COLUMN, pixbuf, |
|
| 3957 CHAT_USERS_ALIAS_COLUMN, alias, |
|
| 3958 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
|
| 3959 CHAT_USERS_NAME_COLUMN, name, |
|
| 3960 CHAT_USERS_FLAGS_COLUMN, flags, |
|
| 3961 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
|
| 3962 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, |
|
| 3963 -1); |
|
| 3964 #endif |
3944 #endif |
| 3965 } |
|
| 3966 |
3945 |
| 3967 if (pixbuf) |
3946 if (pixbuf) |
| 3968 g_object_unref(pixbuf); |
3947 g_object_unref(pixbuf); |
| |
3948 if (is_me && color) |
| |
3949 gdk_color_free(color); |
| 3969 g_free(alias_key); |
3950 g_free(alias_key); |
| 3970 } |
3951 } |
| 3971 |
3952 |
| 3972 static void |
3953 static void |
| 3973 tab_complete_process_item(int *most_matched, char *entered, gsize entered_bytes, char **partial, char *nick_partial, |
3954 tab_complete_process_item(int *most_matched, char *entered, gsize entered_bytes, char **partial, char *nick_partial, |
| 5684 char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup("")); |
5674 char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup("")); |
| 5685 /* The initial offset is to deal with |
5675 /* The initial offset is to deal with |
| 5686 * escaped entities making the string longer */ |
5676 * escaped entities making the string longer */ |
| 5687 int tag_start_offset = alias ? (strlen(alias_escaped) - strlen(alias)) : 0; |
5677 int tag_start_offset = alias ? (strlen(alias_escaped) - strlen(alias)) : 0; |
| 5688 int tag_end_offset = 0; |
5678 int tag_end_offset = 0; |
| |
5679 const char *tagname = NULL; |
| 5689 |
5680 |
| 5690 /* Enforce direction on alias */ |
5681 /* Enforce direction on alias */ |
| 5691 if (is_rtl_message) |
5682 if (is_rtl_message) |
| 5692 str_embed_direction_chars(&alias_escaped); |
5683 str_embed_direction_chars(&alias_escaped); |
| 5693 |
5684 |
| |
5685 str = g_malloc(1024); |
| 5694 if (flags & PURPLE_MESSAGE_WHISPER) { |
5686 if (flags & PURPLE_MESSAGE_WHISPER) { |
| 5695 str = g_malloc(1024); |
|
| 5696 |
|
| 5697 /* If we're whispering, it's not an autoresponse. */ |
5687 /* If we're whispering, it's not an autoresponse. */ |
| 5698 if (purple_message_meify(new_message, -1 )) { |
5688 if (purple_message_meify(new_message, -1 )) { |
| 5699 g_snprintf(str, 1024, "***%s", alias_escaped); |
5689 g_snprintf(str, 1024, "***%s", alias_escaped); |
| 5700 strcpy(color, "#6C2585"); |
|
| 5701 tag_start_offset += 3; |
5690 tag_start_offset += 3; |
| |
5691 tagname = "whisper-action-name"; |
| 5702 } |
5692 } |
| 5703 else { |
5693 else { |
| 5704 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
5694 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
| 5705 tag_start_offset += 1; |
5695 tag_start_offset += 1; |
| 5706 tag_end_offset = 2; |
5696 tag_end_offset = 2; |
| 5707 strcpy(color, "#00FF00"); |
5697 tagname = "whisper-name"; |
| 5708 } |
5698 } |
| 5709 } |
5699 } else { |
| 5710 else { |
|
| 5711 if (purple_message_meify(new_message, -1)) { |
5700 if (purple_message_meify(new_message, -1)) { |
| 5712 GdkColor *col; |
|
| 5713 str = g_malloc(1024); |
|
| 5714 |
|
| 5715 if (flags & PURPLE_MESSAGE_AUTO_RESP) { |
5701 if (flags & PURPLE_MESSAGE_AUTO_RESP) { |
| 5716 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, alias_escaped); |
5702 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, alias_escaped); |
| 5717 tag_start_offset += 4 |
5703 tag_start_offset += 4 |
| 5718 + strlen(AUTO_RESPONSE); |
5704 + strlen(AUTO_RESPONSE); |
| 5719 } else { |
5705 } else { |
| 5720 g_snprintf(str, 1024, "***%s", alias_escaped); |
5706 g_snprintf(str, 1024, "***%s", alias_escaped); |
| 5721 tag_start_offset += 3; |
5707 tag_start_offset += 3; |
| 5722 } |
5708 } |
| 5723 |
5709 |
| 5724 if (flags & PURPLE_MESSAGE_NICK) |
5710 if (flags & PURPLE_MESSAGE_NICK) |
| 5725 gtk_widget_style_get(GTK_WIDGET(gtkconv->imhtml), "highlight-name-color", &col, NULL); |
5711 tagname = "highlight-name"; |
| 5726 else |
5712 else |
| 5727 gtk_widget_style_get(GTK_WIDGET(gtkconv->imhtml), "action-name-color", &col, NULL); |
5713 tagname = "action-name"; |
| 5728 |
5714 } else { |
| 5729 if(col) { |
|
| 5730 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
|
| 5731 col->red >> 8, col->green >> 8, col->blue >> 8); |
|
| 5732 gdk_color_free(col); |
|
| 5733 } else { |
|
| 5734 if (flags & PURPLE_MESSAGE_NICK) |
|
| 5735 strcpy(color, DEFAULT_HIGHLIGHT_COLOR); |
|
| 5736 else |
|
| 5737 strcpy(color, DEFAULT_ACTION_COLOR); |
|
| 5738 } |
|
| 5739 } |
|
| 5740 else { |
|
| 5741 str = g_malloc(1024); |
|
| 5742 if (flags & PURPLE_MESSAGE_AUTO_RESP) { |
5715 if (flags & PURPLE_MESSAGE_AUTO_RESP) { |
| 5743 g_snprintf(str, 1024, "%s %s", alias_escaped, AUTO_RESPONSE); |
5716 g_snprintf(str, 1024, "%s %s", alias_escaped, AUTO_RESPONSE); |
| 5744 tag_start_offset += 1 |
5717 tag_start_offset += 1 |
| 5745 + strlen(AUTO_RESPONSE); |
5718 + strlen(AUTO_RESPONSE); |
| 5746 } else { |
5719 } else { |
| 5747 g_snprintf(str, 1024, "%s:", alias_escaped); |
5720 g_snprintf(str, 1024, "%s:", alias_escaped); |
| 5748 tag_end_offset = 1; |
5721 tag_end_offset = 1; |
| 5749 } |
5722 } |
| |
5723 |
| 5750 if (flags & PURPLE_MESSAGE_NICK) { |
5724 if (flags & PURPLE_MESSAGE_NICK) { |
| 5751 GdkColor *col; |
5725 tagname = "highlight-name"; |
| 5752 gtk_widget_style_get(GTK_WIDGET(gtkconv->imhtml), "highlight-name-color", &col, NULL); |
5726 } else if (flags & PURPLE_MESSAGE_RECV) { |
| 5753 if(col) { |
5727 /* The tagname and color is handled by get_buddy_tag */ |
| 5754 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
5728 if (type == PURPLE_CONV_TYPE_IM) { |
| 5755 col->red >> 8, col->green >> 8, col->blue >> 8); |
5729 tagname = "receive-name"; |
| 5756 gdk_color_free(col); |
|
| 5757 } else { |
|
| 5758 strcpy(color, DEFAULT_HIGHLIGHT_COLOR); |
|
| 5759 } |
5730 } |
| 5760 } |
5731 } else if (flags & PURPLE_MESSAGE_SEND) { |
| 5761 else if (flags & PURPLE_MESSAGE_RECV) { |
5732 tagname = "send-name"; |
| 5762 if (type == PURPLE_CONV_TYPE_CHAT) { |
5733 } else { |
| 5763 const GdkColor *col = get_nick_color(gtkconv, name); |
|
| 5764 |
|
| 5765 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
|
| 5766 col->red >> 8, col->green >> 8, col->blue >> 8); |
|
| 5767 } else { |
|
| 5768 GdkColor *col; |
|
| 5769 gtk_widget_style_get(GTK_WIDGET(gtkconv->imhtml), "receive-name-color", &col, NULL); |
|
| 5770 if(col) { |
|
| 5771 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
|
| 5772 col->red >> 8, col->green >> 8, col->blue >> 8); |
|
| 5773 gdk_color_free(col); |
|
| 5774 } else { |
|
| 5775 strcpy(color, DEFAULT_RECV_COLOR); |
|
| 5776 } |
|
| 5777 } |
|
| 5778 } |
|
| 5779 else if (flags & PURPLE_MESSAGE_SEND) { |
|
| 5780 GdkColor *col; |
|
| 5781 gtk_widget_style_get(GTK_WIDGET(gtkconv->imhtml), "send-name-color", &col, NULL); |
|
| 5782 if(col) { |
|
| 5783 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
|
| 5784 col->red >> 8, col->green >> 8, col->blue >> 8); |
|
| 5785 gdk_color_free(col); |
|
| 5786 } else { |
|
| 5787 strcpy(color, DEFAULT_SEND_COLOR); |
|
| 5788 } |
|
| 5789 } |
|
| 5790 else { |
|
| 5791 purple_debug_error("gtkconv", "message missing flags\n"); |
5734 purple_debug_error("gtkconv", "message missing flags\n"); |
| 5792 strcpy(color, "#000000"); |
|
| 5793 } |
5735 } |
| 5794 } |
5736 } |
| 5795 } |
5737 } |
| 5796 |
5738 |
| 5797 g_free(alias_escaped); |
5739 g_free(alias_escaped); |
| 5798 |
5740 |
| 5799 /* Are we in a chat where we can tell which users are buddies? */ |
5741 g_snprintf(buf2, BUF_LONG, |
| 5800 if (prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
5742 "<FONT %s><FONT SIZE=\"2\"><!--%s --></FONT>%s</FONT> ", |
| 5801 purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
5743 sml_attrib ? sml_attrib : "", mdate, str); |
| 5802 |
|
| 5803 /* Bold buddies to make them stand out from non-buddies. */ |
|
| 5804 if (flags & PURPLE_MESSAGE_SEND || |
|
| 5805 flags & PURPLE_MESSAGE_NICK || |
|
| 5806 purple_find_buddy(account, name) != NULL) { |
|
| 5807 g_snprintf(buf2, BUF_LONG, |
|
| 5808 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--%s --></FONT>" |
|
| 5809 "<B>%s</B></FONT> ", |
|
| 5810 color, sml_attrib ? sml_attrib : "", mdate, str); |
|
| 5811 } else { |
|
| 5812 g_snprintf(buf2, BUF_LONG, |
|
| 5813 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--%s --></FONT>" |
|
| 5814 "%s</FONT> ", |
|
| 5815 color, sml_attrib ? sml_attrib : "", mdate, str); |
|
| 5816 |
|
| 5817 } |
|
| 5818 } else { |
|
| 5819 /* Bold everyone's name to make the name stand out from the message. */ |
|
| 5820 g_snprintf(buf2, BUF_LONG, |
|
| 5821 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--%s --></FONT>" |
|
| 5822 "<B>%s</B></FONT> ", |
|
| 5823 color, sml_attrib ? sml_attrib : "", mdate, str); |
|
| 5824 } |
|
| 5825 |
|
| 5826 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all | GTK_IMHTML_NO_SCROLL); |
5744 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all | GTK_IMHTML_NO_SCROLL); |
| 5827 |
5745 |
| 5828 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && |
5746 if (tagname || |
| 5829 !(flags & PURPLE_MESSAGE_SEND)) { |
5747 (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && |
| 5830 |
5748 !(flags & PURPLE_MESSAGE_SEND))) { |
| 5831 GtkTextIter start, end; |
5749 GtkTextIter start, end; |
| 5832 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
5750 GtkTextTag *tag; |
| 5833 |
5751 GtkTextBuffer *buffer = GTK_IMHTML(gtkconv->imhtml)->text_buffer; |
| 5834 gtk_text_buffer_get_end_iter( |
5752 |
| 5835 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
5753 if (tagname) |
| 5836 &end); |
5754 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer), tagname); |
| 5837 gtk_text_iter_backward_chars(&end, |
5755 else |
| 5838 tag_end_offset + 1); |
5756 tag = get_buddy_tag(conv, name, TRUE); |
| 5839 |
5757 |
| 5840 gtk_text_buffer_get_end_iter( |
5758 gtk_text_buffer_get_end_iter(buffer, &end); |
| 5841 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
5759 gtk_text_iter_backward_chars(&end, tag_end_offset + 1); |
| 5842 &start); |
5760 |
| 5843 gtk_text_iter_backward_chars(&start, |
5761 gtk_text_buffer_get_end_iter(buffer, &start); |
| 5844 strlen(str) + 1 - tag_start_offset); |
5762 gtk_text_iter_backward_chars(&start, strlen(str) + 1 - tag_start_offset); |
| 5845 |
5763 |
| 5846 gtk_text_buffer_apply_tag( |
5764 gtk_text_buffer_apply_tag(buffer, tag, &start, &end); |
| 5847 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
|
| 5848 buddytag, &start, &end); |
|
| 5849 } |
5765 } |
| 5850 |
5766 |
| 5851 g_free(str); |
5767 g_free(str); |
| 5852 |
5768 |
| 5853 if(gc){ |
5769 if(gc){ |