summaryrefslogtreecommitdiff
path: root/libs/ardour/globals.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-01-23 20:45:32 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2013-01-23 20:45:32 +0000
commit02a21a4a3f92c0740a4210bbe569ab197df3f8bc (patch)
tree4fc9f298a34e28a7cfedbb0be4f62e8242e04a60 /libs/ardour/globals.cc
parent80b11d93ee0f1d41e793a0cd652456f8e64d191a (diff)
make trnslation option actually toggle back and forth
git-svn-id: svn://localhost/ardour2/branches/3.0@13983 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/globals.cc')
-rw-r--r--libs/ardour/globals.cc42
1 files changed, 30 insertions, 12 deletions
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;
}