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-image.c File Reference
#include <config.h>
#include <glib/gstdio.h>
#include <unistd.h>
#include "ev-document-misc.h"
#include "ev-file-helpers.h"
#include "ev-image.h"
+ Include dependency graph for ev-image.c:

Go to the source code of this file.

Data Structures

struct  _EvImagePrivate
 

Macros

#define EV_IMAGE_GET_PRIVATE(object)   (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_IMAGE, EvImagePrivate))
 

Functions

static void ev_image_finalize (GObject *object)
 
static void ev_image_class_init (EvImageClass *klass)
 
static void ev_image_init (EvImage *image)
 
EvImageev_image_new (gint page, gint img_id)
 
EvImageev_image_new_from_pixbuf (GdkPixbuf *pixbuf)
 
gint ev_image_get_page (EvImage *image)
 
gint ev_image_get_id (EvImage *image)
 
GdkPixbuf * ev_image_get_pixbuf (EvImage *image)
 
const gchar * ev_image_save_tmp (EvImage *image, GdkPixbuf *pixbuf)
 
const gchar * ev_image_get_tmp_uri (EvImage *image)
 

Macro Definition Documentation

#define EV_IMAGE_GET_PRIVATE (   object)    (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_IMAGE, EvImagePrivate))

Definition at line 36 of file ev-image.c.

Function Documentation

static void ev_image_class_init ( EvImageClass klass)
static

Definition at line 65 of file ev-image.c.

66 {
67  GObjectClass *g_object_class;
68 
69  g_object_class = G_OBJECT_CLASS (klass);
70 
71  g_type_class_add_private (g_object_class, sizeof (EvImagePrivate));
72 
73  g_object_class->finalize = ev_image_finalize;
74 }
static void ev_image_finalize ( GObject *  object)
static

Definition at line 42 of file ev-image.c.

43 {
44  EvImage *image = EV_IMAGE (object);
45 
46  if (image->priv->pixbuf) {
47  g_object_unref (image->priv->pixbuf);
48  image->priv->pixbuf = NULL;
49  }
50 
51  if (image->priv->tmp_uri) {
52  gchar *filename;
53 
54  filename = g_filename_from_uri (image->priv->tmp_uri, NULL, NULL);
55  ev_tmp_filename_unlink (filename);
56  g_free (filename);
57  g_free (image->priv->tmp_uri);
58  image->priv->tmp_uri = NULL;
59  }
60 
61  (* G_OBJECT_CLASS (ev_image_parent_class)->finalize) (object);
62 }

+ Here is the caller graph for this function:

gint ev_image_get_id ( EvImage image)

Definition at line 117 of file ev-image.c.

118 {
119  g_return_val_if_fail (EV_IS_IMAGE (image), -1);
120 
121  return image->priv->id;
122 }

+ Here is the caller graph for this function:

gint ev_image_get_page ( EvImage image)

Definition at line 109 of file ev-image.c.

110 {
111  g_return_val_if_fail (EV_IS_IMAGE (image), -1);
112 
113  return image->priv->page;
114 }

+ Here is the caller graph for this function:

GdkPixbuf* ev_image_get_pixbuf ( EvImage image)

ev_image_get_pixbuf: an EvImage

Returns: (transfer none): a #GdkPixbuf

Definition at line 131 of file ev-image.c.

132 {
133  g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
134  g_return_val_if_fail (GDK_IS_PIXBUF (image->priv->pixbuf), NULL);
135 
136  return image->priv->pixbuf;
137 }
const gchar* ev_image_get_tmp_uri ( EvImage image)

Definition at line 182 of file ev-image.c.

183 {
184  g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
185 
186  return image->priv->tmp_uri;
187 }
static void ev_image_init ( EvImage image)
static

Definition at line 77 of file ev-image.c.

78 {
79  image->priv = EV_IMAGE_GET_PRIVATE (image);
80 }
EvImage* ev_image_new ( gint  page,
gint  img_id 
)

Definition at line 83 of file ev-image.c.

85 {
86  EvImage *image;
87 
88  image = EV_IMAGE (g_object_new (EV_TYPE_IMAGE, NULL));
89  image->priv->page = page;
90  image->priv->id = img_id;
91 
92  return image;
93 }

+ Here is the caller graph for this function:

EvImage* ev_image_new_from_pixbuf ( GdkPixbuf *  pixbuf)

Definition at line 96 of file ev-image.c.

97 {
98  EvImage *image;
99 
100  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
101 
102  image = EV_IMAGE (g_object_new (EV_TYPE_IMAGE, NULL));
103  image->priv->pixbuf = g_object_ref (pixbuf);
104 
105  return image;
106 }
const gchar* ev_image_save_tmp ( EvImage image,
GdkPixbuf *  pixbuf 
)

Definition at line 140 of file ev-image.c.

142 {
143  GError *error = NULL;
144  gchar *filename = NULL;
145  int fd;
146 
147  g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
148  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
149 
150  if (image->priv->tmp_uri)
151  return image->priv->tmp_uri;
152 
153  if ((fd = ev_mkstemp ("image.XXXXXX.png", &filename, &error)) == -1)
154  goto had_error;
155 
156  gdk_pixbuf_save (pixbuf, filename,
157  "png", &error,
158  "compression", "3", NULL);
159  close (fd);
160 
161  if (!error) {
162  image->priv->tmp_uri = g_filename_to_uri (filename, NULL, &error);
163  if (image->priv->tmp_uri == NULL)
164  goto had_error;
165 
166  g_free (filename);
167 
168  return image->priv->tmp_uri;
169  }
170 
171  had_error:
172 
173  /* Erro saving image */
174  g_warning ("Error saving image: %s", error->message);
175  g_error_free (error);
176  g_free (filename);
177 
178  return NULL;
179 }

+ Here is the caller graph for this function: