[PATCH] Add menu entry for divelogs.de upload
subsurface at henrik.synth.no
subsurface at henrik.synth.no
Tue Apr 9 13:18:43 PDT 2013
From: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
The menu entry for upload to divelogs.de was missing. Also renamed
the divelogs context menu entry to something less generic.
Signed-off-by: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
---
We still need to add a error/confirmation dialog after the upload,
right now the user has no way of knowing if the upload was a
success. Other than checking divelogs.de, of course.
Henrik
divelist-gtk.c | 20 +++++++++++++++-----
divelist.h | 1 +
gtk-gui.c | 2 ++
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/divelist-gtk.c b/divelist-gtk.c
index dc44188..b0f70ce 100644
--- a/divelist-gtk.c
+++ b/divelist-gtk.c
@@ -1343,7 +1343,7 @@ static void delete_dive_cb(GtkWidget *menuitem, GtkTreePath *path)
}
#if defined(LIBZIP) && defined(XSLT)
-static void export_selected_dives_cb(GtkWidget *menuitem, GtkTreePath *path)
+static void upload_dives_divelogs(const gboolean selected)
{
int i;
struct dive *dive;
@@ -1380,7 +1380,7 @@ static void export_selected_dives_cb(GtkWidget *menuitem, GtkTreePath *path)
dive = get_dive(i);
if (!dive)
continue;
- if (!dive->selected)
+ if (selected && !dive->selected)
continue;
f = tmpfile();
@@ -1433,6 +1433,16 @@ static void export_selected_dives_cb(GtkWidget *menuitem, GtkTreePath *path)
fprintf(stderr,"upload of %s failed\n", tempfile);
g_free(tempfile);
}
+
+void upload_selected_dives_divelogs_cb(GtkWidget *menuitem, GtkTreePath *path)
+{
+ upload_dives_divelogs(TRUE);
+}
+
+void upload_all_dives_divelogs_cb()
+{
+ upload_dives_divelogs(FALSE);
+}
#endif
#if defined(XSLT)
@@ -1577,7 +1587,7 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
char exportuddflabel[] = N_("Export dive(s) to UDDF");
#endif
#if defined(LIBZIP) && defined(XSLT)
- char exportlabel[] = N_("Export dive(s)");
+ char uploaddivelogslabel[] = N_("Upload dive(s) to divelogs.de");
#endif
GtkTreePath *path, *prevpath, *nextpath;
GtkTreeIter iter, previter, nextiter;
@@ -1647,8 +1657,8 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
#if defined(LIBZIP) && defined(XSLT)
- menuitem = gtk_menu_item_new_with_label(exportlabel);
- g_signal_connect(menuitem, "activate", G_CALLBACK(export_selected_dives_cb), path);
+ menuitem = gtk_menu_item_new_with_label(uploaddivelogslabel);
+ g_signal_connect(menuitem, "activate", G_CALLBACK(upload_selected_dives_divelogs_cb), path);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
#endif
diff --git a/divelist.h b/divelist.h
index 8fcd600..32e2075 100644
--- a/divelist.h
+++ b/divelist.h
@@ -16,6 +16,7 @@ extern void select_prev_dive(void);
extern void show_and_select_dive(struct dive *dive);
extern double init_decompression(struct dive * dive);
extern void export_all_dives_uddf_cb();
+extern void upload_all_dives_divelogs_cb();
/* divelist core logic functions */
extern dive_trip_t *find_trip_by_idx(int idx);
diff --git a/gtk-gui.c b/gtk-gui.c
index c7714e5..378eab8 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1565,6 +1565,7 @@ static GtkActionEntry menu_items[] = {
{ "Print", GTK_STOCK_PRINT, N_("Print..."), CTRLCHAR "P", NULL, G_CALLBACK(do_print) },
{ "ImportFile", NULL, N_("Import File(s)..."), CTRLCHAR "I", NULL, G_CALLBACK(import_files) },
{ "ExportUDDF", NULL, N_("Export UDDF..."), NULL, NULL, G_CALLBACK(export_all_dives_uddf_cb) },
+ { "UploadDivelogs", NULL, N_("Upload to divelogs.de..."), NULL, NULL, G_CALLBACK(upload_all_dives_divelogs_cb) },
{ "DownloadLog", NULL, N_("Download From Dive Computer..."), CTRLCHAR "D", NULL, G_CALLBACK(download_dialog) },
{ "DownloadWeb", GTK_STOCK_CONNECT, N_("Download From Web Service..."), NULL, NULL, G_CALLBACK(webservice_download_dialog) },
{ "AddDive", GTK_STOCK_ADD, N_("Add Dive..."), NULL, NULL, G_CALLBACK(add_dive_cb) },
@@ -1607,6 +1608,7 @@ static const gchar* ui_string = " \
<separator name=\"Separator1\"/> \
<menuitem name=\"Import XML File\" action=\"ImportFile\" /> \
<menuitem name=\"Export to UDDF File\" action=\"ExportUDDF\" /> \
+ <menuitem name=\"Upload to divelogs.de\" action=\"UploadDivelogs\" /> \
<separator name=\"Separator2\"/> \
<menuitem name=\"Print\" action=\"Print\" /> \
<separator name=\"Separator3\"/> \
--
1.8.1.3
More information about the subsurface
mailing list