diff options
author | Thomas White <taw@physics.org> | 2020-08-26 15:00:06 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-08-26 15:00:06 +0200 |
commit | 76ff5be086e96a8f763fd99d21acbc170ff76036 (patch) | |
tree | 6d265285aa73fe8c28a43e31d871a603676522b1 /src/gui_peaksearch.c | |
parent | 94b1f2006a982444de6fe4057268d869251ce3bd (diff) |
Set peak search parameters on focus-out-event
This prevents the potentially surprising behaviour that the values do
not get accepted unless Enter is pressed before clicking Confirm.
Disadvantage: updating the peak detection is kind of slow. Ideally it
would avoid calling update_peaks() unless a value has actually changed.
Diffstat (limited to 'src/gui_peaksearch.c')
-rw-r--r-- | src/gui_peaksearch.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/gui_peaksearch.c b/src/gui_peaksearch.c index 97df46b4..93afbbe1 100644 --- a/src/gui_peaksearch.c +++ b/src/gui_peaksearch.c @@ -158,6 +158,14 @@ static void int_param_callback(GtkWidget *entry, } +static void int_param_focus_callback(GtkWidget *entry, + GdkEvent *event, + struct param_callback_vals *cbvals) +{ + int_param_callback(entry, cbvals); +} + + static void float_param_callback(GtkWidget *entry, struct param_callback_vals *cbvals) { @@ -176,6 +184,14 @@ static void float_param_callback(GtkWidget *entry, } +static void float_param_focus_callback(GtkWidget *entry, + GdkEvent *event, + struct param_callback_vals *cbvals) +{ + float_param_callback(entry, cbvals); +} + + static void free_callback_params(gpointer cbvals, GClosure *closure) { @@ -209,9 +225,14 @@ static void add_int_param(GtkWidget *params_box, const char *labeltext, if ( cbvals != NULL ) { cbvals->proj = proj; cbvals->pival = pval; - g_signal_connect_data(G_OBJECT(entry), "activate", + g_signal_connect_data(G_OBJECT(entry), + "activate", G_CALLBACK(int_param_callback), cbvals, free_callback_params, 0); + g_signal_connect(G_OBJECT(entry), + "focus-out-event", + G_CALLBACK(int_param_focus_callback), + cbvals); } else { ERROR("Failed to connect parameter callback\n"); } @@ -244,9 +265,15 @@ static void add_float_param(GtkWidget *params_box, const char *labeltext, if ( cbvals != NULL ) { cbvals->proj = proj; cbvals->pfval = pval; - g_signal_connect_data(G_OBJECT(entry), "activate", + g_signal_connect_data(G_OBJECT(entry), + "activate", G_CALLBACK(float_param_callback), cbvals, free_callback_params, 0); + g_signal_connect(G_OBJECT(entry), + "focus-out-event", + G_CALLBACK(float_param_focus_callback), + cbvals); + } else { ERROR("Failed to connect parameter callback\n"); } @@ -386,14 +413,13 @@ static void peaksearch_algo_changed(GtkWidget *combo, static void peaksearch_response_sig(GtkWidget *dialog, gint resp, struct crystfelproject *proj) { - if ( (resp == GTK_RESPONSE_DELETE_EVENT) || (resp == GTK_RESPONSE_CANCEL) ) { proj->peak_search_params = proj->original_params; - update_peaks(proj); } + update_peaks(proj); gtk_widget_destroy(dialog); proj->peak_vbox = NULL; proj->peak_params = NULL; |