]> git.street.me.uk Git - andy/viking.git/blobdiff - src/datasource_osm_my_traces.c
added save previous user input string and input label options to datasource search...
[andy/viking.git] / src / datasource_osm_my_traces.c
index 10e9f616609e39524243cc01ed509180a88ff758..78b544bbf5646b39373aa1a5a516cec1df5ae9a2 100644 (file)
@@ -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;
@@ -636,15 +644,21 @@ static gboolean datasource_osm_my_traces_process ( VikTrwLayer *vtl, const gchar
                        // http://developer.gnome.org/gtk/2.24/GtkProgressBar.html
 
                        got_something = got_something || result;
-                       // TODO feedback to UI to inform which traces failed
-                       if ( !result )
-                               g_warning ( _("Unable to get trace: %s"), url );
+                       if ( !result ) {
+                               // Report errors to the status bar
+                               gchar* msg = g_strdup_printf ( _("Unable to get trace: %s"), url );
+                               vik_window_statusbar_update ( adw->vw, msg, VIK_STATUSBAR_INFO );
+                               g_free (msg);
+                       }
+                       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 +690,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;
 }