Beispiel #1
0
/* NB: "noalloc" function. */
value
guestfs_int_mllib_progress_bar_reset (value barv)
{
  struct progress_bar *bar = Bar_val (barv);

  progress_bar_reset (bar);

  return Val_unit;
}
Beispiel #2
0
void progress_bar_start (GtkWidget *pbar, int activity_mode) {
	struct pbarinfo *info;

	progress_bar_reset (pbar);

	if (activity_mode) {
		info = gtk_object_get_user_data (GTK_OBJECT (pbar));
		info->activity_mode = TRUE;
		info->timeout_id = gtk_timeout_add (100, (GtkFunction) progress_bar_timeout_callback, pbar);
		gtk_progress_set_activity_mode (GTK_PROGRESS (pbar), TRUE);
	}
	else {
		gtk_progress_set_show_text (GTK_PROGRESS (pbar), TRUE);
	}
}
Beispiel #3
0
struct progress_bar *
progress_bar_init (unsigned flags)
{
  struct progress_bar *bar;
  char *term;

  bar = malloc (sizeof *bar);
  if (bar == NULL)
    return NULL;

  if (flags & PROGRESS_BAR_MACHINE_READABLE) {
    bar->machine_readable = 1;
    bar->utf8_mode = 0;
    bar->have_terminfo = 0;
  } else {
    bar->machine_readable = 0;

    bar->utf8_mode = STREQ (nl_langinfo (CODESET), "UTF-8");

    bar->have_terminfo = 0;

    term = getenv ("TERM");
    if (term) {
      if (tgetent (NULL, term) == 1)
        bar->have_terminfo = 1;
    }

    bar->fp = fopen ("/dev/tty", "w"); /* deliberately ignore errors */
  }

  /* Call this to ensure the other fields are in a reasonable state.
   * It is still the caller's responsibility to reset the progress bar
   * before each command.
   */
  progress_bar_reset (bar);

  return bar;
}