GData.DocumentsDocument

g GData.AccessHandler GData.AccessHandler GData.DocumentsEntry GData.DocumentsEntry GData.AccessHandler->GData.DocumentsEntry GData.DocumentsDocument GData.DocumentsDocument GData.DocumentsEntry->GData.DocumentsDocument GData.Entry GData.Entry GData.Entry->GData.DocumentsEntry GData.Parsable GData.Parsable GData.Parsable->GData.Entry GObject.GInterface GObject.GInterface GObject.GInterface->GData.AccessHandler GObject.Object GObject.Object GObject.Object->GData.Parsable

Subclasses:

GData.DocumentsDrawing, GData.DocumentsPdf, GData.DocumentsPresentation, GData.DocumentsSpreadsheet, GData.DocumentsText

Methods

Inherited:

GData.DocumentsEntry (16), GData.Entry (24), GData.Parsable (5), GObject.Object (37), GData.AccessHandler (2)

Structs:

GObject.ObjectClass (5)

class

new (id)

download (service, export_format, cancellable)

get_download_uri (export_format)

get_thumbnail_uri ()

Virtual Methods

Inherited:

GData.Parsable (9), GObject.Object (7), GData.AccessHandler (1)

Properties

Inherited:

GData.DocumentsEntry (11), GData.Entry (10), GData.Parsable (1)

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GData.DocumentsEntry

r

Class Details

class GData.DocumentsDocument(**kwargs)
Bases:

GData.DocumentsEntry

Abstract:

No

Structure:

GData.DocumentsDocumentClass

All the fields in the GData.DocumentsDocument structure are private and should never be accessed directly.

New in version 0.7.0.

classmethod new(id)
Parameters:

id (str or None) – the entry’s ID (not the document ID), or None

Returns:

a new GData.DocumentsDocument, or None; unref with GObject.Object.unref()

Return type:

GData.DocumentsDocument

Creates a new GData.DocumentsDocument with the given entry ID (GData.Entry :id).

New in version 0.13.0.

download(service, export_format, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a GData.DownloadStream to download the document with, or None; unref with GObject.Object.unref()

Return type:

GData.DownloadStream

Downloads and returns the document file represented by the GData.DocumentsDocument. If the document doesn’t exist, None is returned, but no error is set in error.

export_format should be the file extension of the desired output format for the document, from the list accepted by Google Documents. For example: GData.DOCUMENTS_PRESENTATION_PDF, GData.DOCUMENTS_SPREADSHEET_ODS or GData.DOCUMENTS_TEXT_ODT.

If self is a GData.DocumentsSpreadsheet, only the first grid, or sheet, in the spreadsheet will be downloaded for some export formats. To download a specific a specific grid, use GData.DocumentsSpreadsheet.get_download_uri() with GData.DownloadStream to download the grid manually. See the

GData protocol specification for more information. To get the content type of the downloaded file, GData.DownloadStream.get_content_type() can be called on the returned GData.DownloadStream. Calling GData.DownloadStream.get_content_length() on the stream will not return a meaningful result, however, as the stream is encoded in chunks, rather than by content length.

In order to cancel the download, a Gio.Cancellable passed in to cancellable must be cancelled using Gio.Cancellable.cancel(). Cancelling the individual Gio.InputStream operations on the GData.DownloadStream will not cancel the entire download; merely the read or close operation in question. See the GData.DownloadStream :cancellable for more details.

If the given export_format is unrecognised or not supported for this document, GData.ServiceError.NOT_FOUND will be returned.

If service isn’t authenticated, a GData.ServiceError.AUTHENTICATION_REQUIRED will be returned.

If there is an error getting the document, a GData.ServiceError.PROTOCOL_ERROR error will be returned.

New in version 0.8.0.

get_download_uri(export_format)
Parameters:

export_format (str) – the format in which the document should be exported when downloaded

Returns:

the download URI, or None; free with GLib.free()

Return type:

str or None

Builds and returns the download URI for the given GData.DocumentsDocument in the desired format. Note that directly downloading the document using this URI isn’t possible, as authentication is required. You should instead use GData.DownloadStream.new() with the URI, and use the resulting Gio.InputStream.

export_format should be the file extension of the desired output format for the document, from the list accepted by Google Documents. For example: GData.DOCUMENTS_PRESENTATION_PDF, GData.DOCUMENTS_SPREADSHEET_ODS or GData.DOCUMENTS_TEXT_ODT.

If the export_format is not recognised or not supported for this document, None is returned.

New in version 0.7.0.

get_thumbnail_uri()
Returns:

the URI of the document’s thumbnail, or None

Return type:

str or None

Gets the URI of the thumbnail for the GData.DocumentsDocument. If no thumbnail exists for the document, None will be returned.

The thumbnail may then be downloaded using a GData.DownloadStream.

<example> <title>Downloading a Document Thumbnail</title> <programlisting> GData.DocumentsService *service; const str *thumbnail_uri; Gio.Cancellable *cancellable; GdkPixbuf *pixbuf; GLib.Error *error = None;

service = get_my_documents_service (); thumbnail_uri = GData.DocumentsDocument.get_thumbnail_uri (my_document); cancellable = Gio.Cancellable.new ();

/<!– –>* Prepare a download stream *<!– –>/ download_stream = GDATA_DOWNLOAD_STREAM (GData.DownloadStream.new (GDATA_SERVICE (service), None, thumbnail_uri, cancellable));

/<!– –>* Download into a new GdkPixbuf. This can be cancelled using ‘cancellable’. *<!– –>/ pixbuf = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (download_stream), None, &error);

if (error != None) { /<!– –>* Handle the error. *<!– –>/ GLib.Error.free (error); }

GObject.Object.unref (download_stream); GObject.Object.unref (cancellable);

/<!– –>* Do something with the GdkPixbuf. *<!– –>/

GObject.Object.unref (pixbuf); </programlisting> </example>

New in version 0.13.1.