aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiff <spiff@xbmc.org>2012-04-15 10:33:03 +0200
committerspiff <spiff@xbmc.org>2012-04-15 10:33:03 +0200
commit5c8f8f1a659da594e9687e8f2a68c7d9a9ce3bf2 (patch)
tree1f09243abeb2cc7349607e953ed781d66d77df3f
parent373f3a60ea0ebcecd539c235307638478c9e50b5 (diff)
added: option to filter out foreign language add-ons in the add-on browser.
English add-ons are always included. Setting defaults to false
-rw-r--r--addons/skin.confluence/720p/AddonBrowser.xml7
-rw-r--r--language/English/strings.xml1
-rw-r--r--xbmc/addons/AddonDatabase.cpp4
-rw-r--r--xbmc/addons/GUIWindowAddonBrowser.cpp46
-rw-r--r--xbmc/settings/Settings.cpp3
-rw-r--r--xbmc/settings/Settings.h1
6 files changed, 60 insertions, 2 deletions
diff --git a/addons/skin.confluence/720p/AddonBrowser.xml b/addons/skin.confluence/720p/AddonBrowser.xml
index 7df9d8f5d3..4a255ab60f 100644
--- a/addons/skin.confluence/720p/AddonBrowser.xml
+++ b/addons/skin.confluence/720p/AddonBrowser.xml
@@ -83,6 +83,13 @@
<include>ButtonCommonValues</include>
<label>25000</label>
</control>
+ <control type="radiobutton" id ="7">
+ <description>Hide foreign</description>
+ <posx>0</posx>
+ <posy>210</posy>
+ <include>ButtonCommonValues</include>
+ <label>25001</label>
+ </control>
<include>CommonNowPlaying_Controls</include>
</control>
</control>
diff --git a/language/English/strings.xml b/language/English/strings.xml
index 9a7fe5a649..41f49ec9fd 100644
--- a/language/English/strings.xml
+++ b/language/English/strings.xml
@@ -2252,6 +2252,7 @@
<string id="24100">To use this feature you must download an Add-on:</string>
<string id="24101">Would you like to download this Add-on?</string>
<string id="25000">Notifications</string>
+ <string id="25001">Hide foreign</string>
<!-- strings 29800 thru 29998 reserved strings used only in the default Project Mayhem III skin and not c++ code -->
<string id="29800">Library Mode</string>
diff --git a/xbmc/addons/AddonDatabase.cpp b/xbmc/addons/AddonDatabase.cpp
index fe4e7b414b..e1f00012b3 100644
--- a/xbmc/addons/AddonDatabase.cpp
+++ b/xbmc/addons/AddonDatabase.cpp
@@ -558,6 +558,10 @@ void CAddonDatabase::SetPropertiesFromAddon(const AddonPtr& addon,
pItem->SetProperty("Addon.StarRating",starrating);
pItem->SetProperty("Addon.Path", addon->Path());
pItem->SetProperty("Addon.Broken", addon->Props().broken);
+ std::map<CStdString,CStdString>::iterator it =
+ addon->Props().extrainfo.find("language");
+ if (it != addon->Props().extrainfo.end())
+ pItem->SetProperty("Addon.Language", it->second);
}
bool CAddonDatabase::DisableAddon(const CStdString &addonID, bool disable /* = true */)
diff --git a/xbmc/addons/GUIWindowAddonBrowser.cpp b/xbmc/addons/GUIWindowAddonBrowser.cpp
index 6d612675f2..1851584312 100644
--- a/xbmc/addons/GUIWindowAddonBrowser.cpp
+++ b/xbmc/addons/GUIWindowAddonBrowser.cpp
@@ -48,9 +48,11 @@
#include "settings/AdvancedSettings.h"
#include "storage/MediaManager.h"
#include "settings/GUISettings.h"
+#include "LangInfo.h"
-#define CONTROL_AUTOUPDATE 5
-#define CONTROL_SHUTUP 6
+#define CONTROL_AUTOUPDATE 5
+#define CONTROL_SHUTUP 6
+#define CONTROL_FOREIGNFILTER 7
using namespace ADDON;
using namespace XFILE;
@@ -100,6 +102,13 @@ bool CGUIWindowAddonBrowser::OnMessage(CGUIMessage& message)
g_settings.Save();
return true;
}
+ else if (iControl == CONTROL_FOREIGNFILTER)
+ {
+ g_settings.m_bAddonForeignFilter = !g_settings.m_bAddonForeignFilter;
+ g_settings.Save();
+ Update(m_vecItems->GetPath());
+ return true;
+ }
else if (m_viewControl.HasControl(iControl)) // list/thumb control
{
// get selected item
@@ -246,9 +255,23 @@ void CGUIWindowAddonBrowser::UpdateButtons()
{
SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE,g_settings.m_bAddonAutoUpdate);
SET_CONTROL_SELECTED(GetID(),CONTROL_SHUTUP,g_settings.m_bAddonNotifications);
+ SET_CONTROL_SELECTED(GetID(),CONTROL_FOREIGNFILTER,g_settings.m_bAddonForeignFilter);
CGUIMediaWindow::UpdateButtons();
}
+static bool FilterVar(bool valid, const CVariant& variant,
+ const std::string& check)
+{
+ if (!valid)
+ return false;
+
+ if (variant.isNull() || variant.asString().empty())
+ return false;
+
+ std::string regions = variant.asString();
+ return regions.find(check) == std::string::npos;
+}
+
bool CGUIWindowAddonBrowser::GetDirectory(const CStdString& strDirectory,
CFileItemList& items)
{
@@ -275,7 +298,26 @@ bool CGUIWindowAddonBrowser::GetDirectory(const CStdString& strDirectory,
}
else
+ {
result = CGUIMediaWindow::GetDirectory(strDirectory,items);
+ if (g_settings.m_bAddonForeignFilter)
+ {
+ int i=0;
+ while (i < items.Size())
+ {
+ if (FilterVar(g_settings.m_bAddonForeignFilter,
+ items[i]->GetProperty("Addon.Language"), "en") ||
+ FilterVar(g_settings.m_bAddonForeignFilter,
+ items[i]->GetProperty("Addon.Language"),
+ g_langInfo.GetLanguageLocale()))
+ {
+ items.Remove(i);
+ }
+ else
+ i++;
+ }
+ }
+ }
if (strDirectory.IsEmpty() && CAddonInstaller::Get().IsDownloading())
{
diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp
index 3557853063..f4a179d8e0 100644
--- a/xbmc/settings/Settings.cpp
+++ b/xbmc/settings/Settings.cpp
@@ -93,6 +93,7 @@ void CSettings::Initialize()
m_bStartVideoWindowed = false;
m_bAddonAutoUpdate = true;
m_bAddonNotifications = true;
+ m_bAddonForeignFilter = false;
m_nVolumeLevel = 0;
m_dynamicRangeCompressionLevel = 0;
@@ -667,6 +668,7 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile)
GetInteger(pElement, "httpapibroadcastport", m_HttpApiBroadcastPort, 8278, 1, 65535);
XMLUtils::GetBoolean(pElement, "addonautoupdate", m_bAddonAutoUpdate);
XMLUtils::GetBoolean(pElement, "addonnotifications", m_bAddonNotifications);
+ XMLUtils::GetBoolean(pElement, "addonforeignfilter", m_bAddonForeignFilter);
}
pElement = pRootElement->FirstChildElement("defaultvideosettings");
@@ -870,6 +872,7 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo
XMLUtils::SetInt(pNode, "httpapibroadcastlevel", m_HttpApiBroadcastLevel);
XMLUtils::SetBoolean(pNode, "addonautoupdate", m_bAddonAutoUpdate);
XMLUtils::SetBoolean(pNode, "addonnotifications", m_bAddonNotifications);
+ XMLUtils::SetBoolean(pNode, "addonforeignfilter", m_bAddonForeignFilter);
// default video settings
TiXmlElement videoSettingsNode("defaultvideosettings");
diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h
index 61428b05e8..8ca148324b 100644
--- a/xbmc/settings/Settings.h
+++ b/xbmc/settings/Settings.h
@@ -208,6 +208,7 @@ public:
bool m_bStartVideoWindowed;
bool m_bAddonAutoUpdate;
bool m_bAddonNotifications;
+ bool m_bAddonForeignFilter;
int m_iVideoStartWindow;