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/>.
26 from gpodder
.gtkui
.interface
.common
import BuilderWidget
29 class gPodderAddPodcast(BuilderWidget
):
30 finger_friendly_widgets
= ['btn_close', 'btn_add' 'btn_paste']
33 if not hasattr(self
, 'add_urls_callback'):
34 self
.add_urls_callback
= None
35 if hasattr(self
, 'custom_label'):
36 self
.label_add
.set_text(self
.custom_label
)
37 if hasattr(self
, 'custom_title'):
38 self
.gPodderAddPodcast
.set_title(self
.custom_title
)
39 if hasattr(self
, 'preset_url'):
40 self
.entry_url
.set_text(self
.preset_url
)
41 if hasattr(self
, 'btn_add_stock_id'):
42 self
.btn_add
.set_label(self
.btn_add_stock_id
)
43 self
.btn_add
.set_use_stock(True)
44 self
.entry_url
.connect('activate', self
.on_entry_url_activate
)
45 if gpodder
.ui
.fremantle
:
46 self
.btn_add
.set_name('HildonButton-finger')
47 # Deactivate capitalization and word completion (Maemo bug 5184)
48 self
.entry_url
.set_property('hildon-input-mode', \
49 gtk
.HILDON_GTK_INPUT_MODE_FULL
)
50 elif gpodder
.ui
.diablo
:
51 self
.entry_url
.set_property('hildon-input-mode', \
52 'HILDON_GTK_INPUT_MODE_FULL')
53 self
.gPodderAddPodcast
.show()
55 def on_btn_close_clicked(self
, widget
):
56 self
.gPodderAddPodcast
.destroy()
58 def on_btn_paste_clicked(self
, widget
):
59 clipboard
= gtk
.Clipboard()
60 clipboard
.request_text(self
.receive_clipboard_text
)
62 def receive_clipboard_text(self
, clipboard
, text
, data
=None):
64 self
.entry_url
.set_text(text
)
66 self
.show_message(_('Nothing to paste.'), _('Clipboard is empty'))
68 def on_entry_url_changed(self
, widget
):
69 self
.btn_add
.set_sensitive(self
.entry_url
.get_text().strip() != '')
71 def on_entry_url_activate(self
, widget
):
72 self
.on_btn_add_clicked(widget
)
74 def on_btn_add_clicked(self
, widget
):
75 url
= self
.entry_url
.get_text()
76 self
.on_btn_close_clicked(widget
)
77 if self
.add_urls_callback
is not None:
78 self
.add_urls_callback([url
])