You are not logged in.

#1 2015-01-18 21:36:20

hb860
Member
Registered: 2014-09-12
Posts: 81
Website

Pidgin - too bright colors in chat, nicks unreadable

I have faced the issue with chat colors in Jabber conference.
Pidgin applied way too bright colors to nicks and some of them become unreadable on the white background.
The solution is actually very simple, we should not allow Pidgin to use colors like FF0000, 00FF00 and so on.
I modified the source code, here is a patch:

--- gtkconv.c	2014-11-23 19:41:26.000000000 +0300
+++ gtkconv-new.c	2015-01-18 23:50:46.000000000 +0300
@@ -171,7 +171,7 @@
 
 static const GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name)
 {
-	static GdkColor col;
+	static GdkColor col;// col ={0, 0x0000, 0x0000, 0x0000}; //0xffff
 	GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml);
 	float scale;
 
@@ -185,7 +185,9 @@
 		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;
 }
 

Call it from PKGBUILD:

prepare() {
  cd "$srcdir/$pkgname-$pkgver"

  # Use Python 2
  sed -i 's/env python$/&2/' */plugins/*.py \
    libpurple/purple-{remote,notifications-example,url-handler}
  
  # darken nicks patch
  patch pidgin/gtkconv.c ../../gtkconv-darkenchatnicks.diff
}

That's it. Rebuild Pidgin and you will not deal with extremely bright colors in chat.
Maybe it is a good idea to include this patch to our "official" PKGBUILD.

Offline

#2 2015-01-18 21:38:00

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Pidgin - too bright colors in chat, nicks unreadable

You should submit this upstream.


Moving to Community Contributions...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-01-19 14:16:26

hb860
Member
Registered: 2014-09-12
Posts: 81
Website

Re: Pidgin - too bright colors in chat, nicks unreadable

Well, I have created a ticket in Pidgin's Trac.
IDK if they will change the code or not.

Last edited by hb860 (2015-01-19 14:16:47)

Offline

#4 2016-07-22 22:31:04

hb860
Member
Registered: 2014-09-12
Posts: 81
Website

Re: Pidgin - too bright colors in chat, nicks unreadable

Hi again, I improved the patch code and uploaded it to github.
Now the patch looks as follows:

--- 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;
 }

This code reduces all color channels proportionally to values calculated by pidgin.
I uploaded everything to github here: https://github.com/tkaserg/pidgin-less- … ick-colors
Tested against the latest version 2.11.0-1 (as of this writing), everything works fine here.
Build it as follows:

makepkg -si --skippgpcheck

Last edited by hb860 (2016-07-22 22:33:39)

Offline

Board footer

Powered by FluxBB