X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/a753a9a9b89b27ce0e243bd7d3980ecc559a3027..b45865b4d393f3ec0353bd5cc634cf1784f68a39:/src/acquire.c?ds=sidebyside diff --git a/src/acquire.c b/src/acquire.c index 386a4860..30525939 100644 --- a/src/acquire.c +++ b/src/acquire.c @@ -213,7 +213,7 @@ static gchar *write_tmp_track ( VikTrack *track ) * the other can be NULL. */ static void acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *source_interface, - VikTrwLayer *vtl, VikTrack *track ) + VikTrwLayer *vtl, VikTrack *track, gpointer userdata, VikDataSourceCleanupFunc cleanup_function ) { /* for manual dialogs */ GtkWidget *dialog = NULL; @@ -226,6 +226,12 @@ static void acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikD gpointer user_data; gpointer options = NULL; + acq_vik_t avt; + avt.vlp = vlp; + avt.vvp = vvp; + avt.vw = vw; + avt.userdata = userdata; + /* for UI builder */ gpointer pass_along_data; VikLayerParamData *paramdatas = NULL; @@ -234,7 +240,7 @@ static void acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikD /*** INIT AND CHECK EXISTENCE ***/ if ( source_interface->init_func ) - user_data = source_interface->init_func(); + user_data = source_interface->init_func(&avt); else user_data = NULL; pass_along_data = user_data; @@ -380,7 +386,11 @@ static void acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikD if ( source_interface->is_thread ) { if ( cmd ) { - g_thread_create((GThreadFunc)get_from_anything, wi, FALSE, NULL ); +#if GLIB_CHECK_VERSION (2, 32, 0) + g_thread_try_new ( "get_from_anything", (GThreadFunc)get_from_anything, wi, NULL ); +#else + g_thread_create ( (GThreadFunc)get_from_anything, wi, FALSE, NULL ); +#endif gtk_dialog_run ( GTK_DIALOG(dialog) ); if (w->running) { // Cancel and mark for thread to finish @@ -427,15 +437,26 @@ static void acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikD } gtk_widget_destroy ( dialog ); + + if ( cleanup_function ) + cleanup_function ( source_interface ); } /** * a_acquire: + * @vw: The #VikWindow to work with + * @vlp: The #VikLayersPanel in which a #VikTrwLayer layer may be created/appended + * @vvp: The #VikViewport defining the current view + * @source_interface: The #VikDataSourceInterface determining how and what actions to take + * @userdata: External data to be passed into the #VikDataSourceInterface + * @cleanup_function: The function to dispose the #VikDataSourceInterface if necessary * * Process the given VikDataSourceInterface for sources with no input data. */ -void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *source_interface ) { - acquire ( vw, vlp, vvp, source_interface, NULL, NULL ); +void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *source_interface, + gpointer userdata, VikDataSourceCleanupFunc cleanup_function ) +{ + acquire ( vw, vlp, vvp, source_interface, NULL, NULL, userdata, cleanup_function ); } static void acquire_trwlayer_callback ( GObject *menuitem, gpointer *pass_along ) @@ -447,7 +468,7 @@ static void acquire_trwlayer_callback ( GObject *menuitem, gpointer *pass_along VikTrwLayer *vtl = pass_along[3]; VikTrack *tr = pass_along[4]; - acquire ( vw, vlp, vvp, iface, vtl, tr ); + acquire ( vw, vlp, vvp, iface, vtl, tr, NULL, NULL ); } static GtkWidget *acquire_build_menu ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp,