mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
move string_is_affirmative() into libpbd
git-svn-id: svn://localhost/ardour2/branches/3.0@11936 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
81a76cc0fd
commit
d6051c9953
11 changed files with 54 additions and 27 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include <list>
|
||||
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/convert.h"
|
||||
|
||||
#include <gtkmm2ext/utils.h>
|
||||
#include <gtkmm2ext/selector.h>
|
||||
|
|
@ -74,14 +75,14 @@ bool
|
|||
AxisView::marked_for_display () const
|
||||
{
|
||||
string const v = gui_property ("visible");
|
||||
return (v == "" || string_is_affirmative (v));
|
||||
return (v == "" || PBD::string_is_affirmative (v));
|
||||
}
|
||||
|
||||
bool
|
||||
AxisView::set_marked_for_display (bool yn)
|
||||
{
|
||||
string const v = gui_property ("visible");
|
||||
if (v == "" || yn != string_is_affirmative (v)) {
|
||||
if (v == "" || yn != PBD::string_is_affirmative (v)) {
|
||||
set_gui_property ("visible", yn);
|
||||
return true; // things changed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
#include <gtkmm/window.h>
|
||||
#include "window_proxy.h"
|
||||
|
||||
#include "pbd/convert.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -57,7 +60,7 @@ WindowProxyBase::WindowProxyBase (string const & name, XMLNode const * node)
|
|||
XMLProperty* prop;
|
||||
|
||||
if ((prop = (*i)->property (X_("visible"))) != 0) {
|
||||
_visible = string_is_affirmative (prop->value ());
|
||||
_visible = PBD::string_is_affirmative (prop->value ());
|
||||
}
|
||||
|
||||
if ((prop = (*i)->property (X_("x-off"))) != 0) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <sstream>
|
||||
|
||||
#include "pbd/xml++.h"
|
||||
#include "pbd/convert.h"
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/utils.h"
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ class ConfigVariable<bool> : public ConfigVariableBase
|
|||
}
|
||||
|
||||
void set_from_string (std::string const & s) {
|
||||
value = string_is_affirmative (s);
|
||||
value = PBD::string_is_affirmative (s);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@
|
|||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
bool string_is_affirmative (const std::string&);
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/data_type.h"
|
||||
#include "ardour/dB.h"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "pbd/error.h"
|
||||
#include "pbd/failed_constructor.h"
|
||||
#include "pbd/pthread_utils.h"
|
||||
#include "pbd/convert.h"
|
||||
|
||||
#include "midi++/port.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "pbd/enumwriter.h"
|
||||
#include "pbd/xml++.h"
|
||||
#include "pbd/convert.h"
|
||||
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/mute_master.h"
|
||||
|
|
@ -144,7 +145,7 @@ MuteMaster::set_state (const XMLNode& node, int /*version*/)
|
|||
}
|
||||
|
||||
if ((prop = node.property ("muted")) != 0) {
|
||||
_muted_by_self = string_is_affirmative (prop->value());
|
||||
_muted_by_self = PBD::string_is_affirmative (prop->value());
|
||||
} else {
|
||||
_muted_by_self = (_mute_point != MutePoint (0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -627,26 +627,6 @@ bool_as_string (bool yn)
|
|||
return (yn ? "yes" : "no");
|
||||
}
|
||||
|
||||
bool
|
||||
string_is_affirmative (const std::string& str)
|
||||
{
|
||||
/* to be used only with XML data - not intended to handle user input */
|
||||
|
||||
if (str.empty ()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* the use of g_strncasecmp() is solely to get around issues with
|
||||
* charsets posed by trying to use C++ for the same
|
||||
* comparison. switching a std::string to its lower- or upper-case
|
||||
* version has several issues, but handled by default
|
||||
* in the way we desire when doing it in C.
|
||||
*/
|
||||
|
||||
return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length())) ||
|
||||
(!g_strncasecmp(str.c_str(), "true", str.length()));
|
||||
}
|
||||
|
||||
const char*
|
||||
native_header_format_extension (HeaderFormat hf, const DataType& type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -255,6 +255,26 @@ strings_equal_ignore_case (const string& a, const string& b)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
string_is_affirmative (const std::string& str)
|
||||
{
|
||||
/* to be used only with XML data - not intended to handle user input */
|
||||
|
||||
if (str.empty ()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* the use of g_strncasecmp() is solely to get around issues with
|
||||
* charsets posed by trying to use C++ for the same
|
||||
* comparison. switching a std::string to its lower- or upper-case
|
||||
* version has several issues, but handled by default
|
||||
* in the way we desire when doing it in C.
|
||||
*/
|
||||
|
||||
return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length())) ||
|
||||
(!g_strncasecmp(str.c_str(), "true", str.length()));
|
||||
}
|
||||
|
||||
/** A wrapper for dgettext that takes a msgid of the form Context|Text.
|
||||
* If Context|Text is translated, the translation is returned, otherwise
|
||||
* just Text is returned. Useful for getting translations of words or phrases
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ to_string (T t, std::ios_base & (*f)(std::ios_base&))
|
|||
return oss.str();
|
||||
}
|
||||
|
||||
bool string_is_affirmative (const std::string&);
|
||||
|
||||
const char *
|
||||
sgettext (const char *, const char *);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
Copyright (C) 2006,2007 John Anderson
|
||||
Copyright (C) 2012 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __ardour_mackie_control_protocol_pot_h__
|
||||
#define __ardour_mackie_control_protocol_pot_h__
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ def build(bld):
|
|||
obj.source = '''
|
||||
button.cc
|
||||
controls.cc
|
||||
device_info.cc
|
||||
fader.cc
|
||||
gui.cc
|
||||
interface.cc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue