X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/805d282e7a5a8ac92df2cf1a0c1987cfe1756101..ecb510183ad77bf7ce7b3a4e2a25ed3364e928ed:/src/acquire.h diff --git a/src/acquire.h b/src/acquire.h index db5ca681..6b8a7a88 100644 --- a/src/acquire.h +++ b/src/acquire.h @@ -22,6 +22,14 @@ #ifndef _VIKING_ACQUIRE_H #define _VIKING_ACQUIRE_H +#include + +#include "vikwindow.h" +#include "viklayerspanel.h" +#include "vikviewport.h" + +typedef struct _VikDataSourceInterface VikDataSourceInterface; + /* global data structure used to expose the progress dialog to the worker thread */ typedef struct { GtkWidget *status; @@ -30,36 +38,53 @@ typedef struct { VikViewport *vvp; GtkWidget *dialog; gboolean ok; /* if OK is false when we exit, we MUST free w */ - gpointer specific_data; + VikDataSourceInterface *interface; + gpointer user_data; } acq_dialog_widgets_t; typedef enum { VIK_DATASOURCE_GPSBABEL_DIRECT, VIK_DATASOURCE_SHELL_CMD } vik_datasource_type_t; typedef enum { VIK_DATASOURCE_CREATENEWLAYER, VIK_DATASOURCE_ADDTOLAYER } vik_datasource_mode_t; -typedef gpointer (*VikDataSourceAddWidgetsFunc) ( GtkWidget *dialog ); + +/* returns pointer to state if OK, otherwise NULL */ +typedef gpointer (*VikDataSourceInitFunc) (); + +/* 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 */ +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. set both to NULL to signal refusal (ie already downloading) */ -typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer widgets_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype ); -typedef void (*VikDataSourceFirstCleanupFunc) ( gpointer widgets_data ); +typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype ); + +/* */ typedef void (*VikDataSourceProgressFunc) (gpointer c, gpointer data, acq_dialog_widgets_t *w); -typedef gpointer (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog ); -typedef void (*VikDataSourceCleanupFunc) ( gpointer progress_widgets_data ); -typedef struct { +/* 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. */ +typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data ); + + +struct _VikDataSourceInterface { + const gchar *window_title; const gchar *layer_title; vik_datasource_type_t type; vik_datasource_type_t mode; - VikDataSourceAddWidgetsFunc add_widgets_func; /* NULL if no first dialog */ - VikDataSourceGetCmdStringFunc get_cmd_string_func; /* passed rv from above */ - VikDataSourceFirstCleanupFunc first_cleanup_func; /* frees rv from addwidgets */ + VikDataSourceInitFunc init_func; + VikDataSourceCheckExistenceFunc check_existence_func; + VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func; + VikDataSourceGetCmdStringFunc get_cmd_string_func; VikDataSourceProgressFunc progress_func; VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func; VikDataSourceCleanupFunc cleanup_func; -} VikDataSourceInterface; +}; void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *interface );