[gnome-photos/wip/rishi/collection: 10/20] source: Support GMount-backed sources for importing
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/collection: 10/20] source: Support GMount-backed sources for importing
- Date: Wed, 6 Sep 2017 07:31:22 +0000 (UTC)
commit 0f1da73224dd689743358714916202f3618c37fc
Author: Debarshi Ray <debarshir gnome org>
Date: Sun Sep 3 12:13:14 2017 +0200
source: Support GMount-backed sources for importing
https://bugzilla.gnome.org/show_bug.cgi?id=751212
src/photos-source.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/photos-source.h | 6 +++++-
2 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-source.c b/src/photos-source.c
index a28435e..4844c8b 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -37,6 +37,7 @@ struct _PhotosSource
{
GObject parent_instance;
GIcon *icon;
+ GMount *mount;
GoaObject *object;
gboolean builtin;
gchar *id;
@@ -48,6 +49,7 @@ enum
PROP_0,
PROP_BUILTIN,
PROP_ID,
+ PROP_MOUNT,
PROP_NAME,
PROP_OBJECT
};
@@ -111,6 +113,7 @@ photos_source_dispose (GObject *object)
PhotosSource *self = PHOTOS_SOURCE (object);
g_clear_object (&self->icon);
+ g_clear_object (&self->mount);
g_clear_object (&self->object);
G_OBJECT_CLASS (photos_source_parent_class)->dispose (object);
@@ -146,6 +149,10 @@ photos_source_get_property (GObject *object, guint prop_id, GValue *value, GPara
g_value_set_string (value, self->id);
break;
+ case PROP_MOUNT:
+ g_value_set_object (value, self->mount);
+ break;
+
case PROP_NAME:
g_value_set_string (value, self->name);
break;
@@ -176,6 +183,27 @@ photos_source_set_property (GObject *object, guint prop_id, const GValue *value,
self->id = g_value_dup_string (value);
break;
+ case PROP_MOUNT:
+ {
+ GFile *root = NULL;
+ gchar *uri = NULL;
+
+ self->mount = G_MOUNT (g_value_dup_object (value));
+ if (self->mount == NULL)
+ break;
+
+ root = g_mount_get_root (self->mount);
+ uri = g_file_get_uri (root);
+ self->id = g_strdup_printf ("gd:g-mount:%s", uri);
+
+ self->icon = g_mount_get_icon (self->mount);
+ self->name = g_mount_get_name (self->mount);
+
+ g_free (uri);
+ g_object_unref (root);
+ break;
+ }
+
case PROP_NAME:
self->name = g_value_dup_string (value);
break;
@@ -242,6 +270,14 @@ photos_source_class_init (PhotosSourceClass *class)
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (object_class,
+ PROP_MOUNT,
+ g_param_spec_object ("mount",
+ "GMount instance",
+ "A mount point representing a removable device (eg.,
camera)",
+ G_TYPE_MOUNT,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
PROP_NAME,
g_param_spec_string ("name",
"",
@@ -283,6 +319,14 @@ photos_source_new_from_goa_object (GoaObject *object)
}
+PhotosSource *
+photos_source_new_from_mount (GMount *mount)
+{
+ g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
+ return g_object_new (PHOTOS_TYPE_SOURCE, "mount", mount, NULL);
+}
+
+
const gchar *
photos_source_get_name (PhotosSource *self)
{
@@ -302,3 +346,10 @@ photos_source_get_icon (PhotosSource *self)
{
return self->icon;
}
+
+
+GMount *
+photos_source_get_mount (PhotosSource *self)
+{
+ return self->mount;
+}
diff --git a/src/photos-source.h b/src/photos-source.h
index b037d49..50958c2 100644
--- a/src/photos-source.h
+++ b/src/photos-source.h
@@ -25,7 +25,7 @@
#ifndef PHOTOS_SOURCE_H
#define PHOTOS_SOURCE_H
-#include <glib-object.h>
+#include <gio/gio.h>
#include <goa/goa.h>
G_BEGIN_DECLS
@@ -40,12 +40,16 @@ PhotosSource *photos_source_new (const gchar *id, const
PhotosSource *photos_source_new_from_goa_object (GoaObject *object);
+PhotosSource *photos_source_new_from_mount (GMount *mount);
+
const gchar *photos_source_get_name (PhotosSource *self);
GoaObject *photos_source_get_goa_object (PhotosSource *self);
GIcon *photos_source_get_icon (PhotosSource *self);
+GMount *photos_source_get_mount (PhotosSource *self);
+
G_END_DECLS
#endif /* PHOTOS_SOURCE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]