aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-09-01 12:48:40 +0200
committerThomas White <taw@physics.org>2020-09-01 12:48:49 +0200
commit4bb477999843f1c14d81672b83607c7394e740b5 (patch)
treeebc068aa700e6af55942ab1aba7b10eb62718264 /src
parent4bed8bd2baa0aa7e126084db41c315843a19b566 (diff)
Keep a separate record of unit cell file
There seems to be no way to get a clear answer from the GtkFileChooser about whether a file is actually set. Instead, it now keeps a separate record which is set to NULL when the "clear" button is pressed, and set to the filename from the GtkFileChooserButton on the "file-set" signal.
Diffstat (limited to 'src')
-rw-r--r--src/crystfelindexingopts.c20
-rw-r--r--src/crystfelindexingopts.h1
2 files changed, 17 insertions, 4 deletions
diff --git a/src/crystfelindexingopts.c b/src/crystfelindexingopts.c
index c2fde290..2f4344a7 100644
--- a/src/crystfelindexingopts.c
+++ b/src/crystfelindexingopts.c
@@ -228,6 +228,7 @@ static GtkWidget *make_indexing_methods(CrystFELIndexingOpts *io)
static void cell_file_clear_sig(GtkButton *buton,
CrystFELIndexingOpts *io)
{
+ io->cell_file = NULL;
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(io->cell_chooser),
"(none)");
}
@@ -253,6 +254,16 @@ static void check_cell_toggle_sig(GtkToggleButton *togglebutton,
}
+static void cell_file_set_sig(GtkFileChooserButton *widget,
+ CrystFELIndexingOpts *io)
+{
+ gchar *filename;
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
+ g_free(io->cell_file);
+ io->cell_file = filename;
+}
+
+
static GtkWidget *indexing_parameters(CrystFELIndexingOpts *io)
{
GtkWidget *box;
@@ -279,6 +290,8 @@ static GtkWidget *indexing_parameters(CrystFELIndexingOpts *io)
TRUE);
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->cell_chooser),
FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(io->cell_chooser), "file-set",
+ G_CALLBACK(cell_file_set_sig), io);
button = gtk_button_new_from_icon_name("edit-clear",
GTK_ICON_SIZE_BUTTON);
g_signal_connect(G_OBJECT(button), "clicked",
@@ -420,6 +433,8 @@ GtkWidget *crystfel_indexing_opts_new()
io = g_object_new(CRYSTFEL_TYPE_INDEXING_OPTS, NULL);
+ io->cell_file = NULL;
+
gtk_notebook_append_page(GTK_NOTEBOOK(io),
indexing_parameters(io),
gtk_label_new("Indexing"));
@@ -435,10 +450,7 @@ GtkWidget *crystfel_indexing_opts_new()
char *crystfel_indexing_opts_get_cell_file(CrystFELIndexingOpts *opts)
{
- gchar *filename;
-
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(opts->cell_chooser));
- return filename;
+ return safe_strdup(opts->cell_file);
}
diff --git a/src/crystfelindexingopts.h b/src/crystfelindexingopts.h
index 58ba39bf..197f8863 100644
--- a/src/crystfelindexingopts.h
+++ b/src/crystfelindexingopts.h
@@ -54,6 +54,7 @@ struct _crystfelindexingopts
GtkNotebook parent_instance;
/*< private >*/
+ char *cell_file;
GtkWidget *cell_chooser;
GtkWidget *auto_indm;
GtkWidget *indm_chooser;