diff options
author | Thomas White <taw@physics.org> | 2020-03-27 17:24:12 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:42:57 +0200 |
commit | ba77d15bc3b743dd506a943189c13c4e95f33760 (patch) | |
tree | c50c604ad5ddb4722a5a985413721ad477bf0521 /src | |
parent | d80dec2c52ce8c7734506440f275467a1ee133cc (diff) |
Add info bar / progress bar
Diffstat (limited to 'src')
-rw-r--r-- | src/crystfel_gui.c | 31 | ||||
-rw-r--r-- | src/crystfel_gui.h | 3 | ||||
-rw-r--r-- | src/gui_backend_local.c | 4 | ||||
-rw-r--r-- | src/gui_index.c | 9 |
4 files changed, 45 insertions, 2 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 2990c488..c086b0cf 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -541,6 +541,19 @@ static void add_gui_message(enum log_msg_type type, const char *msg, } +static void infobar_response_sig(GtkInfoBar *infobar, gint resp, + gpointer data) +{ + struct crystfelproject *proj = data; + + if ( resp == GTK_RESPONSE_CANCEL ) { + proj->backend->cancel(proj); + } + + gtk_info_bar_set_revealed(GTK_INFO_BAR(proj->info_bar), FALSE); +} + + int main(int argc, char *argv[]) { int c; @@ -553,6 +566,7 @@ int main(int argc, char *argv[]) GtkWidget *main_vbox; GtkWidget *toolbar; GtkWidget *button; + GtkWidget *bar_area; /* Long options */ const struct option longopts[] = { @@ -682,6 +696,23 @@ int main(int argc, char *argv[]) gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(main_vbox)); gtk_paned_pack2(GTK_PANED(hpaned), GTK_WIDGET(frame), TRUE, TRUE); + /* Progress info bar */ + proj.info_bar = gtk_info_bar_new_with_buttons(GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + NULL); + gtk_box_pack_end(GTK_BOX(main_vbox), GTK_WIDGET(proj.info_bar), + FALSE, FALSE, 0.0); + bar_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(proj.info_bar)); + proj.progressbar = gtk_progress_bar_new(); + gtk_box_pack_start(GTK_BOX(bar_area), + GTK_WIDGET(proj.progressbar), + TRUE, TRUE, 0.0); + gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(proj.progressbar), + TRUE); + gtk_info_bar_set_revealed(GTK_INFO_BAR(proj.info_bar), FALSE); + g_signal_connect(G_OBJECT(proj.info_bar), "response", + G_CALLBACK(infobar_response_sig), &proj); + /* Icon region at left */ proj.icons = gtk_vbox_new(FALSE, 0.0); scroll = gtk_scrolled_window_new(NULL, NULL); diff --git a/src/crystfel_gui.h b/src/crystfel_gui.h index 5ca37f8e..e303c505 100644 --- a/src/crystfel_gui.h +++ b/src/crystfel_gui.h @@ -95,6 +95,9 @@ struct crystfelproject { GtkWidget *unitcell_combo; + GtkWidget *info_bar; + GtkWidget *progressbar; + struct crystfel_backend *backend; }; diff --git a/src/gui_backend_local.c b/src/gui_backend_local.c index 7ef059ab..80057a03 100644 --- a/src/gui_backend_local.c +++ b/src/gui_backend_local.c @@ -39,6 +39,7 @@ static gboolean index_readable(GIOChannel *source, GIOCondition cond, GError *err = NULL; struct crystfelproject *proj = vp; gchar *line; + double frac = 0.1; r = g_io_channel_read_line(source, &line, NULL, NULL, &err); if ( r == G_IO_STATUS_EOF ) { @@ -52,6 +53,9 @@ static gboolean index_readable(GIOChannel *source, GIOCondition cond, chomp(line); STATUS("Got line '%s'\n", line); + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(proj->progressbar), + frac); + g_free(line); return TRUE; diff --git a/src/gui_index.c b/src/gui_index.c index a09b4c27..46728716 100644 --- a/src/gui_index.c +++ b/src/gui_index.c @@ -58,8 +58,13 @@ static void unitcell_response_sig(GtkWidget *dialog, gint resp, return; } - proj->backend->run_unitcell(proj, algo); - proj->unitcell_combo = NULL; + if ( proj->backend->run_unitcell(proj, algo) == 0 ) { + proj->unitcell_combo = NULL; + + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(proj->progressbar), + "Indexing (determine unit cell parameters)"); + gtk_info_bar_set_revealed(GTK_INFO_BAR(proj->info_bar), TRUE); + } } |