# HG changeset patch # User Sadrul Habib Chowdhury # Date 1212816234 0 # Node ID ea341703b1d3148d401b7f6b0643df9f1a6df9cd # Parent f3b7a07a760774e8db4eda6558b08fd71d96d0dd msgcolor command to change colors of messages in conversations. diff -r f3b7a07a7607 -r ea341703b1d3 ChangeLog --- a/ChangeLog Sat Jun 07 01:58:23 2008 +0000 +++ b/ChangeLog Sat Jun 07 05:23:54 2008 +0000 @@ -22,6 +22,8 @@ * Added "Invite..." menu to chats. * Added "View All Logs" menu in the buddylist to display a list of all IM logs. + * Added '/msgcolor' command to change colors of different classes of + messages in a conversation. See '/help msgcolor' for details. version 2.4.2 (05/17/2008): libpurple: diff -r f3b7a07a7607 -r ea341703b1d3 finch/gntconv.c --- a/finch/gntconv.c Sat Jun 07 01:58:23 2008 +0000 +++ b/finch/gntconv.c Sat Jun 07 05:23:54 2008 +0000 @@ -1241,6 +1241,47 @@ } static PurpleCmdRet +cmd_message_color(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) +{ + int *msgclass = NULL; + int fg, bg; + + if (strcmp(args[0], "receive") == 0) + msgclass = &color_message_receive; + else if (strcmp(args[0], "send") == 0) + msgclass = &color_message_send; + else if (strcmp(args[0], "highlight") == 0) + msgclass = &color_message_highlight; + else if (strcmp(args[0], "action") == 0) + msgclass = &color_message_action; + else if (strcmp(args[0], "timestamp") == 0) + msgclass = &color_timestamp; + else { + if (error) + *error = g_strdup_printf(_("%s is not a valid message class. See '/help msgcolor' for valid message classes."), args[0]); + return PURPLE_CMD_STATUS_FAILED; + } + + fg = gnt_colors_get_color(args[1]); + if (fg == -EINVAL) { + if (error) + *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[1]); + return PURPLE_CMD_STATUS_FAILED; + } + + bg = gnt_colors_get_color(args[2]); + if (bg == -EINVAL) { + if (error) + *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[2]); + return PURPLE_CMD_STATUS_FAILED; + } + + init_pair(*msgclass, fg, bg); + + return PURPLE_CMD_STATUS_OK; +} + +static PurpleCmdRet users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) { FinchConv *fc = FINCH_GET_DATA(conv); @@ -1324,6 +1365,16 @@ PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_show_window, _("statuses: Show the savedstatuses window."), finch_savedstatus_show_all); + /* Allow customizing the message colors using a command during run-time */ + purple_cmd_register("msgcolor", "www", PURPLE_CMD_P_DEFAULT, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, + cmd_message_color, _("msgcolor <class> <foreground> <background>: " + "Set the color for different classes of messages in the conversation window.
" + " <class>: receive, send, highlight, action, timestamp
" + " <foreground/background>: black, red, green, blue, white, gray, darkgray, magenta, cyan, default

" + "EXAMPLE:
msgcolor send cyan default"), + NULL); + purple_signal_connect(purple_conversations_get_handle(), "buddy-typing", finch_conv_get_handle(), PURPLE_CALLBACK(update_buddy_typing), NULL); purple_signal_connect(purple_conversations_get_handle(), "buddy-typing-stopped", finch_conv_get_handle(), diff -r f3b7a07a7607 -r ea341703b1d3 finch/libgnt/gntcolors.c --- a/finch/libgnt/gntcolors.c Sat Jun 07 01:58:23 2008 +0000 +++ b/finch/libgnt/gntcolors.c Sat Jun 07 05:23:54 2008 +0000 @@ -29,6 +29,7 @@ #include +#include #include #include @@ -168,7 +169,7 @@ color = -1; else { g_warning("Invalid color name: %s\n", key); - color = -1; + color = -EINVAL; } return color; } diff -r f3b7a07a7607 -r ea341703b1d3 finch/libgnt/gntcolors.h --- a/finch/libgnt/gntcolors.h Sat Jun 07 01:58:23 2008 +0000 +++ b/finch/libgnt/gntcolors.h Sat Jun 07 05:23:54 2008 +0000 @@ -91,7 +91,7 @@ * * @param kfile The string value * - * @return A color + * @return A color. For an unknown color name, returns -EINVAL. * * @since 2.4.0 */