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-metadata.h File Reference
#include <glib-object.h>
#include <gio/gio.h>
+ Include dependency graph for ev-metadata.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EV_TYPE_METADATA   (ev_metadata_get_type())
 
#define EV_METADATA(object)   (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_METADATA, EvMetadata))
 
#define EV_METADATA_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_METADATA, EvMetadataClass))
 
#define EV_IS_METADATA(object)   (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_METADATA))
 

Typedefs

typedef struct _EvMetadata EvMetadata
 
typedef struct _EvMetadataClass EvMetadataClass
 

Functions

GType ev_metadata_get_type (void) G_GNUC_CONST
 
EvMetadataev_metadata_new (GFile *file)
 
gboolean ev_metadata_is_empty (EvMetadata *metadata)
 
gboolean ev_metadata_get_string (EvMetadata *metadata, const gchar *key, gchar **value)
 
gboolean ev_metadata_set_string (EvMetadata *metadata, const gchar *key, const gchar *value)
 
gboolean ev_metadata_get_int (EvMetadata *metadata, const gchar *key, gint *value)
 
gboolean ev_metadata_set_int (EvMetadata *metadata, const gchar *key, gint value)
 
gboolean ev_metadata_get_double (EvMetadata *metadata, const gchar *key, gdouble *value)
 
gboolean ev_metadata_set_double (EvMetadata *metadata, const gchar *key, gdouble value)
 
gboolean ev_metadata_get_boolean (EvMetadata *metadata, const gchar *key, gboolean *value)
 
gboolean ev_metadata_set_boolean (EvMetadata *metadata, const gchar *key, gboolean value)
 
gboolean ev_metadata_has_key (EvMetadata *metadata, const gchar *key)
 
gboolean ev_is_metadata_supported_for_file (GFile *file)
 

Macro Definition Documentation

#define EV_IS_METADATA (   object)    (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_METADATA))

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

#define EV_METADATA (   object)    (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_METADATA, EvMetadata))

Definition at line 30 of file ev-metadata.h.

#define EV_METADATA_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_METADATA, EvMetadataClass))

Definition at line 31 of file ev-metadata.h.

#define EV_TYPE_METADATA   (ev_metadata_get_type())

Definition at line 29 of file ev-metadata.h.

Typedef Documentation

typedef struct _EvMetadata EvMetadata

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

Definition at line 35 of file ev-metadata.h.

Function Documentation

gboolean ev_is_metadata_supported_for_file ( GFile *  file)

Definition at line 305 of file ev-metadata.c.

306 {
307  GFileAttributeInfoList *namespaces;
308  gint i;
309  gboolean retval = FALSE;
310 
311  namespaces = g_file_query_writable_namespaces (file, NULL, NULL);
312  if (!namespaces)
313  return retval;
314 
315  for (i = 0; i < namespaces->n_infos; i++) {
316  if (strcmp (namespaces->infos[i].name, "metadata") == 0) {
317  retval = TRUE;
318  break;
319  }
320  }
321 
322  g_file_attribute_info_list_unref (namespaces);
323 
324  return retval;
325 }

+ Here is the caller graph for this function:

gboolean ev_metadata_get_boolean ( EvMetadata metadata,
const gchar *  key,
gboolean *  value 
)

Definition at line 276 of file ev-metadata.c.

279 {
280  gint int_value;
281 
282  if (!ev_metadata_get_int (metadata, key, &int_value))
283  return FALSE;
284 
285  *value = int_value;
286  return TRUE;
287 }

+ Here is the caller graph for this function:

gboolean ev_metadata_get_double ( EvMetadata metadata,
const gchar *  key,
gdouble *  value 
)

Definition at line 244 of file ev-metadata.c.

247 {
248  gchar *string_value;
249  gchar *endptr;
250  gdouble double_value;
251 
252  if (!ev_metadata_get_string (metadata, key, &string_value))
253  return FALSE;
254 
255  double_value = g_ascii_strtod (string_value, &endptr);
256  if (double_value == 0. && string_value == endptr)
257  return FALSE;
258 
259  *value = double_value;
260  return TRUE;
261 }

+ Here is the caller graph for this function:

gboolean ev_metadata_get_int ( EvMetadata metadata,
const gchar *  key,
gint *  value 
)

Definition at line 212 of file ev-metadata.c.

215 {
216  gchar *string_value;
217  gchar *endptr;
218  gint int_value;
219 
220  if (!ev_metadata_get_string (metadata, key, &string_value))
221  return FALSE;
222 
223  int_value = g_ascii_strtoull (string_value, &endptr, 0);
224  if (int_value == 0 && string_value == endptr)
225  return FALSE;
226 
227  *value = int_value;
228  return TRUE;
229 }

+ Here is the caller graph for this function:

gboolean ev_metadata_get_string ( EvMetadata metadata,
const gchar *  key,
gchar **  value 
)

Definition at line 148 of file ev-metadata.c.

151 {
152  gchar *v;
153 
154  v = g_hash_table_lookup (metadata->items, key);
155  if (!v)
156  return FALSE;
157 
158  *value = v;
159  return TRUE;
160 }

+ Here is the caller graph for this function:

GType ev_metadata_get_type ( void  )
gboolean ev_metadata_has_key ( EvMetadata metadata,
const gchar *  key 
)

Definition at line 298 of file ev-metadata.c.

300 {
301  return g_hash_table_lookup (metadata->items, key) != NULL;
302 }

+ Here is the caller graph for this function:

gboolean ev_metadata_is_empty ( EvMetadata metadata)

Definition at line 142 of file ev-metadata.c.

143 {
144  return g_hash_table_size (metadata->items) == 0;
145 }
EvMetadata* ev_metadata_new ( GFile *  file)

Definition at line 126 of file ev-metadata.c.

127 {
128  EvMetadata *metadata;
129 
130  g_return_val_if_fail (G_IS_FILE (file), NULL);
131 
132  metadata = EV_METADATA (g_object_new (EV_TYPE_METADATA, NULL));
133  if (!ev_file_is_temp (file)) {
134  metadata->file = g_object_ref (file);
135  ev_metadata_load (metadata);
136  }
137 
138  return metadata;
139 }

+ Here is the caller graph for this function:

gboolean ev_metadata_set_boolean ( EvMetadata metadata,
const gchar *  key,
gboolean  value 
)

Definition at line 290 of file ev-metadata.c.

293 {
294  return ev_metadata_set_string (metadata, key, value ? "1" : "0");
295 }

+ Here is the caller graph for this function:

gboolean ev_metadata_set_double ( EvMetadata metadata,
const gchar *  key,
gdouble  value 
)

Definition at line 264 of file ev-metadata.c.

267 {
268  gchar string_value[G_ASCII_DTOSTR_BUF_SIZE];
269 
270  g_ascii_dtostr (string_value, G_ASCII_DTOSTR_BUF_SIZE, value);
271 
272  return ev_metadata_set_string (metadata, key, string_value);
273 }

+ Here is the caller graph for this function:

gboolean ev_metadata_set_int ( EvMetadata metadata,
const gchar *  key,
gint  value 
)

Definition at line 232 of file ev-metadata.c.

235 {
236  gchar string_value[32];
237 
238  g_snprintf (string_value, sizeof (string_value), "%d", value);
239 
240  return ev_metadata_set_string (metadata, key, string_value);
241 }

+ Here is the caller graph for this function:

gboolean ev_metadata_set_string ( EvMetadata metadata,
const gchar *  key,
const gchar *  value 
)

Definition at line 176 of file ev-metadata.c.

179 {
180  GFileInfo *info;
181  gchar *gio_key;
182 
183  g_hash_table_insert (metadata->items, g_strdup (key), g_strdup (value));
184  if (!metadata->file)
185  return TRUE;
186 
187  info = g_file_info_new ();
188 
189  gio_key = g_strconcat (EV_METADATA_NAMESPACE"::", key, NULL);
190  if (value) {
191  g_file_info_set_attribute_string (info, gio_key, value);
192  } else {
193  g_file_info_set_attribute (info, gio_key,
194  G_FILE_ATTRIBUTE_TYPE_INVALID,
195  NULL);
196  }
197  g_free (gio_key);
198 
199  g_file_set_attributes_async (metadata->file,
200  info,
201  0,
202  G_PRIORITY_DEFAULT,
203  NULL,
204  (GAsyncReadyCallback)metadata_set_callback,
205  metadata);
206  g_object_unref (info);
207 
208  return TRUE;
209 }

+ Here is the caller graph for this function: