Fix copy and paste text encoding in GTK frontend

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13238 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Spray 2006-02-14 14:49:41 +00:00
parent 42843b1c02
commit a50e83ea38
2 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,8 @@
Now I can type Schrödinger.
* codeConvert.h, Makefile.am: Remove codeConvert.h, it's
no longer used.
* GWorkArea.C: fix copy and paste text encoding. Now
I can copy and paste Schrödinger.
2006-02-13 John Spray <spray@lyx.org>
* ghelpers.C: implement Gtk::IconTheme stuff for getting

View File

@ -519,20 +519,26 @@ void GWorkArea::haveSelection(bool toHave) const
}
// ENCODING: Gtk::Clipboard returns UTF-8, we assume that the backend
// wants ISO-8859-1 and convert it to that.
string const GWorkArea::getClipboard() const
{
Glib::RefPtr<Gtk::Clipboard> clipboard =
Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
return Glib::locale_from_utf8(clipboard->wait_for_text());
return Glib::convert_with_fallback(
clipboard->wait_for_text(), "ISO-8859-1", "UTF-8");
}
// ENCODING: we assume that the backend passes us ISO-8859-1 and
// convert from that to UTF-8 before passing to GTK
void GWorkArea::putClipboard(string const & str) const
{
Glib::RefPtr<Gtk::Clipboard> clipboard =
Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
clipboard->set_text(Glib::locale_to_utf8(str));
clipboard->set_text(Glib::convert(str, "UTF-8", "ISO-8859-1"));
}
} // namespace frontend
} // namespace lyx