Changeset 174
- Timestamp:
- 11/12/06 21:28:57 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykoticon/trunk/bin/pykoticon
r172 r174 242 242 self.SetSizerAndFit(vsizer) 243 243 self.Layout() 244 self.Show(True)245 self.Raise()246 244 247 245 … … 314 312 _("About"), \ 315 313 wx.OK | wx.ICON_INFORMATION) 314 dialog.Raise() 316 315 dialog.ShowModal() 317 316 dialog.Destroy() … … 328 327 style |= wx.STAY_ON_TOP 329 328 dialog = wx.MessageDialog(self, message, caption, style) 329 dialog.Raise() 330 330 self.dialogAnswer = ((dialog.ShowModal() == wx.ID_NO) and "CANCEL") or "OK" 331 331 dialog.Destroy() … … 335 335 self.dialogAnswer = None 336 336 dialog = GenericInputDialog(self, wx.ID_ANY, labels, varnames, varvalues) 337 dialog.Raise() 337 338 retvalues = {} 338 339 if dialog.ShowModal() == wx.ID_OK : … … 415 416 if text is not None : 416 417 try : 417 # We don't necessarily trust the default charset, because 418 # xprint sends us titles in UTF-8 but CUPS gives us an ISO-8859-1 charset ! 419 # So we first try to see if the text is already in UTF-8 or not, and 420 # if it is, we delete characters which can't be converted to the user's charset, 421 # then convert back to UTF-8. PostgreSQL 7.3.x used to reject some unicode characters, 422 # this is fixed by the ugly line below : 423 return text.decode("UTF-8").encode(self.charset, "replace").decode(self.charset).encode("UTF-8", "replace") 418 return text.decode(self.charset).encode("UTF-8") 424 419 except (UnicodeError, AttributeError) : 425 420 try : 426 return text.decode(self.charset ).encode("UTF-8", "replace")421 return text.decode(self.charset, "replace").encode("UTF-8") 427 422 except (UnicodeError, AttributeError) : 428 423 try : … … 448 443 def main() : 449 444 """Program's entry point.""" 445 # locale stuff 450 446 try : 451 locale.setlocale(locale.LC_ALL, "")447 locale.setlocale(locale.LC_ALL, ("", None)) 452 448 except (locale.Error, IOError) : 453 sys.stderr.write("Problem while setting locale.\n") 449 locale.setlocale(locale.LC_ALL, None) 450 (language, charset) = locale.getlocale() 451 language = language or "C" 452 charset = charset or locale.getpreferredencoding() 453 454 # translation stuff 454 455 try : 455 gettext.install("pykoticon") 456 try : 457 trans = gettext.translation("pykoticon", languages=["%s.%s" % (language, charset)], codeset=charset) 458 except TypeError : # Python <2.4 459 trans = gettext.translation("pykoticon", languages=["%s.%s" % (language, charset)]) 460 trans.install() 456 461 except : 457 462 gettext.NullTranslations().install() 458 459 localecharset = None 460 try : 461 try : 462 localecharset = locale.nl_langinfo(locale.CODESET) 463 except AttributeError : 464 try : 465 localecharset = locale.getpreferredencoding() 466 except AttributeError : 467 try : 468 localecharset = locale.getlocale()[1] 469 localecharset = localecharset or locale.getdefaultlocale()[1] 470 except ValueError : 471 pass # Unknown locale, strange... 472 except locale.Error : 473 pass 474 charset = os.environ.get("CHARSET") or localecharset or "ISO-8859-15" 463 475 464 476 465 parser = optparse.OptionParser(usage="pykoticon [options] server1 [server2 ...]")