summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Pierre-Yves Chibon <pingou@pingoured.fr>2012-07-17 16:49:27 +0200
committerGravatar Pierre-Yves Chibon <pingou@pingoured.fr>2012-08-17 16:39:28 +0200
commit9cb36850303f8ce6c031926512aad3fc2d800889 (patch)
tree1984c9b8060bfbd16fa0cb4fb889520066c063df
parent1a7695115964887cd19bf1d7e2cef60a2c939482 (diff)
downloadsubsurface-9cb36850303f8ce6c031926512aad3fc2d800889.tar.gz
Add a 'Save As' entry in the menu.
Add a "Save As" entry in the "File" menu allowing the user to specify the file in which to save the data. This is useful as we no longer offer this option through the "Save" entry while the data had been opened from an existing file. Signed-off-by: Pierre-Yves Chibon
-rw-r--r--display-gtk.h2
-rw-r--r--gtk-gui.c26
2 files changed, 28 insertions, 0 deletions
diff --git a/display-gtk.h b/display-gtk.h
index 059c6aa23..1f143077e 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -31,9 +31,11 @@ typedef enum {
#if defined __APPLE__
#define CTRLCHAR "<Meta>"
+#define SHIFTCHAR "<Shift>"
#define PREFERENCE_ACCEL "<Meta>comma"
#else
#define CTRLCHAR "<Control>"
+#define SHIFTCHAR "<Shift>"
#define PREFERENCE_ACCEL NULL
#endif
diff --git a/gtk-gui.c b/gtk-gui.c
index a969e9552..02463d91e 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -197,6 +197,30 @@ static void file_save(GtkWidget *w, gpointer data)
}
}
+static void file_save_as(GtkWidget *w, gpointer data)
+{
+ GtkWidget *dialog;
+ char *filename;
+ dialog = gtk_file_chooser_dialog_new("Save File As",
+ 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);
+
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), existing_filename);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ }
+ gtk_widget_destroy(dialog);
+
+ if (filename){
+ save_dives(filename);
+ mark_divelist_changed(FALSE);
+ }
+}
+
static gboolean ask_save_changes()
{
GtkWidget *dialog, *label, *content;
@@ -666,6 +690,7 @@ static GtkActionEntry menu_items[] = {
{ "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL},
{ "OpenFile", GTK_STOCK_OPEN, NULL, CTRLCHAR "O", NULL, G_CALLBACK(file_open) },
{ "SaveFile", GTK_STOCK_SAVE, NULL, CTRLCHAR "S", NULL, G_CALLBACK(file_save) },
+ { "SaveAsFile", GTK_STOCK_SAVE_AS, NULL, SHIFTCHAR CTRLCHAR "S", NULL, G_CALLBACK(file_save_as) },
{ "Print", GTK_STOCK_PRINT, NULL, CTRLCHAR "P", NULL, G_CALLBACK(do_print) },
{ "Import", NULL, "Import", NULL, NULL, G_CALLBACK(import_dialog) },
{ "AddDive", NULL, "Add Dive", NULL, NULL, G_CALLBACK(add_dive_cb) },
@@ -687,6 +712,7 @@ static const gchar* ui_string = " \
<menu name=\"FileMenu\" action=\"FileMenuAction\"> \
<menuitem name=\"Open\" action=\"OpenFile\" /> \
<menuitem name=\"Save\" action=\"SaveFile\" /> \
+ <menuitem name=\"Save As\" action=\"SaveAsFile\" /> \
<menuitem name=\"Print\" action=\"Print\" /> \
<separator name=\"Separator1\"/> \
<menuitem name=\"Preferences\" action=\"Preferences\" /> \