Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added: if an addon calls itself from addon settings, calling

updatesetting from the addon now only updates the dialog as expected
  • Loading branch information...
commit 947af20c58e58ad39b2b235ba55c4930e204cdf4 1 parent afbe8e6
spiff authored
3  xbmc/GUIUserMessages.h
View
@@ -127,3 +127,6 @@
// Sent to tell window to initiate a search dialog
#define GUI_MSG_SEARCH GUI_MSG_USER + 34
+
+// Sent to the AddonSetting dialogs from addons if they updated a setting
+#define GUI_MSG_SETTING_UPDATED GUI_MSG_USER + 35
19 xbmc/addons/GUIDialogAddonSettings.cpp
View
@@ -44,6 +44,7 @@
#include "FileItem.h"
#include "settings/Settings.h"
#include "GUIInfoManager.h"
+#include "GUIUserMessages.h"
#include "dialogs/GUIDialogSelect.h"
#include "GUIWindowAddonBrowser.h"
#include "utils/log.h"
@@ -126,6 +127,17 @@ bool CGUIDialogAddonSettings::OnMessage(CGUIMessage& message)
}
return true;
}
+ case GUI_MSG_SETTING_UPDATED:
+ {
+ CStdString id = message.GetStringParam(0);
+ CStdString value = message.GetStringParam(1);
+ m_settings[id] = value;
+ int iControl = GetFocusedControl()->GetID();
+ CreateControls();
+ CGUIMessage msg(GUI_MSG_SETFOCUS,GetID(),iControl);
+ OnMessage(msg);
+ return true;
+ }
}
return CGUIDialogBoxBase::OnMessage(message);
}
@@ -1133,3 +1145,10 @@ void CGUIDialogAddonSettings::DoProcess(unsigned int currentTime, CDirtyRegionLi
((CGUIButtonControl *)control)->SetSelected(false);
}
}
+
+CStdString CGUIDialogAddonSettings::GetCurrentID() const
+{
+ if (m_addon)
+ return m_addon->ID();
+ return "";
+}
1  xbmc/addons/GUIDialogAddonSettings.h
View
@@ -38,6 +38,7 @@ class CGUIDialogAddonSettings : public CGUIDialogBoxBase
static bool ShowAndGetInput(const ADDON::AddonPtr &addon, bool saveToDisk = true);
virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions);
+ CStdString GetCurrentID() const;
protected:
virtual void OnInitWindow();
25 xbmc/interfaces/python/xbmcmodule/PythonAddon.cpp
View
@@ -24,6 +24,8 @@
#include "pythreadstate.h"
#include "addons/AddonManager.h"
#include "addons/GUIDialogAddonSettings.h"
+#include "guilib/GUIWindowManager.h"
+#include "GUIUserMessages.h"
#include "utils/log.h"
namespace PYXBMC
@@ -245,8 +247,27 @@ namespace PYXBMC
AddonPtr addon(self->pAddon);
CPyThreadState pyState;
- addon->UpdateSetting(id, value);
- addon->SaveSettings();
+ bool save=true;
+ if (g_windowManager.IsWindowActive(WINDOW_DIALOG_ADDON_SETTINGS))
+ {
+ CGUIDialogAddonSettings* dialog = (CGUIDialogAddonSettings*)g_windowManager.GetWindow(WINDOW_DIALOG_ADDON_SETTINGS);
+ if (dialog->GetCurrentID() == addon->ID())
+ {
+ CGUIMessage message(GUI_MSG_SETTING_UPDATED,0,0);
+ std::vector<CStdString> params;
+ params.push_back(id);
+ params.push_back(value);
+ message.SetStringParams(params);
+ g_windowManager.SendThreadMessage(message,WINDOW_DIALOG_ADDON_SETTINGS);
+ save=false;
+ }
+ }
+ if (save)
+ {
+ addon->UpdateSetting(id, value);
+ addon->SaveSettings();
+ }
+
pyState.Restore();
Py_INCREF(Py_None);
Please sign in to comment.
Something went wrong with that request. Please try again.