mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Remove the ability to 'Import' .SDA files
We can instead 'Open' these files as they are just bastardized XML files. This gets us back to a more consistent point where 'Import' gets data directly from the dive computer (and hopefully soon we will add the ability to load a dive directly from a uemis SDA to libdivecomputer), and 'Open' loads a file from the filesystem of the computer we are running on (this last sentence phrased so awkwardly as the uemis Zurich SDA is a computer and presents a file system when connected via USB - it just doesn't have the dive data in an accessible format in that file system). As a bonus we get to throw away quite a bit of code (the uemis specific file handling, mini-XML parser with helper functions, the file open dialog in the importer). Yay! Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
254b851e44
commit
c15f798a85
5 changed files with 2 additions and 163 deletions
42
gtk-gui.c
42
gtk-gui.c
|
@ -103,6 +103,8 @@ static void file_open(GtkWidget *w, gpointer data)
|
|||
filter = gtk_file_filter_new();
|
||||
gtk_file_filter_add_pattern(filter, "*.xml");
|
||||
gtk_file_filter_add_pattern(filter, "*.XML");
|
||||
gtk_file_filter_add_pattern(filter, "*.sda");
|
||||
gtk_file_filter_add_pattern(filter, "*.SDA");
|
||||
gtk_file_filter_add_mime_type(filter, "text/xml");
|
||||
gtk_file_filter_set_name(filter, "XML file");
|
||||
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
|
||||
|
@ -632,46 +634,6 @@ void run_ui(void)
|
|||
gtk_main();
|
||||
}
|
||||
|
||||
/* get the filenames the user selects and call the parsing function
|
||||
* on them
|
||||
* return 0 if the user cancelled the dialog
|
||||
*/
|
||||
int open_import_file_dialog(char *filterpattern, char *filtertext,
|
||||
void(* parse_function)(char *))
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
GtkWidget *dialog;
|
||||
GtkFileFilter *filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_add_pattern (filter, filterpattern);
|
||||
gtk_file_filter_set_name(filter, filtertext);
|
||||
dialog = gtk_file_chooser_dialog_new("Open File",
|
||||
GTK_WINDOW(main_window),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
|
||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
|
||||
|
||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||
GSList *filenames;
|
||||
char *filename;
|
||||
filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
|
||||
while(filenames != NULL) {
|
||||
filename = (char *)filenames->data;
|
||||
parse_function(filename);
|
||||
g_free(filename);
|
||||
filenames = g_slist_next(filenames);
|
||||
}
|
||||
g_slist_free(filenames);
|
||||
ret = 1;
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
{
|
||||
struct dive *dive = current_dive;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue