diff options
author | Pierre-Yves Chibon <pingou@pingoured.fr> | 2013-02-01 09:28:33 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-02 00:10:14 +1100 |
commit | 20d3b5f71495adccf59d27095445a0d2e63b6a09 (patch) | |
tree | 15b34a49533609ff8ed19de8dd3f62d4752e4f10 /divelist.c | |
parent | 60f9c338e9ddcc18495758ac7ad6926cce5af44d (diff) | |
download | subsurface-20d3b5f71495adccf59d27095445a0d2e63b6a09.tar.gz |
Add 'Save As' entry to context menu shown when right clicking on a dive
Something which is nice especially when asked on the list to share an
interesting dive is the possibility to save just some dives into a file.
This commit adds to the context menu shown with right-click the 'Save As'
entry. This entry allows to save selected dives.
[Dirk Hohndel: clean up white space, commit message and remove unused
variables]
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/divelist.c b/divelist.c index d8c760db9..f7ed6e14d 100644 --- a/divelist.c +++ b/divelist.c @@ -1621,6 +1621,31 @@ gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data) return FALSE; } +static void save_as_cb(GtkWidget *menuitem, struct dive *dive) +{ + GtkWidget *dialog; + char *filename = NULL; + + 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); + + 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){ + set_filename(filename, TRUE); + save_dives_logic(filename, TRUE); + g_free(filename); + } +} + static void expand_all_cb(GtkWidget *menuitem, GtkTreeView *tree_view) { gtk_tree_view_expand_all(tree_view); @@ -2409,6 +2434,10 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int deletelabel = _(deleteplurallabel); editlabel = _(editplurallabel); } + menuitem = gtk_menu_item_new_with_label(_("Save as")); + g_signal_connect(menuitem, "activate", G_CALLBACK(save_as_cb), dive); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + menuitem = gtk_menu_item_new_with_label(deletelabel); g_signal_connect(menuitem, "activate", G_CALLBACK(delete_selected_dives_cb), path); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |