24 |
#include "global.h" |
#include "global.h" |
25 |
#include "compat.h" |
#include "compat.h" |
26 |
|
|
27 |
|
std::string gig_encoding("CP1252"); |
28 |
|
|
29 |
|
Glib::ustring gig_to_utf8(const gig::String& gig_string) { |
30 |
|
return Glib::convert_with_fallback(gig_string, "UTF-8", gig_encoding, "?"); |
31 |
|
} |
32 |
|
|
33 |
|
gig::String gig_from_utf8(const Glib::ustring& utf8_string) { |
34 |
|
return Glib::convert_with_fallback(utf8_string, gig_encoding, "UTF-8", "?"); |
35 |
|
} |
36 |
|
|
37 |
|
|
38 |
namespace { |
namespace { |
39 |
const char* const controlChangeTexts[] = { |
const char* const controlChangeTexts[] = { |
40 |
_("none"), _("channelaftertouch"), _("velocity"), |
_("none"), _("channelaftertouch"), _("velocity"), |
344 |
entry.signal_changed().connect(sig_changed.make_slot()); |
entry.signal_changed().connect(sig_changed.make_slot()); |
345 |
} |
} |
346 |
|
|
347 |
|
gig::String StringEntry::get_value() const |
348 |
|
{ |
349 |
|
return gig_from_utf8(entry.get_text()); |
350 |
|
} |
351 |
|
|
352 |
|
void StringEntry::set_value(const gig::String& value) { |
353 |
|
entry.set_text(gig_to_utf8(value)); |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
StringEntryMultiLine::StringEntryMultiLine(const char* labelText) : |
StringEntryMultiLine::StringEntryMultiLine(const char* labelText) : |
358 |
LabelWidget(labelText, frame) |
LabelWidget(labelText, frame) |
359 |
{ |
{ |
368 |
Glib::ustring value = text_buffer->get_text(); |
Glib::ustring value = text_buffer->get_text(); |
369 |
for (int i = 0 ; (i = value.find("\x0a", i)) >= 0 ; i += 2) |
for (int i = 0 ; (i = value.find("\x0a", i)) >= 0 ; i += 2) |
370 |
value.replace(i, 1, "\x0d\x0a"); |
value.replace(i, 1, "\x0d\x0a"); |
371 |
return value; |
return gig_from_utf8(value); |
372 |
} |
} |
373 |
|
|
374 |
void StringEntryMultiLine::set_value(gig::String value) |
void StringEntryMultiLine::set_value(const gig::String& value) |
375 |
{ |
{ |
376 |
for (int i = 0 ; (i = value.find("\x0d\x0a", i, 2)) >= 0 ; i++) |
Glib::ustring text = gig_to_utf8(value); |
377 |
value.replace(i, 2, "\x0a"); |
for (int i = 0 ; (i = text.find("\x0d\x0a", i, 2)) >= 0 ; i++) |
378 |
text_buffer->set_text(value); |
text.replace(i, 2, "\x0a"); |
379 |
|
text_buffer->set_text(text); |
380 |
} |
} |
381 |
|
|
382 |
|
|