diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 3e3691a..0b9b16f 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -14,6 +14,7 @@ Pause All Start All Exit + Settings Browse for torrent file diff --git a/resources/language/Russian/strings.xml b/resources/language/Russian/strings.xml index 733067e..b953ec1 100644 --- a/resources/language/Russian/strings.xml +++ b/resources/language/Russian/strings.xml @@ -13,6 +13,7 @@ Остановить все Запустить все Выход + Настойки Настройки RPC @@ -20,4 +21,4 @@ Порт Пользователь Пароль - \ No newline at end of file + diff --git a/resources/lib/gui.py b/resources/lib/gui.py index 79df672..08fe0e3 100644 --- a/resources/lib/gui.py +++ b/resources/lib/gui.py @@ -28,24 +28,34 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): self.list = {} self.torrents = {} self.repeater = None - def onInit(self): - p = xbmcgui.DialogProgress() - p.create(_(0), _(1)) # 'Transmission', 'Connecting to Transmission' + def get_settings(self): params = { 'address': __settings__.getSetting('rpc_host'), 'port': __settings__.getSetting('rpc_port'), 'user': __settings__.getSetting('rpc_user'), 'password': __settings__.getSetting('rpc_password') } + return params + def set_settings(self, params): + __settings__.setSetting('rpc_host', params['address']) + __settings__.setSetting('rpc_port', params['port']) + __settings__.setSetting('rpc_user', params['user']) + __settings__.setSetting('rpc_password', params['password']) + def get_rpc_client(self): + params = self.get_settings() import transmissionrpc + return transmissionrpc.Client(**params) + def onInit(self): + p = xbmcgui.DialogProgress() + p.create(_(0), _(1)) # 'Transmission', 'Connecting to Transmission' try: - self.transmission = transmissionrpc.Client(**params) + self.transmission = self.get_rpc_client() except: p.close() self.close() (type, e, traceback) = sys.exc_info() - message = _(9000) # Unexpected error + import transmissionrpc if type is transmissionrpc.TransmissionError: if e.original: if e.original.code is 401: @@ -63,7 +73,6 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): else: message = _(9000) # Unexpected error xbmcgui.Dialog().ok(_(2), message) - return False p.close() self.updateTorrents() @@ -176,6 +185,26 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): if (controlID == 117): # Exit button self.close() + if (controlID == 118): + # Settings button + prev_settings = self.get_settings() + __settings__.openSettings() + p = xbmcgui.DialogProgress() + p.create(_(0), _(1)) # 'Transmission', 'Connecting to Transmission' + try: + self.transmission = self.get_rpc_client() + self.updateTorrents() + p.close() + except: + p.close() + xbmcgui.Dialog().ok(_(2), _(9001)) + # restore settings + self.set_settings(prev_settings) + try: + self.transmission = self.get_rpc_client() + except err: + xbmcgui.Dialog().ok(_(2), _(9001)) + self.close() if (controlID == 120): # A torrent was chosen, show details item = list.getSelectedItem() diff --git a/resources/skins/Default/720p/script-Transmission-main.xml b/resources/skins/Default/720p/script-Transmission-main.xml index 5c1c8f0..c72641d 100644 --- a/resources/skins/Default/720p/script-Transmission-main.xml +++ b/resources/skins/Default/720p/script-Transmission-main.xml @@ -135,8 +135,8 @@ startall-focus.png startall-nofocus.png - - Exit + + Settings 0 450 70 @@ -144,12 +144,12 @@ center top 45 - + font12_title 120 116 - exit-focus.png - exit-nofocus.png + settings-focus.png + settings-nofocus.png 111 @@ -261,5 +261,18 @@ + + Exit + 850 + -5 + 32 + 64 + 45 + + - + DialogCloseButton-focus.png + DialogCloseButton.png + system.getbool(input.enablemouse) + diff --git a/resources/skins/Default/media/icons/configure.png b/resources/skins/Default/media/icons/configure.png new file mode 100644 index 0000000..16ce518 Binary files /dev/null and b/resources/skins/Default/media/icons/configure.png differ diff --git a/resources/skins/Default/media/settings-focus.png b/resources/skins/Default/media/settings-focus.png new file mode 100644 index 0000000..b6ccc9f Binary files /dev/null and b/resources/skins/Default/media/settings-focus.png differ diff --git a/resources/skins/Default/media/settings-nofocus.png b/resources/skins/Default/media/settings-nofocus.png new file mode 100644 index 0000000..39a3da5 Binary files /dev/null and b/resources/skins/Default/media/settings-nofocus.png differ