Browse Source

Separate CTranslationInterface from CClientUIInterface

0.13
Jorge Timón 10 years ago
parent
commit
b74dcb3b4a
  1. 2
      src/bitcoin-cli.cpp
  2. 2
      src/bitcoin-tx.cpp
  3. 1
      src/bitcoind.cpp
  4. 2
      src/init.cpp
  5. 2
      src/qt/bitcoin.cpp
  6. 1
      src/qt/transactiondesc.cpp
  7. 1
      src/rpcclient.cpp
  8. 2
      src/test/test_bitcoin.cpp
  9. 13
      src/ui_interface.h
  10. 1
      src/util.cpp
  11. 20
      src/util.h

2
src/bitcoin-cli.cpp

@ -12,8 +12,6 @@
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#define _(x) std::string(x) /* Keep the _() around in case gettext or such will be used later to translate non-UI */
using namespace std; using namespace std;
using namespace json_spirit; using namespace json_spirit;

2
src/bitcoin-tx.cpp

@ -11,7 +11,6 @@
#include "keystore.h" #include "keystore.h"
#include "script/script.h" #include "script/script.h"
#include "script/sign.h" #include "script/sign.h"
#include "ui_interface.h" // for _(...)
#include "univalue/univalue.h" #include "univalue/univalue.h"
#include "util.h" #include "util.h"
#include "utilstrencodings.h" #include "utilstrencodings.h"
@ -26,7 +25,6 @@ using namespace std;
static bool fCreateBlank; static bool fCreateBlank;
static map<string,UniValue> registers; static map<string,UniValue> registers;
CClientUIInterface uiInterface;
static bool AppInitRawTx(int argc, char* argv[]) static bool AppInitRawTx(int argc, char* argv[])
{ {

1
src/bitcoind.cpp

@ -8,7 +8,6 @@
#include "init.h" #include "init.h"
#include "main.h" #include "main.h"
#include "noui.h" #include "noui.h"
#include "ui_interface.h"
#include "util.h" #include "util.h"
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>

2
src/init.cpp

@ -68,7 +68,7 @@ enum BindFlags {
}; };
static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat"; static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
CClientUIInterface uiInterface; CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //

2
src/qt/bitcoin.cpp

@ -533,7 +533,7 @@ int main(int argc, char *argv[])
// Now that QSettings are accessible, initialize translations // Now that QSettings are accessible, initialize translations
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator; QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator); initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
uiInterface.Translate.connect(Translate); translationInterface.Translate.connect(Translate);
// Show help message immediately after parsing command-line options (for "-lang") and setting locale, // Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen. // but before showing splash screen.

1
src/qt/transactiondesc.cpp

@ -14,7 +14,6 @@
#include "main.h" #include "main.h"
#include "script/script.h" #include "script/script.h"
#include "timedata.h" #include "timedata.h"
#include "ui_interface.h"
#include "util.h" #include "util.h"
#include "wallet/wallet.h" #include "wallet/wallet.h"

1
src/rpcclient.cpp

@ -7,7 +7,6 @@
#include "rpcprotocol.h" #include "rpcprotocol.h"
#include "util.h" #include "util.h"
#include "ui_interface.h"
#include <set> #include <set>
#include <stdint.h> #include <stdint.h>

2
src/test/test_bitcoin.cpp

@ -20,7 +20,7 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
CClientUIInterface uiInterface; CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h
CWallet* pwalletMain; CWallet* pwalletMain;
extern bool fPrintToConsole; extern bool fPrintToConsole;

13
src/ui_interface.h

@ -78,9 +78,6 @@ public:
/** Progress message during initialization. */ /** Progress message during initialization. */
boost::signals2::signal<void (const std::string &message)> InitMessage; boost::signals2::signal<void (const std::string &message)> InitMessage;
/** Translate a message to the native language of the user. */
boost::signals2::signal<std::string (const char* psz)> Translate;
/** Number of network connections changed. */ /** Number of network connections changed. */
boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged; boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
@ -102,14 +99,4 @@ public:
extern CClientUIInterface uiInterface; extern CClientUIInterface uiInterface;
/**
* Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
* If no translation slot is registered, nothing is returned, and simply return the input.
*/
inline std::string _(const char* psz)
{
boost::optional<std::string> rv = uiInterface.Translate(psz);
return rv ? (*rv) : psz;
}
#endif // BITCOIN_UI_INTERFACE_H #endif // BITCOIN_UI_INTERFACE_H

1
src/util.cpp

@ -104,6 +104,7 @@ string strMiscWarning;
bool fLogTimestamps = false; bool fLogTimestamps = false;
bool fLogIPs = false; bool fLogIPs = false;
volatile bool fReopenDebugLog = false; volatile bool fReopenDebugLog = false;
CTranslationInterface translationInterface;
/** Init OpenSSL library multithreading support */ /** Init OpenSSL library multithreading support */
static CCriticalSection** ppmutexOpenSSL; static CCriticalSection** ppmutexOpenSSL;

20
src/util.h

@ -25,8 +25,17 @@
#include <vector> #include <vector>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/thread/exceptions.hpp> #include <boost/thread/exceptions.hpp>
/** Signals for translation. */
class CTranslationInterface
{
public:
/** Translate a message to the native language of the user. */
boost::signals2::signal<std::string (const char* psz)> Translate;
};
extern std::map<std::string, std::string> mapArgs; extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs; extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug; extern bool fDebug;
@ -37,6 +46,17 @@ extern std::string strMiscWarning;
extern bool fLogTimestamps; extern bool fLogTimestamps;
extern bool fLogIPs; extern bool fLogIPs;
extern volatile bool fReopenDebugLog; extern volatile bool fReopenDebugLog;
extern CTranslationInterface translationInterface;
/**
* Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
* If no translation slot is registered, nothing is returned, and simply return the input.
*/
inline std::string _(const char* psz)
{
boost::optional<std::string> rv = translationInterface.Translate(psz);
return rv ? (*rv) : psz;
}
void SetupEnvironment(); void SetupEnvironment();

Loading…
Cancel
Save