linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04573
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2618: customizable country format
------------------------------------------------------------
revno: 2618
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2011-09-30 13:59:16 +0200
message:
customizable country format
modified:
dcpp/GeoIP.cpp
dcpp/SettingsManager.cpp
dcpp/SettingsManager.h
help/settings_appearance.html
win32/AppearancePage.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/GeoIP.cpp'
--- dcpp/GeoIP.cpp 2011-09-28 17:00:17 +0000
+++ dcpp/GeoIP.cpp 2011-09-30 11:59:16 +0000
@@ -21,6 +21,7 @@
#include "File.h"
#include "format.h"
+#include "SettingsManager.h"
#include "Util.h"
#include "ZUtils.h"
@@ -52,23 +53,21 @@
}
}
+namespace { string forwardRet(const char* ret) { return ret ? ret : Util::emptyString; } }
+
string GeoIP::getCountry(const string& ip) const {
if(geo) {
auto id = (v6() ? GeoIP_id_by_addr_v6 : GeoIP_id_by_addr)(geo, ip.c_str());
if(id > 0) {
- auto code = GeoIP_code_by_id(id);
- auto name = GeoIP_country_name_by_id(geo, id);
-
- if(code && name)
- return str(F_("%1% - %2%") % code % name);
-
- if(code && !name)
- return code;
-
- if(name && !code)
- return name;
+ ParamMap params;
+
+ params["2code"] = [id] { return forwardRet(GeoIP_code_by_id(id)); };
+ params["3code"] = [id] { return forwardRet(GeoIP_code3_by_id(id)); };
+ params["name"] = [this, id] { return forwardRet(GeoIP_country_name_by_id(geo, id)); };
+
+ return Util::formatParams(SETTING(COUNTRY_FORMAT), params);
}
}
=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp 2011-08-11 13:02:19 +0000
+++ dcpp/SettingsManager.cpp 2011-09-30 11:59:16 +0000
@@ -45,7 +45,7 @@
"UsersFrameOrder", "UsersFrameWidths", "HttpProxy", "LogDirectory", "LogFormatPostDownload",
"LogFormatPostFinishedDownload", "LogFormatPostUpload", "LogFormatMainChat", "LogFormatPrivateChat",
"TempDownloadDirectory", "BindAddress", "BindAddress6", "SocksServer", "SocksUser", "SocksPassword", "ConfigVersion",
- "DefaultAwayMessage", "TimeStampsFormat", "ADLSearchFrameOrder", "ADLSearchFrameWidths",
+ "DefaultAwayMessage", "TimeStampsFormat", "CountryFormat", "ADLSearchFrameOrder", "ADLSearchFrameWidths",
"CID", "SpyFrameWidths", "SpyFrameOrder", "LogFileMainChat", "LogFilePrivateChat",
"LogFileStatus", "LogFileUpload", "LogFileDownload", "LogFileFinishedDownload", "LogFileSystem",
"LogFormatSystem", "LogFormatStatus", "DirectoryListingFrameOrder", "DirectoryListingFrameWidths",
@@ -203,6 +203,7 @@
setDefault(AUTO_AWAY, false);
setDefault(DEFAULT_AWAY_MESSAGE, "I'm away. State your business and I might answer later if you're lucky.");
setDefault(TIME_STAMPS_FORMAT, "%H:%M");
+ setDefault(COUNTRY_FORMAT, "%[2code] - %[name]");
setDefault(MAX_COMPRESSION, 6);
setDefault(NO_AWAYMSG_TO_BOTS, true);
setDefault(SKIP_ZERO_BYTE, false);
=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h 2011-08-11 13:02:19 +0000
+++ dcpp/SettingsManager.h 2011-09-30 11:59:16 +0000
@@ -65,7 +65,7 @@
USERSFRAME_ORDER, USERSFRAME_WIDTHS, HTTP_PROXY, LOG_DIRECTORY, LOG_FORMAT_POST_DOWNLOAD,
LOG_FORMAT_POST_FINISHED_DOWNLOAD, LOG_FORMAT_POST_UPLOAD, LOG_FORMAT_MAIN_CHAT, LOG_FORMAT_PRIVATE_CHAT,
TEMP_DOWNLOAD_DIRECTORY, BIND_ADDRESS, BIND_ADDRESS6, SOCKS_SERVER, SOCKS_USER, SOCKS_PASSWORD, CONFIG_VERSION,
- DEFAULT_AWAY_MESSAGE, TIME_STAMPS_FORMAT, ADLSEARCHFRAME_ORDER, ADLSEARCHFRAME_WIDTHS,
+ DEFAULT_AWAY_MESSAGE, TIME_STAMPS_FORMAT, COUNTRY_FORMAT, ADLSEARCHFRAME_ORDER, ADLSEARCHFRAME_WIDTHS,
PRIVATE_ID, SPYFRAME_WIDTHS, SPYFRAME_ORDER, LOG_FILE_MAIN_CHAT,
LOG_FILE_PRIVATE_CHAT, LOG_FILE_STATUS, LOG_FILE_UPLOAD, LOG_FILE_DOWNLOAD, LOG_FILE_FINISHED_DOWNLOAD,
LOG_FILE_SYSTEM, LOG_FORMAT_SYSTEM, LOG_FORMAT_STATUS, DIRECTORYLISTINGFRAME_ORDER, DIRECTORYLISTINGFRAME_WIDTHS,
=== modified file 'help/settings_appearance.html'
--- help/settings_appearance.html 2011-09-23 11:47:15 +0000
+++ help/settings_appearance.html 2011-09-30 11:59:16 +0000
@@ -26,8 +26,7 @@
<dd cshelp="IDH_SETTINGS_APPEARANCE_TIME_STAMPS">This option will show time stamps on chat lined in newly opened
hubs. In order to show them in an already open hub, use the <a
href="chat_commands.html#ts">/ts chat command</a>. To customize the
-format of the time stamps, see the <a href="#set_timestamps">Set
-Timestamps</a> option below.</dd>
+format of the time stamps, see the <a href="#timestamp_format">Timestamp format</a> option below.</dd>
<dt id="viewstatus">View status messages in main chat</dt>
<dd cshelp="IDH_SETTINGS_APPEARANCE_STATUS_IN_CHAT">Show some messages destined for the Status Bar in main chat as
well. <i>It's generally a good idea to leave this enabled.</i></dd>
@@ -66,11 +65,22 @@
href="settings_advanced.html#autoaway">Auto-away on Minimize option</a>.
All time formatting variables are available, see <a
href="settings_logs.html#timeformat">Logs</a>. Use Ctrl + Enter to create a new line. <br/>(default: "I'm away. State your business and I might answer later if you're lucky.")</dd>
- <dt id="set_timestamps">Set timestamps</dt>
- <dd cshelp="IDH_SETTINGS_APPEARANCE_TIME_STAMPS_FORMAT">This lets you select the format of the time stamps that can
+ <dt id="timestamp_format">Timestamp format</dt>
+ <dd cshelp="IDH_SETTINGS_APPEARANCE_TIMESTAMP_FORMAT">This lets you select the format of the time stamps that can
appear in the chat and private message windows. For the available
formatting variables, please see <a
href="settings_logs.html#timeformat">Logs</a>. <br/>(default: %H:%M)</dd>
+<dt>Country format</dt>
+<dd cshelp="IDH_SETTINGS_APPEARANCE_COUNTRY_FORMAT">
+This box allows customization of the way user country information is displayed throughout the
+interface. <b>Default: %[2code] - %[name]</b><br/><br/>
+Available variables:
+<ul>
+ <li><b>%[2code]</b> gets replaced by a 2-letters country code</li>
+ <li><b>%[3code]</b> gets replaced by a 3-letters country code</li>
+ <li><b>%[name]</b> gets replaced by the full country name</li>
+</ul>
+</dd>
<dt id="messagelines">Height of the message editing box</dt>
<dd cshelp="IDH_SETTINGS_APPEARANCE_MESSAGE_LINES">
Use these 2 boxes to control how much you want message editing boxes (in <placeholder><a href="window_hub.html">Hub</a></placeholder> and <placeholder><a href="window_pm.html">Private Message</a></placeholder> windows) to resize themselves when you are composing a multiline message. Both settings can have the same value, in which case the message editing box will never redraw itself. Minimum value: 1. Default values: 1 and 10.
=== modified file 'win32/AppearancePage.cpp'
--- win32/AppearancePage.cpp 2011-06-28 20:07:49 +0000
+++ win32/AppearancePage.cpp 2011-09-30 11:59:16 +0000
@@ -51,7 +51,7 @@
};
AppearancePage::AppearancePage(dwt::Widget* parent) :
-PropPage(parent, 5, 1),
+PropPage(parent, 6, 1),
options(0),
languages(0)
{
@@ -64,32 +64,36 @@
options = grid->addChild(GroupBox::Seed(T_("Options")))->addChild(WinUtil::Seeds::Dialog::optionsTable);
{
- auto cur = grid->addChild(Grid::Seed(1, 2));
- cur->column(0).mode = GridInfo::FILL;
- cur->setSpacing(grid->getSpacing());
-
- auto group = cur->addChild(GroupBox::Seed(T_("Default away message")));
+ auto group = grid->addChild(GroupBox::Seed(T_("Default away message")));
group->setHelpId(IDH_SETTINGS_APPEARANCE_DEFAULT_AWAY_MESSAGE);
- TextBox::Seed seed = WinUtil::Seeds::Dialog::textBox;
+ auto seed = WinUtil::Seeds::Dialog::textBox;
seed.style |= ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN;
auto box = group->addChild(seed);
box->setHelpId(IDH_SETTINGS_APPEARANCE_DEFAULT_AWAY_MESSAGE);
items.push_back(Item(box, SettingsManager::DEFAULT_AWAY_MESSAGE, PropPage::T_STR));
-
- group = cur->addChild(GroupBox::Seed(T_("Set timestamps")));
- group->setHelpId(IDH_SETTINGS_APPEARANCE_TIME_STAMPS_FORMAT);
-
- box = group->addChild(WinUtil::Seeds::Dialog::textBox);
- box->setHelpId(IDH_SETTINGS_APPEARANCE_TIME_STAMPS_FORMAT);
- items.push_back(Item(box, SettingsManager::TIME_STAMPS_FORMAT, PropPage::T_STR));
- }
-
- {
- GroupBoxPtr group = grid->addChild(GroupBox::Seed(T_("Height of the message editing box")));
+ }
+
+ {
+ auto cur = grid->addChild(Grid::Seed(1, 2));
+ cur->setSpacing(grid->getSpacing());
+
+ auto group = cur->addChild(GroupBox::Seed(T_("Timestamp format")));
+ group->setHelpId(IDH_SETTINGS_APPEARANCE_TIMESTAMP_FORMAT);
+
+ items.push_back(Item(group->addChild(WinUtil::Seeds::Dialog::textBox), SettingsManager::TIME_STAMPS_FORMAT, PropPage::T_STR));
+
+ group = cur->addChild(GroupBox::Seed(T_("Country format")));
+ group->setHelpId(IDH_SETTINGS_APPEARANCE_COUNTRY_FORMAT);
+
+ items.push_back(Item(group->addChild(WinUtil::Seeds::Dialog::textBox), SettingsManager::COUNTRY_FORMAT, PropPage::T_STR));
+ }
+
+ {
+ auto group = grid->addChild(GroupBox::Seed(T_("Height of the message editing box")));
group->setHelpId(IDH_SETTINGS_APPEARANCE_MESSAGE_LINES);
- GridPtr cur = group->addChild(Grid::Seed(1, 5));
+ auto cur = group->addChild(Grid::Seed(1, 5));
cur->column(1).size = 40;
cur->column(1).mode = GridInfo::STATIC;
cur->column(3).size = 40;
@@ -97,9 +101,9 @@
cur->addChild(Label::Seed(T_("Keep it between")));
- TextBoxPtr box = cur->addChild(WinUtil::Seeds::Dialog::intTextBox);
+ auto box = cur->addChild(WinUtil::Seeds::Dialog::intTextBox);
items.push_back(Item(box, SettingsManager::MIN_MESSAGE_LINES, PropPage::T_INT_WITH_SPIN));
- SpinnerPtr spin = cur->addChild(Spinner::Seed(1, UD_MAXVAL, box));
+ auto spin = cur->addChild(Spinner::Seed(1, UD_MAXVAL, box));
cur->setWidget(spin);
cur->addChild(Label::Seed(T_("and")));
@@ -113,14 +117,14 @@
}
{
- GroupBoxPtr group = grid->addChild(GroupBox::Seed(T_("Language")));
+ auto group = grid->addChild(GroupBox::Seed(T_("Language")));
group->setHelpId(IDH_SETTINGS_APPEARANCE_LANGUAGE);
languages = group->addChild(WinUtil::Seeds::Dialog::comboBox);
languages->setHelpId(IDH_SETTINGS_APPEARANCE_LANGUAGE);
}
- LabelPtr label = grid->addChild(Label::Seed(T_("Note; most of these options require that you restart DC++")));
+ auto label = grid->addChild(Label::Seed(T_("Note; most of these options require that you restart DC++")));
label->setHelpId(IDH_SETTINGS_APPEARANCE_REQUIRES_RESTART);
PropPage::read(items);