[Gio] Merge in introspection annotations from gobject-introspection gio-2.0.c
[platform/upstream/glib.git] / gio / gfileinfo.c
index 0f2ea3c..b101af4 100644 (file)
 /**
  * SECTION:gfileinfo
  * @short_description: File Information and Attributes
- * @see_also: #GFile
- * 
+ * @include: gio/gio.h
+ * @see_also: #GFile, <link linkend="gio-GFileAttribute">GFileAttribute</link>
+ *
  * Functionality for manipulating basic metadata for files. #GFileInfo
- * implements methods for getting information that all files should 
- * contain, and allows for manipulation of extended attributes. 
- * #GFileAttributeMatcher allows for searching through a #GFileInfo for 
+ * implements methods for getting information that all files should
+ * contain, and allows for manipulation of extended attributes.
+ *
+ * See <link linkend="gio-GFileAttribute">GFileAttribute</link> for more
+ * information on how GIO handles file attributes.
+ *
+ * To obtain a #GFileInfo for a #GFile, use g_file_query_info() (or its
+ * async variant). To obtain a #GFileInfo for a file input or output
+ * stream, use g_file_input_stream_query_info() or
+ * g_file_output_stream_query_info() (or their async variants).
+ *
+ * To change the actual attributes of a file, you should then set the
+ * attribute in the #GFileInfo and call g_file_set_attributes_from_info()
+ * or g_file_set_attributes_async() on a GFile.
+ *
+ * However, not all attributes can be changed in the file. For instance,
+ * the actual size of a file cannot be changed via g_file_info_set_size().
+ * You may call g_file_query_settable_attributes() and
+ * g_file_query_writable_namespaces() to discover the settable attributes
+ * of a particular file at runtime.
+ *
+ * #GFileAttributeMatcher allows for searching through a #GFileInfo for
  * attributes.
- * 
- * 
- * 
  **/
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 
 #include "gfileinfo.h"
+#include "gfileinfo-priv.h"
 #include "gfileattribute-priv.h"
+#include "gicon.h"
 #include "glibintl.h"
 
 #include "gioalias.h"
@@ -67,9 +86,6 @@ struct _GFileInfoClass
 };
 
 
-static gboolean g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher,
-                                                    guint32 id);
-
 G_DEFINE_TYPE (GFileInfo, g_file_info, G_TYPE_OBJECT);
 
 typedef struct {
@@ -123,6 +139,133 @@ _lookup_namespace (const char *namespace)
 }
 
 static guint32
+_lookup_attribute (const char *attribute)
+{
+  guint32 attr_id, id;
+  char *ns;
+  const char *colon;
+  NSInfo *ns_info;
+  
+  attr_id = GPOINTER_TO_UINT (g_hash_table_lookup (attribute_hash, attribute));
+
+  if (attr_id != 0)
+    return attr_id;
+
+  colon = strstr (attribute, "::");
+  if (colon)
+    ns = g_strndup (attribute, colon - attribute);
+  else
+    ns = g_strdup ("");
+
+  ns_info = _lookup_namespace (ns);
+  g_free (ns);
+
+  id = ++ns_info->attribute_id_counter;
+  attributes[ns_info->id] = g_realloc (attributes[ns_info->id], (id + 1) * sizeof (char *));
+  attributes[ns_info->id][id] = g_strdup (attribute);
+  
+  attr_id = MAKE_ATTR_ID (ns_info->id, id);
+
+  g_hash_table_insert (attribute_hash, attributes[ns_info->id][id], GUINT_TO_POINTER (attr_id));
+
+  return attr_id;
+}
+
+static void
+ensure_attribute_hash (void)
+{
+  if (attribute_hash != NULL)
+    return;
+
+  ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
+  attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+#define REGISTER_ATTRIBUTE(name) G_STMT_START{\
+  guint _u = _lookup_attribute (G_FILE_ATTRIBUTE_ ## name); \
+  /* use for generating the ID: g_print ("#define G_FILE_ATTRIBUTE_ID_%s (%u + %u)\n", #name + 17, _u & ~ID_MASK, _u & ID_MASK); */ \
+  g_assert (_u == G_FILE_ATTRIBUTE_ID_ ## name); \
+}G_STMT_END
+
+  REGISTER_ATTRIBUTE (STANDARD_TYPE);
+  REGISTER_ATTRIBUTE (STANDARD_IS_HIDDEN);
+  REGISTER_ATTRIBUTE (STANDARD_IS_BACKUP);
+  REGISTER_ATTRIBUTE (STANDARD_IS_SYMLINK);
+  REGISTER_ATTRIBUTE (STANDARD_IS_VIRTUAL);
+  REGISTER_ATTRIBUTE (STANDARD_NAME);
+  REGISTER_ATTRIBUTE (STANDARD_DISPLAY_NAME);
+  REGISTER_ATTRIBUTE (STANDARD_EDIT_NAME);
+  REGISTER_ATTRIBUTE (STANDARD_COPY_NAME);
+  REGISTER_ATTRIBUTE (STANDARD_DESCRIPTION);
+  REGISTER_ATTRIBUTE (STANDARD_ICON);
+  REGISTER_ATTRIBUTE (STANDARD_CONTENT_TYPE);
+  REGISTER_ATTRIBUTE (STANDARD_FAST_CONTENT_TYPE);
+  REGISTER_ATTRIBUTE (STANDARD_SIZE);
+  REGISTER_ATTRIBUTE (STANDARD_ALLOCATED_SIZE);
+  REGISTER_ATTRIBUTE (STANDARD_SYMLINK_TARGET);
+  REGISTER_ATTRIBUTE (STANDARD_TARGET_URI);
+  REGISTER_ATTRIBUTE (STANDARD_SORT_ORDER);
+  REGISTER_ATTRIBUTE (ETAG_VALUE);
+  REGISTER_ATTRIBUTE (ID_FILE);
+  REGISTER_ATTRIBUTE (ID_FILESYSTEM);
+  REGISTER_ATTRIBUTE (ACCESS_CAN_READ);
+  REGISTER_ATTRIBUTE (ACCESS_CAN_WRITE);
+  REGISTER_ATTRIBUTE (ACCESS_CAN_EXECUTE);
+  REGISTER_ATTRIBUTE (ACCESS_CAN_DELETE);
+  REGISTER_ATTRIBUTE (ACCESS_CAN_TRASH);
+  REGISTER_ATTRIBUTE (ACCESS_CAN_RENAME);
+  REGISTER_ATTRIBUTE (MOUNTABLE_CAN_MOUNT);
+  REGISTER_ATTRIBUTE (MOUNTABLE_CAN_UNMOUNT);
+  REGISTER_ATTRIBUTE (MOUNTABLE_CAN_EJECT);
+  REGISTER_ATTRIBUTE (MOUNTABLE_UNIX_DEVICE);
+  REGISTER_ATTRIBUTE (MOUNTABLE_UNIX_DEVICE_FILE);
+  REGISTER_ATTRIBUTE (MOUNTABLE_HAL_UDI);
+  REGISTER_ATTRIBUTE (MOUNTABLE_CAN_START);
+  REGISTER_ATTRIBUTE (MOUNTABLE_CAN_START_DEGRADED);
+  REGISTER_ATTRIBUTE (MOUNTABLE_CAN_STOP);
+  REGISTER_ATTRIBUTE (MOUNTABLE_START_STOP_TYPE);
+  REGISTER_ATTRIBUTE (MOUNTABLE_CAN_POLL);
+  REGISTER_ATTRIBUTE (MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC);
+  REGISTER_ATTRIBUTE (TIME_MODIFIED);
+  REGISTER_ATTRIBUTE (TIME_MODIFIED_USEC);
+  REGISTER_ATTRIBUTE (TIME_ACCESS);
+  REGISTER_ATTRIBUTE (TIME_ACCESS_USEC);
+  REGISTER_ATTRIBUTE (TIME_CHANGED);
+  REGISTER_ATTRIBUTE (TIME_CHANGED_USEC);
+  REGISTER_ATTRIBUTE (TIME_CREATED);
+  REGISTER_ATTRIBUTE (TIME_CREATED_USEC);
+  REGISTER_ATTRIBUTE (UNIX_DEVICE);
+  REGISTER_ATTRIBUTE (UNIX_INODE);
+  REGISTER_ATTRIBUTE (UNIX_MODE);
+  REGISTER_ATTRIBUTE (UNIX_NLINK);
+  REGISTER_ATTRIBUTE (UNIX_UID);
+  REGISTER_ATTRIBUTE (UNIX_GID);
+  REGISTER_ATTRIBUTE (UNIX_RDEV);
+  REGISTER_ATTRIBUTE (UNIX_BLOCK_SIZE);
+  REGISTER_ATTRIBUTE (UNIX_BLOCKS);
+  REGISTER_ATTRIBUTE (UNIX_IS_MOUNTPOINT);
+  REGISTER_ATTRIBUTE (DOS_IS_ARCHIVE);
+  REGISTER_ATTRIBUTE (DOS_IS_SYSTEM);
+  REGISTER_ATTRIBUTE (OWNER_USER);
+  REGISTER_ATTRIBUTE (OWNER_USER_REAL);
+  REGISTER_ATTRIBUTE (OWNER_GROUP);
+  REGISTER_ATTRIBUTE (THUMBNAIL_PATH);
+  REGISTER_ATTRIBUTE (THUMBNAILING_FAILED);
+  REGISTER_ATTRIBUTE (PREVIEW_ICON);
+  REGISTER_ATTRIBUTE (FILESYSTEM_SIZE);
+  REGISTER_ATTRIBUTE (FILESYSTEM_FREE);
+  REGISTER_ATTRIBUTE (FILESYSTEM_TYPE);
+  REGISTER_ATTRIBUTE (FILESYSTEM_READONLY);
+  REGISTER_ATTRIBUTE (FILESYSTEM_USE_PREVIEW);
+  REGISTER_ATTRIBUTE (GVFS_BACKEND);
+  REGISTER_ATTRIBUTE (SELINUX_CONTEXT);
+  REGISTER_ATTRIBUTE (TRASH_ITEM_COUNT);
+  REGISTER_ATTRIBUTE (TRASH_ORIG_PATH);
+  REGISTER_ATTRIBUTE (TRASH_DELETION_DATE);
+
+#undef REGISTER_ATTRIBUTE
+}
+
+static guint32
 lookup_namespace (const char *namespace)
 {
   NSInfo *ns_info;
@@ -130,11 +273,7 @@ lookup_namespace (const char *namespace)
   
   G_LOCK (attribute_hash);
   
-  if (attribute_hash == NULL)
-    {
-      ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
-      attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
-    }
+  ensure_attribute_hash ();
 
   ns_info = _lookup_namespace (namespace);
   id = 0;
@@ -159,42 +298,12 @@ get_attribute_for_id (int attribute)
 static guint32
 lookup_attribute (const char *attribute)
 {
-  guint32 attr_id, id;
-  char *ns;
-  const char *colon;
-  NSInfo *ns_info;
+  guint32 attr_id;
   
   G_LOCK (attribute_hash);
-  if (attribute_hash == NULL)
-    {
-      ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
-      attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
-    }
-
-  attr_id = GPOINTER_TO_UINT (g_hash_table_lookup (attribute_hash, attribute));
-
-  if (attr_id != 0)
-    {
-      G_UNLOCK (attribute_hash);
-      return attr_id;
-    }
-
-  colon = strstr (attribute, "::");
-  if (colon)
-    ns = g_strndup (attribute, colon - attribute);
-  else
-    ns = g_strdup ("");
-
-  ns_info = _lookup_namespace (ns);
-  g_free (ns);
-
-  id = ++ns_info->attribute_id_counter;
-  attributes[ns_info->id] = g_realloc (attributes[ns_info->id], (id + 1) * sizeof (char *));
-  attributes[ns_info->id][id] = g_strdup (attribute);
-  
-  attr_id = MAKE_ATTR_ID (ns_info->id, id);
+  ensure_attribute_hash ();
 
-  g_hash_table_insert (attribute_hash, attributes[ns_info->id][id], GUINT_TO_POINTER (attr_id));
+  attr_id = _lookup_attribute (attribute);
   
   G_UNLOCK (attribute_hash);
   
@@ -213,13 +322,12 @@ g_file_info_finalize (GObject *object)
   attrs = (GFileAttribute *)info->attributes->data;
   for (i = 0; i < info->attributes->len; i++)
     _g_file_attribute_value_clear (&attrs[i].value);
-  g_array_free (info->attributes, TRUE);  
+  g_array_free (info->attributes, TRUE);
 
   if (info->mask != NO_ATTRIBUTE_MASK)
     g_file_attribute_matcher_unref (info->mask);
-  
-  if (G_OBJECT_CLASS (g_file_info_parent_class)->finalize)
-    (*G_OBJECT_CLASS (g_file_info_parent_class)->finalize) (object);
+
+  G_OBJECT_CLASS (g_file_info_parent_class)->finalize (object);
 }
 
 static void
@@ -285,6 +393,9 @@ g_file_info_copy_into (GFileInfo *src_info,
       _g_file_attribute_value_set (&dest[i].value, &source[i].value);
     }
 
+  if (dest_info->mask != NO_ATTRIBUTE_MASK)
+    g_file_attribute_matcher_unref (dest_info->mask);
+
   if (src_info->mask == NO_ATTRIBUTE_MASK)
     dest_info->mask = NO_ATTRIBUTE_MASK;
   else
@@ -326,7 +437,6 @@ g_file_info_set_attribute_mask (GFileInfo             *info,
   int i;
   
   g_return_if_fail (G_IS_FILE_INFO (info));
-  g_return_if_fail (mask != NULL);
   
   if (mask != info->mask)
     {
@@ -338,7 +448,7 @@ g_file_info_set_attribute_mask (GFileInfo             *info,
       for (i = 0; i < info->attributes->len; i++)
        {
          attr = &g_array_index (info->attributes, GFileAttribute, i);
-         if (!g_file_attribute_matcher_matches_id (mask,
+         if (!_g_file_attribute_matcher_matches_id (mask,
                                                    attr->attribute))
            {
              _g_file_attribute_value_clear (&attr->value);
@@ -391,7 +501,7 @@ g_file_info_find_place (GFileInfo  *info,
 {
   int min, max, med;
   GFileAttribute *attrs;
-  /* Binary search for the place where attribute would be, if its
+  /* Binary search for the place where attribute would be, if it's
      in the array */
 
   min = 0;
@@ -449,8 +559,8 @@ g_file_info_find_value_by_name (GFileInfo  *info,
  * 
  * Checks if a file info structure has an attribute named @attribute.
  * 
- * Returns: %TRUE if @GFileInfo has an attribute named @attribute, 
- * %FALSE otherwise.
+ * Returns: %TRUE if @Ginfo has an attribute named @attribute, 
+ *     %FALSE otherwise.
  **/
 gboolean
 g_file_info_has_attribute (GFileInfo  *info,
@@ -466,13 +576,49 @@ g_file_info_has_attribute (GFileInfo  *info,
 }
 
 /**
+ * g_file_info_has_namespace:
+ * @info: a #GFileInfo.
+ * @name_space: a file attribute namespace.
+ *
+ * Checks if a file info structure has an attribute in the
+ * specified @name_space.
+ *
+ * Returns: %TRUE if @Ginfo has an attribute in @name_space,
+ *     %FALSE otherwise.
+ *
+ * Since: 2.22
+ **/
+gboolean
+g_file_info_has_namespace (GFileInfo  *info,
+                          const char *name_space)
+{
+  GFileAttribute *attrs;
+  guint32 ns_id;
+  int i;
+
+  g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE);
+  g_return_val_if_fail (name_space != NULL, FALSE);
+
+  ns_id = lookup_namespace (name_space);
+
+  attrs = (GFileAttribute *)info->attributes->data;
+  for (i = 0; i < info->attributes->len; i++)
+    {
+      if (GET_NS (attrs[i].attribute) == ns_id)
+       return TRUE;
+    }
+
+  return FALSE;
+}
+
+/**
  * g_file_info_list_attributes:
  * @info: a #GFileInfo.
  * @name_space: a file attribute key's namespace.
  * 
  * Lists the file info structure's attributes.
  * 
- * Returns: a null-terminated array of strings of all of the 
+ * Returns: (array zero-terminated=1) (transfer full): a null-terminated array of strings of all of the 
  * possible attribute types for the given @name_space, or 
  * %NULL on error.
  **/
@@ -511,7 +657,7 @@ g_file_info_list_attributes (GFileInfo  *info,
  * Gets the attribute type for an attribute key.
  * 
  * Returns: a #GFileAttributeType for the given @attribute, or 
- * %G_FILE_ATTRIBUTE_TYPE_INVALID if the key is invalid.
+ * %G_FILE_ATTRIBUTE_TYPE_INVALID if the key is not set.
  **/
 GFileAttributeType
 g_file_info_get_attribute_type (GFileInfo  *info,
@@ -535,7 +681,6 @@ g_file_info_get_attribute_type (GFileInfo  *info,
  * @attribute: a file attribute key.
  * 
  * Removes all cases of @attribute from @info if it exists.
- *
  **/
 void
 g_file_info_remove_attribute (GFileInfo  *info,
@@ -560,11 +705,24 @@ g_file_info_remove_attribute (GFileInfo  *info,
     }
 }
 
+/**
+ * g_file_info_get_attribute_data:
+ * @info: a #GFileInfo
+ * @attribute: a file attribute key
+ * @type: (out) (allow-none): return location for the attribute type, or %NULL
+ * @value_pp: (out) (allow-none): return location for the attribute value, or %NULL
+ * @status: (out) (allow-none): return location for the attribute status, or %NULL
+ *
+ * Gets the attribute type, value and status for an attribute key.
+ *
+ * Returns: (transfer none): %TRUE if @info has an attribute named @attribute, 
+ *      %FALSE otherwise.
+ */
 gboolean
-g_file_info_get_attribute_data (GFileInfo  *info,
-                               const char *attribute,
-                               GFileAttributeType *type,
-                               gpointer   *value_pp,
+g_file_info_get_attribute_data (GFileInfo            *info,
+                               const char           *attribute,
+                               GFileAttributeType   *type,
+                               gpointer             *value_pp,
                                GFileAttributeStatus *status)
 {
   GFileAttributeValue *value;
@@ -585,6 +743,17 @@ g_file_info_get_attribute_data (GFileInfo  *info,
   return TRUE;
 }
 
+/** 
+ * g_file_info_get_attribute_status:
+ * @info: a #GFileInfo
+ * @attribute: a file attribute key
+ *
+ * Gets the attribute status for an attribute key.
+ *
+ * Returns: a #GFileAttributeStatus for the given @attribute, or 
+ *    %G_FILE_ATTRIBUTE_STATUS_UNSET if the key is invalid.
+ *
+ */
 GFileAttributeStatus
 g_file_info_get_attribute_status (GFileInfo  *info,
                                  const char *attribute)
@@ -598,9 +767,45 @@ g_file_info_get_attribute_status (GFileInfo  *info,
   if (val)
     return val->status;
 
-  return 0;
+  return G_FILE_ATTRIBUTE_STATUS_UNSET;
 }
 
+/**
+ * g_file_info_set_attribute_status:
+ * @info: a #GFileInfo
+ * @attribute: a file attribute key
+ * @status: a #GFileAttributeStatus
+ *
+ * Sets the attribute status for an attribute key. This is only
+ * needed by external code that implement g_file_set_attributes_from_info()
+ * or similar functions.
+ *
+ * The attribute must exist in @info for this to work. Otherwise %FALSE
+ * is returned and @info is unchanged.
+ *
+ * Returns: %TRUE if the status was changed, %FALSE if the key was not set.
+ *
+ * Since: 2.22
+ */
+gboolean
+g_file_info_set_attribute_status (GFileInfo  *info,
+                                 const char *attribute,
+                                 GFileAttributeStatus status)
+{
+  GFileAttributeValue *val;
+
+  g_return_val_if_fail (G_IS_FILE_INFO (info), 0);
+  g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0);
+
+  val = g_file_info_find_value_by_name (info, attribute);
+  if (val)
+    {
+      val->status = status;
+      return TRUE;
+    }
+
+  return FALSE;
+}
 
 GFileAttributeValue *
 _g_file_info_get_attribute_value (GFileInfo  *info,
@@ -622,8 +827,8 @@ _g_file_info_get_attribute_value (GFileInfo  *info,
  * This escapes things as needed to make the string valid
  * utf8.
  * 
- * Returns: a utf8 string associated with the given @attribute.
- *    When you're done with the string it must be freed.
+ * Returns: a UTF-8 string associated with the given @attribute.
+ *    When you're done with the string it must be freed with g_free().
  **/
 char *
 g_file_info_get_attribute_as_string (GFileInfo  *info,
@@ -645,7 +850,7 @@ g_file_info_get_attribute_as_string (GFileInfo  *info,
  * Gets the value of a #GObject attribute. If the attribute does 
  * not contain a #GObject, %NULL will be returned.
  * 
- * Returns: a #GObject associated with the given @attribute, or
+ * Returns: (transfer none): a #GObject associated with the given @attribute, or
  * %NULL otherwise.
  **/
 GObject *
@@ -710,6 +915,32 @@ g_file_info_get_attribute_byte_string (GFileInfo  *info,
 }
 
 /**
+ * g_file_info_get_attribute_stringv:
+ * @info: a #GFileInfo.
+ * @attribute: a file attribute key.
+ *
+ * Gets the value of a stringv attribute. If the attribute does
+ * not contain a stringv, %NULL will be returned.
+ *
+ * Returns: the contents of the @attribute value as a stringv, or
+ * %NULL otherwise. Do not free.
+ *
+ * Since: 2.22
+ **/
+char **
+g_file_info_get_attribute_stringv (GFileInfo  *info,
+                                  const char *attribute)
+{
+  GFileAttributeValue *value;
+
+  g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
+  g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
+
+  value = g_file_info_find_value_by_name (info, attribute);
+  return _g_file_attribute_value_get_stringv (value);
+}
+
+/**
  * g_file_info_get_attribute_boolean:
  * @info: a #GFileInfo.
  * @attribute: a file attribute key.
@@ -836,7 +1067,7 @@ g_file_info_create_value (GFileInfo *info,
   int i;
 
   if (info->mask != NO_ATTRIBUTE_MASK &&
-      !g_file_attribute_matcher_matches_id (info->mask, attr_id))
+      !_g_file_attribute_matcher_matches_id (info->mask, attr_id))
     return NULL;
   
   i = g_file_info_find_place (info, attr_id);
@@ -856,25 +1087,28 @@ g_file_info_create_value (GFileInfo *info,
     }
 }
 
-static GFileAttributeValue *
-g_file_info_create_value_by_name (GFileInfo *info,
-                                 const char *attribute)
+void
+_g_file_info_set_attribute_by_id (GFileInfo                 *info,
+                                  guint32                    attribute,
+                                  GFileAttributeType         type,
+                                  gpointer                   value_p)
 {
-  guint32 attr_id;
+  GFileAttributeValue *value;
 
-  attr_id = lookup_attribute (attribute);
+  value = g_file_info_create_value (info, attribute);
 
-  return g_file_info_create_value (info, attr_id);
+  if (value)
+    _g_file_attribute_value_set_from_pointer (value, type, value_p, TRUE);
 }
 
 /**
  * g_file_info_set_attribute:
  * @info: a #GFileInfo.
  * @attribute: a file attribute key.
- * @attr_value: a #GFileAttributeValue.
+ * @type: a #GFileAttributeType
+ * @value_p: pointer to the value
  * 
- * Sets the @attribute to contain the given @attr_value, 
- * if possible.
+ * Sets the @attribute to contain the given value, if possible.
  **/
 void
 g_file_info_set_attribute (GFileInfo                 *info,
@@ -882,15 +1116,22 @@ g_file_info_set_attribute (GFileInfo                 *info,
                           GFileAttributeType         type,
                           gpointer                   value_p)
 {
-  GFileAttributeValue *value;
-
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
 
-  value = g_file_info_create_value_by_name (info, attribute);
+  _g_file_info_set_attribute_by_id (info, lookup_attribute (attribute), type, value_p);
+}
 
+void
+_g_file_info_set_attribute_object_by_id (GFileInfo *info,
+                                         guint32    attribute,
+                                        GObject   *attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
   if (value)
-    _g_file_attribute_value_set_from_pointer (value, type, value_p, TRUE);
+    _g_file_attribute_value_set_object (value, attr_value);
 }
 
 /**
@@ -907,15 +1148,62 @@ g_file_info_set_attribute_object (GFileInfo  *info,
                                  const char *attribute,
                                  GObject    *attr_value)
 {
+  g_return_if_fail (G_IS_FILE_INFO (info));
+  g_return_if_fail (attribute != NULL && *attribute != '\0');
+  g_return_if_fail (G_IS_OBJECT (attr_value));
+
+  _g_file_info_set_attribute_object_by_id (info,
+                                           lookup_attribute (attribute),
+                                           attr_value);
+}
+
+void
+_g_file_info_set_attribute_stringv_by_id (GFileInfo *info,
+                                          guint32    attribute,
+                                         char     **attr_value)
+{
   GFileAttributeValue *value;
 
+  value = g_file_info_create_value (info, attribute);
+  if (value)
+    _g_file_attribute_value_set_stringv (value, attr_value);
+}
+
+/**
+ * g_file_info_set_attribute_stringv:
+ * @info: a #GFileInfo.
+ * @attribute: a file attribute key.
+ * @attr_value: a %NULL terminated string array
+ *
+ * Sets the @attribute to contain the given @attr_value,
+ * if possible.
+ *
+ * Sinze: 2.22
+ **/
+void
+g_file_info_set_attribute_stringv (GFileInfo  *info,
+                                  const char *attribute,
+                                  char      **attr_value)
+{
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
-  g_return_if_fail (G_IS_OBJECT (attr_value));
+  g_return_if_fail (attr_value != NULL);
 
-  value = g_file_info_create_value_by_name (info, attribute);
+  _g_file_info_set_attribute_stringv_by_id (info, 
+                                            lookup_attribute (attribute),
+                                            attr_value);
+}
+
+void
+_g_file_info_set_attribute_string_by_id (GFileInfo  *info,
+                                         guint32     attribute,
+                                        const char *attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
   if (value)
-    _g_file_attribute_value_set_object (value, attr_value);
+    _g_file_attribute_value_set_string (value, attr_value);
 }
 
 /**
@@ -932,15 +1220,25 @@ g_file_info_set_attribute_string (GFileInfo  *info,
                                  const char *attribute,
                                  const char *attr_value)
 {
-  GFileAttributeValue *value;
-  
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
   g_return_if_fail (attr_value != NULL);
 
-  value = g_file_info_create_value_by_name (info, attribute);
+  _g_file_info_set_attribute_string_by_id (info,
+                                           lookup_attribute (attribute),
+                                           attr_value);
+}
+
+void
+_g_file_info_set_attribute_byte_string_by_id (GFileInfo  *info,
+                                              guint32     attribute,
+                                             const char *attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
   if (value)
-    _g_file_attribute_value_set_string (value, attr_value);
+    _g_file_attribute_value_set_byte_string (value, attr_value);
 }
 
 /**
@@ -957,15 +1255,25 @@ g_file_info_set_attribute_byte_string (GFileInfo  *info,
                                       const char *attribute,
                                       const char *attr_value)
 {
-  GFileAttributeValue *value;
-
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
   g_return_if_fail (attr_value != NULL);
 
-  value = g_file_info_create_value_by_name (info, attribute);
+  _g_file_info_set_attribute_byte_string_by_id (info,
+                                                lookup_attribute (attribute),
+                                                attr_value);
+}
+
+void
+_g_file_info_set_attribute_boolean_by_id (GFileInfo *info,
+                                          guint32    attribute,
+                                         gboolean   attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
   if (value)
-    _g_file_attribute_value_set_byte_string (value, attr_value);
+    _g_file_attribute_value_set_boolean (value, attr_value);
 }
 
 /**
@@ -982,14 +1290,24 @@ g_file_info_set_attribute_boolean (GFileInfo  *info,
                                   const char *attribute,
                                   gboolean    attr_value)
 {
-  GFileAttributeValue *value;
-
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
 
-  value = g_file_info_create_value_by_name (info, attribute);
+  _g_file_info_set_attribute_boolean_by_id (info,
+                                            lookup_attribute (attribute),
+                                            attr_value);
+}
+
+void
+_g_file_info_set_attribute_uint32_by_id (GFileInfo *info,
+                                         guint32    attribute,
+                                        guint32    attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
   if (value)
-    _g_file_attribute_value_set_boolean (value, attr_value);
+    _g_file_attribute_value_set_uint32 (value, attr_value);
 }
 
 /**
@@ -1006,16 +1324,25 @@ g_file_info_set_attribute_uint32 (GFileInfo  *info,
                                  const char *attribute,
                                  guint32     attr_value)
 {
-  GFileAttributeValue *value;
-
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
 
-  value = g_file_info_create_value_by_name (info, attribute);
-  if (value)
-    _g_file_attribute_value_set_uint32 (value, attr_value);
+  _g_file_info_set_attribute_uint32_by_id (info,
+                                           lookup_attribute (attribute),
+                                           attr_value);
 }
 
+void
+_g_file_info_set_attribute_int32_by_id (GFileInfo *info,
+                                        guint32    attribute,
+                                       gint32     attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
+  if (value)
+    _g_file_attribute_value_set_int32 (value, attr_value);
+}
 
 /**
  * g_file_info_set_attribute_int32:
@@ -1031,14 +1358,24 @@ g_file_info_set_attribute_int32 (GFileInfo  *info,
                                  const char *attribute,
                                  gint32      attr_value)
 {
-  GFileAttributeValue *value;
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
 
-  value = g_file_info_create_value_by_name (info, attribute);
+  _g_file_info_set_attribute_int32_by_id (info,
+                                          lookup_attribute (attribute),
+                                          attr_value);
+}
+
+void
+_g_file_info_set_attribute_uint64_by_id (GFileInfo *info,
+                                         guint32    attribute,
+                                        guint64    attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
   if (value)
-    _g_file_attribute_value_set_int32 (value, attr_value);
+    _g_file_attribute_value_set_uint64 (value, attr_value);
 }
 
 /**
@@ -1055,14 +1392,24 @@ g_file_info_set_attribute_uint64 (GFileInfo  *info,
                                  const char *attribute,
                                  guint64     attr_value)
 {
-  GFileAttributeValue *value;
-
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
 
-  value = g_file_info_create_value_by_name (info, attribute);
+  _g_file_info_set_attribute_uint64_by_id (info,
+                                           lookup_attribute (attribute),
+                                           attr_value);
+}
+
+void
+_g_file_info_set_attribute_int64_by_id (GFileInfo *info,
+                                        guint32    attribute,
+                                       gint64     attr_value)
+{
+  GFileAttributeValue *value;
+
+  value = g_file_info_create_value (info, attribute);
   if (value)
-    _g_file_attribute_value_set_uint64 (value, attr_value);
+    _g_file_attribute_value_set_int64 (value, attr_value);
 }
 
 /**
@@ -1080,14 +1427,12 @@ g_file_info_set_attribute_int64  (GFileInfo  *info,
                                  const char *attribute,
                                  gint64      attr_value)
 {
-  GFileAttributeValue *value;
-
   g_return_if_fail (G_IS_FILE_INFO (info));
   g_return_if_fail (attribute != NULL && *attribute != '\0');
 
-  value = g_file_info_create_value_by_name (info, attribute);
-  if (value)
-    _g_file_attribute_value_set_int64 (value, attr_value);
+  _g_file_info_set_attribute_int64_by_id (info,
+                                          lookup_attribute (attribute),
+                                          attr_value);
 }
 
 /* Helper getters */
@@ -1109,7 +1454,7 @@ g_file_info_get_file_type (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), G_FILE_TYPE_UNKNOWN);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_TYPE);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_TYPE);
   
   value = g_file_info_find_value (info, attr);
   return (GFileType)_g_file_attribute_value_get_uint32 (value);
@@ -1132,7 +1477,7 @@ g_file_info_get_is_hidden (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_HIDDEN);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN);
   
   value = g_file_info_find_value (info, attr);
   return (GFileType)_g_file_attribute_value_get_boolean (value);
@@ -1155,7 +1500,7 @@ g_file_info_get_is_backup (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_BACKUP);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP);
   
   value = g_file_info_find_value (info, attr);
   return (GFileType)_g_file_attribute_value_get_boolean (value);
@@ -1178,7 +1523,7 @@ g_file_info_get_is_symlink (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_SYMLINK);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK);
   
   value = g_file_info_find_value (info, attr);
   return (GFileType)_g_file_attribute_value_get_boolean (value);
@@ -1201,7 +1546,7 @@ g_file_info_get_name (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_NAME);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_NAME);
   
   value = g_file_info_find_value (info, attr);
   return _g_file_attribute_value_get_byte_string (value);
@@ -1224,7 +1569,7 @@ g_file_info_get_display_name (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_DISPLAY_NAME);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
   
   value = g_file_info_find_value (info, attr);
   return _g_file_attribute_value_get_string (value);
@@ -1247,7 +1592,7 @@ g_file_info_get_edit_name (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_EDIT_NAME);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
   
   value = g_file_info_find_value (info, attr);
   return _g_file_attribute_value_get_string (value);
@@ -1259,7 +1604,7 @@ g_file_info_get_edit_name (GFileInfo *info)
  * 
  * Gets the icon for a file.
  * 
- * Returns: #GIcon for the given @info.
+ * Returns: (transfer none): #GIcon for the given @info.
  **/
 GIcon *
 g_file_info_get_icon (GFileInfo *info)
@@ -1271,11 +1616,11 @@ g_file_info_get_icon (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_ICON);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_ICON);
   
   value = g_file_info_find_value (info, attr);
   obj = _g_file_attribute_value_get_object (value);
-  if (obj != NULL && G_IS_ICON (obj))
+  if (G_IS_ICON (obj))
     return G_ICON (obj);
   return NULL;
 }
@@ -1286,7 +1631,7 @@ g_file_info_get_icon (GFileInfo *info)
  * 
  * Gets the file's content type.
  * 
- * Returns: a string containing the file's content type.s
+ * Returns: a string containing the file's content type.
  **/
 const char *
 g_file_info_get_content_type (GFileInfo *info)
@@ -1297,7 +1642,7 @@ g_file_info_get_content_type (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_CONTENT_TYPE);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
   
   value = g_file_info_find_value (info, attr);
   return _g_file_attribute_value_get_string (value);
@@ -1320,7 +1665,7 @@ g_file_info_get_size (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), (goffset) 0);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SIZE);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_SIZE);
   
   value = g_file_info_find_value (info, attr);
   return (goffset) _g_file_attribute_value_get_uint64 (value);
@@ -1373,7 +1718,7 @@ g_file_info_get_symlink_target (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET);
   
   value = g_file_info_find_value (info, attr);
   return _g_file_attribute_value_get_byte_string (value);
@@ -1408,9 +1753,9 @@ g_file_info_get_etag (GFileInfo *info)
  * @info: a #GFileInfo.
  * 
  * Gets the value of the sort_order attribute from the #GFileInfo.
- * See %G_FILE_ATTRIBUTE_STD_SORT_ORDER.
+ * See %G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
  * 
- * Returns: a #gint32 containing the value of the "std:sort_order" attribute.
+ * Returns: a #gint32 containing the value of the "standard::sort_order" attribute.
  **/
 gint32
 g_file_info_get_sort_order (GFileInfo *info)
@@ -1421,7 +1766,7 @@ g_file_info_get_sort_order (GFileInfo *info)
   g_return_val_if_fail (G_IS_FILE_INFO (info), 0);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SORT_ORDER);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER);
   
   value = g_file_info_find_value (info, attr);
   return _g_file_attribute_value_get_int32 (value);
@@ -1434,7 +1779,7 @@ g_file_info_get_sort_order (GFileInfo *info)
  * @type: a #GFileType.
  * 
  * Sets the file type in a #GFileInfo to @type.
- * See %G_FILE_ATTRIBUTE_STD_TYPE.
+ * See %G_FILE_ATTRIBUTE_STANDARD_TYPE.
  **/
 void
 g_file_info_set_file_type (GFileInfo *info,
@@ -1446,7 +1791,7 @@ g_file_info_set_file_type (GFileInfo *info,
   g_return_if_fail (G_IS_FILE_INFO (info));
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_TYPE);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_TYPE);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1459,7 +1804,7 @@ g_file_info_set_file_type (GFileInfo *info,
  * @is_hidden: a #gboolean.
  * 
  * Sets the "is_hidden" attribute in a #GFileInfo according to @is_symlink.
- * See %G_FILE_ATTRIBUTE_STD_IS_HIDDEN.
+ * See %G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN.
  **/
 void
 g_file_info_set_is_hidden (GFileInfo *info,
@@ -1471,7 +1816,7 @@ g_file_info_set_is_hidden (GFileInfo *info,
   g_return_if_fail (G_IS_FILE_INFO (info));
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_HIDDEN);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1484,7 +1829,7 @@ g_file_info_set_is_hidden (GFileInfo *info,
  * @is_symlink: a #gboolean.
  * 
  * Sets the "is_symlink" attribute in a #GFileInfo according to @is_symlink.
- * See %G_FILE_ATTRIBUTE_STD_IS_SYMLINK.
+ * See %G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK.
  **/
 void
 g_file_info_set_is_symlink (GFileInfo *info,
@@ -1496,7 +1841,7 @@ g_file_info_set_is_symlink (GFileInfo *info,
   g_return_if_fail (G_IS_FILE_INFO (info));
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_SYMLINK);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1509,7 +1854,7 @@ g_file_info_set_is_symlink (GFileInfo *info,
  * @name: a string containing a name.
  * 
  * Sets the name attribute for the current #GFileInfo. 
- * See %G_FILE_ATTRIBUTE_STD_NAME.
+ * See %G_FILE_ATTRIBUTE_STANDARD_NAME.
  **/
 void
 g_file_info_set_name (GFileInfo  *info,
@@ -1522,7 +1867,7 @@ g_file_info_set_name (GFileInfo  *info,
   g_return_if_fail (name != NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_NAME);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_NAME);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1535,7 +1880,7 @@ g_file_info_set_name (GFileInfo  *info,
  * @display_name: a string containing a display name.
  * 
  * Sets the display name for the current #GFileInfo.
- * See %G_FILE_ATTRIBUTE_STD_DISPLAY_NAME.
+ * See %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME.
  **/
 void
 g_file_info_set_display_name (GFileInfo  *info,
@@ -1548,7 +1893,7 @@ g_file_info_set_display_name (GFileInfo  *info,
   g_return_if_fail (display_name != NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_DISPLAY_NAME);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1561,7 +1906,7 @@ g_file_info_set_display_name (GFileInfo  *info,
  * @edit_name: a string containing an edit name.
  * 
  * Sets the edit name for the current file.
- * See %G_FILE_ATTRIBUTE_STD_EDIT_NAME.
+ * See %G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME.
  **/
 void
 g_file_info_set_edit_name (GFileInfo  *info,
@@ -1574,7 +1919,7 @@ g_file_info_set_edit_name (GFileInfo  *info,
   g_return_if_fail (edit_name != NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_EDIT_NAME);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1587,7 +1932,7 @@ g_file_info_set_edit_name (GFileInfo  *info,
  * @icon: a #GIcon.
  * 
  * Sets the icon for a given #GFileInfo. 
- * See %G_FILE_ATTRIBUTE_STD_ICON.
+ * See %G_FILE_ATTRIBUTE_STANDARD_ICON.
  **/
 void
 g_file_info_set_icon (GFileInfo *info,
@@ -1600,7 +1945,7 @@ g_file_info_set_icon (GFileInfo *info,
   g_return_if_fail (G_IS_ICON (icon));
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_ICON);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_ICON);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1613,7 +1958,7 @@ g_file_info_set_icon (GFileInfo *info,
  * @content_type: a content type. See #GContentType.
  * 
  * Sets the content type attribute for a given #GFileInfo.
- * See %G_FILE_ATTRIBUTE_STD_CONTENT_TYPE.
+ * See %G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE.
  **/
 void
 g_file_info_set_content_type (GFileInfo  *info,
@@ -1626,7 +1971,7 @@ g_file_info_set_content_type (GFileInfo  *info,
   g_return_if_fail (content_type != NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_CONTENT_TYPE);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1638,7 +1983,7 @@ g_file_info_set_content_type (GFileInfo  *info,
  * @info: a #GFileInfo.
  * @size: a #goffset containing the file's size.
  * 
- * Sets the %G_FILE_ATTRIBUTE_STD_SIZE attribute in the file info 
+ * Sets the %G_FILE_ATTRIBUTE_STANDARD_SIZE attribute in the file info 
  * to the given size.
  **/
 void
@@ -1651,7 +1996,7 @@ g_file_info_set_size (GFileInfo *info,
   g_return_if_fail (G_IS_FILE_INFO (info));
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SIZE);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_SIZE);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1695,7 +2040,7 @@ g_file_info_set_modification_time (GFileInfo *info,
  * @info: a #GFileInfo.
  * @symlink_target: a static string containing a path to a symlink target.
  * 
- * Sets the %G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET attribute in the file info 
+ * Sets the %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET attribute in the file info 
  * to the given symlink target.
  **/
 void
@@ -1709,7 +2054,7 @@ g_file_info_set_symlink_target (GFileInfo  *info,
   g_return_if_fail (symlink_target != NULL);
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1722,7 +2067,7 @@ g_file_info_set_symlink_target (GFileInfo  *info,
  * @sort_order: a sort order integer.
  * 
  * Sets the sort order attribute in the file info structure. See 
- * %G_FILE_ATTRIBUTE_STD_SORT_ORDER.
+ * %G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER.
  **/
 void
 g_file_info_set_sort_order (GFileInfo *info,
@@ -1734,7 +2079,7 @@ g_file_info_set_sort_order (GFileInfo *info,
   g_return_if_fail (G_IS_FILE_INFO (info));
   
   if (attr == 0)
-    attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SORT_ORDER);
+    attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER);
   
   value = g_file_info_create_value (info, attr);
   if (value)
@@ -1803,6 +2148,24 @@ matcher_add (GFileAttributeMatcher *matcher,
   g_array_append_val (matcher->more_sub_matchers, s);
 }
 
+GType
+g_file_attribute_matcher_get_type (void)
+{
+  static volatile gsize g_define_type_id__volatile = 0;
+
+  if (g_once_init_enter (&g_define_type_id__volatile))
+    {
+      GType g_define_type_id =
+        g_boxed_type_register_static (I_("GFileAttributeMatcher"),
+                                      (GBoxedCopyFunc) g_file_attribute_matcher_ref,
+                                      (GBoxedFreeFunc) g_file_attribute_matcher_unref);
+
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+    }
+
+  return g_define_type_id__volatile;
+}
+
 /**
  * g_file_attribute_matcher_new:
  * @attributes: an attribute string to match.
@@ -1815,7 +2178,7 @@ matcher_add (GFileAttributeMatcher *matcher,
  * 
  * The @attribute string should be formatted with specific keys separated
  * from namespaces with a double colon. Several "namespace::key" strings may be 
- * concatenated with a single comma (e.g. "std::type,std::is-hidden"). 
+ * concatenated with a single comma (e.g. "standard::type,standard::is-hidden"). 
  * The wildcard "*" may be used to match all keys and namespaces, or 
  * "namespace::*" will match all keys in a given namespace. 
  * 
@@ -1826,9 +2189,9 @@ matcher_add (GFileAttributeMatcher *matcher,
  * <row><entry> Matcher String </entry><entry> Matches </entry></row></thead>
  * <tbody>
  * <row><entry>"*"</entry><entry>matches all attributes.</entry></row>
- * <row><entry>"std::is-hidden"</entry><entry>matches only the key is-hidden in the std namespace.</entry></row>
- * <row><entry>"std::type,unix::*"</entry><entry>matches the type key in the std namespace and all keys in the unix 
- * namespace.</entry></row>
+ * <row><entry>"standard::is-hidden"</entry><entry>matches only the key is-hidden in the standard namespace.</entry></row>
+ * <row><entry>"standard::type,unix::*"</entry><entry>matches the type key in the standard namespace and
+ * all keys in the unix namespace.</entry></row>
  * </tbody></tgroup>
  * </table>
  * 
@@ -1896,11 +2259,11 @@ g_file_attribute_matcher_new (const char *attributes)
 GFileAttributeMatcher *
 g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher)
 {
-  g_return_val_if_fail (matcher != NULL, NULL);
-  g_return_val_if_fail (matcher->ref > 0, NULL);
-
-  g_atomic_int_inc (&matcher->ref);
-  
+  if (matcher)
+    {
+      g_return_val_if_fail (matcher->ref > 0, NULL);
+      g_atomic_int_inc (&matcher->ref);
+    }
   return matcher;
 }
 
@@ -1915,15 +2278,17 @@ g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher)
 void
 g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher)
 {
-  g_return_if_fail (matcher != NULL);
-  g_return_if_fail (matcher->ref > 0);
-
-  if (g_atomic_int_dec_and_test (&matcher->ref))
+  if (matcher)
     {
-      if (matcher->more_sub_matchers)
-       g_array_free (matcher->more_sub_matchers, TRUE);
+      g_return_if_fail (matcher->ref > 0);
       
-      g_free (matcher);
+      if (g_atomic_int_dec_and_test (&matcher->ref))
+       {
+         if (matcher->more_sub_matchers)
+           g_array_free (matcher->more_sub_matchers, TRUE);
+         
+         g_free (matcher);
+       }
     }
 }
 
@@ -1943,10 +2308,10 @@ g_file_attribute_matcher_matches_only (GFileAttributeMatcher *matcher,
 {
   guint32 id;
 
-  g_return_val_if_fail (matcher != NULL, FALSE);
   g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
 
-  if (matcher->all)
+  if (matcher == NULL ||
+      matcher->all)
     return FALSE;
   
   id = lookup_attribute (attribute);
@@ -1989,11 +2354,13 @@ matcher_matches_id (GFileAttributeMatcher *matcher,
   return FALSE;
 }
 
-static gboolean
-g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher,
-                                     guint32                id)
+gboolean
+_g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher,
+                                      guint32                id)
 {
-  g_return_val_if_fail (matcher != NULL, FALSE);
+  /* We return a NULL matcher for an empty match string, so handle this */
+  if (matcher == NULL)
+    return FALSE;
   
   if (matcher->all)
     return TRUE;
@@ -2016,9 +2383,12 @@ gboolean
 g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,
                                  const char            *attribute)
 {
-  g_return_val_if_fail (matcher != NULL, FALSE);
   g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
 
+  /* We return a NULL matcher for an empty match string, so handle this */
+  if (matcher == NULL)
+    return FALSE;
+  
   if (matcher->all)
     return TRUE;
   
@@ -2033,7 +2403,7 @@ g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,
  * 
  * Checks if the matcher will match all of the keys in a given namespace.
  * This will always return %TRUE if a wildcard character is in use (e.g. if 
- * matcher was created with "std::*" and @ns is "std", or if matcher was created
+ * matcher was created with "standard::*" and @ns is "standard", or if matcher was created
  * using "*" and namespace is anything.) 
  * 
  * TODO: this is awkwardly worded.
@@ -2049,8 +2419,11 @@ g_file_attribute_matcher_enumerate_namespace (GFileAttributeMatcher *matcher,
   int ns_id;
   int i;
   
-  g_return_val_if_fail (matcher != NULL, FALSE);
   g_return_val_if_fail (ns != NULL && *ns != '\0', FALSE);
+
+  /* We return a NULL matcher for an empty match string, so handle this */
+  if (matcher == NULL)
+    return FALSE;
   
   if (matcher->all)
     return TRUE;
@@ -2093,8 +2466,10 @@ g_file_attribute_matcher_enumerate_next (GFileAttributeMatcher *matcher)
 {
   int i;
   SubMatcher *sub_matcher;
-  
-  g_return_val_if_fail (matcher != NULL, NULL);
+
+  /* We return a NULL matcher for an empty match string, so handle this */
+  if (matcher == NULL)
+    return NULL;
 
   while (1)
     {