+/*!
+ *\brief Set/reset/update progressbar, max. 10 redraws/second
+ *
+ *\param action What to do with the statusbar
+ * = 0 : Reset to zero
+ * < 0 : Init maximum to -(action)
+ * > 0 : Increase by (action)
+ */
+void news_doprogress(glong action) {
+ static glong curcount=0;
+ static glong maxval;
+ static MainWindow *mainwin=0;
+ static struct timeval tv_prev, tv_cur;
+
+ if (!mainwin)
+ mainwin = mainwindow_get_mainwindow();
+ g_return_if_fail(mainwin);
+
+ if (action < 0)
+ maxval = -action;
+ else if (action == 0) {
+ curcount=0;
+ gtk_progress_bar_update(
+ GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
+ } else {
+ curcount += action;
+ gettimeofday(&tv_cur, NULL);
+ if (!(tv_cur.tv_sec - tv_prev.tv_sec > 0 ||
+ tv_cur.tv_usec - tv_prev.tv_usec > 100)
+ || !maxval)
+ return;
+
+ gtk_progress_bar_update(
+ GTK_PROGRESS_BAR(mainwin->progressbar),
+ (float)curcount/maxval);
+ while (gtk_events_pending()) gtk_main_iteration ();
+ gettimeofday(&tv_prev, NULL);
+ }
+}
+