programmatically enable/disable a setting

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
tarora Offline
Junior Member
Posts: 16
Joined: Aug 2011
Reputation: 0
Post: #1
1. Is there any way to enable/disable a setting programmatically?
2. Programmatically, can I find whether a setting is enabled/disabled?

e.g.
PHP Code:
<setting id="youtube" type="bool" enable="System.HasAddon(plugin.video.youtube)" label="31002"/> 

how can I find property youtube is enabled/disabled?

for youtube setting above default="System.HasAddon(plugin.video.youtube)" is always returning false.
find quote
Martijn Offline
Team-XBMC
Posts: 10,264
Joined: Jul 2011
Reputation: 154
Location: Dawn of time
Post: #2
PHP Code:
setSetting(id="youtube"value='false')
(
this will set it false)

getSetting(id="youtube") == "true"
getSetting(id="youtube") == True (can also be this one i think)
(
value returns true when it is enable in settings

Hope you meant this Smile

Here is an example on how i handle my settings: settings

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

For your mediacenter artwork go to
[Image: fanarttv.png]
(This post was last modified: 2012-01-26 13:26 by Martijn.)
find quote
tarora Offline
Junior Member
Posts: 16
Joined: Aug 2011
Reputation: 0
Post: #3
Martijn Wrote:
PHP Code:
setSetting(id="youtube"value='false')
(
this will set it false)

getSetting(id="youtube") == "true"
getSetting(id="youtube") == True (can also be this one i think)
(
value returns true when it is enable in settings

Hope you meant this Smile

This will get/set a setting. There are two cases for me
1. Setting is disabled but default is set to true
2. Setting is enabled. Default is true and user can change the value

If a setting is disabled then its value is still true, I want to distinguish this case from case2 (where true is set/reset by user). In case one, setting value is to be ignored.

Any pointers?
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 25,683
Joined: Oct 2003
Reputation: 169
Post: #4
Not sure why you can't use the same boolean condition that you set for the enable attribute for this?

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
tarora Offline
Junior Member
Posts: 16
Joined: Aug 2011
Reputation: 0
Post: #5
jmarshall Wrote:Not sure why you can't use the same boolean condition that you set for the enable attribute for this?


Tried setting default value based on same condition

PHP Code:
<setting id="youtube" type="bool" enable="System.HasAddon(plugin.video.youtube)" default="System.HasAddon(plugin.video.youtube)" label="31002"/> 
<
setting id="vimeo" type="bool" default="System.HasAddon(plugin.video.vimeo)" enable="System.HasAddon(plugin.video.vimeo)" label="31003"/> 

but for default="System.HasAddon(id)" is always returning false. In my case I have youtube installed but not vimeo. But default is showing off for both cases.
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 25,683
Joined: Oct 2003
Reputation: 169
Post: #6
I didn't say set the default value to it.

You just want to know later on (i.e. from your script) whether the utube addon is enabled - if not, you know how to deal with the youtube setting.

So, from your script, use the same setting as you do in settings.xml and then you know exactly what is going on.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
tarora Offline
Junior Member
Posts: 16
Joined: Aug 2011
Reputation: 0
Post: #7
jmarshall Wrote:I didn't say set the default value to it.

You just want to know later on (i.e. from your script) whether the utube addon is enabled - if not, you know how to deal with the youtube setting.

So, from your script, use the same setting as you do in settings.xml and then you know exactly what is going on.

Currently, I am using (addon = xbmcaddon.Addon(id=addon_id)) to find out whether a plugin is installed.

PHP Code:
try:
    
addon xbmcaddon.Addon(id=addon_id)
    if 
addon:
       
installed True
except
:
    
installed False 
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 25,683
Joined: Oct 2003
Reputation: 169
Post: #8
So what's the problem? If you know the addon is not installed, then you can ignore the setting for it, right?

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote