2010-08-16

Starting with version 2.18, the GTK library allowed for adding links to Labels, and this is exactly how I handled adding clickable URLs and names in heybuddy. Unfortunately, the version of GTK on Maemo devices is too old to use links in Labels.

Another unfortunate problem with links in Labels is that no GTK theme seems to have set a custom link color and all themes are stuck with the default bright blue link color. Egads! It sure would be nice if the user could set the color of links in heybuddy.

After searching and searching, I couldn't find an example of how to set a custom color for links in a GTK Label so I first needed to write some code to experiment with. The end result was a very simple example of exactly what I needed: a custom link color in a GTK Label.

Enter the Python

#!/usr/bin/env python
import gtk

gtk.Window()
gtk.Label()
"go to <a href='http://www.jezra.net'>jezra.net</a>"
l.set_markup(m)

style='''
style "label" {
  GtkLabel::link-color="#ff6600"
}
widget_class "*GtkLabel" style "label"
'''

gtk.rc_parse_string(style)

w.add(l)
w.show_all()
gtk.main()

shazaam! Custom color, baby!

Now quit reading, and go make things colorful.

Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
1 plus 4
Answer:
required
subscribe
 
2019
2016
2015
2014
2013
2012
2011
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008