aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/crystfel_gui.c36
-rw-r--r--src/crystfel_gui.h2
-rw-r--r--src/gui_ambi.c6
-rw-r--r--src/gui_index.c6
-rw-r--r--src/gui_merge.c10
5 files changed, 56 insertions, 4 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index 8b330bb9..e2be0841 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -41,6 +41,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <ctype.h>
#include <datatemplate.h>
#include <peaks.h>
@@ -1135,3 +1136,38 @@ void force_refls_on(struct crystfelproject *proj)
w = gtk_ui_manager_get_widget(proj->ui, "/ui/mainwindow/view/refls");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), 1);
}
+
+
+/* Given an "old" job title (possibly NULL), generate a new job title */
+char *make_new_job_title(const char *orig_old_title)
+{
+ size_t len, i;
+ char *old_title;
+
+ if ( orig_old_title == NULL ) return NULL;
+
+ old_title = strdup(orig_old_title);
+ if ( old_title == NULL ) return NULL;
+
+ len = strlen(old_title);
+
+ for ( i=len-1; i>0; i-- ) {
+ if ( !isdigit(old_title[i]) ) break;
+ }
+ if ( i == len-1 ) {
+ /* No digits at end */
+ char *new_title = malloc(len+3);
+ if ( new_title == NULL ) return NULL;
+ strcpy(new_title, old_title);
+ strcat(new_title, "-2");
+ return new_title;
+ } else {
+ /* Digits at end */
+ int n = atoi(&old_title[i+1]);
+ char *new_title = malloc(len+6);
+ if ( new_title == NULL ) return NULL;
+ old_title[i+1] = '\0';
+ snprintf(new_title, len+6, "%s%i", old_title, n+1);
+ return new_title;
+ }
+}
diff --git a/src/crystfel_gui.h b/src/crystfel_gui.h
index c2332fca..43c07014 100644
--- a/src/crystfel_gui.h
+++ b/src/crystfel_gui.h
@@ -70,4 +70,6 @@ extern GFile *make_job_folder(const char *job_title, const char *job_notes);
extern void force_peaks_on(struct crystfelproject *proj);
extern void force_refls_on(struct crystfelproject *proj);
+extern char *make_new_job_title(const char *old_title);
+
#endif
diff --git a/src/gui_ambi.c b/src/gui_ambi.c
index 8d07f436..00f2ffe0 100644
--- a/src/gui_ambi.c
+++ b/src/gui_ambi.c
@@ -389,6 +389,7 @@ gint ambi_sig(GtkWidget *widget, struct crystfelproject *proj)
GtkWidget *notebook;
GtkWidget *backend_page;
struct ambi_window *win;
+ char *new_title;
int i;
if ( proj->ambi_opts != NULL ) return FALSE;
@@ -426,6 +427,11 @@ gint ambi_sig(GtkWidget *widget, struct crystfelproject *proj)
gtk_entry_set_width_chars(GTK_ENTRY(win->jobname), 16);
gtk_entry_set_placeholder_text(GTK_ENTRY(win->jobname),
"ambi-trial-1");
+ new_title = make_new_job_title(proj->ambi_new_job_title);
+ if ( new_title != NULL ) {
+ gtk_entry_set_text(GTK_ENTRY(win->jobname), new_title);
+ free(new_title);
+ }
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->jobname),
TRUE, TRUE, 4.0);
diff --git a/src/gui_index.c b/src/gui_index.c
index d3217f54..03f7e831 100644
--- a/src/gui_index.c
+++ b/src/gui_index.c
@@ -326,6 +326,7 @@ gint index_all_sig(GtkWidget *widget, struct crystfelproject *proj)
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *backend_page;
+ char *new_title;
struct new_index_job_params *njp;
if ( proj->indexing_opts != NULL ) return FALSE;
@@ -361,6 +362,11 @@ gint index_all_sig(GtkWidget *widget, struct crystfelproject *proj)
gtk_entry_set_width_chars(GTK_ENTRY(njp->job_title_entry), 16);
gtk_entry_set_placeholder_text(GTK_ENTRY(njp->job_title_entry),
"indexing-trial-1");
+ new_title = make_new_job_title(proj->indexing_new_job_title);
+ if ( new_title != NULL ) {
+ gtk_entry_set_text(GTK_ENTRY(njp->job_title_entry), new_title);
+ free(new_title);
+ }
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(njp->job_title_entry),
TRUE, TRUE, 4.0);
diff --git a/src/gui_merge.c b/src/gui_merge.c
index 17f4e0b4..0a207bad 100644
--- a/src/gui_merge.c
+++ b/src/gui_merge.c
@@ -266,6 +266,7 @@ gint merge_sig(GtkWidget *widget, struct crystfelproject *proj)
GtkWidget *hbox;
GtkWidget *backend_page;
int i;
+ char *new_title;
struct new_merging_job_params *njp;
if ( proj->merging_opts != NULL ) return FALSE;
@@ -300,12 +301,13 @@ gint merge_sig(GtkWidget *widget, struct crystfelproject *proj)
njp->job_title_entry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(njp->job_title_entry),
TRUE, TRUE, 2.0);
- if ( proj->merging_new_job_title != NULL ) {
- gtk_entry_set_text(GTK_ENTRY(njp->job_title_entry),
- proj->merging_new_job_title);
- }
gtk_entry_set_placeholder_text(GTK_ENTRY(njp->job_title_entry),
"merge-trial-1");
+ new_title = make_new_job_title(proj->merging_new_job_title);
+ if ( new_title != NULL ) {
+ gtk_entry_set_text(GTK_ENTRY(njp->job_title_entry), new_title);
+ free(new_title);
+ }
label = gtk_label_new("Input:");
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label),