+static GtkEntry *dive_computer_device(GtkWidget *vbox)
+{
+ GtkWidget *hbox, *entry, *frame;
+
+ hbox = gtk_hbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
+
+ frame = gtk_frame_new("Device name");
+ gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 3);
+
+ entry = gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER(frame), entry);
+ gtk_entry_set_text(GTK_ENTRY(entry), "/dev/ttyUSB0");
+
+ return GTK_ENTRY(entry);
+}
+
+/* once a file is selected in the FileChooserButton we want to exit the import dialog */
+static void on_file_set(GtkFileChooserButton *widget, gpointer _data)
+{
+ GtkDialog *main_dialog = _data;
+
+ gtk_dialog_response(main_dialog, GTK_RESPONSE_ACCEPT);
+}
+
+static GtkWidget *xml_file_selector(GtkWidget *vbox, GtkWidget *main_dialog)
+{
+ GtkWidget *hbox, *frame, *chooser, *dialog;
+ GtkFileFilter *filter;
+
+ hbox = gtk_hbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
+
+ frame = gtk_frame_new("XML file name");
+ gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 3);
+ dialog = gtk_file_chooser_dialog_new("Open XML File",
+ GTK_WINDOW(main_window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+
+ filter = gtk_file_filter_new();
+ gtk_file_filter_add_pattern(filter, "*.xml");
+ gtk_file_filter_add_pattern(filter, "*.XML");
+ gtk_file_filter_add_pattern(filter, "*.sda");
+ gtk_file_filter_add_pattern(filter, "*.SDA");
+ gtk_file_filter_add_mime_type(filter, "text/xml");
+ gtk_file_filter_set_name(filter, "XML file");
+ gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
+
+ chooser = gtk_file_chooser_button_new_with_dialog(dialog);
+ g_signal_connect(G_OBJECT(chooser), "file-set", G_CALLBACK(on_file_set), main_dialog);
+
+ gtk_file_chooser_button_set_width_chars(GTK_FILE_CHOOSER_BUTTON(chooser), 30);
+ gtk_container_add(GTK_CONTAINER(frame), chooser);
+
+ return chooser;
+}
+
+static void do_import_file(gpointer data, gpointer user_data)
+{
+ GError *error = NULL;
+ parse_xml_file(data, &error);
+
+ if (error != NULL)
+ {
+ report_error(error);
+ g_error_free(error);
+ error = NULL;
+ }
+}
+