- if (req->initial_request && bgpdf.create_pages) {
- bgpdf_create_page_with_bg(req->pageno, bgpg);
- // create page n, resize it, set its bg - all without any undo effect
- } else {
- if (!req->is_printing) bgpdf_update_bg(req->pageno, bgpg);
- // look for all pages with this bg, and update their bg pixmaps
- }
- }
- else {
-// printf("failed or aborted\n");
- bgpdf.create_pages = FALSE;
- req->initial_request = FALSE;
- }
-
- bgpdf.pid = 0;
- g_spawn_close_pid(pid);
-
- if (req->initial_request)
- req->pageno++; // try for next page
- else
- bgpdf.requests = g_list_delete_link(bgpdf.requests, bgpdf.requests);
-
- if (bgpdf.status == STATUS_SHUTDOWN) {
- end_bgpdf_shutdown();
- return;
- }
-
- bgpdf.status = STATUS_IDLE;
- if (bgpdf.requests != NULL) bgpdf_spawn_child();
-}
-
-/* spawn a child to process the head request */
-
-void bgpdf_spawn_child(void)
-{
- struct BgPdfRequest *req;
- GPid pid;
- gchar pageno_str[10], dpi_str[10];
- gchar *pdf_filename = bgpdf.tmpfile_copy;
- gchar *ppm_root = g_strdup_printf("%s/p", bgpdf.tmpdir);
- gchar *argv[]= PDFTOPPM_ARGV;
- GtkWidget *dialog;
-
- if (bgpdf.requests == NULL) return;
- req = (struct BgPdfRequest *)bgpdf.requests->data;
- if (req->pageno > bgpdf.npages+1 ||
- (!req->initial_request && req->pageno <= bgpdf.npages &&
- req->dpi == ((struct BgPdfPage *)g_list_nth_data(bgpdf.pages, req->pageno-1))->dpi))
- { // ignore this request - it's redundant, or in outer space
- bgpdf.pid = 0;
- bgpdf.status = STATUS_IDLE;
- bgpdf.requests = g_list_delete_link(bgpdf.requests, bgpdf.requests);
- g_free(ppm_root);
- if (bgpdf.requests != NULL) bgpdf_spawn_child();
- return;
- }
- g_snprintf(pageno_str, 10, "%d", req->pageno);
- g_snprintf(dpi_str, 10, "%d", req->dpi);
-/* printf("Processing request for page %d at %d dpi -- in %s\n",
- req->pageno, req->dpi, ppm_root); */
- if (!g_spawn_async(NULL, argv, NULL,
- G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
- NULL, NULL, &pid, NULL))
- {
- // couldn't spawn... abort this request, try next one maybe ?
-// printf("Couldn't spawn\n");
- bgpdf.pid = 0;
- bgpdf.status = STATUS_IDLE;
- bgpdf.requests = g_list_delete_link(bgpdf.requests, bgpdf.requests);
- g_free(ppm_root);