-void repaint_dive(void)
-{
- update_dive(current_dive);
- gtk_widget_queue_draw(dive_profile);
-}
-
-static char *existing_filename;
-
-static void on_info_bar_response(GtkWidget *widget, gint response,
- gpointer data)
-{
- if (response == GTK_RESPONSE_OK)
- {
- gtk_widget_destroy(widget);
- error_info_bar = NULL;
- }
-}
-
-static void report_error(GError* error)
-{
- if (error == NULL)
- {
- return;
- }
-
- if (error_info_bar == NULL)
- {
- error_count = 1;
- error_info_bar = gtk_info_bar_new_with_buttons(GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
- g_signal_connect(error_info_bar, "response", G_CALLBACK(on_info_bar_response), NULL);
- gtk_info_bar_set_message_type(GTK_INFO_BAR(error_info_bar),
- GTK_MESSAGE_ERROR);
-
- error_label = gtk_label_new(error->message);
- GtkWidget *container = gtk_info_bar_get_content_area(GTK_INFO_BAR(error_info_bar));
- gtk_container_add(GTK_CONTAINER(container), error_label);
-
- gtk_box_pack_start(GTK_BOX(main_vbox), error_info_bar, FALSE, FALSE, 0);
- gtk_widget_show_all(main_vbox);
- }
- else
- {
- error_count++;
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "Failed to open %i files.", error_count);
- gtk_label_set(GTK_LABEL(error_label), buffer);
- }
-}
-
-static void file_open(GtkWidget *w, gpointer data)
-{
- GtkWidget *dialog;
- dialog = gtk_file_chooser_dialog_new("Open 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), TRUE);
-
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
- GSList *filenames;
- char *filename;
- filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
-
- GError *error = NULL;
- while(filenames != NULL) {
- filename = (char *)filenames->data;
- parse_xml_file(filename, &error);
- if (error != NULL)
- {
- report_error(error);
- g_error_free(error);
- error = NULL;
- }
-
- g_free(filename);
- filenames = g_slist_next(filenames);
- }
- g_slist_free(filenames);
- report_dives();
- dive_list_update_dives(dive_list);
- }
- gtk_widget_destroy(dialog);
-}
-
-static void file_save(GtkWidget *w, gpointer data)
-{
- GtkWidget *dialog;
- dialog = gtk_file_chooser_dialog_new("Save File",
- GTK_WINDOW(main_window),
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
- if (!existing_filename) {
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document");
- } else
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), existing_filename);
-
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
- char *filename;
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
- save_dives(filename);
- g_free(filename);
- }
- gtk_widget_destroy(dialog);
-}
-
-static void quit(GtkWidget *w, gpointer data)
-{
- gtk_main_quit();
-}
-
-static void create_radio(GtkWidget *dialog, const char *name, ...)