1 # -*- coding: utf-8 -*-
3 # gPodder - A media aggregator and podcast client
4 # Copyright (c) 2005-2010 Thomas Perl and the gPodder Team
6 # gPodder is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # gPodder is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # gpodder.gtkui.mygpodder- UI code for gpodder.net settings
21 # Thomas Perl <thpinfo.com>; 2010-01-19
30 from gpodder
import util
32 from gpodder
.gtkui
.interface
.progress
import ProgressIndicator
33 from gpodder
.gtkui
.interface
.common
import BuilderWidget
36 class MygPodderSettings(BuilderWidget
):
37 # Columns IDs for the combo box model
38 C_ID
, C_CAPTION
= range(2)
41 # We need to have a MygPoClient instance available
42 assert getattr(self
, 'mygpo_client', None) is not None
46 # Initialize the UI state with configuration settings
47 self
.checkbutton_enable
.set_active(self
.config
.mygpo_enabled
)
48 self
.entry_username
.set_text(self
.config
.mygpo_username
)
49 self
.entry_password
.set_text(self
.config
.mygpo_password
)
50 #self.label_uid_value.set_label(self.config.mygpo_device_uid)
51 self
.entry_caption
.set_text(self
.config
.mygpo_device_caption
)
53 if gpodder
.ui
.fremantle
:
54 self
.checkbutton_enable
.set_name('HildonButton-finger')
55 self
.button_overwrite
.set_name('HildonButton-finger')
56 #self.button_list_uids.set_name('HildonButton-finger')
58 # Disable mygpo sync while the dialog is open
59 self
._enable
_mygpo
= self
.config
.mygpo_enabled
60 self
.config
.mygpo_enabled
= False
62 def on_enabled_toggled(self
, widget
):
63 # Only update indirectly (see on_delete_event)
64 self
._enable
_mygpo
= widget
.get_active()
66 def on_username_changed(self
, widget
):
67 self
.config
.mygpo_username
= widget
.get_text()
69 def on_password_changed(self
, widget
):
70 self
.config
.mygpo_password
= widget
.get_text()
72 def on_device_caption_changed(self
, widget
):
73 self
.config
.mygpo_device_caption
= widget
.get_text()
75 def on_button_overwrite_clicked(self
, button
):
76 title
= _('Replace subscription list on server')
77 message
= _('Remote podcasts that have not been added locally will be removed on the server. Continue?')
78 if self
.show_confirmation(message
, title
):
80 self
.config
.mygpo_enabled
= True
81 self
.on_send_full_subscriptions()
82 self
.config
.mygpo_enabled
= False
83 threading
.Thread(target
=thread_proc
).start()
85 def on_delete_event(self
, widget
, event
):
86 # Re-enable mygpo sync if the user has selected it
87 self
.config
.mygpo_enabled
= self
._enable
_mygpo
88 # Make sure the device is successfully created/updated
89 self
.mygpo_client
.create_device()
90 # Flush settings for mygpo client now
91 self
.mygpo_client
.flush(now
=True)
93 def on_button_close_clicked(self
, button
):
94 self
.on_delete_event(self
.main_window
, None)
95 self
.main_window
.destroy()