finished working on extended import
[meabook] / ui / hildon_ui / imports.py
index f81d080..781d74b 100644 (file)
@@ -16,17 +16,17 @@ class ImportDialog:
         dialog = hildon.Dialog()
         dialog.set_title(_('Import'))
         selector = hildon.TouchSelector(text=True)
-        items_dict = {\
+        self.items_dict = {\
             _('Import from LDIF'): 'ldif', \
             _('Import from database'): 'db'}
-        for item in items_dict:
+        for item in self.items_dict:
             selector.append_text(item)
         selector.set_active(0, 0)
         # create file format button
         format_button = hildon.PickerButton(gtk.HILDON_SIZE_AUTO | \
             gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
         format_button.set_alignment(0, 0, 0, 0)
-        format_button.set_title(_("File to import from"))
+        format_button.set_title(_("Import type"))
         format_button.set_selector(selector)
         # create file chooser button
         fname_button = create_button(_('File name'), _('Choose file name'))
@@ -39,23 +39,20 @@ class ImportDialog:
         dialog.vbox.pack_start(fname_button)
         dialog.vbox.show_all()
 
-        """
-        chooser = gobject.new(hildon.FileChooserDialog, \
-            action=gtk.FILE_CHOOSER_ACTION_OPEN)
-        chooser.set_property('show-files', True)
-        chooser.run()
-        self.path = chooser.get_filename()
-        chooser.destroy()
-        """
         # create class attributes
         self.dialog = dialog
+        self.import_button = import_button
+        self.format_button = format_button
+        self.fname_button = fname_button
 
     def run(self):
         response = self.dialog.run()
+        result = None 
         if response == gtk.RESPONSE_OK:
-            print 'importing'
-        return None
-        #return self.path
+            result = (self.items_dict[self.format_button.get_value().\
+                decode('utf-8')], self.fname_button.get_value())
+        self.dialog.destroy()
+        return result
 
     def choose_file_name_cb(self, widget):
         """Shows file chooser dialog."""
@@ -67,5 +64,6 @@ class ImportDialog:
         path = chooser.get_filename()
         if path:
             widget.set_value(path)
+            self.import_button.set_sensitive(True)
         chooser.destroy()