[Goodies-dev] genmon-plugin colored text support
Jaromír Cápík
tavvva at seznam.cz
Tue Sep 8 15:15:05 CEST 2009
Hello folks.
I just wrote a support for colored text in the genmon-plugin.
I added a new tag <txtcolor> resp. </txtcolor>
where you can put either the color name
or the #RRGGBB hex value...
Examples:
<txtcolor>red</txtcolor>
or
<txtcolor>#FF0000</txtcolor>
If You're interrested in the patch, then feel free to check the attachement.
Have a nice day.
Regards,
Jaromir.
-------------- next part --------------
--- main_old.c 2008-03-15 23:38:18.000000000 +0100
+++ main.c 2009-09-08 15:05:46.383934639 +0200
@@ -5,6 +5,8 @@
* <http://rmlx.dyndns.org>
* Copyright (c) 2006 Julien Devemy <jujucece at gmail.com>
*
+ * Copyright (c) 2009 Jaromir Capik <tavvva at seznam.cz>
+ * <http://tavvva.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -187,6 +189,23 @@
gtk_widget_hide (poMonitor->wImage);
}
+ /* Test if the result is a Text Color */
+ begin=strstr(p_poPlugin->acValue, "<txtcolor>");
+ end=strstr(p_poPlugin->acValue, "</txtcolor>");
+ if ((begin != NULL) && (end != NULL) && (begin < end) && (end-begin < 256*sizeof(char)))
+ {
+ char buf[256];
+ GdkColor txtcolor;
+
+ /* Get the color */
+ strncpy(buf, begin+10*sizeof(char), end-begin-10*sizeof(char));
+ buf[end-begin-10*sizeof(char)]='\0';
+ gdk_color_parse (buf, &txtcolor);
+ gtk_widget_modify_fg (poMonitor->wValue, GTK_STATE_NORMAL, &txtcolor);
+
+ newVersion=1;
+ }
+
/* Test if the result is a Text */
begin=strstr(p_poPlugin->acValue, "<txt>");
end=strstr(p_poPlugin->acValue, "</txt>");
More information about the Goodies-dev
mailing list