static void datasource_osm_my_traces_get_process_options ( gpointer user_data, ProcessOptions *po, DownloadMapOptions *options, const gchar *notused1, const gchar *notused2 ) { datasource_osm_my_traces_t *data = (datasource_osm_my_traces_t*) user_data; /* overwrite authentication info */ osm_set_login ( gtk_entry_get_text ( GTK_ENTRY(data->user_entry) ), gtk_entry_get_text ( GTK_ENTRY(data->password_entry) ) ); // If going to use the values passed back into the process function parameters then they need to be set. // But ATM we aren't options = NULL; }
static void datasource_osm_my_traces_get_cmd_string ( gpointer user_data, gchar **args, gchar **extra, DownloadMapOptions *options ) { datasource_osm_my_traces_t *data = (datasource_osm_my_traces_t*) user_data; /* overwrite authentication info */ osm_set_login ( gtk_entry_get_text ( GTK_ENTRY(data->user_entry) ), gtk_entry_get_text ( GTK_ENTRY(data->password_entry) ) ); // If going to use the values passed back into the process function parameters then these need to be set. // But ATM we aren't *args = NULL; *extra = NULL; options = NULL; }
/** * Uploading a VikTrwLayer * * @param vtl VikTrwLayer * @param trk if not null, the track to upload */ void osm_traces_upload_viktrwlayer ( VikTrwLayer *vtl, VikTrack *trk ) { GtkWidget *dia = gtk_dialog_new_with_buttons (_("OSM upload"), VIK_GTK_WINDOW_FROM_LAYER(vtl), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); const gchar *name = NULL; GtkWidget *user_label, *user_entry = NULL; GtkWidget *password_label, *password_entry = NULL; GtkWidget *name_label, *name_entry; GtkWidget *description_label, *description_entry; GtkWidget *tags_label, *tags_entry; GtkWidget *visibility; GtkWidget *anonymize_checkbutton = NULL; const OsmTraceVis_t *vis_t; if ( osm_use_basic_auth() ) { user_label = gtk_label_new(_("Email/username:"******"The email/username used as login\n" "<small>Enter the email/username you use to login into www.openstreetmap.org.</small>")); password_label = gtk_label_new(_("Password:"******"The password used to login\n" "<small>Enter the password you use to login into www.openstreetmap.org.</small>")); osm_login_widgets ( user_entry, password_entry ); } name_label = gtk_label_new(_("File's name:")); name_entry = ui_entry_new ( NULL, GTK_ENTRY_ICON_SECONDARY ); if (trk != NULL) name = trk->name; else name = vik_layer_get_name(VIK_LAYER(vtl)); gtk_entry_set_text(GTK_ENTRY(name_entry), name); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), name_label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), name_entry, FALSE, FALSE, 0); gtk_widget_set_tooltip_markup(GTK_WIDGET(name_entry), _("The name of the file on OSM\n" "<small>This is the name of the file created on the server." "This is not the name of the local file.</small>")); description_label = gtk_label_new(_("Description:")); description_entry = ui_entry_new ( NULL, GTK_ENTRY_ICON_SECONDARY ); const gchar *description = NULL; if (trk != NULL) description = trk->description; else { VikTRWMetadata *md = vik_trw_layer_get_metadata (vtl); description = md ? md->description : NULL; } if (description) gtk_entry_set_text(GTK_ENTRY(description_entry), description); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), description_label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), description_entry, FALSE, FALSE, 0); gtk_widget_set_tooltip_text(GTK_WIDGET(description_entry), _("The description of the trace")); if (trk != NULL) { GtkWidget *label = gtk_label_new(_("Anonymize Times:")); anonymize_checkbutton = gtk_check_button_new (); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), anonymize_checkbutton, FALSE, FALSE, 0); gtk_widget_set_tooltip_text(GTK_WIDGET(anonymize_checkbutton), _("Anonymize times of the trace.\n" "<small>You may choose to make the trace identifiable, yet mask the actual real time values</small>")); } tags_label = gtk_label_new(_("Tags:")); tags_entry = ui_entry_new ( NULL, GTK_ENTRY_ICON_SECONDARY ); VikTRWMetadata *md = vik_trw_layer_get_metadata (vtl); if (md->keywords) gtk_entry_set_text(GTK_ENTRY(tags_entry), md->keywords); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), tags_label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), tags_entry, FALSE, FALSE, 0); gtk_widget_set_tooltip_text(GTK_WIDGET(tags_entry), _("The tags associated to the trace")); visibility = vik_combo_box_text_new(); for (vis_t = OsmTraceVis; vis_t->combostr != NULL; vis_t++) vik_combo_box_text_append (visibility, vis_t->combostr); // Set identifiable by default or use the settings for the value if ( last_active < 0 ) { gint find_entry = -1; gint wanted_entry = -1; gchar *vis = NULL; if ( a_settings_get_string ( VIK_SETTINGS_OSM_TRACE_VIS, &vis ) ) { // Use setting if ( vis ) { for (vis_t = OsmTraceVis; vis_t->apistr != NULL; vis_t++) { find_entry++; if (!strcmp(vis, vis_t->apistr)) { wanted_entry = find_entry; } } } g_free ( vis ); // If not found set it to the first entry, otherwise use the entry last_active = ( wanted_entry < 0 ) ? 0 : wanted_entry; } else last_active = 0; } gtk_combo_box_set_active(GTK_COMBO_BOX(visibility), last_active); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dia))), GTK_WIDGET(visibility), FALSE, FALSE, 0); /* User should think about it first... */ gtk_dialog_set_default_response ( GTK_DIALOG(dia), GTK_RESPONSE_REJECT ); gtk_widget_show_all ( dia ); gtk_widget_grab_focus ( description_entry ); if ( gtk_dialog_run ( GTK_DIALOG(dia) ) == GTK_RESPONSE_ACCEPT ) { gchar *title = NULL; if ( osm_use_basic_auth() ) { /* overwrite authentication info */ osm_set_login(gtk_entry_get_text(GTK_ENTRY(user_entry)), gtk_entry_get_text(GTK_ENTRY(password_entry))); } /* Storing data for the future thread */ OsmTracesInfo *info = g_malloc(sizeof(OsmTracesInfo)); info->name = g_strdup(gtk_entry_get_text(GTK_ENTRY(name_entry))); info->description = g_strdup(gtk_entry_get_text(GTK_ENTRY(description_entry))); /* TODO Normalize tags: they will be used as URL part */ info->tags = g_strdup(gtk_entry_get_text(GTK_ENTRY(tags_entry))); info->vistype = &OsmTraceVis[gtk_combo_box_get_active(GTK_COMBO_BOX(visibility))]; info->vtl = VIK_TRW_LAYER(g_object_ref(vtl)); info->trk = trk; if (trk != NULL && anonymize_checkbutton != NULL ) info->anonymize_times = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(anonymize_checkbutton)); else info->anonymize_times = FALSE; // Save visibility value for default reuse last_active = gtk_combo_box_get_active(GTK_COMBO_BOX(visibility)); a_settings_set_string ( VIK_SETTINGS_OSM_TRACE_VIS, OsmTraceVis[last_active].apistr ); title = g_strdup_printf(_("Uploading %s to OSM"), info->name); // launch the thread a_background_thread( BACKGROUND_POOL_REMOTE, VIK_GTK_WINDOW_FROM_LAYER(vtl), /* parent window */ title, /* description string */ (vik_thr_func) osm_traces_upload_thread, /* function to call within thread */ info, /* pass along data */ (vik_thr_free_func) oti_free, /* function to free pass along data */ (vik_thr_free_func) NULL, 1 ); g_free ( title ); title = NULL; } gtk_widget_destroy ( dia ); }