# HG changeset patch # User Sadrul Habib Chowdhury # Date 1157178290 0 # Node ID 64e28f46c6957d43c05c426d43ef794071e7540e # Parent eeca8be382a572a726b82d1ca877675cffdd76d9 [gaim-migrate @ 17125] This should fix the problem where multi-column characters would screw up a window-title. committer: Tailor Script diff -r eeca8be382a5 -r 64e28f46c695 configure.ac --- a/configure.ac Sat Sep 02 05:31:10 2006 +0000 +++ b/configure.ac Sat Sep 02 06:24:50 2006 +0000 @@ -820,6 +820,7 @@ fi AC_SUBST(GNT_LIBS) AM_CONDITIONAL(ENABLE_GNT, test "x$enable_gnt" = "xyes") +AC_CHECK_FUNC(wcwidth, [AC_DEFINE([HAVE_WCWIDTH], [1], [Define to 1 if you have wcwidth function.])]) dnl ####################################################################### dnl # Look for startup-notification, evolution integration, X-libraries, diff -r eeca8be382a5 -r 64e28f46c695 console/libgnt/configure.ac --- a/console/libgnt/configure.ac Sat Sep 02 05:31:10 2006 +0000 +++ b/console/libgnt/configure.ac Sat Sep 02 06:24:50 2006 +0000 @@ -198,6 +198,7 @@ AC_CHECK_HEADERS(sys/file.h sys/filio.h sys/ioctl.h sys/msgbuf.h) AC_CHECK_HEADERS(sys/select.h sys/uio.h sys/utsname.h sys/wait.h) AC_CHECK_HEADERS(termios.h) +AC_CHECK_FUNC(wcwidth, [AC_DEFINE([HAVE_WCWIDTH], [1], [Define to 1 if you have wcwidth function.])]) #AC_VAR_TIMEZONE_EXTERNALS AC_CHECK_LIB(ncursesw, initscr, , [AC_MSG_ERROR([ diff -r eeca8be382a5 -r 64e28f46c695 console/libgnt/gntbox.c --- a/console/libgnt/gntbox.c Sat Sep 02 05:31:10 2006 +0000 +++ b/console/libgnt/gntbox.c Sat Sep 02 06:24:50 2006 +0000 @@ -1,4 +1,5 @@ #include "gntbox.h" +#include "gntutils.h" #include @@ -28,26 +29,14 @@ get_title_thingies(GntBox *box, char *title, int *p, int *r) { GntWidget *widget = GNT_WIDGET(box); - int pos = g_utf8_strlen(title, -1), right; - - if (pos >= widget->priv.width - 4) - { - g_utf8_strncpy(title, title, widget->priv.width - 4); - pos = 2; - right = pos + g_utf8_strlen(title, -1); - } - else - { - /* XXX: Position of the title might be configurable */ - right = pos; - pos = (widget->priv.width - pos) / 2; - right += pos; - } - + int len; + char *end = gnt_util_onscreen_width_to_pointer(title, widget->priv.width - 4, &len); + if (p) - *p = pos; + *p = (widget->priv.width - len) / 2; if (r) - *r = right; + *r = (widget->priv.width + len) / 2; + *end = '\0'; } static void diff -r eeca8be382a5 -r 64e28f46c695 console/libgnt/gntutils.c --- a/console/libgnt/gntutils.c Sat Sep 02 05:31:10 2006 +0000 +++ b/console/libgnt/gntutils.c Sat Sep 02 06:24:50 2006 +0000 @@ -4,7 +4,9 @@ #include #include -#ifndef __USE_XOPEN +#include "config.h" + +#ifndef HAVE_WCWIDTH #define wcwidth(X) 1 #endif