diff options
Diffstat (limited to 'libview/ev-jobs.c')
-rw-r--r-- | libview/ev-jobs.c | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c index 607bc2c2..134324e4 100644 --- a/libview/ev-jobs.c +++ b/libview/ev-jobs.c @@ -176,14 +176,14 @@ emit_finished (EvJob *job) ev_debug_message (DEBUG_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); job->idle_finished_id = 0; - + if (job->cancelled) { ev_debug_message (DEBUG_JOBS, "%s (%p) job was cancelled, do not emit finished", EV_GET_TYPE_NAME (job), job); } else { ev_profiler_stop (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); g_signal_emit (job, job_signals[FINISHED], 0); } - + return FALSE; } @@ -196,9 +196,9 @@ ev_job_emit_finished (EvJob *job) ev_debug_message (DEBUG_JOBS, "%s (%p) job was cancelled, returning", EV_GET_TYPE_NAME (job), job); return; } - + job->finished = TRUE; - + if (job->run_mode == EV_JOB_RUN_THREAD) { job->idle_finished_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, @@ -215,7 +215,7 @@ gboolean ev_job_run (EvJob *job) { EvJobClass *class = EV_JOB_GET_CLASS (job); - + return class-> run (job); } @@ -227,7 +227,7 @@ ev_job_cancel (EvJob *job) ev_debug_message (DEBUG_JOBS, "job %s (%p) cancelled", EV_GET_TYPE_NAME (job), job); ev_profiler_stop (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); - + /* This should never be called from a thread */ job->cancelled = TRUE; g_cancellable_cancel (job->cancellable); @@ -247,22 +247,22 @@ ev_job_failed (EvJob *job, { va_list args; gchar *message; - + if (job->failed || job->finished) return; ev_debug_message (DEBUG_JOBS, "job %s (%p) failed", EV_GET_TYPE_NAME (job), job); - + job->failed = TRUE; - + va_start (args, format); message = g_strdup_vprintf (format, args); va_end (args); - + job->error = g_error_new_literal (domain, code, message); g_free (message); - - ev_job_emit_finished (job); + + ev_job_emit_finished (job); } /** @@ -278,7 +278,7 @@ ev_job_failed_from_error (EvJob *job, { if (job->failed || job->finished) return; - + ev_debug_message (DEBUG_JOBS, "job %s (%p) failed", EV_GET_TYPE_NAME (job), job); job->failed = TRUE; @@ -294,7 +294,7 @@ ev_job_succeeded (EvJob *job) return; ev_debug_message (DEBUG_JOBS, "job %s (%p) succeeded", EV_GET_TYPE_NAME (job), job); - + job->failed = FALSE; ev_job_emit_finished (job); } @@ -337,7 +337,7 @@ ev_job_links_dispose (GObject *object) EvJobLinks *job; ev_debug_message (DEBUG_JOBS, NULL); - + job = EV_JOB_LINKS (object); if (job->model) { @@ -387,7 +387,7 @@ ev_job_links_run (EvJob *job) ev_debug_message (DEBUG_JOBS, NULL); ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); - + ev_document_doc_mutex_lock (); job_links->model = ev_document_links_get_links_model (EV_DOCUMENT_LINKS (job->document)); ev_document_doc_mutex_unlock (); @@ -395,7 +395,7 @@ ev_job_links_run (EvJob *job) gtk_tree_model_foreach (job_links->model, (GtkTreeModelForeachFunc)fill_page_labels, job); ev_job_succeeded (job); - + return FALSE; } @@ -418,7 +418,7 @@ ev_job_links_new (EvDocument *document) job = g_object_new (EV_TYPE_JOB_LINKS, NULL); job->document = g_object_ref (document); - + return job; } @@ -435,7 +435,7 @@ ev_job_attachments_dispose (GObject *object) EvJobAttachments *job; ev_debug_message (DEBUG_JOBS, NULL); - + job = EV_JOB_ATTACHMENTS (object); if (job->attachments) { @@ -484,7 +484,7 @@ ev_job_attachments_new (EvDocument *document) job = g_object_new (EV_TYPE_JOB_ATTACHMENTS, NULL); job->document = g_object_ref (document); - + return job; } @@ -610,11 +610,11 @@ ev_job_render_run (EvJob *job) ev_debug_message (DEBUG_JOBS, "page: %d (%p)", job_render->page, job); ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); - + ev_document_doc_mutex_lock (); ev_profiler_start (EV_PROFILE_JOBS, "Rendering page %d", job_render->page); - + ev_document_fc_mutex_lock (); ev_page = ev_document_get_page (job->document, job_render->page); @@ -622,7 +622,7 @@ ev_job_render_run (EvJob *job) if ( job->document->iswebdocument == TRUE ) { return TRUE; - + if (g_cancellable_is_cancelled (job->cancellable)) { ev_document_fc_mutex_unlock (); ev_document_doc_mutex_unlock (); @@ -630,7 +630,7 @@ ev_job_render_run (EvJob *job) return FALSE; } - + ev_document_fc_mutex_unlock (); ev_document_doc_mutex_unlock (); ev_job_succeeded (job); @@ -670,9 +670,9 @@ ev_job_render_run (EvJob *job) ev_document_fc_mutex_unlock (); ev_document_doc_mutex_unlock (); - + ev_job_succeeded (job); - + return FALSE; } @@ -697,7 +697,7 @@ ev_job_render_new (EvDocument *document, EvJobRender *job; ev_debug_message (DEBUG_JOBS, "page: %d", page); - + job = g_object_new (EV_TYPE_JOB_RENDER, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -830,7 +830,7 @@ ev_job_thumbnail_dispose (GObject *object) job = EV_JOB_THUMBNAIL (object); ev_debug_message (DEBUG_JOBS, "%d (%p)", job->page, job); - + if (job->thumbnail) { g_object_unref (job->thumbnail); job->thumbnail = NULL; @@ -941,7 +941,7 @@ ev_job_thumbnail_run (EvJob *job) if (job->document->iswebdocument == TRUE) { GtkWidget *webview; GtkWidget *offscreenwindow; - + webview = webkit_web_view_new (); offscreenwindow = gtk_offscreen_window_new (); @@ -957,7 +957,7 @@ ev_job_thumbnail_run (EvJob *job) g_object_ref (job_thumb)); webkit_web_view_load_uri (WEBKIT_WEB_VIEW (webview), (gchar*) rc->page->backend_page); } - else + else #endif /* ENABLE_EPUB */ { ev_document_doc_mutex_lock (); @@ -967,7 +967,7 @@ ev_job_thumbnail_run (EvJob *job) ev_job_succeeded (job); } g_object_unref (rc); - + return FALSE; } @@ -990,7 +990,7 @@ ev_job_thumbnail_new (EvDocument *document, EvJobThumbnail *job; ev_debug_message (DEBUG_JOBS, "%d", page); - + job = g_object_new (EV_TYPE_JOB_THUMBNAIL, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -1015,11 +1015,11 @@ ev_job_fonts_run (EvJob *job) EvDocumentFonts *fonts = EV_DOCUMENT_FONTS (job->document); ev_debug_message (DEBUG_JOBS, NULL); - + /* Do not block the main loop */ if (!ev_document_doc_mutex_trylock ()) return TRUE; - + if (!ev_document_fc_mutex_trylock ()) { ev_document_doc_mutex_unlock (); return TRUE; @@ -1040,7 +1040,7 @@ ev_job_fonts_run (EvJob *job) if (job_fonts->scan_completed) ev_job_succeeded (job); - + return !job_fonts->scan_completed; } @@ -1048,9 +1048,9 @@ static void ev_job_fonts_class_init (EvJobFontsClass *class) { EvJobClass *job_class = EV_JOB_CLASS (class); - + job_class->run = ev_job_fonts_run; - + job_fonts_signals[FONTS_UPDATED] = g_signal_new ("updated", EV_TYPE_JOB_FONTS, @@ -1068,7 +1068,7 @@ ev_job_fonts_new (EvDocument *document) EvJobFonts *job; ev_debug_message (DEBUG_JOBS, NULL); - + job = g_object_new (EV_TYPE_JOB_FONTS, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -1089,7 +1089,7 @@ ev_job_load_dispose (GObject *object) EvJobLoad *job = EV_JOB_LOAD (object); ev_debug_message (DEBUG_JOBS, "%s", job->uri); - + if (job->uri) { g_free (job->uri); job->uri = NULL; @@ -1108,10 +1108,10 @@ ev_job_load_run (EvJob *job) { EvJobLoad *job_load = EV_JOB_LOAD (job); GError *error = NULL; - + ev_debug_message (DEBUG_JOBS, "%s", job_load->uri); ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); - + ev_document_fc_mutex_lock (); /* This job may already have a document even if the job didn't complete @@ -1124,7 +1124,7 @@ ev_job_load_run (EvJob *job) ev_document_security_set_password (EV_DOCUMENT_SECURITY (job->document), job_load->password); } - + job->failed = FALSE; job->finished = FALSE; g_clear_error (&job->error); @@ -1167,7 +1167,7 @@ ev_job_load_new (const gchar *uri) EvJobLoad *job; ev_debug_message (DEBUG_JOBS, "%s", uri); - + job = g_object_new (EV_TYPE_JOB_LOAD, NULL); job->uri = g_strdup (uri); @@ -1178,7 +1178,7 @@ void ev_job_load_set_uri (EvJobLoad *job, const gchar *uri) { ev_debug_message (DEBUG_JOBS, "%s", uri); - + if (job->uri) g_free (job->uri); job->uri = g_strdup (uri); @@ -1207,7 +1207,7 @@ ev_job_save_dispose (GObject *object) EvJobSave *job = EV_JOB_SAVE (object); ev_debug_message (DEBUG_JOBS, "%s", job->uri); - + if (job->uri) { g_free (job->uri); job->uri = NULL; @@ -1229,7 +1229,7 @@ ev_job_save_run (EvJob *job) gchar *tmp_filename = NULL; gchar *local_uri; GError *error = NULL; - + ev_debug_message (DEBUG_JOBS, "uri: %s, document_uri: %s", job_save->uri, job_save->document_uri); ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); @@ -1257,7 +1257,7 @@ ev_job_save_run (EvJob *job) g_free (local_uri); ev_job_failed_from_error (job, error); g_error_free (error); - + return FALSE; } @@ -1268,11 +1268,11 @@ ev_job_save_run (EvJob *job) EvCompressionType ctype = EV_COMPRESSION_NONE; const gchar *ext; gchar *uri_comp; - + ext = g_strrstr (job_save->document_uri, ".gz"); if (ext && g_ascii_strcasecmp (ext, ".gz") == 0) ctype = EV_COMPRESSION_GZIP; - + ext = g_strrstr (job_save->document_uri, ".bz2"); if (ext && g_ascii_strcasecmp (ext, ".bz2") == 0) ctype = EV_COMPRESSION_BZIP2; @@ -1294,7 +1294,7 @@ ev_job_save_run (EvJob *job) g_free (local_uri); ev_job_failed_from_error (job, error); g_error_free (error); - + return FALSE; } @@ -1310,7 +1310,7 @@ ev_job_save_run (EvJob *job) } else { ev_job_succeeded (job); } - + return FALSE; } @@ -1376,7 +1376,7 @@ ev_job_find_dispose (GObject *object) if (job->results) { g_free(job->results); } - + (* G_OBJECT_CLASS (ev_job_find_parent_class)->dispose) (object); } @@ -1388,11 +1388,11 @@ ev_job_find_run (EvJob *job) EvPage *ev_page; GList *matches; ev_debug_message (DEBUG_JOBS, NULL); - + /* Do not block the main loop */ if (!ev_document_doc_mutex_trylock ()) return TRUE; - + #ifdef EV_ENABLE_DEBUG /* We use the #ifdef in this case because of the if */ if (job_find->current_page == job_find->start_page) @@ -1406,11 +1406,11 @@ ev_job_find_run (EvJob *job) job_find->case_sensitive); }else { matches = ev_document_find_find_text (find, ev_page, job_find->text, - job_find->case_sensitive); + job_find->case_sensitive); } - + g_object_unref (ev_page); - + ev_document_doc_mutex_unlock (); if (!job_find->has_results && !job->document->iswebdocument) { @@ -1425,7 +1425,7 @@ ev_job_find_run (EvJob *job) } g_signal_emit (job_find, job_find_signals[FIND_UPDATED], 0, job_find->current_page); - + job_find->current_page = (job_find->current_page + 1) % job_find->n_pages; if (job_find->current_page == job_find->start_page) { ev_job_succeeded (job); @@ -1441,10 +1441,10 @@ ev_job_find_class_init (EvJobFindClass *class) { EvJobClass *job_class = EV_JOB_CLASS (class); GObjectClass *gobject_class = G_OBJECT_CLASS (class); - + job_class->run = ev_job_find_run; gobject_class->dispose = ev_job_find_dispose; - + job_find_signals[FIND_UPDATED] = g_signal_new ("updated", EV_TYPE_JOB_FIND, @@ -1464,9 +1464,9 @@ ev_job_find_new (EvDocument *document, gboolean case_sensitive) { EvJobFind *job; - + ev_debug_message (DEBUG_JOBS, NULL); - + job = g_object_new (EV_TYPE_JOB_FIND, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -1506,7 +1506,7 @@ ev_job_find_get_progress (EvJobFind *job) if (ev_job_is_finished (EV_JOB (job))) return 1.0; - + if (job->current_page > job->start_page) { pages_done = job->current_page - job->start_page + 1; } else if (job->current_page == job->start_page) { @@ -1549,7 +1549,7 @@ ev_job_layers_dispose (GObject *object) EvJobLayers *job; ev_debug_message (DEBUG_JOBS, NULL); - + job = EV_JOB_LAYERS (object); if (job->model) { @@ -1567,13 +1567,13 @@ ev_job_layers_run (EvJob *job) ev_debug_message (DEBUG_JOBS, NULL); ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); - + ev_document_doc_mutex_lock (); job_layers->model = ev_document_layers_get_layers (EV_DOCUMENT_LAYERS (job->document)); ev_document_doc_mutex_unlock (); - + ev_job_succeeded (job); - + return FALSE; } @@ -1596,7 +1596,7 @@ ev_job_layers_new (EvDocument *document) job = g_object_new (EV_TYPE_JOB_LAYERS, NULL); job->document = g_object_ref (document); - + return job; } @@ -1614,7 +1614,7 @@ ev_job_export_dispose (GObject *object) EvJobExport *job; ev_debug_message (DEBUG_JOBS, NULL); - + job = EV_JOB_EXPORT (object); if (job->rc) { @@ -1635,27 +1635,27 @@ ev_job_export_run (EvJob *job) ev_debug_message (DEBUG_JOBS, NULL); ev_profiler_start (EV_PROFILE_JOBS, "%s (%p)", EV_GET_TYPE_NAME (job), job); - + ev_document_doc_mutex_lock (); - + ev_page = ev_document_get_page (job->document, job_export->page); if (job_export->rc) { job->failed = FALSE; job->finished = FALSE; g_clear_error (&job->error); - + ev_render_context_set_page (job_export->rc, ev_page); } else { job_export->rc = ev_render_context_new (ev_page, 0, 1.0); } g_object_unref (ev_page); - + ev_file_exporter_do_page (EV_FILE_EXPORTER (job->document), job_export->rc); - + ev_document_doc_mutex_unlock (); - + ev_job_succeeded (job); - + return FALSE; } @@ -1678,7 +1678,7 @@ ev_job_export_new (EvDocument *document) job = g_object_new (EV_TYPE_JOB_EXPORT, NULL); job->document = g_object_ref (document); - + return job; } |