Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-attachment.h File Reference
#include <glib-object.h>
#include <gio/gio.h>
+ Include dependency graph for ev-attachment.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _EvAttachment
 
struct  _EvAttachmentClass
 

Macros

#define EV_TYPE_ATTACHMENT   (ev_attachment_get_type())
 
#define EV_ATTACHMENT(object)   (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_ATTACHMENT, EvAttachment))
 
#define EV_ATTACHMENT_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_ATTACHMENT, EvAttachmentClass))
 
#define EV_IS_ATTACHMENT(object)   (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_ATTACHMENT))
 
#define EV_IS_ATTACHMENT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_ATTACHMENT))
 
#define EV_ATTACHMENT_GET_CLASS(object)   (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_ATTACHMENT, EvAttachmentClass))
 
#define EV_ATTACHMENT_ERROR   (ev_attachment_error_quark ())
 

Typedefs

typedef typedefG_BEGIN_DECLS
struct _EvAttachment 
EvAttachment
 
typedef struct _EvAttachmentClass EvAttachmentClass
 
typedef struct _EvAttachmentPrivate EvAttachmentPrivate
 

Functions

GType ev_attachment_get_type (void) G_GNUC_CONST
 
GQuark ev_attachment_error_quark (void) G_GNUC_CONST
 
EvAttachmentev_attachment_new (const gchar *name, const gchar *description, GTime mtime, GTime ctime, gsize size, gpointer data)
 
const gchar * ev_attachment_get_name (EvAttachment *attachment)
 
const gchar * ev_attachment_get_description (EvAttachment *attachment)
 
GTime ev_attachment_get_modification_date (EvAttachment *attachment)
 
GTime ev_attachment_get_creation_date (EvAttachment *attachment)
 
const gchar * ev_attachment_get_mime_type (EvAttachment *attachment)
 
gboolean ev_attachment_save (EvAttachment *attachment, GFile *file, GError **error)
 
gboolean ev_attachment_open (EvAttachment *attachment, GdkScreen *screen, guint32 timestamp, GError **error)
 

Macro Definition Documentation

#define EV_ATTACHMENT (   object)    (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_ATTACHMENT, EvAttachment))

Definition at line 37 of file ev-attachment.h.

#define EV_ATTACHMENT_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_ATTACHMENT, EvAttachmentClass))

Definition at line 38 of file ev-attachment.h.

#define EV_ATTACHMENT_ERROR   (ev_attachment_error_quark ())

Definition at line 43 of file ev-attachment.h.

#define EV_ATTACHMENT_GET_CLASS (   object)    (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_ATTACHMENT, EvAttachmentClass))

Definition at line 41 of file ev-attachment.h.

#define EV_IS_ATTACHMENT (   object)    (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_ATTACHMENT))

Definition at line 39 of file ev-attachment.h.

#define EV_IS_ATTACHMENT_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_ATTACHMENT))

Definition at line 40 of file ev-attachment.h.

#define EV_TYPE_ATTACHMENT   (ev_attachment_get_type())

Definition at line 36 of file ev-attachment.h.

Typedef Documentation

typedef typedefG_BEGIN_DECLS struct _EvAttachment EvAttachment

Definition at line 32 of file ev-attachment.h.

Definition at line 33 of file ev-attachment.h.

Definition at line 34 of file ev-attachment.h.

Function Documentation

GQuark ev_attachment_error_quark ( void  )

Definition at line 57 of file ev-attachment.c.

58 {
59  static GQuark error_quark = 0;
60 
61  if (error_quark == 0)
62  error_quark =
63  g_quark_from_static_string ("ev-attachment-error-quark");
64 
65  return error_quark;
66 }
GTime ev_attachment_get_creation_date ( EvAttachment attachment)

Definition at line 275 of file ev-attachment.c.

276 {
277  g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), 0);
278 
279  return attachment->priv->ctime;
280 }
const gchar* ev_attachment_get_description ( EvAttachment attachment)

Definition at line 259 of file ev-attachment.c.

260 {
261  g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL);
262 
263  return attachment->priv->description;
264 }
const gchar* ev_attachment_get_mime_type ( EvAttachment attachment)

Definition at line 283 of file ev-attachment.c.

284 {
285  g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL);
286 
287  return attachment->priv->mime_type;
288 }

+ Here is the caller graph for this function:

GTime ev_attachment_get_modification_date ( EvAttachment attachment)

Definition at line 267 of file ev-attachment.c.

268 {
269  g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), 0);
270 
271  return attachment->priv->mtime;
272 }
const gchar* ev_attachment_get_name ( EvAttachment attachment)

Definition at line 251 of file ev-attachment.c.

252 {
253  g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), NULL);
254 
255  return attachment->priv->name;
256 }

+ Here is the caller graph for this function:

GType ev_attachment_get_type ( void  )
EvAttachment* ev_attachment_new ( const gchar *  name,
const gchar *  description,
GTime  mtime,
GTime  ctime,
gsize  size,
gpointer  data 
)

Definition at line 229 of file ev-attachment.c.

235 {
236  EvAttachment *attachment;
237 
238  attachment = g_object_new (EV_TYPE_ATTACHMENT,
239  "name", name,
240  "description", description,
241  "mtime", mtime,
242  "ctime", ctime,
243  "size", size,
244  "data", data,
245  NULL);
246 
247  return attachment;
248 }

+ Here is the caller graph for this function:

gboolean ev_attachment_open ( EvAttachment attachment,
GdkScreen *  screen,
guint32  timestamp,
GError **  error 
)

Definition at line 395 of file ev-attachment.c.

399 {
400  GAppInfo *app_info;
401  gboolean retval = FALSE;
402 
403  g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE);
404 
405  if (!attachment->priv->app) {
406  app_info = g_app_info_get_default_for_type (attachment->priv->mime_type, FALSE);
407  attachment->priv->app = app_info;
408  }
409 
410  if (!attachment->priv->app) {
411  g_set_error (error,
413  0,
414  _("Couldn’t open attachment “%s”"),
415  attachment->priv->name);
416 
417  return FALSE;
418  }
419 
420  if (attachment->priv->tmp_file) {
421  retval = ev_attachment_launch_app (attachment, screen,
422  timestamp, error);
423  } else {
424  char *basename;
425  char *template;
426  GFile *file;
427 
428  /* FIXMEchpe: convert to filename encoding first! */
429  basename = g_path_get_basename (ev_attachment_get_name (attachment));
430  template = g_strdup_printf ("%s.XXXXXX", basename);
431  file = ev_mkstemp_file (template, error);
432  g_free (template);
433  g_free (basename);
434 
435  if (file != NULL && ev_attachment_save (attachment, file, error)) {
436  if (attachment->priv->tmp_file)
437  g_object_unref (attachment->priv->tmp_file);
438  attachment->priv->tmp_file = g_object_ref (file);
439 
440  retval = ev_attachment_launch_app (attachment, screen,
441  timestamp, error);
442  }
443 
444  g_object_unref (file);
445  }
446 
447  return retval;
448 }

+ Here is the caller graph for this function:

gboolean ev_attachment_save ( EvAttachment attachment,
GFile *  file,
GError **  error 
)

Definition at line 291 of file ev-attachment.c.

294 {
295  GFileOutputStream *output_stream;
296  GError *ioerror = NULL;
297  gssize written_bytes;
298 
299  g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE);
300  g_return_val_if_fail (G_IS_FILE (file), FALSE);
301 
302  output_stream = g_file_replace (file, NULL, FALSE, 0, NULL, &ioerror);
303  if (output_stream == NULL) {
304  char *uri;
305 
306  uri = g_file_get_uri (file);
307  g_set_error (error,
309  ioerror->code,
310  _("Couldn’t save attachment “%s”: %s"),
311  uri,
312  ioerror->message);
313 
314  g_error_free (ioerror);
315  g_free (uri);
316 
317  return FALSE;
318  }
319 
320  written_bytes = g_output_stream_write (G_OUTPUT_STREAM (output_stream),
321  attachment->priv->data,
322  attachment->priv->size,
323  NULL, &ioerror);
324  if (written_bytes == -1) {
325  char *uri;
326 
327  uri = g_file_get_uri (file);
328  g_set_error (error,
330  ioerror->code,
331  _("Couldn’t save attachment “%s”: %s"),
332  uri,
333  ioerror->message);
334 
335  g_output_stream_close (G_OUTPUT_STREAM (output_stream), NULL, NULL);
336  g_error_free (ioerror);
337  g_free (uri);
338 
339  return FALSE;
340  }
341 
342  g_output_stream_close (G_OUTPUT_STREAM (output_stream), NULL, NULL);
343 
344  return TRUE;
345 
346 }

+ Here is the caller graph for this function: