GnuCash  5.6-150-g038405b370+
Files | Typedefs | Functions
Progress Dialog

Dialog for displaying progress of long-running operations. More...

Files

file  dialog-progress.h
 API for displaying progress of long-running operations.
 

Typedefs

typedef gboolean(* GNCProgressCancelFunc) (gpointer user_data)
 

Functions

GNCProgressDialog * gnc_progress_dialog_new (GtkWidget *parent, gboolean use_ok_button)
 Displays a pop-up dialog for showing the progress of a long-running activity. More...
 
GNCProgressDialog * gnc_progress_dialog_custom (GtkLabel *primary, GtkLabel *secondary, GtkProgressBar *bar, GtkLabel *suboperation, GtkTextView *log)
 Creates a dialog for displaying the progress of an activity using existing widgets. More...
 
void gnc_progress_dialog_set_title (GNCProgressDialog *progress, const char *title)
 Set the title of a pop-up progress dialog. More...
 
void gnc_progress_dialog_set_primary (GNCProgressDialog *progress, const gchar *str)
 Set the primary text of the progress dialog. More...
 
void gnc_progress_dialog_set_heading (GNCProgressDialog *progress, const char *heading)
 Set the primary text of the progress dialog. More...
 
void gnc_progress_dialog_set_secondary (GNCProgressDialog *progress, const gchar *str)
 Set the secondary text of the progress dialog. More...
 
void gnc_progress_dialog_set_sub (GNCProgressDialog *progress, const gchar *str)
 Set the suboperation text of the progress dialog. More...
 
void gnc_progress_dialog_reset_log (GNCProgressDialog *progress)
 Show the progress log and delete any existing text. More...
 
void gnc_progress_dialog_append_log (GNCProgressDialog *progress, const gchar *str)
 Append str to the progress log. More...
 
void gnc_progress_dialog_pause (GNCProgressDialog *progress)
 Show that progress has been paused by appending "(paused)" to the suboperation text, the window title, or the primary text. More...
 
void gnc_progress_dialog_resume (GNCProgressDialog *progress)
 Remove any indication that progress has paused by removing any existing "(paused)" suffix from the suboperation text, the window title, and the primary text. More...
 
void gnc_progress_dialog_set_cancel_func (GNCProgressDialog *progress, GNCProgressCancelFunc cancel_func, gpointer user_data)
 Show a Cancel button and set the C function which will be called when it is pressed by the user. More...
 
void gnc_progress_dialog_set_cancel_scm_func (GNCProgressDialog *progress, SCM cancel_scm_func)
 Show a Cancel button and set the Guile procedure that will be called when it is pressed by the user. More...
 
void gnc_progress_dialog_set_value (GNCProgressDialog *progress, gdouble value)
 Set the fraction of the progress bar to fill, where 0 is empty and 1 is full. More...
 
guint gnc_progress_dialog_push (GNCProgressDialog *progress, gdouble weight)
 Create a new "virtual" progress bar that, as it becomes full, will fill the current bar by the fraction specified by weight. More...
 
guint gnc_progress_dialog_pop (GNCProgressDialog *progress)
 Moves up one level in the stack of virtual bars. More...
 
guint gnc_progress_dialog_pop_full (GNCProgressDialog *progress)
 Fills the current progress bar, then calls gnc_progress_dialog_pop(). More...
 
void gnc_progress_dialog_reset_value (GNCProgressDialog *progress)
 Pop up to the top level and clear the progress bar. More...
 
void gnc_progress_dialog_update (GNCProgressDialog *progress)
 Update the GUI of the progress dialog, and call any pending cancel callbacks. More...
 
void gnc_progress_dialog_finish (GNCProgressDialog *progress)
 Set the progress meter to fully complete, change the heading, if any, to "Complete", enable the 'OK' button, and make the dialog non-modal. More...
 
void gnc_progress_dialog_destroy (GNCProgressDialog *progress)
 Destroy the dialog. More...
 

Detailed Description

Dialog for displaying progress of long-running operations.

These functions constitute an API for streamlining the creation and management of progress dialogs. Once registered with the API, the dialog's display and behavior can be controlled via simple calls that prevent the caller from needing to know anything about the underlying GUI.

A pop-up progress dialog can be created, displayed, and registered with the API by calling gnc_progress_dialog_new(). Alternatively, existing widgets can be registered with the API by calling gnc_progress_dialog_custom(). This method allows custom-made dialogs to hand off the management of typical progress-related widgets, and allows long-running operations report progress in a standard way.

Function Documentation

◆ gnc_progress_dialog_append_log()

void gnc_progress_dialog_append_log ( GNCProgressDialog *  progress,
const gchar *  str 
)

Append str to the progress log.

Parameters
progressa ::GNCProgressDialog
strthe text to be appended

Definition at line 458 of file dialog-progress.c.

459 {
460  GtkTextBuffer *buf;
461  GtkTextIter iter;
462 
463  g_return_if_fail(progress);
464 
465  if (progress->log == NULL || !str || !*str)
466  return;
467 
468  /* Append to the text buffer. */
469  buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(progress->log));
470  gtk_text_buffer_get_end_iter(buf, &iter);
471  gtk_text_buffer_insert(buf, &iter, str, -1);
472 
473  gnc_progress_dialog_update(progress);
474 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_custom()

GNCProgressDialog* gnc_progress_dialog_custom ( GtkLabel *  primary,
GtkLabel *  secondary,
GtkProgressBar *  bar,
GtkLabel *  suboperation,
GtkTextView *  log 
)

Creates a dialog for displaying the progress of an activity using existing widgets.

This allows long-running operations to update the progress in a custom dialog instead of a new pop-up.

Parameters
primarya GtkLabel widget to use for primary text
secondarya GtkLabel widget to use for secondary text
bara GtkProgressBar widget for filling or pulsing
suboperationa GtkLabel widget to use for suboperation text
loga GtkTextView widget for logging progress textually

Any of the parameters may be passed as NULL if management of that visual element is not desired.

Returns
A ::GNCProgressDialog that identifies the dialog and is needed when making subsequent API calls.

Definition at line 286 of file dialog-progress.c.

291 {
292  GNCProgressDialog *progress;
293 
294  progress = g_new0(GNCProgressDialog, 1);
295 
296  /* Set up widgets. */
297  progress->dialog = NULL;
298  progress->primary_label = GTK_WIDGET(primary);
299  progress->secondary_label = GTK_WIDGET(secondary);
300  progress->progress_bar = GTK_WIDGET(bar);
301  progress->sub_label = GTK_WIDGET(suboperation);
302  progress->log = GTK_WIDGET(log);
303  progress->ok_button = NULL;
304  progress->cancel_button = NULL;
305 
306  /* Initialize all other items. */
307  progress->total_offset = 0;
308  progress->total_weight = 1;
309  progress->bar_value = 0;
310  progress->cancel_func = NULL;
311  progress->user_data = NULL;
312  progress->cancel_scm_func = SCM_UNDEFINED;
313  progress->use_ok_button = FALSE;
314  progress->closed = FALSE;
315  progress->finished = FALSE;
316  progress->destroyed = FALSE;
317  progress->title_set = FALSE;
318 
319  return progress;
320 }

◆ gnc_progress_dialog_destroy()

void gnc_progress_dialog_destroy ( GNCProgressDialog *  progress)

Destroy the dialog.

If gnc_progress_dialog_finish has been called, the dialog will not be destroyed until the user dismisses the window. This function must be called in order to reclaim the dialog's memory.

Parameters
progressa ::GNCProgressDialog

Definition at line 782 of file dialog-progress.c.

783 {
784  g_return_if_fail(progress);
785 
786  /* Make sure the callbacks aren't invoked */
787  progress->cancel_func = NULL;
788  if (progress->cancel_scm_func != SCM_UNDEFINED)
789  scm_gc_unprotect_object(progress->cancel_scm_func);
790  progress->cancel_scm_func = SCM_UNDEFINED;
791 
792  if (!progress->finished)
793  {
794  if (progress->dialog != NULL)
795  gtk_widget_hide(progress->dialog);
796  progress->closed = TRUE;
797  }
798 
799  progress->destroyed = TRUE;
800 
801  gnc_progress_maybe_destroy(progress);
802 }

◆ gnc_progress_dialog_finish()

void gnc_progress_dialog_finish ( GNCProgressDialog *  progress)

Set the progress meter to fully complete, change the heading, if any, to "Complete", enable the 'OK' button, and make the dialog non-modal.

Parameters
progressa ::GNCProgressDialog

Definition at line 751 of file dialog-progress.c.

752 {
753  g_return_if_fail(progress);
754 
755  if (!progress->use_ok_button)
756  {
757  if (progress->dialog != NULL)
758  gtk_widget_hide(progress->dialog);
759  progress->closed = TRUE;
760  }
761 
762  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress->progress_bar), 1.0);
763 
764  gtk_widget_set_sensitive(progress->ok_button, TRUE);
765  gtk_widget_set_sensitive(progress->cancel_button, FALSE);
766 
767  if (gtk_widget_get_visible(progress->primary_label))
768  gnc_progress_dialog_set_heading(progress, _("Complete"));
769 
770  if (!progress->title_set)
771  gtk_window_set_title(GTK_WINDOW(progress->dialog), _("Complete"));
772 
773  gtk_window_set_modal(GTK_WINDOW(progress->dialog), FALSE);
774 
775  progress->finished = TRUE;
776 
777  gnc_progress_dialog_update(progress);
778 }
void gnc_progress_dialog_set_heading(GNCProgressDialog *progress, const char *heading)
Set the primary text of the progress dialog.
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_new()

GNCProgressDialog* gnc_progress_dialog_new ( GtkWidget *  parent,
gboolean  use_ok_button 
)

Displays a pop-up dialog for showing the progress of a long-running activity.

By default only a title and progress bar are shown, but additional visual elements such as a Cancel button, text log, and additional labels can be activated by following with calls to some of the other API functions.

Parameters
parentThe parent window for which the progress dialog becomes modal.
use_ok_buttonIf TRUE, an OK button is shown and must be clicked when progress is completed.
Returns
A ::GNCProgressDialog that identifies the dialog and is needed when making subsequent API calls.

Definition at line 267 of file dialog-progress.c.

268 {
269  GNCProgressDialog *progress;
270 
271  progress = g_new0(GNCProgressDialog, 1);
272 
273  progress->use_ok_button = use_ok_button;
274 
275  gnc_progress_dialog_create(parent, progress);
276 
277  gtk_widget_show(progress->dialog);
278 
279  gnc_progress_dialog_update(progress);
280 
281  return progress;
282 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_pause()

void gnc_progress_dialog_pause ( GNCProgressDialog *  progress)

Show that progress has been paused by appending "(paused)" to the suboperation text, the window title, or the primary text.

The first that is both known and currently shown will be the one used.

Parameters
progressa ::GNCProgressDialog

Definition at line 478 of file dialog-progress.c.

479 {
480  gchar *suffix;
481 
482  g_return_if_fail(progress);
483 
484  suffix = g_strconcat(" ", _("(paused)"), NULL);
485 
486  if (progress->sub_label && gtk_widget_get_visible(progress->sub_label))
487  {
488  const gchar *txt = gtk_label_get_text(GTK_LABEL(progress->sub_label));
489 
490  if (txt && !g_str_has_suffix(txt, suffix))
491  {
492  gchar *newtxt = g_strconcat(txt, suffix, NULL);
493  gnc_progress_dialog_set_sub(progress, newtxt);
494  g_free(newtxt);
495  }
496  }
497  else if (progress->dialog)
498  {
499  const gchar *txt = gtk_window_get_title(GTK_WINDOW(progress->dialog));
500 
501  if (txt && !g_str_has_suffix(txt, suffix))
502  {
503  gchar *newtxt = g_strconcat(txt, suffix, NULL);
504  gtk_window_set_title(GTK_WINDOW(progress->dialog), newtxt);
505  g_free(newtxt);
506  }
507  }
508  else if (progress->primary_label &&
509  gtk_widget_get_visible(progress->primary_label))
510  {
511  const gchar *txt = gtk_label_get_text(GTK_LABEL(progress->primary_label));
512 
513  if (txt && !g_str_has_suffix(txt, suffix))
514  {
515  gchar *newtxt = g_strconcat(txt, suffix, NULL);
516  gnc_progress_dialog_set_primary(progress, newtxt);
517  g_free(newtxt);
518  }
519  }
520 
521  g_free(suffix);
522 
523  gnc_progress_dialog_update(progress);
524 }
void gnc_progress_dialog_set_sub(GNCProgressDialog *progress, const gchar *str)
Set the suboperation text of the progress dialog.
void gnc_progress_dialog_set_primary(GNCProgressDialog *progress, const gchar *str)
Set the primary text of the progress dialog.
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_pop()

guint gnc_progress_dialog_pop ( GNCProgressDialog *  progress)

Moves up one level in the stack of virtual bars.

See gnc_progress_dialog_push() for an explanation of virtual bars.

Parameters
progressa ::GNCProgressDialog
Returns
the number of times that gnc_progress_dialog_pop() would have to be called again to return to the top level.

Definition at line 684 of file dialog-progress.c.

685 {
686  VirtualBar *bar;
687 
688  g_return_val_if_fail(progress, 0);
689 
690  /* Get the progress bar widget. */
691  if (progress->progress_bar == NULL || progress->bars == NULL)
692  return 0;
693 
694  /* Pop the bar off the bar stack. */
695  bar = progress->bars->data;
696  progress->bars = g_list_delete_link(progress->bars, progress->bars);
697 
698  /* Determine the value of the current bar. */
699  progress->bar_value = bar->offset + bar->weight * progress->bar_value;
700 
701  /* Set the total effective offset and weight. */
702  if (progress->bars == NULL)
703  {
704  progress->total_offset = 0;
705  progress->total_weight = 1;
706  }
707  else
708  {
709  progress->total_offset -= bar->offset *
710  ((VirtualBar *) progress->bars->data)->weight;
711  progress->total_weight /= bar->weight;
712  }
713  g_free(bar);
714 
715  if (progress->bars == NULL)
716  return 0;
717  return g_list_length(progress->bars);
718 }

◆ gnc_progress_dialog_pop_full()

guint gnc_progress_dialog_pop_full ( GNCProgressDialog *  progress)

Fills the current progress bar, then calls gnc_progress_dialog_pop().

Parameters
progressa ::GNCProgressDialog
Returns
the value returned by gnc_progress_dialog_pop()

Definition at line 722 of file dialog-progress.c.

723 {
724  gnc_progress_dialog_set_value(progress, 1);
725  return gnc_progress_dialog_pop(progress);
726 }
void gnc_progress_dialog_set_value(GNCProgressDialog *progress, gdouble value)
Set the fraction of the progress bar to fill, where 0 is empty and 1 is full.
guint gnc_progress_dialog_pop(GNCProgressDialog *progress)
Moves up one level in the stack of virtual bars.

◆ gnc_progress_dialog_push()

guint gnc_progress_dialog_push ( GNCProgressDialog *  progress,
gdouble  weight 
)

Create a new "virtual" progress bar that, as it becomes full, will fill the current bar by the fraction specified by weight.

All calls to gnc_progress_dialog_set_value() will operate on the new bar until gnc_progress_dialog_pop() is called.

This can be used to split an operation into weighted sub-operations. For example, if a particular suboperation should fill 30% of the bar, call gnc_progress_dialog_push() with a weight of 0.3. Calls to gnc_progress_dialog_set_value() will fill the virtual bar, which in turn trickles up at the 0.3 rate.

Multiple calls to gnc_progress_dialog_push() can be used to create a stack of virtual bars, each subordinate to the last. This allows a task to be split into any number of levels of sub-tasks.

Parameters
progressa ::GNCProgressDialog
weightthe requested fraction of the current bar that the new bar will represent (The fraction actually assigned will be the lesser of the requested amount and the amount of the bar that is unfilled.)
Returns
the number of times that gnc_progress_dialog_pop() would have to be called to return to the top level.

Definition at line 649 of file dialog-progress.c.

650 {
651  GtkProgressBar *bar;
652  VirtualBar *newbar;
653 
654  g_return_val_if_fail(progress, 0);
655  g_return_val_if_fail(weight > 0, 0);
656 
657  /* Get the progress bar widget. */
658  bar = GTK_PROGRESS_BAR(progress->progress_bar);
659  if (bar == NULL)
660  return 0;
661 
662  /* Create the new virtual progress bar. */
663  newbar = g_new0(VirtualBar, 1);
664  newbar->offset = progress->bar_value;
665  if (newbar->offset + weight > 1)
666  /* The requested weight is more than the unfilled portion of the bar. */
667  newbar->weight = 1 - newbar->offset;
668  else
669  newbar->weight = weight;
670  progress->bars = g_list_prepend(progress->bars, newbar);
671 
672  /* Set the total effective offset and weight */
673  progress->total_offset = gtk_progress_bar_get_fraction(bar);
674  progress->total_weight *= newbar->weight;
675 
676  /* Set the new bar as unfilled. */
677  progress->bar_value = 0;
678 
679  return g_list_length(progress->bars);
680 }

◆ gnc_progress_dialog_reset_log()

void gnc_progress_dialog_reset_log ( GNCProgressDialog *  progress)

Show the progress log and delete any existing text.

If the dialog was created via gnc_progress_dialog_new(), the log is not shown by default. Calling this function will make it appear.

Parameters
progressa ::GNCProgressDialog

Definition at line 435 of file dialog-progress.c.

436 {
437  GtkTextBuffer *buf;
438 
439  g_return_if_fail(progress);
440 
441  if (progress->log == NULL)
442  return;
443 
444  /* Reset the text buffer. */
445  buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(progress->log));
446  gtk_text_buffer_set_text(buf, "", -1);
447  gtk_text_buffer_set_modified(buf, FALSE);
448 
449  /* Show the log and its parent (in case it is in a scrolled window). */
450  gtk_widget_show(progress->log);
451  gtk_widget_show(gtk_widget_get_parent(progress->log));
452 
453  gnc_progress_dialog_update(progress);
454 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_reset_value()

void gnc_progress_dialog_reset_value ( GNCProgressDialog *  progress)

Pop up to the top level and clear the progress bar.

Parameters
progressa ::GNCProgressDialog

Definition at line 730 of file dialog-progress.c.

731 {
732  g_return_if_fail(progress);
733 
734  /* Return to the top level. */
735  while (gnc_progress_dialog_pop(progress));
736 
737  /* Reset the bar to empty. */
738  gnc_progress_dialog_set_value(progress, 0);
739 }
void gnc_progress_dialog_set_value(GNCProgressDialog *progress, gdouble value)
Set the fraction of the progress bar to fill, where 0 is empty and 1 is full.
guint gnc_progress_dialog_pop(GNCProgressDialog *progress)
Moves up one level in the stack of virtual bars.

◆ gnc_progress_dialog_resume()

void gnc_progress_dialog_resume ( GNCProgressDialog *  progress)

Remove any indication that progress has paused by removing any existing "(paused)" suffix from the suboperation text, the window title, and the primary text.

Parameters
progressa ::GNCProgressDialog

Definition at line 527 of file dialog-progress.c.

528 {
529  gchar *suffix;
530 
531  g_return_if_fail(progress);
532 
533  suffix = g_strconcat(" ", _("(paused)"), NULL);
534 
535  /* Remove any pause indication from the suboperation label. */
536  if (progress->sub_label)
537  {
538  const gchar *txt = gtk_label_get_text(GTK_LABEL(progress->sub_label));
539 
540  if (txt && g_str_has_suffix(txt, suffix))
541  {
542  gchar *newtxt = g_strndup(txt, strlen(txt) - strlen(suffix));
543  gnc_progress_dialog_set_sub(progress, newtxt);
544  g_free(newtxt);
545  }
546  }
547 
548  /* Remove any pause indication from the window title. */
549  if (progress->dialog)
550  {
551  const gchar *txt = gtk_window_get_title(GTK_WINDOW(progress->dialog));
552 
553  if (txt && g_str_has_suffix(txt, suffix))
554  {
555  gchar *newtxt = g_strndup(txt, strlen(txt) - strlen(suffix));
556  gtk_window_set_title(GTK_WINDOW(progress->dialog), newtxt);
557  g_free(newtxt);
558  }
559  }
560 
561  /* Remove any pause indication from the primary text. */
562  if (progress->primary_label)
563  {
564  const gchar *txt = gtk_label_get_text(GTK_LABEL(progress->primary_label));
565 
566  if (txt && g_str_has_suffix(txt, suffix))
567  {
568  gchar *newtxt = g_strndup(txt, strlen(txt) - strlen(suffix));
569  gnc_progress_dialog_set_primary(progress, newtxt);
570  g_free(newtxt);
571  }
572  }
573 
574  g_free(suffix);
575 
576  gnc_progress_dialog_update(progress);
577 }
void gnc_progress_dialog_set_sub(GNCProgressDialog *progress, const gchar *str)
Set the suboperation text of the progress dialog.
void gnc_progress_dialog_set_primary(GNCProgressDialog *progress, const gchar *str)
Set the primary text of the progress dialog.
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_set_cancel_func()

void gnc_progress_dialog_set_cancel_func ( GNCProgressDialog *  progress,
GNCProgressCancelFunc  cancel_func,
gpointer  user_data 
)

Show a Cancel button and set the C function which will be called when it is pressed by the user.

The cancel function must return a boolean value. If the value is TRUE, the window is hidden.

Parameters
progressa ::GNCProgressDialog
cancel_functhe callback function
user_datauser data to be passed to cancel_func

Definition at line 581 of file dialog-progress.c.

584 {
585  g_return_if_fail(progress);
586 
587  if (progress->cancel_button == NULL)
588  return;
589 
590  progress->cancel_func = cancel_func;
591  progress->user_data = user_data;
592 
593  if (cancel_func)
594  gtk_widget_show(progress->cancel_button);
595 }

◆ gnc_progress_dialog_set_cancel_scm_func()

void gnc_progress_dialog_set_cancel_scm_func ( GNCProgressDialog *  progress,
SCM  cancel_scm_func 
)

Show a Cancel button and set the Guile procedure that will be called when it is pressed by the user.

It will be called after any C function registered with gnc_progress_dialog_set_cancel_func(). The procedure must return #t if the dialog should be hidden. If there is no C or Guile cancel callback (the default state), the Cancel button is hidden.

Parameters
progressa ::GNCProgressDialog
cancel_scm_functhe Guile callback procedure

Definition at line 599 of file dialog-progress.c.

601 {
602  g_return_if_fail(progress);
603 
604  if (progress->cancel_button == NULL)
605  return;
606 
607  if (progress->cancel_scm_func != SCM_UNDEFINED)
608  scm_gc_unprotect_object(progress->cancel_scm_func);
609 
610  if (scm_is_procedure(cancel_scm_func))
611  {
612  progress->cancel_scm_func = cancel_scm_func;
613  scm_gc_protect_object(cancel_scm_func);
614  gtk_widget_show(progress->cancel_button);
615  }
616  else
617  progress->cancel_scm_func = SCM_UNDEFINED;
618 }

◆ gnc_progress_dialog_set_heading()

void gnc_progress_dialog_set_heading ( GNCProgressDialog *  progress,
const char *  heading 
)

Set the primary text of the progress dialog.

If str is NULL or blank, the label is hidden (this is the default state).

Parameters
progressa ::GNCProgressDialog
headingthe text to be displayed

NOTE: For HIG-compliant dialogs, use gnc_progress_dialog_set_primary() instead.

Definition at line 368 of file dialog-progress.c.

370 {
371  g_return_if_fail(progress);
372 
373  if (progress->primary_label == NULL)
374  return;
375 
376  if (heading == NULL || *heading == '\0')
377  gtk_widget_hide(progress->primary_label);
378  else
379  {
380  gtk_label_set_text(GTK_LABEL(progress->primary_label), heading);
381  gtk_widget_show(progress->primary_label);
382  }
383 
384  gnc_progress_dialog_update(progress);
385 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_set_primary()

void gnc_progress_dialog_set_primary ( GNCProgressDialog *  progress,
const gchar *  str 
)

Set the primary text of the progress dialog.

The text will be displayed using the HIG-recommended style. If str is NULL or blank, the label is hidden (this is the default state).

Parameters
progressa ::GNCProgressDialog
strthe text to be displayed

Definition at line 343 of file dialog-progress.c.

345 {
346  g_return_if_fail(progress);
347 
348  if (progress->primary_label == NULL)
349  return;
350 
351  if (str == NULL || *str == '\0')
352  gtk_widget_hide(progress->primary_label);
353  else
354  {
355  /* Display the primary text with the HIG-recommended style. */
356  char *markup = g_markup_printf_escaped("<span weight=\"bold\" size=\"larger\">%s</span>", str);
357 
358  gtk_label_set_markup(GTK_LABEL(progress->primary_label), markup);
359  g_free(markup);
360  gtk_widget_show(progress->primary_label);
361  }
362 
363  gnc_progress_dialog_update(progress);
364 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_set_secondary()

void gnc_progress_dialog_set_secondary ( GNCProgressDialog *  progress,
const gchar *  str 
)

Set the secondary text of the progress dialog.

The text will be displayed using the HIG-recommended style. If str is NULL or blank, the label is hidden (this is the default state).

Parameters
progressa ::GNCProgressDialog
strthe text to be displayed

Definition at line 389 of file dialog-progress.c.

391 {
392  g_return_if_fail(progress);
393 
394  if (progress->secondary_label == NULL)
395  return;
396 
397  if (str == NULL || *str == '\0')
398  gtk_widget_hide(progress->secondary_label);
399  else
400  {
401  gtk_label_set_text(GTK_LABEL(progress->secondary_label), str);
402  gtk_widget_show(progress->secondary_label);
403  }
404 
405  gnc_progress_dialog_update(progress);
406 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_set_sub()

void gnc_progress_dialog_set_sub ( GNCProgressDialog *  progress,
const gchar *  str 
)

Set the suboperation text of the progress dialog.

The text will be displayed using the HIG-recommended style. If str is NULL or blank, the label is hidden (this is the default state).

Parameters
progressa ::GNCProgressDialog
strthe text to be displayed

Definition at line 410 of file dialog-progress.c.

412 {
413  g_return_if_fail(progress);
414 
415  if (progress->sub_label == NULL)
416  return;
417 
418  if (str == NULL || *str == '\0')
419  gtk_widget_hide(progress->sub_label);
420  else
421  {
422  /* Display the suboperation text with the HIG-recommended style. */
423  char *markup = g_markup_printf_escaped("<span style=\"italic\">%s</span>", str);
424 
425  gtk_label_set_markup(GTK_LABEL(progress->sub_label), markup);
426  g_free(markup);
427  gtk_widget_show(progress->sub_label);
428  }
429 
430  gnc_progress_dialog_update(progress);
431 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_set_title()

void gnc_progress_dialog_set_title ( GNCProgressDialog *  progress,
const char *  title 
)

Set the title of a pop-up progress dialog.

This function has no effect on dialogs registered using gnc_progress_dialog_custom().

Parameters
progressa ::GNCProgressDialog
titlethe window title to display

Definition at line 324 of file dialog-progress.c.

325 {
326  g_return_if_fail(progress);
327 
328  if (!progress->dialog)
329  return;
330 
331  if (title == NULL)
332  title = "";
333 
334  gtk_window_set_title(GTK_WINDOW(progress->dialog), title);
335 
336  progress->title_set = TRUE;
337 
338  gnc_progress_dialog_update(progress);
339 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_set_value()

void gnc_progress_dialog_set_value ( GNCProgressDialog *  progress,
gdouble  value 
)

Set the fraction of the progress bar to fill, where 0 is empty and 1 is full.

If value is over 1, the bar will pulse instead of fill.

Parameters
progressa ::GNCProgressDialog
valuethe fraction of the bar to fill

Definition at line 622 of file dialog-progress.c.

623 {
624  GtkProgressBar *bar;
625 
626  g_return_if_fail(progress);
627 
628  /* Get the progress bar widget. */
629  bar = GTK_PROGRESS_BAR(progress->progress_bar);
630  if (bar == NULL)
631  return;
632 
633  /* Update the progress bar. If value is over 1,
634  * the bar will pulse instead of fill. */
635  if (value > 1)
636  gtk_progress_bar_pulse(bar);
637  else
638  {
639  progress->bar_value = value > 0 ? value : 0;
640  gtk_progress_bar_set_fraction(bar,
641  progress->total_offset + progress->bar_value * progress->total_weight);
642  }
643 
644  gnc_progress_dialog_update(progress);
645 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
Update the GUI of the progress dialog, and call any pending cancel callbacks.

◆ gnc_progress_dialog_update()

void gnc_progress_dialog_update ( GNCProgressDialog *  progress)

Update the GUI of the progress dialog, and call any pending cancel callbacks.

This function will be called automatically by the other functions, including gnc_progress_dialog_set_value.

Parameters
progressa ::GNCProgressDialog

Definition at line 743 of file dialog-progress.c.

744 {
745  while (gtk_events_pending())
746  gtk_main_iteration();
747 }