diff options
author | Thomas White <taw@physics.org> | 2021-02-17 10:57:06 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-02-17 10:57:06 +0100 |
commit | 96ec886a632a64072992b3a94babafe8ad7088ef (patch) | |
tree | bd0b7462d9b97eb33cb8deb22a48f53d83bbfcd0 /src/gui_ambi.c | |
parent | fa7855fded3420940efb4cc88c4f5ff90990cbef (diff) |
GUI: Move ambigator options into a GtkNotebook
Diffstat (limited to 'src/gui_ambi.c')
-rw-r--r-- | src/gui_ambi.c | 165 |
1 files changed, 126 insertions, 39 deletions
diff --git a/src/gui_ambi.c b/src/gui_ambi.c index 666da6eb..79bbde7e 100644 --- a/src/gui_ambi.c +++ b/src/gui_ambi.c @@ -45,6 +45,7 @@ struct ambi_window { struct crystfelproject *proj; + GtkWidget *jobname; GtkWidget *dataset; GtkWidget *limit_res; GtkWidget *min_res; @@ -96,57 +97,20 @@ static void ambi_response_sig(GtkWidget *dialog, gint resp, } -gint ambi_sig(GtkWidget *widget, struct crystfelproject *proj) +static GtkWidget *make_ambigator_options(struct ambi_window *win) { - GtkWidget *dialog; - GtkWidget *content_area; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *label; - struct ambi_window *win; - int i; char tmp[64]; - - win = malloc(sizeof(struct ambi_window)); - if ( win == NULL ) return 0; - - win->proj = proj; - - dialog = gtk_dialog_new_with_buttons("Resolve indexing ambiguity", - GTK_WINDOW(proj->window), - GTK_DIALOG_DESTROY_WITH_PARENT, - "Close", GTK_RESPONSE_CLOSE, - "Run", GTK_RESPONSE_ACCEPT, - NULL); - - g_signal_connect(G_OBJECT(dialog), "response", - G_CALLBACK(ambi_response_sig), - win); + struct crystfelproject *proj = win->proj; vbox = gtk_vbox_new(FALSE, 0.0); - content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - gtk_container_add(GTK_CONTAINER(content_area), vbox); - gtk_container_set_border_width(GTK_CONTAINER(content_area), 8); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); hbox = gtk_hbox_new(FALSE, 0.0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, FALSE, 4.0); - label = gtk_label_new("Indexing result for input:"); - gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), - FALSE, FALSE, 4.0); - win->dataset = gtk_combo_box_text_new(); - gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->dataset), - FALSE, FALSE, 4.0); - for ( i=0; i<proj->n_results; i++ ) { - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->dataset), - proj->results[i].name, - proj->results[i].name); - } - - hbox = gtk_hbox_new(FALSE, 0.0); - gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), - FALSE, FALSE, 4.0); label = gtk_label_new("Target ('real') point group:"); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 4.0); @@ -254,6 +218,129 @@ gint ambi_sig(GtkWidget *widget, struct crystfelproject *proj) gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->niter), FALSE, FALSE, 4.0); + return vbox; +} + + +static GtkWidget *make_job_notes_page() +{ + GtkWidget *box; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *scroll; + GtkWidget *job_notes_text; + + box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8); + gtk_container_set_border_width(GTK_CONTAINER(box), 8); + + label = gtk_label_new("Whatever you enter here will be placed in the job's folder as 'notes.txt'"); + gtk_label_set_markup(GTK_LABEL(label), + "<i>Whatever you enter here will be placed in the job's folder as 'notes.txt'</i>"); + gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(label), + FALSE, FALSE, 0); + + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); + gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox), + TRUE, TRUE, 0); + job_notes_text = gtk_text_view_new(); + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(job_notes_text), + GTK_WRAP_WORD_CHAR); + scroll = gtk_scrolled_window_new(NULL, NULL); + gtk_container_add(GTK_CONTAINER(scroll), job_notes_text); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), + GTK_SHADOW_ETCHED_IN); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(scroll), + TRUE, TRUE, 2.0); + + return box; +} + + +static GtkWidget *make_ambi_backend_opts(struct ambi_window *win) +{ + return gtk_vbox_new(FALSE, 0.0); +} + + +gint ambi_sig(GtkWidget *widget, struct crystfelproject *proj) +{ + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *notebook; + GtkWidget *backend_page; + GtkWidget *notes_page; + struct ambi_window *win; + int i; + + win = malloc(sizeof(struct ambi_window)); + if ( win == NULL ) return 0; + + win->proj = proj; + + dialog = gtk_dialog_new_with_buttons("Resolve indexing ambiguity", + GTK_WINDOW(proj->window), + GTK_DIALOG_DESTROY_WITH_PARENT, + "Close", GTK_RESPONSE_CLOSE, + "Run", GTK_RESPONSE_ACCEPT, + NULL); + + g_signal_connect(G_OBJECT(dialog), "response", + G_CALLBACK(ambi_response_sig), + win); + + vbox = gtk_vbox_new(FALSE, 0.0); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + gtk_container_add(GTK_CONTAINER(content_area), vbox); + gtk_container_set_border_width(GTK_CONTAINER(content_area), 8); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); + + hbox = gtk_hbox_new(FALSE, 0.0); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), + FALSE, FALSE, 4.0); + label = gtk_label_new("Job/output name:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + win->jobname = gtk_entry_new(); + gtk_entry_set_width_chars(GTK_ENTRY(win->jobname), 16); + gtk_entry_set_placeholder_text(GTK_ENTRY(win->jobname), + "ambi-trial-1"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->jobname), + TRUE, TRUE, 4.0); + + label = gtk_label_new("Input:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + win->dataset = gtk_combo_box_text_new(); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->dataset), + FALSE, FALSE, 4.0); + for ( i=0; i<proj->n_results; i++ ) { + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->dataset), + proj->results[i].name, + proj->results[i].name); + } + + notebook = gtk_notebook_new(); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_LEFT); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(notebook), + FALSE, FALSE, 4.0); + + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), + make_ambigator_options(win), + gtk_label_new("Indexing ambiguity")); + + backend_page = make_ambi_backend_opts(win); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), + backend_page, + gtk_label_new("Cluster/batch system")); + + notes_page = make_job_notes_page(); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), + notes_page, + gtk_label_new("Notes")); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE); gtk_widget_show_all(dialog); |