Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2006 03:53:41 +0200
From:      Jean-Yves Lefort <jylefort@FreeBSD.org>
To:        Joe Marcus Clarke <marcus@marcuscom.com>
Cc:        gnome@freebsd.org, lofi@freebsd.org
Subject:   Re: How to change the sort order in gtk2/gnome file dialogs?
Message-ID:  <20060719035341.0bc44958.jylefort@FreeBSD.org>
In-Reply-To: <1153269484.56053.146.camel@shumai.marcuscom.com>
References:  <200607180145.14402.lofi@freebsd.org> <1153183811.40886.1.camel@shumai.marcuscom.com> <200607182059.52274.lofi@freebsd.org> <1153269484.56053.146.camel@shumai.marcuscom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--Signature=_Wed__19_Jul_2006_03_53_41_+0200_vzwQI+NeHEN8/JN+
Content-Type: multipart/mixed;
	boundary="Multipart=_Wed__19_Jul_2006_03_53_41_+0200_cCa6GAf0pHTs9TXC"


--Multipart=_Wed__19_Jul_2006_03_53_41_+0200_cCa6GAf0pHTs9TXC
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, 18 Jul 2006 20:38:04 -0400
Joe Marcus Clarke <marcus@marcuscom.com> wrote:

> On Tue, 2006-07-18 at 20:59 +0200, Michael Nottebrock wrote:
> > On Tuesday, 18. July 2006 02:50, Joe Marcus Clarke wrote:
> >=20
> > > This was discussed a while back as I recall, and the conclusion was t=
hat
> > > since FreeBSD didn't honor LC_COLLATE, that there was no way to change
> > > the sort order.  I may be wrong on the conclusion, but you could try
> > > hunting down LC_COLLATE in the archive, and see what comes up.
> >=20
> > Surely you aren't saying every GNOME user on FreeBSD has to put up with=
=20
> > case-sensitively sorted lists? Isn't there at least a gconf key I could=
=20
> > modify or something? :(
>=20
> GConf is outside of GTK+, but there's no such key of which I am aware.
> As I said, I recall this problem being tied to LC_COLLATE, and thus
> nothing that can be easily done.

The attached glib20 patch copes with the FreeBSD libc deficiencies (no
collation for wide char locales, see BUGS in wcscoll(3)) by using
devel/icu for string collation. If there are no objections I'll add it.

--=20
Jean-Yves Lefort

jylefort@FreeBSD.org
http://lefort.be.eu.org/

--Multipart=_Wed__19_Jul_2006_03_53_41_+0200_cCa6GAf0pHTs9TXC
Content-Type: text/plain;
 name="glib-icu.diff"
Content-Disposition: attachment;
 filename="glib-icu.diff"
Content-Transfer-Encoding: quoted-printable

diff -ruN /usr/ports/devel/glib20/Makefile glib20/Makefile
--- /usr/ports/devel/glib20/Makefile	Thu Jun  1 00:18:43 2006
+++ glib20/Makefile	Wed Jul 19 01:17:20 2006
@@ -8,7 +8,7 @@
=20
 PORTNAME=3D	glib
 PORTVERSION=3D	2.10.3
-PORTREVISION?=3D	0
+PORTREVISION?=3D	1
 CATEGORIES=3D	devel
 MASTER_SITES=3D	${MASTER_SITE_GNOME:S,%SUBDIR%,sources/${PORTNAME}/2.10,} \
 		ftp://ftp.gtk.org/pub/gtk/v${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}/ \
@@ -27,6 +27,8 @@
 USE_BZIP2=3D	yes
=20
 .if !defined(REFERENCE_PORT)
+
+LIB_DEPENDS=3D	icui18n:${PORTSDIR}/devel/icu
=20
 USE_GETTEXT=3D	yes
 USE_AUTOTOOLS=3D	libtool:15
diff -ruN /usr/ports/devel/glib20/files/patch-glib_Makefile.in glib20/files=
/patch-glib_Makefile.in
--- /usr/ports/devel/glib20/files/patch-glib_Makefile.in	Thu Jan  1 01:00:0=
0 1970
+++ glib20/files/patch-glib_Makefile.in	Wed Jul 19 01:10:38 2006
@@ -0,0 +1,11 @@
+--- glib/Makefile.in.orig	Wed Jul 19 01:08:13 2006
++++ glib/Makefile.in	Wed Jul 19 01:09:10 2006
+@@ -130,7 +130,7 @@
+ INSTALL_STRIP_PROGRAM =3D @INSTALL_STRIP_PROGRAM@
+ INSTOBJEXT =3D @INSTOBJEXT@
+ INTLLIBS =3D @INTLLIBS@
+-LDFLAGS =3D @LDFLAGS@
++LDFLAGS =3D @LDFLAGS@ -licui18n
+ LIBOBJS =3D @LIBOBJS@
+ LIBS =3D @LIBS@
+ LIBTOOL =3D @LIBTOOL@
diff -ruN /usr/ports/devel/glib20/files/patch-glib_gunicollate.c glib20/fil=
es/patch-glib_gunicollate.c
--- /usr/ports/devel/glib20/files/patch-glib_gunicollate.c	Thu Jan  1 01:00=
:00 1970
+++ glib20/files/patch-glib_gunicollate.c	Wed Jul 19 01:07:23 2006
@@ -0,0 +1,116 @@
+--- glib/gunicollate.c.orig	Sun Nov 27 21:15:41 2005
++++ glib/gunicollate.c	Wed Jul 19 01:06:32 2006
+@@ -26,10 +26,57 @@
+ #include <wchar.h>
+ #endif
+=20
++#include <unicode/umachine.h>
++#include <unicode/ustring.h>
++#include <unicode/ucol.h>
++
+ #include "glib.h"
+ #include "gunicodeprivate.h"
+ #include "galias.h"
+=20
++static gboolean icu_collator_initialized =3D FALSE;
++static UCollator *icu_collator =3D NULL;
++G_LOCK_DEFINE_STATIC(icu_collator);
++
++static void
++init_icu_collator (void)
++{
++  G_LOCK(icu_collator);
++  if (! icu_collator_initialized)
++    {
++      UErrorCode error =3D U_ZERO_ERROR;
++
++      icu_collator =3D ucol_open(NULL, &error);
++      if (icu_collator =3D=3D NULL)
++	g_warning("unable to initialize the ICU collator (%s), FreeBSD collation=
 routines will be used", u_errorName(error));
++
++      icu_collator_initialized =3D TRUE;
++    }
++  G_UNLOCK(icu_collator);
++}
++
++static UChar *
++utf8_to_uchar (const char *str, int32_t len, int32_t *result_len)
++{
++  UErrorCode error =3D U_ZERO_ERROR;
++  UChar *result =3D NULL;
++
++  u_strFromUTF8(NULL, 0, result_len, str, len, &error);
++  if (error <=3D U_ZERO_ERROR || error =3D=3D U_BUFFER_OVERFLOW_ERROR)
++    {
++      error =3D U_ZERO_ERROR;
++      result =3D g_new(UChar, *result_len);
++      u_strFromUTF8(result, *result_len, NULL, str, len, &error);
++      if (error > U_ZERO_ERROR)
++	{
++	  g_free(result);
++	  result =3D NULL;
++	}
++    }
++
++  return result;
++}
++
+ /**
+  * g_utf8_collate:
+  * @str1: a UTF-8 encoded string
+@@ -76,6 +123,28 @@
+   g_return_val_if_fail (str1 !=3D NULL, 0);
+   g_return_val_if_fail (str2 !=3D NULL, 0);
+=20
++  init_icu_collator();
++  if (icu_collator !=3D NULL)
++    {
++      int32_t wstr1_len;
++      UChar *wstr1 =3D utf8_to_uchar(str1, -1, &wstr1_len);
++      if (wstr1 !=3D NULL)
++	{
++	  int32_t wstr2_len;
++	  UChar *wstr2 =3D utf8_to_uchar(str2, -1, &wstr2_len);
++	  if (wstr2 !=3D NULL)
++	    {
++	      result =3D ucol_strcoll(icu_collator, wstr1, wstr1_len, wstr2, wst=
r2_len);
++
++	      g_free(wstr1);
++	      g_free(wstr2);
++
++	      return result;
++	    }
++	  g_free(wstr1);
++	}
++    }
++
+   str1_norm =3D g_utf8_normalize (str1, -1, G_NORMALIZE_ALL_COMPOSE);
+   str2_norm =3D g_utf8_normalize (str2, -1, G_NORMALIZE_ALL_COMPOSE);
+=20
+@@ -217,6 +286,26 @@
+   gchar *str_norm;
+=20
+   g_return_val_if_fail (str !=3D NULL, NULL);
++
++  init_icu_collator();
++  if (icu_collator !=3D NULL)
++    {
++      int32_t wstr_len;
++      UChar *wstr =3D utf8_to_uchar(str, len, &wstr_len);
++      if (wstr !=3D NULL)
++	{
++	  uint8_t dummy;
++	  int32_t result_len;
++
++	  /* get size of result */
++	  result_len =3D ucol_getSortKey(icu_collator, wstr, wstr_len, &dummy, 1=
);
++
++	  result =3D g_new(char, result_len);
++	  ucol_getSortKey(icu_collator, wstr, wstr_len, result, result_len);
++
++	  return result;
++	}
++    }
+=20
+   str_norm =3D g_utf8_normalize (str, len, G_NORMALIZE_ALL_COMPOSE);
+=20

--Multipart=_Wed__19_Jul_2006_03_53_41_+0200_cCa6GAf0pHTs9TXC--

--Signature=_Wed__19_Jul_2006_03_53_41_+0200_vzwQI+NeHEN8/JN+
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (FreeBSD)

iD8DBQFEvZCsyzD7UaO4AGoRAug6AJ0Z2a4t3PNiIqTPo1RZidkuOEXhyACffphs
U/YZuv/W9p0Fta6/zKjLcVM=
=jEV7
-----END PGP SIGNATURE-----

--Signature=_Wed__19_Jul_2006_03_53_41_+0200_vzwQI+NeHEN8/JN+--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060719035341.0bc44958.jylefort>