GIcon: add g_icon_[de]serialize()

Add support for serialising a GIcon to a GVariant and deserialising the
result back to a GIcon.

This solves a number of problems suffered by the existing to_string()
API, primarily these:

 - not forcing the icon to be a utf8 string means that we can
   efficiently encode a PNG (ie: just give the array of bytes)

 - there is no need to ensure that proper types are loaded before using
   the deserialisation interface.  'Foreign' icon types will probably
   emit a serialised format the deserialises to a GBytesIcon.

We additionally clearly document what is required for being a consumer
or implementation of #GIcon.

Further patches will be required to GdkPixbuf and GVfsIcon to bring
their implementations in line with the new rules (essentially: introduce
implementations of the new serialize() API).

https://bugzilla.gnome.org/show_bug.cgi?id=688820
This commit is contained in:
Ryan Lortie
2013-04-20 18:50:21 -04:00
parent 9cc222c0bf
commit c16f914b40
9 changed files with 439 additions and 8 deletions

View File

@@ -95,6 +95,8 @@ struct _GVfsClass
void (* local_file_moved) (GVfs *vfs,
const char *source,
const char *dest);
GIcon * (* deserialize_icon) (GVfs *vfs,
GVariant *value);
/* Padding for future expansion */
void (*_g_reserved1) (void);
void (*_g_reserved2) (void);
@@ -102,7 +104,6 @@ struct _GVfsClass
void (*_g_reserved4) (void);
void (*_g_reserved5) (void);
void (*_g_reserved6) (void);
void (*_g_reserved7) (void);
};
GLIB_AVAILABLE_IN_ALL