+void
+downloadcb(WebKitDownload *o, GParamSpec *pspec, gpointer d) {
+ Client *c = (Client *) d;
+ GSList *i;
+ WebKitDownload *dl;
+ GString *text;
+
+ text = g_string_new("");
+ for (i = downloads; i != NULL; i = i->next) {
+ dl = i->data;
+ if (webkit_download_get_status(dl) == WEBKIT_DOWNLOAD_STATUS_STARTED
+ || webkit_download_get_status(dl) == WEBKIT_DOWNLOAD_STATUS_CREATED) {
+ g_string_append_printf(text, "%s[%.0f%%] ",
+ webkit_download_get_suggested_filename(dl),
+ webkit_download_get_progress(dl)*100);
+ } else {
+ downloads = g_slist_remove(downloads, dl);
+ }
+ }
+ if (downloads == NULL) {
+ gtk_label_set_text((GtkLabel *) c->pbar, "");
+ gtk_widget_hide(c->pbar);
+ } else {
+ gtk_label_set_text((GtkLabel *) c->pbar, text->str);
+ }
+ g_string_free(text, TRUE);
+}
+