Mercurial > pidgin
diff console/libgnt/gntbox.c @ 14417:64e28f46c695
[gaim-migrate @ 17125]
This should fix the problem where multi-column characters would screw up
a window-title.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 02 Sep 2006 06:24:50 +0000 |
parents | 9e9699792bb9 |
children | c4a32405af68 |
line wrap: on
line diff
--- 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 <string.h> @@ -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