Mercurial > pidgin.yaz
changeset 28984:a18f421696dc
Fix showing umlauts etc. on non-utf8 locales.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 20 Nov 2009 21:45:44 +0000 |
parents | 8356e2f2486a |
children | 1a349e6a27da |
files | ChangeLog finch/libgnt/gntbox.c finch/libgnt/gntbutton.c finch/libgnt/gntcheckbox.c finch/libgnt/gntcombobox.c finch/libgnt/gntentry.c finch/libgnt/gntinternal.h finch/libgnt/gntlabel.c finch/libgnt/gntmain.c finch/libgnt/gntmenu.c finch/libgnt/gnttextview.c finch/libgnt/gnttree.c finch/libgnt/gntws.c |
diffstat | 13 files changed, 52 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Nov 20 16:46:58 2009 +0000 +++ b/ChangeLog Fri Nov 20 21:45:44 2009 +0000 @@ -58,6 +58,7 @@ * The TinyURL plugin now creates shorter URLs for long non-conversation URLs, e.g. URLs to open Inbox in Yahoo/MSN protocols, or the Yahoo Captcha when joining chat rooms. + * Fix displaying umlauts etc. in non-utf8 locale (fix in libgnt). Pidgin: * The userlist in a multiuser chat can be styled via gtkrc by using the
--- a/finch/libgnt/gntbox.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntbox.c Fri Nov 20 21:45:44 2009 +0000 @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" #include "gntbox.h" #include "gntstyle.h" #include "gntutils.h" @@ -90,7 +91,7 @@ else wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_TITLE_D)); mvwaddch(widget->window, 0, pos-1, ACS_RTEE | gnt_color_pair(GNT_COLOR_NORMAL)); - mvwaddstr(widget->window, 0, pos, title); + mvwaddstr(widget->window, 0, pos, C_(title)); mvwaddch(widget->window, 0, right, ACS_LTEE | gnt_color_pair(GNT_COLOR_NORMAL)); g_free(title); }
--- a/finch/libgnt/gntbutton.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntbutton.c Fri Nov 20 21:45:44 2009 +0000 @@ -23,6 +23,7 @@ #include <stdlib.h> #include <string.h> +#include "gntinternal.h" #include "gntbutton.h" #include "gntstyle.h" #include "gntutils.h" @@ -48,7 +49,7 @@ type = GNT_COLOR_NORMAL; wbkgdset(widget->window, '\0' | gnt_color_pair(type)); - mvwaddstr(widget->window, (small_button) ? 0 : 1, 2, button->priv->text); + mvwaddstr(widget->window, (small_button) ? 0 : 1, 2, C_(button->priv->text)); if (small_button) { type = GNT_COLOR_HIGHLIGHT; mvwchgat(widget->window, 0, 0, widget->priv.width, focus ? A_BOLD : A_REVERSE, type, NULL);
--- a/finch/libgnt/gntcheckbox.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntcheckbox.c Fri Nov 20 21:45:44 2009 +0000 @@ -51,7 +51,7 @@ mvwaddch(widget->window, 0, 2, ']'); wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_NORMAL)); - mvwaddstr(widget->window, 0, 4, (GNT_BUTTON(cb)->priv->text)); + mvwaddstr(widget->window, 0, 4, C_(GNT_BUTTON(cb)->priv->text)); wmove(widget->window, 0, 1); GNTDEBUG;
--- a/finch/libgnt/gntcombobox.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntcombobox.c Fri Nov 20 21:45:44 2009 +0000 @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" #include "gntbox.h" #include "gntcombobox.h" #include "gnttree.h" @@ -90,7 +91,7 @@ s = (char*)gnt_util_onscreen_width_to_pointer(text, widget->priv.width - 4, &len); *s = '\0'; - mvwaddstr(widget->window, 1, 1, text); + mvwaddstr(widget->window, 1, 1, C_(text)); whline(widget->window, ' ' | gnt_color_pair(type), widget->priv.width - 4 - len); mvwaddch(widget->window, 1, widget->priv.width - 3, ACS_VLINE | gnt_color_pair(GNT_COLOR_NORMAL)); mvwaddch(widget->window, 1, widget->priv.width - 2, ACS_DARROW | gnt_color_pair(GNT_COLOR_NORMAL));
--- a/finch/libgnt/gntentry.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntentry.c Fri Nov 20 21:45:44 2009 +0000 @@ -23,6 +23,7 @@ #include <ctype.h> #include <string.h> +#include "gntinternal.h" #include "gntbox.h" #include "gntentry.h" #include "gntmarshal.h" @@ -284,7 +285,7 @@ g_utf8_pointer_to_offset(entry->scroll, entry->end)); } else - mvwprintw(widget->window, 0, 0, "%s", entry->scroll); + mvwprintw(widget->window, 0, 0, "%s", C_(entry->scroll)); stop = gnt_util_onscreen_width(entry->scroll, entry->end); if (stop < widget->priv.width)
--- a/finch/libgnt/gntinternal.h Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntinternal.h Fri Nov 20 21:45:44 2009 +0000 @@ -19,6 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include <glib.h> #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "Gnt" @@ -31,3 +32,6 @@ # define gnt_warning g_warning #endif +extern int gnt_need_conversation_to_locale; +extern const char *C_(const char *x); +
--- a/finch/libgnt/gntlabel.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntlabel.c Fri Nov 20 21:45:44 2009 +0000 @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" #include "gntlabel.h" #include "gntutils.h" @@ -53,7 +54,7 @@ chtype flag = gnt_text_format_flag_to_chtype(label->flags); wbkgdset(widget->window, '\0' | flag); - mvwaddstr(widget->window, 0, 0, label->text); + mvwaddstr(widget->window, 0, 0, C_(label->text)); GNTDEBUG; }
--- a/finch/libgnt/gntmain.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntmain.c Fri Nov 20 21:45:44 2009 +0000 @@ -82,6 +82,8 @@ static GntWM *wm; static GntClipboard *clipboard; +int gnt_need_conversation_to_locale; + #define HOLDING_ESCAPE (escape_stuff.timer != 0) static struct { @@ -465,10 +467,12 @@ #ifdef NO_WIDECHAR ascii_only = TRUE; #else - if (locale && (strstr(locale, "UTF") || strstr(locale, "utf"))) + if (locale && (strstr(locale, "UTF") || strstr(locale, "utf"))) { ascii_only = FALSE; - else + } else { ascii_only = TRUE; + gnt_need_conversation_to_locale = TRUE; + } #endif initscr(); @@ -731,3 +735,24 @@ #endif } +const char *C_(const char *x) +{ + static char *c = NULL; + if (gnt_need_conversation_to_locale) { + GError *error = NULL; + g_free(c); + c = g_locale_from_utf8(x, -1, NULL, NULL, &error); + if (c == NULL || error) { + char *store = c; + c = NULL; + gnt_warning("Error: %s\n", error ? error->message : "(unknown)"); + g_error_free(error); + error = NULL; + g_free(c); + c = store; + } + return c ? c : x; + } else + return x; +} +
--- a/finch/libgnt/gntmenu.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntmenu.c Fri Nov 20 21:45:44 2009 +0000 @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" #include "gntmenu.h" #include "gntmenuitemcheck.h" @@ -92,7 +93,7 @@ item->priv.x = getcurx(widget->window) + widget->priv.x; item->priv.y = getcury(widget->window) + widget->priv.y + 1; wbkgdset(widget->window, type); - wprintw(widget->window, " %s ", item->text); + wprintw(widget->window, " %s ", C_(item->text)); } } else { org_draw(widget);
--- a/finch/libgnt/gnttextview.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gnttextview.c Fri Nov 20 21:45:44 2009 +0000 @@ -118,7 +118,7 @@ if (select_start && select_start < view->string->str + seg->start && select_end > view->string->str + seg->end) { fl |= A_REVERSE; wattrset(widget->window, fl); - wprintw(widget->window, "%s", (view->string->str + seg->start)); + wprintw(widget->window, "%s", C_(view->string->str + seg->start)); } else if (select_start && select_end && ((select_start >= view->string->str + seg->start && select_start <= view->string->str + seg->end) || (select_end <= view->string->str + seg->end && select_start <= view->string->str + seg->start))) { @@ -132,13 +132,13 @@ fl = seg->flags; str = g_strndup(cur, last - cur); wattrset(widget->window, fl); - waddstr(widget->window, str); + waddstr(widget->window, C_(str)); g_free(str); cur = g_utf8_next_char(cur); } } else { wattrset(widget->window, fl); - wprintw(widget->window, "%s", (view->string->str + seg->start)); + wprintw(widget->window, "%s", C_(view->string->str + seg->start)); } *end = back; }
--- a/finch/libgnt/gnttree.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gnttree.c Fri Nov 20 21:45:44 2009 +0000 @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" #include "gntmarshal.h" #include "gntstyle.h" #include "gnttree.h" @@ -549,7 +550,7 @@ } wbkgdset(widget->window, '\0' | attr); - mvwaddstr(widget->window, i, pos, str); + mvwaddstr(widget->window, i, pos, C_(str)); whline(widget->window, ' ', scrcol - wr); tree->bottom = row; g_free(str);
--- a/finch/libgnt/gntws.c Fri Nov 20 16:46:58 2009 +0000 +++ b/finch/libgnt/gntws.c Fri Nov 20 21:45:44 2009 +0000 @@ -1,5 +1,6 @@ #include <gmodule.h> +#include "gntinternal.h" #include "gntbox.h" #include "gntwidget.h" #include "gntwindow.h" @@ -73,7 +74,7 @@ else mvwhline(taskbar, 0, width * i, ' ' | gnt_color_pair(color), getmaxx(stdscr) - width * i); title = GNT_BOX(w)->title; - mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>"); + mvwprintw(taskbar, 0, width * i, "%s", title ? C_(title) : "<gnt>"); if (i) mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | gnt_color_pair(GNT_COLOR_NORMAL)); }