]> git.tdb.fi Git - ext/subsurface.git/blobdiff - gtk-gui.c
When the file has been opened rely on it to save.
[ext/subsurface.git] / gtk-gui.c
index 9f37c1a0b95f9f193673d521efd9a666ee323d6d..f28dde4844d5de2ce134844ae2d701d9603a4cf0 100644 (file)
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -173,26 +173,28 @@ static void file_open(GtkWidget *w, gpointer data)
 static void file_save(GtkWidget *w, gpointer data)
 {
        GtkWidget *dialog;
-       dialog = gtk_file_chooser_dialog_new("Save File",
+       char *filename;
+       if (!existing_filename) {
+               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);
+               gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
 
-       if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
-               char *filename;
-               filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+               gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document");
+               if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+                       filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+               }
+               gtk_widget_destroy(dialog);
+       } else {
+               filename = existing_filename;
+       }
+       if (filename){
                save_dives(filename);
-               g_free(filename);
                mark_divelist_changed(FALSE);
        }
-       gtk_widget_destroy(dialog);
 }
 
 static void ask_save_changes()
@@ -204,7 +206,18 @@ static void ask_save_changes()
                GTK_STOCK_NO, GTK_RESPONSE_NO,
                NULL);
        content = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-       label = gtk_label_new ("You have unsaved changes\nWould you like to save those before exiting the program?");
+
+       if (!existing_filename){
+               label = gtk_label_new (
+                       "You have unsaved changes\nWould you like to save those before exiting the program?");
+       } else {
+               char *label_text = (char*) malloc(sizeof(char) * (92 + strlen(existing_filename)));
+               sprintf(label_text,
+                       "You have unsaved changes to file: %s \nWould you like to save those before exiting the program?",
+                       existing_filename);
+               label = gtk_label_new (label_text);
+               g_free(label_text);
+       }
        gtk_container_add (GTK_CONTAINER (content), label);
        gtk_widget_show_all (dialog);
        gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
@@ -405,43 +418,43 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
                "lbs",  set_lbs, (output_units.weight == LBS),
                NULL);
 
-       frame = gtk_frame_new("Columns");
+       frame = gtk_frame_new("Show Columns");
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
 
        box = gtk_hbox_new(FALSE, 6);
        gtk_container_add(GTK_CONTAINER(frame), box);
 
-       button = gtk_check_button_new_with_label("Show Temp");
+       button = gtk_check_button_new_with_label("Temp");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.temperature);
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(temperature_toggle), NULL);
 
-       button = gtk_check_button_new_with_label("Show Cyl");
+       button = gtk_check_button_new_with_label("Cyl");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.cylinder);
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(cylinder_toggle), NULL);
 
-       button = gtk_check_button_new_with_label("Show O" UTF8_SUBSCRIPT_2 "%");
+       button = gtk_check_button_new_with_label("O" UTF8_SUBSCRIPT_2 "%");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.nitrox);
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(nitrox_toggle), NULL);
 
-       button = gtk_check_button_new_with_label("Show SAC");
+       button = gtk_check_button_new_with_label("SAC");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.sac);
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(sac_toggle), NULL);
 
-       button = gtk_check_button_new_with_label("Show OTU");
+       button = gtk_check_button_new_with_label("OTU");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.otu);
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(otu_toggle), NULL);
 
-       button = gtk_check_button_new_with_label("Show Weight");
+       button = gtk_check_button_new_with_label("Weight");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.totalweight);
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(totalweight_toggle), NULL);
 
-       button = gtk_check_button_new_with_label("Show Suit");
+       button = gtk_check_button_new_with_label("Suit");
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.suit);
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(suit_toggle), NULL);
@@ -810,7 +823,7 @@ void init_ui(int *argcp, char ***argvp)
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new("Dive Notes"));
 
        /* Frame for dive equipment */
-       nb_page = equipment_widget();
+       nb_page = equipment_widget(W_IDX_PRIMARY);
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), nb_page, gtk_label_new("Equipment"));
 
        /* Frame for single dive statistics */