changeset 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 5f1ba65b018e
children ae95a1714442
files ChangeLog ChangeLog.API doc/finch.1.in finch/gntblist.c finch/gntconv.c finch/libgnt/gntstyle.c finch/libgnt/gntstyle.h
diffstat 7 files changed, 104 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Dec 03 02:01:52 2007 +0000
+++ b/ChangeLog	Mon Dec 03 07:01:32 2007 +0000
@@ -1,13 +1,17 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
-version 2.3.1 (??/??/????):
+version 2.3.2 (??/??/????):
 	libpurple:
 	* Fixed various problems with loss of status messages when going
 	  or returning from idle on MySpaceIM.
 
 	Finch:
-	* Color is used in the buddylist to indicate status. Look at the sample
-	  gntrc file in the man-page for details.
+	* Color is used in the buddylist to indicate status, and the conversation
+	  window to indicate various message attributes. Look at the sample gntrc
+	  file in the man-page for details.
+	* The default keybinding for dump-screen is now M-D and uses a file
+	  request dialog. M-d will properly delete-forward-word, and M-f has been
+	  fixed to imitate readline's behavior.
 
 version 2.3.0 (11/24/2007):
 	http://developer.pidgin.im/query?status=closed&milestone=2.3.0
--- a/ChangeLog.API	Mon Dec 03 02:01:52 2007 +0000
+++ b/ChangeLog.API	Mon Dec 03 07:01:32 2007 +0000
@@ -1,6 +1,6 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
-version 2.3.1 (??/??/????):
+version 2.3.2 (??/??/????):
 	Finch:
 		libgnt:
 		* Added gnt_tree_set_row_color to set the color for a row in a tree.
@@ -8,6 +8,8 @@
 		* Added gnt_color_add_pair to define a new color.
 		* Added gnt_colors_get_color to get an ncurses color value from a
 		  string.
+		* Added gnt_style_get_color to get a color pair from an entry in
+		  ~/.gntrc
 
 version 2.3.0 (11/24/2007):
 	libpurple:
--- a/doc/finch.1.in	Mon Dec 03 02:01:52 2007 +0000
+++ b/doc/finch.1.in	Mon Dec 03 07:01:32 2007 +0000
@@ -145,6 +145,16 @@
 .br
 color-offline = red; black
 .br
+color-message-sent = cyan; default
+.br
+color-message-received = red; default
+.br
+color-message-highlight = black; green
+.br
+color-message-action = yellow; default
+.br
+color-timestamp = blue; default
+.br
 #See below for details on color
 .br
 [general]
@@ -237,6 +247,8 @@
 .br
 urgent = green; black
 .br
+urgent = green; black
+.br
 
 .br
 # Remap some keys for GntEntry
--- a/finch/gntblist.c	Mon Dec 03 02:01:52 2007 +0000
+++ b/finch/gntblist.c	Mon Dec 03 07:01:32 2007 +0000
@@ -1768,37 +1768,18 @@
 	draw_tooltip(ggblist);
 }
 
-static int
-get_color(char *key)
-{
-#if GLIB_CHECK_VERSION(2,6,0)
-	int fg = 0, bg = 0;
-	gsize n;
-	char **vals;
-	vals = gnt_style_get_string_list(NULL, key, &n);
-	if (vals && n == 2) {
-		fg = gnt_colors_get_color(vals[0]);
-		bg = gnt_colors_get_color(vals[1]);
-		return gnt_color_add_pair(fg, bg);
-	}
-	return 0;
-#else
-	return 0;
-#endif
-}
-
 void finch_blist_init()
 {
-	color_available = get_color("color-available");
+	color_available = gnt_style_get_color(NULL, "color-available");
 	if (!color_available)
 		color_available = gnt_color_add_pair(COLOR_GREEN, -1);
-	color_away = get_color("color-away");
+	color_away = gnt_style_get_color(NULL, "color-away");
 	if (!color_away)
 		color_away = gnt_color_add_pair(COLOR_BLUE, -1);
-	color_idle = get_color("color-idle");
+	color_idle = gnt_style_get_color(NULL, "color-idle");
 	if (!color_idle)
 		color_idle = gnt_color_add_pair(COLOR_CYAN, -1);
-	color_offline = get_color("color-offline");
+	color_offline = gnt_style_get_color(NULL, "color-offline");
 	if (!color_offline)
 		color_offline = gnt_color_add_pair(COLOR_RED, -1);
 
--- a/finch/gntconv.c	Mon Dec 03 02:01:52 2007 +0000
+++ b/finch/gntconv.c	Mon Dec 03 07:01:32 2007 +0000
@@ -49,6 +49,7 @@
 #include "gntmenu.h"
 #include "gntmenuitem.h"
 #include "gntmenuitemcheck.h"
+#include "gntstyle.h"
 #include "gnttextview.h"
 #include "gnttree.h"
 #include "gntutils.h"
@@ -64,6 +65,12 @@
 		const char *message, PurpleMessageFlags flags, time_t mtime);
 static void generate_send_to_menu(FinchConv *ggc);
 
+static int color_message_receive;
+static int color_message_send;
+static int color_message_highlight;
+static int color_message_action;
+static int color_timestamp;
+
 static PurpleBlistNode *
 get_conversation_blist_node(PurpleConversation *conv)
 {
@@ -753,7 +760,9 @@
 	/* Unnecessary to print the timestamp for delayed message */
 	if (purple_prefs_get_bool("/finch/conversations/timestamps"))
 		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
-					purple_utf8_strftime("(%H:%M:%S) ", localtime(&mtime)), GNT_TEXT_FLAG_DIM);
+					purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), gnt_color_pair(color_timestamp));
+
+	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), " ", GNT_TEXT_FLAG_NORMAL);
 
 	if (flags & PURPLE_MESSAGE_AUTO_RESP)
 		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
@@ -764,22 +773,31 @@
 	{
 		char * name = NULL;
 
-		if (purple_message_meify((char*)message, -1))
-			name = g_strdup_printf("*** %s ", who);
-		else
-			name =  g_strdup_printf("%s: ", who);
-
-		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
-				name, GNT_TEXT_FLAG_BOLD);
+		if (purple_message_meify((char*)message, -1)) {
+			name = g_strdup_printf("*** %s", who);
+			gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
+				name, gnt_color_pair(color_message_action));
+		} else {
+			name =  g_strdup_printf("%s", who);
+			if (flags & PURPLE_MESSAGE_SEND)
+				gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
+					name, gnt_color_pair(color_message_send));
+			else
+				if (flags & PURPLE_MESSAGE_NICK) {
+					gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
+						name, gnt_color_pair(color_message_highlight));
+				} else {
+					gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
+						name, gnt_color_pair(color_message_receive));
+				}
+		}
+		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), ": ", GNT_TEXT_FLAG_NORMAL);
 		g_free(name);
-	}
-	else
+	} else
 		fl = GNT_TEXT_FLAG_DIM;
 
 	if (flags & PURPLE_MESSAGE_ERROR)
 		fl |= GNT_TEXT_FLAG_BOLD;
-	if (flags & PURPLE_MESSAGE_NICK)
-		fl |= GNT_TEXT_FLAG_UNDERLINE;
 
 	/* XXX: Remove this workaround when textview can parse messages. */
 	newline = purple_strdup_withhtml(message);
@@ -1126,6 +1144,21 @@
 
 void finch_conversation_init()
 {
+	color_message_send = gnt_style_get_color(NULL, "color-message-sent");
+	if (!color_message_send)
+		color_message_send = gnt_color_add_pair(COLOR_CYAN, -1);
+	color_message_receive = gnt_style_get_color(NULL, "color-message-received");
+	if (!color_message_receive)
+		color_message_receive = gnt_color_add_pair(COLOR_RED, -1);
+	color_message_highlight = gnt_style_get_color(NULL, "color-message-highlight");
+	if (!color_message_highlight)
+		color_message_highlight = gnt_color_add_pair(COLOR_GREEN, -1);
+	color_timestamp = gnt_style_get_color(NULL, "color-timestamp");
+	if (!color_timestamp)
+		color_timestamp = gnt_color_add_pair(COLOR_BLUE, -1);
+	color_message_action = gnt_style_get_color(NULL, "color-message-action");
+	if (!color_message_action)
+		color_message_action = gnt_color_add_pair(COLOR_YELLOW, -1);
 	purple_prefs_add_none(PREF_ROOT);
 	purple_prefs_add_none(PREF_ROOT "/size");
 	purple_prefs_add_int(PREF_ROOT "/size/width", 70);
--- a/finch/libgnt/gntstyle.c	Mon Dec 03 02:01:52 2007 +0000
+++ b/finch/libgnt/gntstyle.c	Mon Dec 03 07:01:32 2007 +0000
@@ -59,6 +59,25 @@
 #endif
 }
 
+int
+gnt_style_get_color(char *group, char *key)
+{
+#if GLIB_CHECK_VERSION(2,6,0)
+	int fg = 0, bg = 0;
+	gsize n;
+	char **vals;
+	vals = gnt_style_get_string_list(group, key, &n);
+	if (vals && n == 2) {
+		fg = gnt_colors_get_color(vals[0]);
+		bg = gnt_colors_get_color(vals[1]);
+		return gnt_color_add_pair(fg, bg);
+	}
+	return 0;
+#else
+	return 0;
+#endif
+}
+
 char **gnt_style_get_string_list(const char *group, const char *key, gsize *length)
 {
 #if GLIB_CHECK_VERSION(2,6,0)
--- a/finch/libgnt/gntstyle.h	Mon Dec 03 02:01:52 2007 +0000
+++ b/finch/libgnt/gntstyle.h	Mon Dec 03 07:01:32 2007 +0000
@@ -74,11 +74,24 @@
  *
  * @return        NULL terminated string array. The array should be freed with g_strfreev().
  *
- * @since 2.3.1 (gnt), 2.3.1 (pidgin)
+ * @since 2.3.2
  */
 char **gnt_style_get_string_list(const char *group, const char *key, gsize *length);
 
 /**
+ * Get the value of a color pair in ~/.gntrc.
+ *
+ * @param group   The name of the group in the keyfile. If @c NULL, the prgname
+ *                will be used first, if available. Otherwise, "general" will be used.
+ * @param key     The key
+ *
+ * @return  The value of the color as an int, or 0 on error.
+ *
+ * @since 2.3.2
+ */
+int gnt_style_get_color(char *group, char *key);
+
+/**
  * Parse a boolean preference. For example, if 'value' is "false" (ignoring case)
  * or "0", the return value will be @c FALSE, otherwise @c TRUE.
  *