#include <gio/gio.h>
#include <string.h>
#include "ev-metadata.h"
#include "ev-file-helpers.h"
Go to the source code of this file.
|
static void | ev_metadata_finalize (GObject *object) |
|
static void | ev_metadata_init (EvMetadata *metadata) |
|
static void | ev_metadata_class_init (EvMetadataClass *klass) |
|
static void | ev_metadata_load (EvMetadata *metadata) |
|
EvMetadata * | ev_metadata_new (GFile *file) |
|
gboolean | ev_metadata_is_empty (EvMetadata *metadata) |
|
gboolean | ev_metadata_get_string (EvMetadata *metadata, const gchar *key, gchar **value) |
|
static void | metadata_set_callback (GObject *file, GAsyncResult *result, EvMetadata *metadata) |
|
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) |
|
#define EV_METADATA_NAMESPACE "metadata::evince" |
gboolean ev_is_metadata_supported_for_file |
( |
GFile * |
file) | |
|
Definition at line 305 of file ev-metadata.c.
307 GFileAttributeInfoList *namespaces;
309 gboolean retval =
FALSE;
311 namespaces = g_file_query_writable_namespaces (file, NULL, NULL);
315 for (i = 0; i < namespaces->n_infos; i++) {
316 if (strcmp (namespaces->infos[i].name,
"metadata") == 0) {
322 g_file_attribute_info_list_unref (namespaces);
Definition at line 70 of file ev-metadata.c.
72 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
static void ev_metadata_finalize |
( |
GObject * |
object) | |
|
|
static |
Definition at line 43 of file ev-metadata.c.
47 if (metadata->
items) {
48 g_hash_table_destroy (metadata->
items);
49 metadata->
items = NULL;
53 g_object_unref (metadata->
file);
54 metadata->
file = NULL;
57 G_OBJECT_CLASS (ev_metadata_parent_class)->finalize (
object);
gboolean ev_metadata_get_boolean |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
gboolean * |
value |
|
) |
| |
gboolean ev_metadata_get_double |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
gdouble * |
value |
|
) |
| |
Definition at line 244 of file ev-metadata.c.
250 gdouble double_value;
255 double_value = g_ascii_strtod (string_value, &endptr);
256 if (double_value == 0. && string_value == endptr)
259 *value = double_value;
gboolean ev_metadata_get_int |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
gint * |
value |
|
) |
| |
Definition at line 212 of file ev-metadata.c.
223 int_value = g_ascii_strtoull (string_value, &endptr, 0);
224 if (int_value == 0 && string_value == endptr)
gboolean ev_metadata_get_string |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
gchar ** |
value |
|
) |
| |
gboolean ev_metadata_has_key |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key |
|
) |
| |
Definition at line 298 of file ev-metadata.c.
301 return g_hash_table_lookup (metadata->
items, key) != NULL;
static void ev_metadata_init |
( |
EvMetadata * |
metadata) | |
|
|
static |
Definition at line 61 of file ev-metadata.c.
63 metadata->
items = g_hash_table_new_full (g_str_hash,
gboolean ev_metadata_is_empty |
( |
EvMetadata * |
metadata) | |
|
static void ev_metadata_load |
( |
EvMetadata * |
metadata) | |
|
|
static |
Definition at line 78 of file ev-metadata.c.
85 info = g_file_query_info (metadata->
file,
"metadata::*", 0, NULL, &error);
87 g_warning (
"%s", error->message);
93 if (!g_file_info_has_namespace (info,
"metadata")) {
94 g_object_unref (info);
99 attrs = g_file_info_list_attributes (info,
"metadata");
100 for (i = 0; attrs[i]; i++) {
101 GFileAttributeType type;
108 if (!g_file_info_get_attribute_data (info, attrs[i],
109 &type, &value, NULL)) {
115 if (type == G_FILE_ATTRIBUTE_TYPE_STRING) {
116 g_hash_table_insert (metadata->
items,
122 g_object_unref (info);
Definition at line 126 of file ev-metadata.c.
130 g_return_val_if_fail (G_IS_FILE (file), NULL);
134 metadata->
file = g_object_ref (file);
gboolean ev_metadata_set_boolean |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
gboolean |
value |
|
) |
| |
gboolean ev_metadata_set_double |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
gdouble |
value |
|
) |
| |
Definition at line 264 of file ev-metadata.c.
268 gchar string_value[G_ASCII_DTOSTR_BUF_SIZE];
270 g_ascii_dtostr (string_value, G_ASCII_DTOSTR_BUF_SIZE, value);
gboolean ev_metadata_set_int |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
gint |
value |
|
) |
| |
Definition at line 232 of file ev-metadata.c.
236 gchar string_value[32];
238 g_snprintf (string_value,
sizeof (string_value),
"%d", value);
gboolean ev_metadata_set_string |
( |
EvMetadata * |
metadata, |
|
|
const gchar * |
key, |
|
|
const gchar * |
value |
|
) |
| |
Definition at line 176 of file ev-metadata.c.
183 g_hash_table_insert (metadata->
items, g_strdup (key), g_strdup (value));
187 info = g_file_info_new ();
191 g_file_info_set_attribute_string (info, gio_key, value);
193 g_file_info_set_attribute (info, gio_key,
194 G_FILE_ATTRIBUTE_TYPE_INVALID,
199 g_file_set_attributes_async (metadata->
file,
206 g_object_unref (info);
static void metadata_set_callback |
( |
GObject * |
file, |
|
|
GAsyncResult * |
result, |
|
|
EvMetadata * |
metadata |
|
) |
| |
|
static |
Definition at line 163 of file ev-metadata.c.
167 GError *error = NULL;
169 if (!g_file_set_attributes_finish (G_FILE (file), result, NULL, &error)) {
170 g_warning (
"%s", error->message);
171 g_error_free (error);