From 02a21a4a3f92c0740a4210bbe569ab197df3f8bc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 23 Jan 2013 20:45:32 +0000 Subject: make trnslation option actually toggle back and forth git-svn-id: svn://localhost/ardour2/branches/3.0@13983 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/globals.cc | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index b21f3038bb..4c91956ffd 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -480,28 +480,46 @@ ARDOUR::translation_enable_path () bool ARDOUR::translations_are_enabled () { - if (Glib::file_test (translation_enable_path(), Glib::FILE_TEST_EXISTS)) { - return true; - } + int fd = ::open (ARDOUR::translation_enable_path().c_str(), O_RDONLY); - return translate_by_default; + if (fd < 0) { + return translate_by_default; + } + + char c; + bool ret = false; + + if (::read (fd, &c, 1) == 1 && c == '1') { + ret = true; + } + + ::close (fd); + + return ret; } bool ARDOUR::set_translations_enabled (bool yn) { string i18n_enabler = ARDOUR::translation_enable_path(); + int fd = ::open (i18n_enabler.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0644); - if (yn) { - int fd = ::open (i18n_enabler.c_str(), O_RDONLY|O_CREAT, 0644); - if (fd >= 0) { - close (fd); - return true; - } + if (fd < 0) { return false; - } + } + + char c; + + if (yn) { + c = '1'; + } else { + c = '0'; + } + + ::write (fd, &c, 1); + ::close (fd); - return unlink (i18n_enabler.c_str()) == 0; + return true; } -- cgit v1.2.3