Made RSDownloader translateable and added german translation
[enigma2-plugins.git] / rsdownloader / src / RSConfig.py
1 ##\r
2 ## RS Downloader\r
3 ## by AliAbdul\r
4 ##\r
5 from Components.ActionMap import ActionMap\r
6 from Components.config import config, ConfigText, ConfigYesNo, ConfigClock, ConfigSubsection, getConfigListEntry\r
7 from Components.ConfigList import ConfigListScreen\r
8 from Components.Label import Label
9 from RSTranslation import _, TitleScreen\r
10 from time import time\r
11 \r
12 ##############################################################################\r
13 \r
14 config.plugins.RSDownloader = ConfigSubsection()\r
15 config.plugins.RSDownloader.username = ConfigText(default="", fixed_size=False)\r
16 config.plugins.RSDownloader.password = ConfigText(default="", fixed_size=False)\r
17 config.plugins.RSDownloader.lists_directory = ConfigText(default="/media/cf/rs/lists/", fixed_size=False)\r
18 config.plugins.RSDownloader.downloads_directory = ConfigText(default="/media/cf/rs/downloads", fixed_size=False)\r
19 config.plugins.RSDownloader.start_time = ConfigClock(default = time())\r
20 config.plugins.RSDownloader.end_time = ConfigClock(default = time())\r
21 config.plugins.RSDownloader.write_log = ConfigYesNo(default = True)
22 config.plugins.RSDownloader.reconnect_fritz = ConfigYesNo(default = False)\r
23 \r
24 ##############################################################################\r
25 \r
26 class RSConfig(ConfigListScreen, TitleScreen):\r
27         skin = """\r
28                 <screen position="80,170" size="560,270" title="RS Downloader">\r
29                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />\r
30                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />\r
31                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />\r
32                         <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />\r
33                         <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />\r
34                         <widget name="config" position="0,45" size="560,220" scrollbarMode="showOnDemand" />\r
35                 </screen>"""\r
36 \r
37         def __init__(self, session):\r
38                 TitleScreen.__init__(self, session)\r
39                 \r
40                 self["key_green"] = Label(_("Save"))\r
41                 \r
42                 list = []\r
43                 list.append(getConfigListEntry(_("Username:"), config.plugins.RSDownloader.username))\r
44                 list.append(getConfigListEntry(_("Password:"), config.plugins.RSDownloader.password))\r
45                 list.append(getConfigListEntry(_("Lists directory:"), config.plugins.RSDownloader.lists_directory))\r
46                 list.append(getConfigListEntry(_("Downloads directory:"), config.plugins.RSDownloader.downloads_directory))\r
47                 list.append(getConfigListEntry(_("Don't download before:"), config.plugins.RSDownloader.start_time))\r
48                 list.append(getConfigListEntry(_("Don't download after:"), config.plugins.RSDownloader.end_time))\r
49                 list.append(getConfigListEntry(_("Write log:"), config.plugins.RSDownloader.write_log))
50                 list.append(getConfigListEntry(_("Reconnect fritz.Box before downloading:"), config.plugins.RSDownloader.reconnect_fritz))\r
51                 ConfigListScreen.__init__(self, list)\r
52                 \r
53                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "cancel": self.exit}, -1)\r
54 \r
55         def save(self):\r
56                 for x in self["config"].list:\r
57                         x[1].save()\r
58                 self.close()\r
59 \r
60         def exit(self):\r
61                 for x in self["config"].list:\r
62                         x[1].cancel()\r
63                 self.close()\r