GData.DocumentsDocument¶
- 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:
class |
|
|
|
|
|
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:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class GData.DocumentsDocument(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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
orNone
) – the entry’s ID (not the document ID), orNone
- Returns:
a new
GData.DocumentsDocument
, orNone
; unref withGObject.Object.unref
()- Return type:
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:
service (
GData.DocumentsService
) – aGData.DocumentsService
export_format (
str
) – the format in which the document should be exportedcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
for the entire download stream, orNone
- Raises:
- Returns:
a
GData.DownloadStream
to download the document with, orNone
; unref withGObject.Object.unref
()- Return type:
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
orGData.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, useGData.DocumentsSpreadsheet.get_download_uri
() withGData.DownloadStream
to download the grid manually. See theGData protocol specification for more information. To get the content type of the downloaded file,
GData.DownloadStream.get_content_type
() can be called on the returnedGData.DownloadStream
. CallingGData.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 usingGio.Cancellable.cancel
(). Cancelling the individualGio.InputStream
operations on theGData.DownloadStream
will not cancel the entire download; merely the read or close operation in question. See theGData.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:
- Return type:
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 useGData.DownloadStream.new
() with the URI, and use the resultingGio.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
orGData.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()¶
-
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; conststr
*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.