No capitalization and word completion for URLs (Maemo bug 5184)
[gpodder.git] / src / gpodder / gtkui / interface / addpodcast.py
blob69e3129a4ea8233fa76377c76e7f4d5cd556ffd0
1 # -*- coding: utf-8 -*-
3 # gPodder - A media aggregator and podcast client
4 # Copyright (c) 2005-2009 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 import gtk
22 import gpodder
24 _ = gpodder.gettext
26 from gpodder.gtkui.interface.common import BuilderWidget
29 class gPodderAddPodcast(BuilderWidget):
30 finger_friendly_widgets = ['btn_close', 'btn_add' 'btn_paste']
32 def new(self):
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 self.gPodderAddPodcast.show()
52 def on_btn_close_clicked(self, widget):
53 self.gPodderAddPodcast.destroy()
55 def on_btn_paste_clicked(self, widget):
56 clipboard = gtk.Clipboard()
57 clipboard.request_text(self.receive_clipboard_text)
59 def receive_clipboard_text(self, clipboard, text, data=None):
60 if text is not None:
61 self.entry_url.set_text(text)
62 else:
63 self.show_message(_('Nothing to paste.'), _('Clipboard is empty'))
65 def on_entry_url_changed(self, widget):
66 self.btn_add.set_sensitive(self.entry_url.get_text().strip() != '')
68 def on_entry_url_activate(self, widget):
69 self.on_btn_add_clicked(widget)
71 def on_btn_add_clicked(self, widget):
72 url = self.entry_url.get_text()
73 self.on_btn_close_clicked(widget)
74 if self.add_urls_callback is not None:
75 self.add_urls_callback([url])