]> git.street.me.uk Git - andy/viking.git/blobdiff - src/datasource_osm_my_traces.c
[QA] Remove unused parameter
[andy/viking.git] / src / datasource_osm_my_traces.c
index 1f29e8c0f39d8b1a4c3a034f6304931b2585185a..f496206c4724c616bc527f8257acac0fdf69c6ba 100644 (file)
@@ -49,7 +49,7 @@ typedef struct {
        VikViewport *vvp;
 } datasource_osm_my_traces_t;
 
-static gpointer datasource_osm_my_traces_init( );
+static gpointer datasource_osm_my_traces_init ( acq_vik_t *avt );
 static void datasource_osm_my_traces_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
 static void datasource_osm_my_traces_get_cmd_string ( gpointer user_data, gchar **args, gchar **extra, DownloadMapOptions *options );
 static gboolean datasource_osm_my_traces_process  ( VikTrwLayer *vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, DownloadMapOptions *options_unused );
@@ -80,7 +80,7 @@ VikDataSourceInterface vik_datasource_osm_my_traces_interface = {
   0
 };
 
-static gpointer datasource_osm_my_traces_init ( )
+static gpointer datasource_osm_my_traces_init ( acq_vik_t *avt )
 {
   datasource_osm_my_traces_t *data = g_malloc(sizeof(*data));
   // Reuse GPS functions
@@ -111,11 +111,14 @@ static void datasource_osm_my_traces_add_setup_widgets ( GtkWidget *dialog, VikV
        password_label = gtk_label_new ( _("Password:") );
        data->password_entry = gtk_entry_new ();
 
-       gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), password_label, FALSE, FALSE, 0 );
-       gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), data->password_entry, FALSE, FALSE, 0 );
        gtk_widget_set_tooltip_markup ( GTK_WIDGET(data->password_entry), _("The password used to login to OSM") );
 
        osm_login_widgets (data->user_entry, data->password_entry);
+
+       /* Packing all widgets */
+       GtkBox *box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
+       gtk_box_pack_start ( box, password_label, FALSE, FALSE, 0 );
+       gtk_box_pack_start ( box, data->password_entry, FALSE, FALSE, 0 );
        gtk_widget_show_all ( dialog );
 
        /* Keep reference to viewport */
@@ -491,6 +494,7 @@ static GList *select_from_list (GtkWindow *parent, GList *list, const gchar *tit
                                                }
                                                list_runner = g_list_next ( list_runner );
                                        }
+                                       g_free ( name );
                                }
                        }
                        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL(store), &iter ) );
@@ -564,7 +568,8 @@ static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar
 
        gchar *user_pass = osm_get_login();
 
-       DownloadMapOptions options = { FALSE, FALSE, NULL, 2, NULL, user_pass }; // Allow a couple of redirects
+       // Support .zip + bzip2 files directly
+       DownloadMapOptions options = { FALSE, FALSE, NULL, 2, NULL, user_pass, a_try_decompress_file }; // Allow a couple of redirects
 
        xml_data *xd = g_malloc ( sizeof (xml_data) );
        //xd->xpath = g_string_new ( "" );
@@ -600,6 +605,10 @@ static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar
        GList *selected = select_from_list ( GTK_WINDOW(adw->vw), xd->list_of_gpx_meta_data, "Select GPS Traces", "Select the GPS traces you want to add." );
     if (vik_datasource_osm_my_traces_interface.is_thread) gdk_threads_leave();
 
+       // If non thread - show program is 'doing something...'
+       if ( !vik_datasource_osm_my_traces_interface.is_thread )
+               vik_window_set_busy_cursor ( adw->vw );
+
        // If passed in on an existing layer - we will create everything into that.
        //  thus with many differing gpx's - this will combine all waypoints into this single layer!
        // Hence the preference is to create multiple layers
@@ -618,12 +627,11 @@ static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar
 
                if ( create_new_layer ) {
                        // Have data but no layer - so create one
-                       vtlX = VIK_TRW_LAYER ( vik_layer_create ( VIK_LAYER_TRW, vik_window_viewport(adw->vw), NULL, FALSE ) );
+                       vtlX = VIK_TRW_LAYER ( vik_layer_create ( VIK_LAYER_TRW, adw->vvp, FALSE ) );
                        if ( ((gpx_meta_data_t*)selected_iterator->data)->name )
                                vik_layer_rename ( VIK_LAYER ( vtlX ), ((gpx_meta_data_t*)selected_iterator->data)->name );
                        else
                                vik_layer_rename ( VIK_LAYER ( vtlX ), _("My OSM Traces") );
-                       vik_aggregate_layer_add_layer ( vik_layers_panel_get_top_layer (adw->vlp), VIK_LAYER(vtlX), TRUE );
                }
 
                result = FALSE;
@@ -639,12 +647,15 @@ static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar
                        // TODO feedback to UI to inform which traces failed
                        if ( !result )
                                g_warning ( _("Unable to get trace: %s"), url );
+                       g_free ( url );
                }
 
                if ( result ) {
+                       // Can use the layer
+                       vik_aggregate_layer_add_layer ( vik_layers_panel_get_top_layer (adw->vlp), VIK_LAYER(vtlX), TRUE );
                        // Move to area of the track
-                       vik_trw_layer_auto_set_view ( vtlX, vik_window_viewport(adw->vw) );
                        vik_layer_post_read ( VIK_LAYER(vtlX), vik_window_viewport(adw->vw), TRUE );
+                       vik_trw_layer_auto_set_view ( vtlX, vik_window_viewport(adw->vw) );
                        vtl_last = vtlX;
                }
                else if ( create_new_layer ) {
@@ -676,6 +687,9 @@ static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar
                // Process was cancelled but need to return that it proceeded as expected
                result = TRUE;
 
+       if ( !vik_datasource_osm_my_traces_interface.is_thread )
+               vik_window_clear_busy_cursor ( adw->vw );
+
        return result;
 }