--- config.h.in 2006-02-05 21:42:27.000000000 -0500 +++ config.h.in 2006-02-05 21:48:46.000000000 -0500 @@ -151,4 +151,7 @@ #undef HAVE_PANGO_X #undef HAVE_PANGO_XFT +/* Define if you have glib */ +#undef HAVE_GLIB + #endif /* SAWMILL_CONFIG_H */ --- configure.in 2006-02-05 21:42:27.000000000 -0500 +++ configure.in 2006-02-05 21:48:46.000000000 -0500 @@ -127,7 +127,14 @@ CPPFLAGS="${_cppflags}" -dnl Checks for pango +dnl Checks for pango. Disabled by default + +AC_ARG_WITH(pango, + [ --with-pango Enable pango font rendering engine + --without-pango], [], + [with_pango=no]) + +if test "${with_pango}" = "yes"; then PKG_CHECK_MODULES(PANGO, pango >= 1.2.0, [if $PKG_CONFIG --exists pangoxft; then AC_DEFINE(HAVE_PANGO_XFT, 1) @@ -142,6 +149,7 @@ PANGO_LIBS=`$PKG_CONFIG --libs $PANGO_MODULES` PANGO_CFLAGS=`$PKG_CONFIG --cflags $PANGO_MODULES` fi], [: nothing]) +fi dnl Check for librep AM_PATH_REP(0.14) @@ -247,6 +255,17 @@ AC_DEFINE(HAVE_ESD) fi +AC_ARG_WITH(glib, + [ --with-glib Use glib for locale -> utf8 + --without-glib], [], [with_glib=yes]) + +if test "$with_glib" = "yes"; then + PKG_CHECK_MODULES(GLIB, glib-2.0 > 2.0) + AC_SUBST(GLIB_LIBS) + AC_SUBST(GLIB_CFLAGS) + AC_DEFINE(HAVE_GLIB) +fi + AC_ARG_ENABLE(capplet, [ --enable-capplet Build the sawfish GNOME capplet [default] --disable-capplet Don't built the capplet], [], --- lisp/sawfish/wm/ext/beos-window-menu.jl 2006-02-05 21:42:27.000000000 -0500 +++ lisp/sawfish/wm/ext/beos-window-menu.jl 2006-02-05 21:49:07.000000000 -0500 @@ -25,6 +25,7 @@ (export beos-window-menu) (open rep + rep.regexp sawfish.wm.windows sawfish.wm.misc sawfish.wm.custom @@ -38,9 +39,16 @@ (define (abbreviate name #!optional len) (unless len (setq len 20)) - (if (> (length name) len) - (concat (substring name 0 len) "...") - name)) + (setq name (locale-to-utf8 name)) + (let ((namelen (length name))) + (let loop ((idx len)) + (cond ((>= idx namelen) + name) + ((string-match "[\200-\277]" (substring name idx (1+ idx))) + ;; move to utf-8 mbchar boundary + (loop (1+ idx))) + (t + (concat (substring name 0 idx) "...")))))) (define (make-label w) (let ((name (window-name w)) --- src/fonts.c 2006-02-05 21:42:27.000000000 -0500 +++ src/fonts.c 2006-02-05 21:49:22.000000000 -0500 @@ -42,14 +42,18 @@ #include #include +#ifdef HAVE_GLIB +# include +#endif + #ifdef HAVE_X11_XFT_XFT_H # include #else # undef HAVE_PANGO #endif + #ifdef HAVE_PANGO -# include # define PANGO_ENABLE_BACKEND # include # undef PANGO_ENABLE_BACKEND @@ -364,9 +368,22 @@ xft_measure (Lisp_Font *f, u_char *string, size_t length) { XGlyphInfo info; - - XftTextExtents8 (dpy, f->font, string, length, &info); - +#ifdef HAVE_GLIB + gsize r, w; + u_char *utf8str; + utf8str = g_locale_to_utf8 (string, length, &r, &w, NULL); + if (utf8str != NULL){ + string = utf8str; + length = w; + } + + XftTextExtentsUtf8 (dpy, f->font, string, length, &info); + + g_free(utf8str); +#else + XftTextExtents8 (dpy, f->font, string, length, &info); +#endif + return info.xOff; } @@ -375,6 +392,10 @@ Window id, GC gc, Lisp_Color *fg, int x, int y) { static XftDraw *draw; +#ifdef HAVE_GLIB + gsize r, w; + u_char *utf8str; +#endif XftColor xft_color; @@ -389,8 +410,21 @@ xft_color.color.blue = fg->blue; xft_color.color.alpha = fg->alpha; +#ifdef HAVE_GLIB + utf8str = g_locale_to_utf8 (string, length, &r, &w, NULL); + if (utf8str != NULL){ + string = utf8str; + length = w; + } + + XftDrawStringUtf8 (draw, &xft_color, f->font, + x, y, string, length); + g_free(utf8str); +#else XftDrawString8 (draw, &xft_color, f->font, x, y, string, length); +#endif + } static const Lisp_Font_Class xft_class = { --- src/functions.c 2006-02-05 21:42:27.000000000 -0500 +++ src/functions.c 2006-02-05 21:49:27.000000000 -0500 @@ -43,7 +43,9 @@ #include "sawmill.h" #include #include - +#ifdef HAVE_GLIB +#include +#endif /* Number of outstanding server grabs made; only when this is zero is the server ungrabbed. */ static int server_grabs; @@ -1340,6 +1342,37 @@ } } +DEFUN("locale-to-utf8", Flocale_to_utf8, Slocale_to_utf8, + (repv src), rep_Subr1) +{ +#ifdef HAVE_GLIB + gsize r, w; + u_char *utf8str; + repv res; + + rep_DECLARE1 (src, rep_STRINGP); + + utf8str = g_locale_to_utf8 (rep_STR (src), -1, &r, &w, NULL); + if (utf8str == NULL) { + return src; + } + + res = rep_make_string (w + 1); + if (!res) + return rep_mem_error (); + + strncpy (rep_STR (res), utf8str, w); + rep_STR (res)[w] = '\0'; + + g_free (utf8str); + return res; +#else + return src; +#endif +} + + + /* initialisation */ @@ -1380,6 +1413,7 @@ rep_ADD_SUBR(Shead_dimensions); rep_ADD_SUBR(Shead_offset); rep_ADD_SUBR(Sdisplay_message); + rep_ADD_SUBR(Slocale_to_utf8); rep_pop_structure (tem); tem = rep_push_structure ("sawfish.wm.events"); --- src/Makefile.in 2006-02-05 21:42:27.000000000 -0500 +++ src/Makefile.in 2006-02-05 21:53:35.000000000 -0500 @@ -38,14 +38,14 @@ sawfish/wm/util/play-sample.la DL_DIRS = sawfish/wm/util -override CFLAGS := $(CFLAGS) $(REP_CFLAGS) $(IMAGE_CFLAGS) $(X11_CFLAGS) $(ESD_CFLAGS) $(PANGO_CFLAGS) +override CFLAGS := $(CFLAGS) $(REP_CFLAGS) $(IMAGE_CFLAGS) $(X11_CFLAGS) $(ESD_CFLAGS) $(PANGO_CFLAGS) $(GLIB_CFLAGS) all : sawfish libclient.o $(DL_OBJS) .libexec gtk-style sawfish : $(OBJS) $(LIBOBJS) $(rep_LIBTOOL) --mode=link --tag=CC $(CC) -export-dynamic $(LDFLAGS) \ -o sawfish $(OBJS) $(LIBOBJS) $(REP_LIBS) $(PANGO_LIBS) \ - $(IMAGE_LIBS) $(X11_LIBS) $(EXTRA_X11_LIBS) $(LIBS) + $(IMAGE_LIBS) $(X11_LIBS) $(EXTRA_X11_LIBS) $(LIBS) $(GLIB_LIBS) %.la : %.lo $(rep_DL_LD) $(LDFLAGS) -o $@ $<