8 from gettext import gettext as _
9 from meabook.ui.hildon_ui.common import create_button
16 dialog = hildon.Dialog()
17 dialog.set_title(_('Import'))
18 selector = hildon.TouchSelector(text=True)
20 _('Import from LDIF'): 'ldif', \
21 _('Import from database'): 'db'}
22 for item in self.items_dict:
23 selector.append_text(item)
24 selector.set_active(0, 0)
25 # create file format button
26 format_button = hildon.PickerButton(gtk.HILDON_SIZE_AUTO | \
27 gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
28 format_button.set_alignment(0, 0, 0, 0)
29 format_button.set_title(_("Import type"))
30 format_button.set_selector(selector)
31 # create file chooser button
32 fname_button = create_button(_('File name'), _('Choose file name'))
33 fname_button.connect('clicked', self.choose_file_name_cb)
35 import_button = dialog.add_button(_('Import'), gtk.RESPONSE_OK)
36 import_button.set_sensitive(False)
38 dialog.vbox.pack_start(format_button)
39 dialog.vbox.pack_start(fname_button)
40 dialog.vbox.show_all()
42 # create class attributes
44 self.import_button = import_button
45 self.format_button = format_button
46 self.fname_button = fname_button
49 response = self.dialog.run()
51 if response == gtk.RESPONSE_OK:
52 result = (self.items_dict[self.format_button.get_value().\
53 decode('utf-8')], self.fname_button.get_value())
57 def choose_file_name_cb(self, widget):
58 """Shows file chooser dialog."""
60 chooser = gobject.new(hildon.FileChooserDialog, \
61 action=gtk.FILE_CHOOSER_ACTION_OPEN)
62 chooser.set_property('show-files', True)
64 path = chooser.get_filename()
66 widget.set_value(path)
67 self.import_button.set_sensitive(True)