]> git.street.me.uk Git - andy/viking.git/blobdiff - src/acquire.h
Fix waypoints may not be drawn when created by paste of a text location.
[andy/viking.git] / src / acquire.h
index a8691df21788330545328b8e54559733084c1ba9..fb22918fcf18ae0025d5ff5dcec42de1c2135226 100644 (file)
@@ -33,29 +33,34 @@ G_BEGIN_DECLS
 
 typedef struct _VikDataSourceInterface VikDataSourceInterface;
 
-/* global data structure used to expose the progress dialog to the worker thread */
+typedef struct {
+  VikWindow *vw;
+  VikLayersPanel *vlp;
+  VikViewport *vvp;
+  gpointer userdata;
+} acq_vik_t;
+
+/**
+ * acq_dialog_widgets_t:
+ *
+ * global data structure used to expose the progress dialog to the worker thread.
+ */
 typedef struct {
   GtkWidget *status;
   VikWindow *vw;
   VikLayersPanel *vlp;
   VikViewport *vvp;
   GtkWidget *dialog;
-  gboolean ok; /* if OK is false when we exit, we MUST free w */
+  gboolean running;
   VikDataSourceInterface *source_interface;
   gpointer user_data;
 } acq_dialog_widgets_t;
 
-/* Direct, URL & Shell types process the results with GPSBabel to create tracks/waypoint */
 typedef enum {
-  VIK_DATASOURCE_GPSBABEL_DIRECT,
-  VIK_DATASOURCE_URL,
-  VIK_DATASOURCE_SHELL_CMD,
-  VIK_DATASOURCE_INTERNAL
-} vik_datasource_type_t;
-
-typedef enum {
-  VIK_DATASOURCE_CREATENEWLAYER,
-  VIK_DATASOURCE_ADDTOLAYER
+  VIK_DATASOURCE_CREATENEWLAYER, // Generally Datasources shouldn't use these and let the HCI decide
+  VIK_DATASOURCE_ADDTOLAYER,     //    between the create or add to layer options
+  VIK_DATASOURCE_AUTO_LAYER_MANAGEMENT,
+  VIK_DATASOURCE_MANUAL_LAYER_MANAGEMENT,
 } vik_datasource_mode_t;
 /* TODO: replace track/layer? */
 
@@ -66,47 +71,87 @@ typedef enum {
   VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK
 } vik_datasource_inputtype_t;
 
-/* returns pointer to state if OK, otherwise NULL */
-typedef gpointer (*VikDataSourceInitFunc) ();
+/**
+ * VikDataSourceInitFunc:
+ * 
+ * Returns: pointer to state if OK, otherwise %NULL
+ */
+typedef gpointer (*VikDataSourceInitFunc) ( acq_vik_t *avt );
 
-/* returns NULL if OK, otherwise returns an error message. */
+/**
+ * VikDataSourceCheckExistenceFunc:
+ * 
+ * Returns: %NULL if OK, otherwise returns an error message.
+ */
 typedef gchar *(*VikDataSourceCheckExistenceFunc) ();
 
-/* Create widgets to show in a setup dialog, set up state via user_data */
+/**
+ * VikDataSourceAddSetupWidgetsFunc:
+ * 
+ * Create widgets to show in a setup dialog, set up state via user_data.
+ */
 typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data );
 
-/* if VIK_DATASOURCE_GPSBABEL_DIRECT, babelargs and inputfile.
-   if VIK_DATASOURCE_SHELL_CMD, shellcmd and inputtype.
-   if VIK_DATASOURCE_URL, url and inputtype.
-   set both to NULL to signal refusal (ie already downloading) */
-typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );
+/**
+ * VikDataSourceGetCmdStringFunc:
+ * @user_data: provided by #VikDataSourceInterface.init_func or dialog with params
+ * @args: the arguments computed for #VikDataSourceInterface.process_func
+ * @extra: extra arguments for #VikDataSourceInterface.process_func
+ * @options: even more options for #VikDataSourceInterface.process_func
+ * 
+ * set both to %NULL to signal refusal (ie already downloading).
+ */
+typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **args, gchar **extra, gpointer options );
 
 typedef void (*VikDataSourceGetCmdStringFuncWithInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name );
 typedef void (*VikDataSourceGetCmdStringFuncWithInputInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name, const gchar *input_track_file_name );
 
-/* The actual function to do stuff - must report success/failure */
-typedef gboolean (*VikDataSourceProcessFunc)  ( gpointer vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw );
+/**
+ * VikDataSourceProcessFunc:
+ * @vtl:
+ * @cmd: the arguments computed by #VikDataSourceInterface.get_cmd_string_func
+ * @extra: the extra arguments computed by #VikDataSourceInterface.get_cmd_string_func
+ * @status_cb: the #VikDataSourceInterface.progress_func
+ * @adw: the widgets and data used by #VikDataSourceInterface.progress_func
+ * @options: more options returned by #VikDataSourceInterface.get_cmd_string_func
+ * 
+ * The actual function to do stuff - must report success/failure.
+ */
+typedef gboolean (*VikDataSourceProcessFunc)  ( gpointer vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw, gpointer options );
 
 /* */
-typedef void  (*VikDataSourceProgressFunc)  (gpointer c, gpointer data, acq_dialog_widgets_t *w);
+typedef void  (*VikDataSourceProgressFunc)  ( BabelProgressCode c, gpointer data, acq_dialog_widgets_t *w );
 
-/* Creates widgets to show in a progress dialog, may set up state via user_data */
+/**
+ * VikDataSourceAddProgressWidgetsFunc:
+ * 
+ * Creates widgets to show in a progress dialog, may set up state via user_data.
+ */
 typedef void  (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data );
 
-/* Frees any widgets created for the setup or progress dialogs, any allocated state, etc. */
+/**
+ * VikDataSourceCleanupFunc:
+ * 
+ * Frees any widgets created for the setup or progress dialogs, any allocated state, etc.
+ */
 typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data );
 
 typedef void (*VikDataSourceOffFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype );;
 
+/**
+ * VikDataSourceInterface:
+ * 
+ * Main interface.
+ */
 struct _VikDataSourceInterface {
   const gchar *window_title;
   const gchar *layer_title;
-  vik_datasource_type_t type;
   vik_datasource_mode_t mode;
   vik_datasource_inputtype_t inputtype;
   gboolean autoview;
   gboolean keep_dialog_open; /* when done */
 
+  gboolean is_thread;
 
   /*** Manual UI Building ***/
   VikDataSourceInitFunc init_func;
@@ -133,27 +178,22 @@ struct _VikDataSourceInterface {
 
 };
 
-/**********************************/
-/**********************************/
 /**********************************/
 
-/* for sources with no input data */
-void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *source_interface );
+void a_acquire ( VikWindow *vw,
+                 VikLayersPanel *vlp,
+                 VikViewport *vvp,
+                 vik_datasource_mode_t mode,
+                 VikDataSourceInterface *source_interface,
+                 gpointer userdata,
+                 VikDataSourceCleanupFunc cleanup_function );
 
-/* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter"
- * returns NULL if no filters */
 GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
 
-/* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter with Track "TRACKNAME"..."
- * returns NULL if no filters or no filter track has been set
- */
 GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl);
 
-/* Create a sub menu intended for rightclicking on a track. menu called "Filter"
- * returns NULL if no applicable filters */
 GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr);
 
-/* sets application-wide track to use with filter. references the track. */
 void a_acquire_set_filter_track ( VikTrack *tr );
 
 G_END_DECLS