[gnome-documents] pdf-loader: load an EvinceDocumentModel directly
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] pdf-loader: load an EvinceDocumentModel directly
- Date: Thu, 5 Jul 2012 18:10:34 +0000 (UTC)
commit a4c0bdabb357b22096583fa66f9fb5e35303af67
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Jul 5 14:09:31 2012 -0400
pdf-loader: load an EvinceDocumentModel directly
Instead of having the caller create one: simplifies code.
src/documents.js | 28 ++++++++++++----------------
src/lib/gd-pdf-loader.c | 16 +++++++++-------
src/lib/gd-pdf-loader.h | 14 +++++++-------
3 files changed, 28 insertions(+), 30 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index cf2c60d..738e89e 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -611,13 +611,9 @@ const DocCommon = new Lang.Class({
return retval;
},
- _finishLoad: function(document, callback, exception) {
- let docModel = null;
- if (exception) {
+ _finishLoad: function(docModel, callback, exception) {
+ if (exception)
Global.errorHandler.addLoadError(this, exception);
- } else {
- docModel = EvView.DocumentModel.new_with_document(document);
- }
callback(this, docModel, exception);
}
@@ -653,8 +649,8 @@ const LocalDocument = new Lang.Class({
Gd.pdf_loader_load_uri_async(this.uri, cancellable, Lang.bind(this,
function(source, res) {
try {
- let document = Gd.pdf_loader_load_uri_finish(res);
- this._finishLoad(document, callback, null);
+ let docModel = Gd.pdf_loader_load_uri_finish(res);
+ this._finishLoad(docModel, callback, null);
} catch (e) {
this._finishLoad(null, callback, e);
}
@@ -724,8 +720,8 @@ const GoogleDocument = new Lang.Class({
Gd.pdf_loader_load_uri_async(this.identifier, cancellable, Lang.bind(this,
function(source, res) {
try {
- let document = Gd.pdf_loader_load_uri_finish(res);
- this._finishLoad(document, callback, null);
+ let docModel = Gd.pdf_loader_load_uri_finish(res);
+ this._finishLoad(docModel, callback, null);
} catch (e) {
// report the outmost error only
this._finishLoad(null, callback, exception);
@@ -739,8 +735,8 @@ const GoogleDocument = new Lang.Class({
(entry, service, cancellable, Lang.bind(this,
function(source, res) {
try {
- let document = Gd.pdf_loader_load_uri_finish(res);
- this._finishLoad(document, callback, null);
+ let docModel = Gd.pdf_loader_load_uri_finish(res);
+ this._finishLoad(docModel, callback, null);
} catch (e) {
this._finishLoad(null, callback, e);
}
@@ -863,8 +859,8 @@ const SkydriveDocument = new Lang.Class({
Gd.pdf_loader_load_uri_async(this.identifier, cancellable, Lang.bind(this,
function(source, res) {
try {
- let document = Gd.pdf_loader_load_uri_finish(res);
- this._finishLoad(document, callback, null);
+ let docModel = Gd.pdf_loader_load_uri_finish(res);
+ this._finishLoad(docModel, callback, null);
} catch (e) {
// report the outmost error only
this._finishLoad(null, callback, exception);
@@ -878,8 +874,8 @@ const SkydriveDocument = new Lang.Class({
(entry, service, cancellable, Lang.bind(this,
function(source, res) {
try {
- let document = Gd.pdf_loader_load_zpj_entry_finish(res);
- this._finishLoad(document, callback, null);
+ let docModel = Gd.pdf_loader_load_zpj_entry_finish(res);
+ this._finishLoad(docModel, callback, null);
} catch (e) {
this._finishLoad(null, callback, e);
}
diff --git a/src/lib/gd-pdf-loader.c b/src/lib/gd-pdf-loader.c
index 16fccbe..1f46788 100644
--- a/src/lib/gd-pdf-loader.c
+++ b/src/lib/gd-pdf-loader.c
@@ -187,7 +187,9 @@ pdf_load_job_complete_error (PdfLoadJob *job,
static void
pdf_load_job_complete_success (PdfLoadJob *job)
{
- g_simple_async_result_set_op_res_gpointer (job->result, g_object_ref (job->document), NULL);
+ EvDocumentModel *doc_model = ev_document_model_new_with_document (job->document);
+
+ g_simple_async_result_set_op_res_gpointer (job->result, doc_model, NULL);
g_simple_async_result_complete_in_idle (job->result);
pdf_load_job_free (job);
@@ -940,11 +942,11 @@ gd_pdf_loader_load_uri_async (const gchar *uri,
*
* Returns: (transfer full):
*/
-EvDocument *
+EvDocumentModel *
gd_pdf_loader_load_uri_finish (GAsyncResult *res,
GError **error)
{
- EvDocument *retval;
+ EvDocumentModel *retval;
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
@@ -982,11 +984,11 @@ gd_pdf_loader_load_gdata_entry_async (GDataEntry *entry,
*
* Returns: (transfer full):
*/
-EvDocument *
+EvDocumentModel *
gd_pdf_loader_load_gdata_entry_finish (GAsyncResult *res,
GError **error)
{
- EvDocument *retval;
+ EvDocumentModel *retval;
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
@@ -1024,11 +1026,11 @@ gd_pdf_loader_load_zpj_entry_async (ZpjSkydriveEntry *entry,
*
* Returns: (transfer full):
*/
-EvDocument *
+EvDocumentModel *
gd_pdf_loader_load_zpj_entry_finish (GAsyncResult *res,
GError **error)
{
- EvDocument *retval;
+ EvDocumentModel *retval;
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
diff --git a/src/lib/gd-pdf-loader.h b/src/lib/gd-pdf-loader.h
index deee7aa..f0c2a60 100644
--- a/src/lib/gd-pdf-loader.h
+++ b/src/lib/gd-pdf-loader.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
#include <gio/gio.h>
-#include <evince-document.h>
+#include <evince-view.h>
#include <gdata/gdata.h>
#include <zpj/zpj.h>
@@ -34,24 +34,24 @@ void gd_pdf_loader_load_uri_async (const gchar *uri,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
-EvDocument *gd_pdf_loader_load_uri_finish (GAsyncResult *res,
- GError **error);
+EvDocumentModel *gd_pdf_loader_load_uri_finish (GAsyncResult *res,
+ GError **error);
void gd_pdf_loader_load_gdata_entry_async (GDataEntry *entry,
GDataDocumentsService *service,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
-EvDocument *gd_pdf_loader_load_gdata_entry_finish (GAsyncResult *res,
- GError **error);
+EvDocumentModel *gd_pdf_loader_load_gdata_entry_finish (GAsyncResult *res,
+ GError **error);
void gd_pdf_loader_load_zpj_entry_async (ZpjSkydriveEntry *entry,
ZpjSkydrive *service,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
-EvDocument *gd_pdf_loader_load_zpj_entry_finish (GAsyncResult *res,
- GError **error);
+EvDocumentModel *gd_pdf_loader_load_zpj_entry_finish (GAsyncResult *res,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]