programmatically enable/disable a setting
#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.
Reply
#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
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#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?
Reply
#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
Reply
#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.
Reply
#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
Reply
#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 
Reply
#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
Reply

Logout Mark Read Team Forum Stats Members Help
programmatically enable/disable a setting0