GTK+ Themes

There is a burst of activity in the GTK+ theme world these days.
How do I know? Well, I get bugs like this for Gnumeric. This was a debug build with a reporter
that took the time (and had the knowledge) to tell us that a theme was involved, so it was pretty easy to diagnose as Someone Else’s Problem.
But when it happens with some distribution’s theme, it generally
requires a crystal ball.

In my humble opinion, something is wrong with the way themes are
done in GTK+. The current situation is:

  • When a theme engine crashes, the blame is placed on the application by both the user and Bug Buddy.
  • There is no fault-separation between the application and the theme. Theme engines are written in a fault-intolerant language.
  • Theme code is written by people more interested in visual effects than code. The code receives less scrutiny than, say, GTK+’s main code.
  • Application developers cannot test with themes they do not know.

Ideas?

Week numbers

Week numbers are not used in the US who it is pointless to start
thinking about how weeks might be numbered there. I do not know
if week numbers are in use in Asia, but I do not think so.

That leaves Europe[*] and the name of the game is ISO 8601 and The Right
Answer[tm] therefore is:

Week number of 24/12/2005: 51
Week number of 25/12/2005: 51
Week number of 26/12/2005: 52
Week number of 27/12/2005: 52
Week number of 28/12/2005: 52
Week number of 29/12/2005: 52
Week number of 30/12/2005: 52
Week number of 31/12/2005: 52
Week number of 1/1/2006: 52
Week number of 2/1/2006: 1
Week number of 3/1/2006: 1
Week number of 4/1/2006: 1
Week number of 5/1/2006: 1
Week number of 6/1/2006: 1
Week number of 7/1/2006: 1

as dumped by

static void
dump (int d, int m, int y)
{
	GDate *gd = g_date_new ();
	g_date_set_dmy (gd, d, m, y);
	printf ("Week number of %d/%d/%d: %d\n",
		d, m, y,
		g_date_get_iso8601_week_of_year (gd));
	g_date_free (gd);
}

So there you have it: all weeks are seven days long (what a concept!)
and go from Monday to Sunday. The first week of 2006 starts on the second day of January 2006.

[*] Thus assuming that no-one in Africa, for example, has been
stupid
enough to invent their own date magic for no good reason.

Optimizing g_utf8_offset_to_pointer

Do not bother.

No, really. That function, regardless of implementation, basically
screams “if you call me often, your program will exhibit quadratic
or worse time behaviour, so do not do that.”

It is fine for occasional use, but then you would not care about its
efficiency.