
--[[
=head1 NAME

applets.JogglerStandby.JogglerStandbyApplet

=head1 DESCRIPTION

JogglerStandby v1.01 (10th April 2012)

This applet sets the display standby time on O2 Jogglers running the native operating system.

=head1 FUNCTIONS

Applet related methods are described in L<jive.Applet>. 
JogglerStandbyApplet overrides the following methods:

=cut
--]]


-- stuff we use
local ipairs, pairs, tostring, tonumber = ipairs, pairs, tostring, tonumber

local os               = require("os")
local oo               = require("loop.simple")

local Applet           = require("jive.Applet")
local Timer            = require("jive.ui.Timer")
local Framework        = require("jive.ui.Framework")
local Window           = require("jive.ui.Window")
local RadioGroup       = require("jive.ui.RadioGroup")
local RadioButton      = require("jive.ui.RadioButton")
local Label            = require("jive.ui.Label")
local SimpleMenu       = require("jive.ui.SimpleMenu")
local System           = require("jive.System")
local Textarea         = require("jive.ui.Textarea")
local string           = require("string")
local table            = require("jive.utils.table")
local debug            = require("jive.utils.debug")
local Player           = require("jive.slim.Player")

local appletManager    = appletManager

local jnt = jnt
local jiveMain = jiveMain


module(..., Framework.constants)
oo.class(_M, Applet)



function standbySetting(self, menuItem)

	local group = RadioGroup()

	local standby = self:getSettings()["standby"]

	local window = Window("text_list", menuItem.text, 'DISPLAYSTANDBY')
	window:addWidget(SimpleMenu("menu",
		{
			{
				text = self:string("SEC5"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 5 0 0")
						self:getSettings()["standby"] = 5
					end,
					(standby == 5)
				),
			},
			{
				text = self:string("SEC10"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 10 0 0")
						self:getSettings()["standby"] = 10
					end,
					(standby == 10)
				),
			},
			{
				text = self:string("SEC30"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 30 0 0")
						self:getSettings()["standby"] = 30
					end,
					(standby == 30)
				),
			},
			{
				text = self:string("MIN1"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 60 0 0")
						self:getSettings()["standby"] = 60
					end,
					(standby == 60)
				),
			},
			{
				text = self:string("MIN5"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 300 0 0")
						self:getSettings()["standby"] = 300
					end,
					(standby == 300)
				),
			},
			{
				text = self:string("MIN10"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 600 0 0")
						self:getSettings()["standby"] = 600
					end,
					(standby == 600)
				),
			},
			{
				text = self:string("MIN30"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 1800 0 0")
						self:getSettings()["standby"] = 1800
					end,
					(standby == 1800)
				),
			},
			{
				text = self:string("MIN60"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 3600 0 0")
						self:getSettings()["standby"] = 3600
					end,
					(standby == 3600)
				),
			},
			{
				text = self:string("ON"),
				style = 'item_choice',
				check = RadioButton(
					"radio",
					group,
					function()
						os.execute("xset -display :0.0 dpms 0 0 0")
						self:getSettings()["standby"] = 0
					end,
					(standby == 0)
				),
			},
		}))

	window:addListener(EVENT_WINDOW_POP, function() self:storeSettings() end)

	self:tieAndShowWindow(window)
	return window
end



--[[

=head1 LICENSE

Created by Andy Davison
birdslikewires.co.uk

This file is made available under the following Creative Commons licence:

Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0).

Please see http://creativecommons.org/licenses/by-sa/3.0/ for details.

=cut
--]]

