#include "viking.h"
#include "acquire.h"
#include "babel.h"
+#include "ui_util.h"
// Initially was just going to be a URL and always in GPX format
// But might as well specify the file type as per datasource_file.c
static gpointer datasource_url_init ( acq_vik_t *avt );
static void datasource_url_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
-static void datasource_url_get_cmd_string ( datasource_url_widgets_t *widgets, gchar **cmd, gchar **input_file_type, DownloadMapOptions *options );
+static void datasource_url_get_process_options ( datasource_url_widgets_t *widgets, ProcessOptions *po, DownloadFileOptions *download_options, const gchar *not_used2, const gchar *not_used3 );
static void datasource_url_cleanup ( gpointer data );
VikDataSourceInterface vik_datasource_url_interface = {
N_("Acquire from URL"),
N_("URL"),
- VIK_DATASOURCE_CREATENEWLAYER,
+ VIK_DATASOURCE_AUTO_LAYER_MANAGEMENT,
VIK_DATASOURCE_INPUTTYPE_NONE,
TRUE,
TRUE,
(VikDataSourceInitFunc) datasource_url_init,
(VikDataSourceCheckExistenceFunc) NULL,
(VikDataSourceAddSetupWidgetsFunc) datasource_url_add_setup_widgets,
- (VikDataSourceGetCmdStringFunc) datasource_url_get_cmd_string,
- (VikDataSourceProcessFunc) a_babel_convert_from_url,
+ (VikDataSourceGetProcessOptionsFunc) datasource_url_get_process_options,
+ (VikDataSourceProcessFunc) a_babel_convert_from,
(VikDataSourceProgressFunc) NULL,
(VikDataSourceAddProgressWidgetsFunc) NULL,
(VikDataSourceCleanupFunc) datasource_url_cleanup,
{
datasource_url_widgets_t *widgets = (datasource_url_widgets_t *)user_data;
GtkWidget *label = gtk_label_new (_("URL:"));
- widgets->url = gtk_entry_new ( );
+ widgets->url = ui_entry_new ( NULL, GTK_ENTRY_ICON_SECONDARY );
+ // 'ok' when press return in the entry
+ g_signal_connect_swapped ( widgets->url, "activate", G_CALLBACK(a_dialog_response_accept), dialog );
GtkWidget *type_label = gtk_label_new (_("File type:"));
last_type = ( wanted_entry < 0 ) ? 0 : wanted_entry;
}
- if ( a_babel_file_list ) {
+ if ( a_babel_available() ) {
widgets->type = vik_combo_box_text_new ();
g_list_foreach (a_babel_file_list, fill_combo_box, widgets->type);
gtk_combo_box_set_active (GTK_COMBO_BOX (widgets->type), last_type);
gtk_widget_show_all(dialog);
}
-static void datasource_url_get_cmd_string ( datasource_url_widgets_t *widgets, gchar **cmd, gchar **input_file_type, DownloadMapOptions *options )
+static void datasource_url_get_process_options ( datasource_url_widgets_t *widgets, ProcessOptions *po, DownloadFileOptions *download_options, const gchar *not_used2, const gchar *not_used3 )
{
// Retrieve the user entered value
const gchar *value = gtk_entry_get_text ( GTK_ENTRY(widgets->url) );
if (GTK_IS_COMBO_BOX (widgets->type) )
last_type = gtk_combo_box_get_active ( GTK_COMBO_BOX (widgets->type) );
- *input_file_type = NULL; // Default to gpx
+ po->input_file_type = NULL; // Default to gpx
if ( a_babel_file_list )
- *input_file_type = g_strdup ( ((BabelFile*)g_list_nth_data (a_babel_file_list, last_type))->name );
+ po->input_file_type = g_strdup ( ((BabelFile*)g_list_nth_data (a_babel_file_list, last_type))->name );
- *cmd = g_strdup ( value );
- options = NULL;
+ po->url = g_strdup ( value );
+
+ // Support .zip + bzip2 files directly
+ download_options->convert_file = a_try_decompress_file;
+ download_options->follow_location = 5;
}
static void datasource_url_cleanup ( gpointer data )