[glib] Add "default location" support to GMount



commit 09b1b6414b6aa001733fa7897f48970cb3cf258a
Author: Christian Kellner <gicmo gnome org>
Date:   Fri Oct 9 15:06:44 2009 +0200

    Add "default location" support to GMount
    
    The "default location" of the given mount is a path that reflects
    the main entry point for the user (e.g. the home directory, or the
    root of the volume).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=561998

 gio/gmount.c |   31 +++++++++++++++++++++++++++++++
 gio/gmount.h |    3 +++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gio/gmount.c b/gio/gmount.c
index 124583c..0dfd406 100644
--- a/gio/gmount.c
+++ b/gio/gmount.c
@@ -185,6 +185,37 @@ g_mount_get_root (GMount *mount)
 }
 
 /**
+ * g_mount_get_default_location:
+ * @mount: a #GMount.
+ *
+ * Gets the default location of @mount. The default location of the given
+ * @mount is a path that reflects the main entry point for the user (e.g.
+ * the home directory, or the root of the volume).
+ *
+ * Returns: a #GFile.
+ *      The returned object should be unreffed with
+ *      g_object_unref() when no longer needed.
+ **/
+GFile *
+g_mount_get_default_location (GMount *mount)
+{
+  GMountIface *iface;
+  GFile       *file;
+
+  g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
+
+  iface = G_MOUNT_GET_IFACE (mount);
+  
+  /* Fallback to get_root when default_location () is not available */
+  if (iface->get_default_location)
+    file = (* iface->get_default_location) (mount);
+  else
+    file = (* iface->get_root) (mount);
+
+  return file;
+}
+
+/**
  * g_mount_get_name:
  * @mount: a #GMount.
  * 
diff --git a/gio/gmount.h b/gio/gmount.h
index 18e9229..779bac5 100644
--- a/gio/gmount.h
+++ b/gio/gmount.h
@@ -68,6 +68,7 @@ typedef struct _GMountIface    GMountIface;
  * @unmount_with_operation_finish: Finishes an unmounting operation using a #GMountOperation. Since 2.22.
  * @eject_with_operation: Starts ejecting a #GMount using a #GMountOperation. Since 2.22.
  * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
+ * @get_default_location: Gets a #GFile indication a start location that can be use as the entry point for this mount. Since 2.24.
  *
  * Interface for implementing operations for mounts.
  **/
@@ -154,11 +155,13 @@ struct _GMountIface
   gboolean    (* eject_with_operation_finish) (GMount            *mount,
                                              GAsyncResult        *result,
                                              GError             **error);
+  GFile     * (* get_default_location)      (GMount              *mount);
 };
 
 GType       g_mount_get_type                  (void) G_GNUC_CONST;
 
 GFile     * g_mount_get_root                  (GMount              *mount);
+GFile     * g_mount_get_default_location      (GMount              *mount);
 char      * g_mount_get_name                  (GMount              *mount);
 GIcon     * g_mount_get_icon                  (GMount              *mount);
 char      * g_mount_get_uuid                  (GMount              *mount);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]