]>
Commit | Line | Data |
---|---|---|
1d1bc3c1 EB |
1 | /* |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
4 | * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | * | |
20 | */ | |
21 | ||
22 | #ifndef _VIKING_ACQUIRE_H | |
23 | #define _VIKING_ACQUIRE_H | |
24 | ||
a25c4c50 GB |
25 | #include <gtk/gtk.h> |
26 | ||
27 | #include "vikwindow.h" | |
28 | #include "viklayerspanel.h" | |
29 | #include "vikviewport.h" | |
30 | ||
cf697cc2 EB |
31 | typedef struct _VikDataSourceInterface VikDataSourceInterface; |
32 | ||
7b3479e3 EB |
33 | /* global data structure used to expose the progress dialog to the worker thread */ |
34 | typedef struct { | |
35 | GtkWidget *status; | |
36 | VikWindow *vw; | |
37 | VikLayersPanel *vlp; | |
38 | VikViewport *vvp; | |
39 | GtkWidget *dialog; | |
40 | gboolean ok; /* if OK is false when we exit, we MUST free w */ | |
cf697cc2 | 41 | VikDataSourceInterface *interface; |
65f0ccab | 42 | gpointer user_data; |
7b3479e3 EB |
43 | } acq_dialog_widgets_t; |
44 | ||
28c82d8b EB |
45 | typedef enum { |
46 | VIK_DATASOURCE_GPSBABEL_DIRECT, | |
47 | VIK_DATASOURCE_SHELL_CMD | |
48 | } vik_datasource_type_t; | |
49 | ||
50 | typedef enum { | |
51 | VIK_DATASOURCE_CREATENEWLAYER, | |
52 | VIK_DATASOURCE_ADDTOLAYER | |
53 | } vik_datasource_mode_t; | |
54 | /* TODO: replace track/layer? */ | |
55 | ||
56 | typedef enum { | |
57 | VIK_DATASOURCE_INPUTTYPE_NONE = 0, | |
58 | VIK_DATASOURCE_INPUTTYPE_TRWLAYER, | |
59 | VIK_DATASOURCE_INPUTTYPE_TRACK, | |
60 | VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK | |
61 | } vik_datasource_inputtype_t; | |
7b3479e3 | 62 | |
7b3479e3 | 63 | |
65f0ccab AF |
64 | /* returns pointer to state if OK, otherwise NULL */ |
65 | typedef gpointer (*VikDataSourceInitFunc) (); | |
92255687 EB |
66 | |
67 | /* returns NULL if OK, otherwise returns an error message. */ | |
68 | typedef gchar *(*VikDataSourceCheckExistenceFunc) (); | |
69 | ||
65f0ccab AF |
70 | /* Create widgets to show in a setup dialog, set up state via user_data */ |
71 | typedef void (*VikDataSourceAddSetupWidgetsFunc) ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data ); | |
72 | ||
73 | /* if VIK_DATASOURCE_GPSBABEL_DIRECT, babelargs and inputfile. | |
74 | if VIK_DATASOURCE_SHELL_CMD, shellcmd and inputtype. | |
75 | set both to NULL to signal refusal (ie already downloading) */ | |
76 | typedef void (*VikDataSourceGetCmdStringFunc) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype ); | |
77 | ||
28c82d8b EB |
78 | typedef void (*VikDataSourceGetCmdStringFuncWithInput) ( gpointer user_data, gchar **babelargs_or_shellcmd, gchar **inputfile_or_inputtype, const gchar *input_file_name ); |
79 | 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 ); | |
80 | ||
65f0ccab | 81 | /* */ |
7b3479e3 | 82 | typedef void (*VikDataSourceProgressFunc) (gpointer c, gpointer data, acq_dialog_widgets_t *w); |
65f0ccab AF |
83 | |
84 | /* Creates widgets to show in a progress dialog, may set up state via user_data */ | |
85 | typedef void (*VikDataSourceAddProgressWidgetsFunc) ( GtkWidget *dialog, gpointer user_data ); | |
86 | ||
87 | /* Frees any widgets created for the setup or progress dialogs, any allocated state, etc. */ | |
88 | typedef void (*VikDataSourceCleanupFunc) ( gpointer user_data ); | |
89 | ||
7b3479e3 | 90 | |
cf697cc2 | 91 | struct _VikDataSourceInterface { |
a8d46e0b | 92 | const gchar *window_title; |
7b3479e3 EB |
93 | const gchar *layer_title; |
94 | vik_datasource_type_t type; | |
28c82d8b EB |
95 | vik_datasource_mode_t mode; |
96 | vik_datasource_inputtype_t inputtype; | |
97 | gboolean keep_dialog_open; /* when done */ | |
98 | ||
7b3479e3 | 99 | |
28c82d8b | 100 | /*** Manual UI Building ***/ |
65f0ccab AF |
101 | VikDataSourceInitFunc init_func; |
102 | VikDataSourceCheckExistenceFunc check_existence_func; | |
103 | VikDataSourceAddSetupWidgetsFunc add_setup_widgets_func; | |
28c82d8b EB |
104 | /*** ***/ |
105 | ||
106 | /* or VikDataSourceGetCmdStringFuncWithInput, if inputtype is not NONE */ | |
65f0ccab | 107 | VikDataSourceGetCmdStringFunc get_cmd_string_func; |
7b3479e3 EB |
108 | |
109 | VikDataSourceProgressFunc progress_func; | |
110 | VikDataSourceAddProgressWidgetsFunc add_progress_widgets_func; | |
111 | VikDataSourceCleanupFunc cleanup_func; | |
28c82d8b EB |
112 | |
113 | ||
114 | /*** UI Building ***/ | |
115 | VikLayerParam * params; | |
116 | guint16 params_count; | |
117 | VikLayerParamData * params_defaults; | |
118 | gchar ** params_groups; | |
119 | guint8 params_groups_count; | |
120 | ||
cf697cc2 | 121 | }; |
7b3479e3 | 122 | |
28c82d8b EB |
123 | /**********************************/ |
124 | /**********************************/ | |
125 | /**********************************/ | |
7b3479e3 | 126 | |
28c82d8b | 127 | /* for sources with no input data */ |
7b3479e3 | 128 | void a_acquire ( VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikDataSourceInterface *interface ); |
1d1bc3c1 | 129 | |
28c82d8b EB |
130 | /* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter" |
131 | * returns NULL if no filters */ | |
132 | GtkWidget *a_acquire_trwlayer_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl); | |
133 | ||
134 | /* Create a sub menu intended for rightclicking on a TRWLayer. menu called "Filter with Track "TRACKNAME"..." | |
135 | * returns NULL if no filters or no filter track has been set | |
136 | */ | |
137 | GtkWidget *a_acquire_trwlayer_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrwLayer *vtl); | |
138 | ||
139 | /* Create a sub menu intended for rightclicking on a track. menu called "Filter" | |
140 | * returns NULL if no applicable filters */ | |
141 | GtkWidget *a_acquire_track_menu (VikWindow *vw, VikLayersPanel *vlp, VikViewport *vvp, VikTrack *tr); | |
142 | ||
143 | /* sets aplication-wide track to use with filter. references the track. */ | |
144 | void a_acquire_set_filter_track ( VikTrack *tr, const gchar *name ); | |
145 | ||
146 | ||
1d1bc3c1 | 147 | #endif |