Opened 4 years ago

Last modified 3 years ago

#16540 new enhancement

Unreadable nicks in Pidgin chat

Reported by: hb860 Owned by: EionRobb
Milestone: Component: unclassified
Version: 2.10.11 Keywords: chat colors formatting
Cc:

Description

Sometimes Pidgin picks too bright colors in conference/chat so nicks become unreadable on the default white background. In my case, it used #00FF00 for one of participants. Can we limit the color channel value to a half in the get_nick_color function? To get something like this:

static const GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name)
{
	static GdkColor col;
	GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml);
	float scale;

	col = nick_colors[g_str_hash(name) % nbr_nick_colors];
	scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) *
		       (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green)));

	/* The colors are chosen to look fine on white; we should never have to darken */
	if (scale > 1) {
		col.red   *= scale;
		col.green *= scale;
		col.blue  *= scale;
	}
	col.red = MIN(col.red,32767);
	col.green = MIN(col.green,32767);
	col.blue = MIN(col.blue,32767);
	return &col;
} 

Change History (5)

comment:1 Changed 4 years ago by renatosilva

The nick colors are also too similar.

comment:2 Changed 3 years ago by Robby

  • Milestone changed from 2.10.12 to 2.10.13

comment:3 Changed 3 years ago by grim

  • Milestone changed from 2.10.13 to 2.11.0

comment:4 Changed 3 years ago by Robby

  • Milestone 2.11.0 deleted

comment:5 Changed 3 years ago by hb860

Here is a better patch code.

--- gtkconv-ori.c	2016-06-19 08:33:11.000000000 +0300
+++ gtkconv.c	2016-07-23 00:56:07.893682523 +0300
@@ -174,6 +174,8 @@
 	static GdkColor col;
 	GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml);
 	float scale;
+	float percent;
+	int halfcolor;
 
 	col = nick_colors[g_str_hash(name) % nbr_nick_colors];
 	scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) *
@@ -186,6 +188,17 @@
 		col.blue  *= scale;
 	}
 
+	halfcolor = G_MAXUINT16/2;
+	
+	percent = (col.red*100)/G_MAXUINT16;
+	col.red = (percent*halfcolor)/100;
+	
+	percent = (col.green*100)/G_MAXUINT16;
+	col.green = (percent*halfcolor)/100;
+	
+	percent = (col.blue*100)/G_MAXUINT16;
+	col.blue = (percent*halfcolor)/100;
+
 	return &col;
 }
 

Note: See TracTickets for help on using tickets.
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!