]> git.street.me.uk Git - andy/viking.git/blobdiff - src/datasource_geotag.c
Menu option to (re)open an MBTiles file.
[andy/viking.git] / src / datasource_geotag.c
index f061f7bf5c50575d93bf3d1693fe8225c098fd68..a3a4ed41992c7292883e9612b55207eb5e1e5188 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
  *
- * Copyright (C) 2011, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
+ * Copyright (C) 2012-2015, Rob Norris <rw_norris@hotmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 typedef struct {
        GtkWidget *files;
-       VikViewport *vvp;
        GSList *filelist;  // Files selected
 } datasource_geotag_user_data_t;
 
 /* The last used directory */
 static gchar *last_folder_uri = NULL;
 
-static gpointer datasource_geotag_init( );
+static gpointer datasource_geotag_init ( acq_vik_t *avt );
 static void datasource_geotag_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
-static void datasource_geotag_get_cmd_string ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );
-static gboolean datasource_geotag_process ( VikTrwLayer *vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw );
+static void datasource_geotag_get_process_options ( gpointer user_data, ProcessOptions *po, gpointer not_used, const gchar *not_used2, const gchar *not_used3 );
+static gboolean datasource_geotag_process ( VikTrwLayer *vtl, ProcessOptions *po, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, gpointer not_used );
 static void datasource_geotag_cleanup ( gpointer user_data );
 
 VikDataSourceInterface vik_datasource_geotag_interface = {
   N_("Create Waypoints from Geotagged Images"),
   N_("Geotagged Images"),
-  VIK_DATASOURCE_INTERNAL,
-  VIK_DATASOURCE_ADDTOLAYER,
+  VIK_DATASOURCE_AUTO_LAYER_MANAGEMENT,
   VIK_DATASOURCE_INPUTTYPE_NONE,
   TRUE,
+  FALSE, // We should be able to see the data on the screen so no point in keeping the dialog open
   TRUE,
   (VikDataSourceInitFunc)                      datasource_geotag_init,
   (VikDataSourceCheckExistenceFunc)        NULL,
   (VikDataSourceAddSetupWidgetsFunc)    datasource_geotag_add_setup_widgets,
-  (VikDataSourceGetCmdStringFunc)          datasource_geotag_get_cmd_string,
-  (VikDataSourceProcessFunc)               datasource_geotag_process,
+  (VikDataSourceGetProcessOptionsFunc)  datasource_geotag_get_process_options,
+  (VikDataSourceProcessFunc)            datasource_geotag_process,
   (VikDataSourceProgressFunc)              NULL,
   (VikDataSourceAddProgressWidgetsFunc)        NULL,
   (VikDataSourceCleanupFunc)               datasource_geotag_cleanup,
@@ -74,7 +73,7 @@ VikDataSourceInterface vik_datasource_geotag_interface = {
 };
 
 /* See VikDataSourceInterface */
-static gpointer datasource_geotag_init ( )
+static gpointer datasource_geotag_init ( acq_vik_t *avt )
 {
        datasource_geotag_user_data_t *user_data = g_malloc(sizeof(datasource_geotag_user_data_t));
        user_data->filelist = NULL;
@@ -86,8 +85,6 @@ static void datasource_geotag_add_setup_widgets ( GtkWidget *dialog, VikViewport
 {
        datasource_geotag_user_data_t *userdata = (datasource_geotag_user_data_t *)user_data;
 
-       userdata->vvp = vvp;
-
        /* The files selector */
        userdata->files = gtk_file_chooser_widget_new ( GTK_FILE_CHOOSER_ACTION_OPEN );
 
@@ -122,12 +119,13 @@ static void datasource_geotag_add_setup_widgets ( GtkWidget *dialog, VikViewport
        //  However not much point since these will have images associated with them!
 
        /* Packing all widgets */
-       gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), userdata->files, TRUE, TRUE, 0 );
+       GtkBox *box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
+       gtk_box_pack_start ( box, userdata->files, TRUE, TRUE, 0 );
 
        gtk_widget_show_all ( dialog );
 }
 
-static void datasource_geotag_get_cmd_string ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype )
+static void datasource_geotag_get_process_options ( gpointer user_data, ProcessOptions *po, gpointer not_used, const gchar *not_used2, const gchar *not_used3 )
 {
        datasource_geotag_user_data_t *userdata = (datasource_geotag_user_data_t *)user_data;
        /* Retrieve the files selected */
@@ -141,15 +139,14 @@ static void datasource_geotag_get_cmd_string ( gpointer user_data, gchar **babel
        /* TODO Memorize the file filter for later use... */
        //GtkFileFilter *filter = gtk_file_chooser_get_filter ( GTK_FILE_CHOOSER(userdata->files) );
 
-       // return some value so processing will continue
-       *babelargs_or_shellcmd = g_strdup ("fake command"); // Not really used, thus no translations
+       // return some value so *thread* processing will continue
+       po->babelargs = g_strdup ("fake command"); // Not really used, thus no translations
 }
 
-
 /**
  * Process selected files and try to generate waypoints storing them in the given vtl
  */
-static gboolean datasource_geotag_process ( VikTrwLayer *vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw )
+static gboolean datasource_geotag_process ( VikTrwLayer *vtl, ProcessOptions *po, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, gpointer not_used )
 {
        datasource_geotag_user_data_t *user_data = (datasource_geotag_user_data_t *)adw->user_data;
 
@@ -159,7 +156,7 @@ static gboolean datasource_geotag_process ( VikTrwLayer *vtl, const gchar *cmd,
        while ( cur_file ) {
                gchar *filename = cur_file->data;
                gchar *name;
-               VikWaypoint *wp = a_geotag_create_waypoint_from_file ( filename, vik_viewport_get_coord_mode ( user_data->vvp ), &name );
+               VikWaypoint *wp = a_geotag_create_waypoint_from_file ( filename, vik_viewport_get_coord_mode ( adw->vvp ), &name );
                if ( wp ) {
                        // Create name if geotag method didn't return one
                        if ( !name )
@@ -168,7 +165,9 @@ static gboolean datasource_geotag_process ( VikTrwLayer *vtl, const gchar *cmd,
                        g_free ( name );
                }
                else {
-                       g_warning ( _("Unable to create waypoint from %s"), filename );
+                       gchar* msg = g_strdup_printf ( _("Unable to create waypoint from %s"), filename );
+                       vik_window_statusbar_update ( adw->vw, msg, VIK_STATUSBAR_INFO );
+                       g_free (msg);
                }
                g_free ( filename );
                cur_file = g_slist_next ( cur_file );