GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 struct _GNCProgressDialog GNCProgressDialog
 
typedef gboolean(* GNCProgressCancelFunc )(gpointer user_data)
 

Functions

GNCProgressDialoggnc_progress_dialog_new (GtkWidget *parent, gboolean use_ok_button)
 
GNCProgressDialoggnc_progress_dialog_custom (GtkLabel *primary, GtkLabel *secondary, GtkProgressBar *bar, GtkLabel *suboperation, GtkTextView *log)
 
void gnc_progress_dialog_set_title (GNCProgressDialog *progress, const char *title)
 
void gnc_progress_dialog_set_primary (GNCProgressDialog *progress, const gchar *str)
 
void gnc_progress_dialog_set_heading (GNCProgressDialog *progress, const char *heading)
 
void gnc_progress_dialog_set_secondary (GNCProgressDialog *progress, const gchar *str)
 
void gnc_progress_dialog_set_sub (GNCProgressDialog *progress, const gchar *str)
 
void gnc_progress_dialog_reset_log (GNCProgressDialog *progress)
 
void gnc_progress_dialog_append_log (GNCProgressDialog *progress, const gchar *str)
 
void gnc_progress_dialog_pause (GNCProgressDialog *progress)
 
void gnc_progress_dialog_resume (GNCProgressDialog *progress)
 
void gnc_progress_dialog_set_cancel_func (GNCProgressDialog *progress, GNCProgressCancelFunc cancel_func, gpointer user_data)
 
void gnc_progress_dialog_set_cancel_scm_func (GNCProgressDialog *progress, SCM cancel_scm_func)
 
void gnc_progress_dialog_set_value (GNCProgressDialog *progress, gdouble value)
 
guint gnc_progress_dialog_push (GNCProgressDialog *progress, gdouble weight)
 
guint gnc_progress_dialog_pop (GNCProgressDialog *progress)
 
guint gnc_progress_dialog_pop_full (GNCProgressDialog *progress)
 
void gnc_progress_dialog_reset_value (GNCProgressDialog *progress)
 
void gnc_progress_dialog_update (GNCProgressDialog *progress)
 
void gnc_progress_dialog_finish (GNCProgressDialog *progress)
 
void gnc_progress_dialog_destroy (GNCProgressDialog *progress)
 

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

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 457 of file dialog-progress.c.

458 {
459  GtkTextBuffer *buf;
460  GtkTextIter iter;
461 
462  g_return_if_fail(progress);
463 
464  if (progress->log == NULL || !str || !*str)
465  return;
466 
467  /* Append to the text buffer. */
468  buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(progress->log));
469  gtk_text_buffer_get_end_iter(buf, &iter);
470  gtk_text_buffer_insert(buf, &iter, str, -1);
471 
472  gnc_progress_dialog_update(progress);
473 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 285 of file dialog-progress.c.

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

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

751 {
752  g_return_if_fail(progress);
753 
754  if (!progress->use_ok_button)
755  {
756  if (progress->dialog != NULL)
757  gtk_widget_hide(progress->dialog);
758  progress->closed = TRUE;
759  }
760 
761  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress->progress_bar), 1.0);
762 
763  gtk_widget_set_sensitive(progress->ok_button, TRUE);
764  gtk_widget_set_sensitive(progress->cancel_button, FALSE);
765 
766  if (gtk_widget_get_visible(progress->primary_label))
767  gnc_progress_dialog_set_heading(progress, _("Complete"));
768 
769  if (!progress->title_set)
770  gtk_window_set_title(GTK_WINDOW(progress->dialog), _("Complete"));
771 
772  gtk_window_set_modal(GTK_WINDOW(progress->dialog), FALSE);
773 
774  progress->finished = TRUE;
775 
776  gnc_progress_dialog_update(progress);
777 }
void gnc_progress_dialog_set_heading(GNCProgressDialog *progress, const char *heading)
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 266 of file dialog-progress.c.

267 {
268  GNCProgressDialog *progress;
269 
270  progress = g_new0(GNCProgressDialog, 1);
271 
272  progress->use_ok_button = use_ok_button;
273 
274  gnc_progress_dialog_create(parent, progress);
275 
276  gtk_widget_show(progress->dialog);
277 
278  gnc_progress_dialog_update(progress);
279 
280  return progress;
281 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 477 of file dialog-progress.c.

478 {
479  gchar *suffix;
480 
481  g_return_if_fail(progress);
482 
483  suffix = g_strconcat(" ", _("(paused)"), NULL);
484 
485  if (progress->sub_label && gtk_widget_get_visible(progress->sub_label))
486  {
487  const gchar *txt = gtk_label_get_text(GTK_LABEL(progress->sub_label));
488 
489  if (txt && !g_str_has_suffix(txt, suffix))
490  {
491  gchar *newtxt = g_strconcat(txt, suffix, NULL);
492  gnc_progress_dialog_set_sub(progress, newtxt);
493  g_free(newtxt);
494  }
495  }
496  else if (progress->dialog)
497  {
498  const gchar *txt = gtk_window_get_title(GTK_WINDOW(progress->dialog));
499 
500  if (txt && !g_str_has_suffix(txt, suffix))
501  {
502  gchar *newtxt = g_strconcat(txt, suffix, NULL);
503  gtk_window_set_title(GTK_WINDOW(progress->dialog), newtxt);
504  g_free(newtxt);
505  }
506  }
507  else if (progress->primary_label &&
508  gtk_widget_get_visible(progress->primary_label))
509  {
510  const gchar *txt = gtk_label_get_text(GTK_LABEL(progress->primary_label));
511 
512  if (txt && !g_str_has_suffix(txt, suffix))
513  {
514  gchar *newtxt = g_strconcat(txt, suffix, NULL);
515  gnc_progress_dialog_set_primary(progress, newtxt);
516  g_free(newtxt);
517  }
518  }
519 
520  g_free(suffix);
521 
522  gnc_progress_dialog_update(progress);
523 }
void gnc_progress_dialog_set_sub(GNCProgressDialog *progress, const gchar *str)
void gnc_progress_dialog_set_primary(GNCProgressDialog *progress, const gchar *str)
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 683 of file dialog-progress.c.

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

722 {
723  gnc_progress_dialog_set_value(progress, 1);
724  return gnc_progress_dialog_pop(progress);
725 }
void gnc_progress_dialog_set_value(GNCProgressDialog *progress, gdouble value)
guint gnc_progress_dialog_pop(GNCProgressDialog *progress)
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 648 of file dialog-progress.c.

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

435 {
436  GtkTextBuffer *buf;
437 
438  g_return_if_fail(progress);
439 
440  if (progress->log == NULL)
441  return;
442 
443  /* Reset the text buffer. */
444  buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(progress->log));
445  gtk_text_buffer_set_text(buf, "", -1);
446  gtk_text_buffer_set_modified(buf, FALSE);
447 
448  /* Show the log and its parent (in case it is in a scrolled window). */
449  gtk_widget_show(progress->log);
450  gtk_widget_show(gtk_widget_get_parent(progress->log));
451 
452  gnc_progress_dialog_update(progress);
453 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 729 of file dialog-progress.c.

730 {
731  g_return_if_fail(progress);
732 
733  /* Return to the top level. */
734  while (gnc_progress_dialog_pop(progress));
735 
736  /* Reset the bar to empty. */
737  gnc_progress_dialog_set_value(progress, 0);
738 }
void gnc_progress_dialog_set_value(GNCProgressDialog *progress, gdouble value)
guint gnc_progress_dialog_pop(GNCProgressDialog *progress)
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 526 of file dialog-progress.c.

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

583 {
584  g_return_if_fail(progress);
585 
586  if (progress->cancel_button == NULL)
587  return;
588 
589  progress->cancel_func = cancel_func;
590  progress->user_data = user_data;
591 
592  if (cancel_func)
593  gtk_widget_show(progress->cancel_button);
594 }
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 598 of file dialog-progress.c.

600 {
601  g_return_if_fail(progress);
602 
603  if (progress->cancel_button == NULL)
604  return;
605 
606  if (progress->cancel_scm_func != SCM_UNDEFINED)
607  scm_gc_unprotect_object(progress->cancel_scm_func);
608 
609  if (scm_is_procedure(cancel_scm_func))
610  {
611  progress->cancel_scm_func = cancel_scm_func;
612  scm_gc_protect_object(cancel_scm_func);
613  gtk_widget_show(progress->cancel_button);
614  }
615  else
616  progress->cancel_scm_func = SCM_UNDEFINED;
617 }
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 367 of file dialog-progress.c.

369 {
370  g_return_if_fail(progress);
371 
372  if (progress->primary_label == NULL)
373  return;
374 
375  if (heading == NULL || *heading == '\0')
376  gtk_widget_hide(progress->primary_label);
377  else
378  {
379  gtk_label_set_text(GTK_LABEL(progress->primary_label), heading);
380  gtk_widget_show(progress->primary_label);
381  }
382 
383  gnc_progress_dialog_update(progress);
384 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 342 of file dialog-progress.c.

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

390 {
391  g_return_if_fail(progress);
392 
393  if (progress->secondary_label == NULL)
394  return;
395 
396  if (str == NULL || *str == '\0')
397  gtk_widget_hide(progress->secondary_label);
398  else
399  {
400  gtk_label_set_text(GTK_LABEL(progress->secondary_label), str);
401  gtk_widget_show(progress->secondary_label);
402  }
403 
404  gnc_progress_dialog_update(progress);
405 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 409 of file dialog-progress.c.

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

324 {
325  g_return_if_fail(progress);
326 
327  if (!progress->dialog)
328  return;
329 
330  if (title == NULL)
331  title = "";
332 
333  gtk_window_set_title(GTK_WINDOW(progress->dialog), title);
334 
335  progress->title_set = TRUE;
336 
337  gnc_progress_dialog_update(progress);
338 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 621 of file dialog-progress.c.

622 {
623  GtkProgressBar *bar;
624 
625  g_return_if_fail(progress);
626 
627  /* Get the progress bar widget. */
628  bar = GTK_PROGRESS_BAR(progress->progress_bar);
629  if (bar == NULL)
630  return;
631 
632  /* Update the progress bar. If value is over 1,
633  * the bar will pulse instead of fill. */
634  if (value > 1)
635  gtk_progress_bar_pulse(bar);
636  else
637  {
638  progress->bar_value = value > 0 ? value : 0;
639  gtk_progress_bar_set_fraction(bar,
640  progress->total_offset + progress->bar_value * progress->total_weight);
641  }
642 
643  gnc_progress_dialog_update(progress);
644 }
void gnc_progress_dialog_update(GNCProgressDialog *progress)
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 742 of file dialog-progress.c.

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