Mercurial > pidgin.yaz
comparison finch/gntconv.c @ 21738:e3e64d1e4869
Add color to the conversation window to indicate various message attributes
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Mon, 03 Dec 2007 07:01:32 +0000 |
parents | 6de09629f091 |
children | 5ff16647c50d |
comparison
equal
deleted
inserted
replaced
21735:5f1ba65b018e | 21738:e3e64d1e4869 |
---|---|
47 #include "gntentry.h" | 47 #include "gntentry.h" |
48 #include "gntlabel.h" | 48 #include "gntlabel.h" |
49 #include "gntmenu.h" | 49 #include "gntmenu.h" |
50 #include "gntmenuitem.h" | 50 #include "gntmenuitem.h" |
51 #include "gntmenuitemcheck.h" | 51 #include "gntmenuitemcheck.h" |
52 #include "gntstyle.h" | |
52 #include "gnttextview.h" | 53 #include "gnttextview.h" |
53 #include "gnttree.h" | 54 #include "gnttree.h" |
54 #include "gntutils.h" | 55 #include "gntutils.h" |
55 #include "gntwindow.h" | 56 #include "gntwindow.h" |
56 | 57 |
61 #include "config.h" | 62 #include "config.h" |
62 | 63 |
63 static void finch_write_common(PurpleConversation *conv, const char *who, | 64 static void finch_write_common(PurpleConversation *conv, const char *who, |
64 const char *message, PurpleMessageFlags flags, time_t mtime); | 65 const char *message, PurpleMessageFlags flags, time_t mtime); |
65 static void generate_send_to_menu(FinchConv *ggc); | 66 static void generate_send_to_menu(FinchConv *ggc); |
67 | |
68 static int color_message_receive; | |
69 static int color_message_send; | |
70 static int color_message_highlight; | |
71 static int color_message_action; | |
72 static int color_timestamp; | |
66 | 73 |
67 static PurpleBlistNode * | 74 static PurpleBlistNode * |
68 get_conversation_blist_node(PurpleConversation *conv) | 75 get_conversation_blist_node(PurpleConversation *conv) |
69 { | 76 { |
70 PurpleBlistNode *node = NULL; | 77 PurpleBlistNode *node = NULL; |
751 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL); | 758 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL); |
752 | 759 |
753 /* Unnecessary to print the timestamp for delayed message */ | 760 /* Unnecessary to print the timestamp for delayed message */ |
754 if (purple_prefs_get_bool("/finch/conversations/timestamps")) | 761 if (purple_prefs_get_bool("/finch/conversations/timestamps")) |
755 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | 762 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
756 purple_utf8_strftime("(%H:%M:%S) ", localtime(&mtime)), GNT_TEXT_FLAG_DIM); | 763 purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), gnt_color_pair(color_timestamp)); |
764 | |
765 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), " ", GNT_TEXT_FLAG_NORMAL); | |
757 | 766 |
758 if (flags & PURPLE_MESSAGE_AUTO_RESP) | 767 if (flags & PURPLE_MESSAGE_AUTO_RESP) |
759 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | 768 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
760 _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD); | 769 _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD); |
761 | 770 |
762 if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) && | 771 if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) && |
763 !(flags & PURPLE_MESSAGE_NOTIFY)) | 772 !(flags & PURPLE_MESSAGE_NOTIFY)) |
764 { | 773 { |
765 char * name = NULL; | 774 char * name = NULL; |
766 | 775 |
767 if (purple_message_meify((char*)message, -1)) | 776 if (purple_message_meify((char*)message, -1)) { |
768 name = g_strdup_printf("*** %s ", who); | 777 name = g_strdup_printf("*** %s", who); |
769 else | 778 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
770 name = g_strdup_printf("%s: ", who); | 779 name, gnt_color_pair(color_message_action)); |
771 | 780 } else { |
772 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | 781 name = g_strdup_printf("%s", who); |
773 name, GNT_TEXT_FLAG_BOLD); | 782 if (flags & PURPLE_MESSAGE_SEND) |
783 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | |
784 name, gnt_color_pair(color_message_send)); | |
785 else | |
786 if (flags & PURPLE_MESSAGE_NICK) { | |
787 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | |
788 name, gnt_color_pair(color_message_highlight)); | |
789 } else { | |
790 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | |
791 name, gnt_color_pair(color_message_receive)); | |
792 } | |
793 } | |
794 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), ": ", GNT_TEXT_FLAG_NORMAL); | |
774 g_free(name); | 795 g_free(name); |
775 } | 796 } else |
776 else | |
777 fl = GNT_TEXT_FLAG_DIM; | 797 fl = GNT_TEXT_FLAG_DIM; |
778 | 798 |
779 if (flags & PURPLE_MESSAGE_ERROR) | 799 if (flags & PURPLE_MESSAGE_ERROR) |
780 fl |= GNT_TEXT_FLAG_BOLD; | 800 fl |= GNT_TEXT_FLAG_BOLD; |
781 if (flags & PURPLE_MESSAGE_NICK) | |
782 fl |= GNT_TEXT_FLAG_UNDERLINE; | |
783 | 801 |
784 /* XXX: Remove this workaround when textview can parse messages. */ | 802 /* XXX: Remove this workaround when textview can parse messages. */ |
785 newline = purple_strdup_withhtml(message); | 803 newline = purple_strdup_withhtml(message); |
786 strip = purple_markup_strip_html(newline); | 804 strip = purple_markup_strip_html(newline); |
787 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | 805 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
1124 return PURPLE_CMD_STATUS_OK; | 1142 return PURPLE_CMD_STATUS_OK; |
1125 } | 1143 } |
1126 | 1144 |
1127 void finch_conversation_init() | 1145 void finch_conversation_init() |
1128 { | 1146 { |
1147 color_message_send = gnt_style_get_color(NULL, "color-message-sent"); | |
1148 if (!color_message_send) | |
1149 color_message_send = gnt_color_add_pair(COLOR_CYAN, -1); | |
1150 color_message_receive = gnt_style_get_color(NULL, "color-message-received"); | |
1151 if (!color_message_receive) | |
1152 color_message_receive = gnt_color_add_pair(COLOR_RED, -1); | |
1153 color_message_highlight = gnt_style_get_color(NULL, "color-message-highlight"); | |
1154 if (!color_message_highlight) | |
1155 color_message_highlight = gnt_color_add_pair(COLOR_GREEN, -1); | |
1156 color_timestamp = gnt_style_get_color(NULL, "color-timestamp"); | |
1157 if (!color_timestamp) | |
1158 color_timestamp = gnt_color_add_pair(COLOR_BLUE, -1); | |
1159 color_message_action = gnt_style_get_color(NULL, "color-message-action"); | |
1160 if (!color_message_action) | |
1161 color_message_action = gnt_color_add_pair(COLOR_YELLOW, -1); | |
1129 purple_prefs_add_none(PREF_ROOT); | 1162 purple_prefs_add_none(PREF_ROOT); |
1130 purple_prefs_add_none(PREF_ROOT "/size"); | 1163 purple_prefs_add_none(PREF_ROOT "/size"); |
1131 purple_prefs_add_int(PREF_ROOT "/size/width", 70); | 1164 purple_prefs_add_int(PREF_ROOT "/size/width", 70); |
1132 purple_prefs_add_int(PREF_ROOT "/size/height", 20); | 1165 purple_prefs_add_int(PREF_ROOT "/size/height", 20); |
1133 purple_prefs_add_none(PREF_ROOT "/position"); | 1166 purple_prefs_add_none(PREF_ROOT "/position"); |