+ priv->count++;
+
+ /* Set progress. Tinymail sometimes returns us 1/100 when it
+ does not have any clue, NOTE that 1/100 could be also a
+ valid progress (we will loose it), but it will be recovered
+ once the done is greater than 1 */
+ determined = (done > 0 && total > 1) &&
+ !(done == 1 && total == 100);
+/* if ((done == 0 && total == 0) || */
+/* (done == 1 && total == 100)) { */
+ if (!determined) {
+ gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (priv->progress_bar), /* Deprecated */
+ GTK_PROGRESS_CONTINUOUS);
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->progress_bar));
+/* printf ("debug: %s:\n undetermined progress (%i) changed (%i/%i) : %i\n", __FUNCTION__, */
+/* (int) priv->progress_bar, */
+/* done, */
+/* total, */
+/* priv->count); */
+ } else {
+ gdouble percent = 0;
+ if (total != 0) /* Avoid division by zero. */
+ percent = (gdouble)done/(gdouble)total;
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress_bar),
+ percent);
+
+/* printf ("debug: %s:\n determined progress (%i) changed (%i/%i) : %i\n", __FUNCTION__, */
+/* (int) priv->progress_bar, */
+/* done, */
+/* total, */
+/* priv->count); */
+ }
+