[gvfs] GVfsIcon: support icon serialisation
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] GVfsIcon: support icon serialisation
- Date: Sun, 21 Apr 2013 20:37:01 +0000 (UTC)
commit c9bbd01b70fea6488f48d2360893196295e13429
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Apr 20 19:35:34 2013 -0400
GVfsIcon: support icon serialisation
Add support for the new icon serialisation interface to GVfsIcon as well
as implementing the new interface on GVfsClass for deserialising.
https://bugzilla.gnome.org/show_bug.cgi?id=688820
client/gdaemonvfs.c | 8 ++++++++
common/gvfsicon.c | 34 ++++++++++++++++++++++++++++++++++
common/gvfsicon.h | 3 +++
configure.ac | 2 +-
4 files changed, 46 insertions(+), 1 deletion(-)
---
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index b712b22..7c7f9a7 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -1473,6 +1473,13 @@ g_daemon_vfs_local_file_moved (GVfs *vfs,
meta_lookup_cache_free (cache);
}
+static GIcon *
+g_daemon_vfs_deserialize_icon (GVfs *vfs,
+ GVariant *value)
+{
+ return g_vfs_icon_deserialize (value);
+}
+
GDBusConnection *
_g_daemon_vfs_get_async_bus (void)
{
@@ -1515,6 +1522,7 @@ g_daemon_vfs_class_init (GDaemonVfsClass *class)
vfs_class->local_file_set_attributes = g_daemon_vfs_local_file_set_attributes;
vfs_class->local_file_removed = g_daemon_vfs_local_file_removed;
vfs_class->local_file_moved = g_daemon_vfs_local_file_moved;
+ vfs_class->deserialize_icon = g_daemon_vfs_deserialize_icon;
}
/* Module API */
diff --git a/common/gvfsicon.c b/common/gvfsicon.c
index 318440c..3bacf8c 100644
--- a/common/gvfsicon.c
+++ b/common/gvfsicon.c
@@ -272,6 +272,39 @@ g_vfs_icon_from_tokens (gchar **tokens,
return icon;
}
+static GVariant *
+g_vfs_icon_serialize (GIcon *icon)
+{
+ GVfsIcon *vfs_icon = G_VFS_ICON (icon);
+
+ return g_variant_new ("(@ss)",
+ g_variant_new_take_string (g_mount_spec_to_string (vfs_icon->mount_spec)),
+ vfs_icon->icon_id);
+}
+
+GIcon *
+g_vfs_icon_deserialize (GVariant *value)
+{
+ const gchar *mount_spec_str;
+ const gchar *id_str;
+ GMountSpec *mount_spec;
+ GIcon *icon;
+
+ if (!g_variant_is_of_type (value, G_VARIANT_TYPE ("(ss)")))
+ return NULL;
+
+ g_variant_get (value, "(&s&s)", &mount_spec_str, &id_str);
+
+ mount_spec = g_mount_spec_new_from_string (mount_spec_str, NULL);
+ if (mount_spec == NULL)
+ return NULL;
+
+ icon = g_vfs_icon_new (mount_spec, id_str);
+ g_mount_spec_unref (mount_spec);
+
+ return icon;
+}
+
static void
g_vfs_icon_icon_iface_init (GIconIface *iface)
{
@@ -279,4 +312,5 @@ g_vfs_icon_icon_iface_init (GIconIface *iface)
iface->equal = g_vfs_icon_equal;
iface->to_tokens = g_vfs_icon_to_tokens;
iface->from_tokens = g_vfs_icon_from_tokens;
+ iface->serialize = g_vfs_icon_serialize;
}
diff --git a/common/gvfsicon.h b/common/gvfsicon.h
index 7ed0935..1bba7e7 100644
--- a/common/gvfsicon.h
+++ b/common/gvfsicon.h
@@ -61,9 +61,12 @@ GType g_vfs_icon_get_type (void) G_GNUC_CONST;
GIcon *g_vfs_icon_new (GMountSpec *mount_spec,
const gchar *icon_id);
+GIcon *g_vfs_icon_deserialize (GVariant *value);
+
GMountSpec *g_vfs_icon_get_mount_spec (GVfsIcon *vfs_icon);
const gchar *g_vfs_icon_get_icon_id (GVfsIcon *vfs_icon);
+
G_END_DECLS
#endif /* __G_VFS_ICON_H__ */
diff --git a/configure.ac b/configure.ac
index a63daf7..ab7c390 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,7 @@ GTK_DOC_CHECK
DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.35.0 gobject-2.0 gmodule-no-export-2.0 gio-unix-2.0 gio-2.0 )
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.37.0 gobject-2.0 gmodule-no-export-2.0 gio-unix-2.0 gio-2.0 )
PKG_CHECK_MODULES(DBUS, dbus-1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]