mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
gio: Add g_file_info_set/get_file
Attaching the original GFile to a GFileInfo created from it useful to avoid having to carry around the (file, info) pair. In particular, it allows to store just a self-contained GFileInfo in a list model. This is going to be used in the GTK file chooser.
This commit is contained in:
@@ -400,6 +400,7 @@ g_file_info_get_symlink_target
|
||||
g_file_info_get_etag
|
||||
g_file_info_get_sort_order
|
||||
g_file_info_get_deletion_date
|
||||
g_file_info_get_file
|
||||
g_file_info_set_attribute_mask
|
||||
g_file_info_unset_attribute_mask
|
||||
g_file_info_set_file_type
|
||||
@@ -416,6 +417,7 @@ g_file_info_set_modification_time
|
||||
g_file_info_set_modification_date_time
|
||||
g_file_info_set_symlink_target
|
||||
g_file_info_set_sort_order
|
||||
g_file_info_set_file
|
||||
g_file_attribute_matcher_new
|
||||
g_file_attribute_matcher_ref
|
||||
g_file_attribute_matcher_subtract
|
||||
|
@@ -73,6 +73,8 @@ struct _GFileInfo
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GFile *file;
|
||||
|
||||
GArray *attributes;
|
||||
GFileAttributeMatcher *mask;
|
||||
};
|
||||
@@ -323,6 +325,8 @@ g_file_info_finalize (GObject *object)
|
||||
|
||||
info = G_FILE_INFO (object);
|
||||
|
||||
g_clear_object (&info->file);
|
||||
|
||||
attrs = (GFileAttribute *)info->attributes->data;
|
||||
for (i = 0; i < info->attributes->len; i++)
|
||||
_g_file_attribute_value_clear (&attrs[i].value);
|
||||
@@ -381,6 +385,8 @@ g_file_info_copy_into (GFileInfo *src_info,
|
||||
g_return_if_fail (G_IS_FILE_INFO (src_info));
|
||||
g_return_if_fail (G_IS_FILE_INFO (dest_info));
|
||||
|
||||
g_set_object (&dest_info->file, src_info->file);
|
||||
|
||||
dest = (GFileAttribute *)dest_info->attributes->data;
|
||||
for (i = 0; i < dest_info->attributes->len; i++)
|
||||
_g_file_attribute_value_clear (&dest[i].value);
|
||||
@@ -2283,6 +2289,41 @@ g_file_info_set_sort_order (GFileInfo *info,
|
||||
_g_file_attribute_value_set_int32 (value, sort_order);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_file_info_set_file:
|
||||
* @info: a #GFileInfo
|
||||
* @file: the #GFile that @info is for
|
||||
*
|
||||
* Sets the file that @info belongs to.
|
||||
*
|
||||
* Since: 2.66
|
||||
*/
|
||||
void
|
||||
g_file_info_set_file (GFileInfo *info,
|
||||
GFile *file)
|
||||
{
|
||||
g_return_if_fail (G_IS_FILE_INFO (info));
|
||||
|
||||
g_set_object (&info->file, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_file_info_get_file:
|
||||
* @info: a #GFileInfo
|
||||
*
|
||||
* Gets the file that @info belongs to.
|
||||
*
|
||||
* Returns: (transfer none): the #GFile
|
||||
*
|
||||
* Since: 2.66
|
||||
*/
|
||||
GFile *
|
||||
g_file_info_get_file (GFileInfo *info)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
|
||||
|
||||
return info->file;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
guint32 id;
|
||||
|
@@ -1113,6 +1113,11 @@ void g_file_info_set_symlink_target (GFileInfo *info,
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
void g_file_info_set_sort_order (GFileInfo *info,
|
||||
gint32 sort_order);
|
||||
GLIB_AVAILABLE_IN_2_66
|
||||
void g_file_info_set_file (GFileInfo *info,
|
||||
GFile *file);
|
||||
GLIB_AVAILABLE_IN_2_66
|
||||
GFile * g_file_info_get_file (GFileInfo *info);
|
||||
|
||||
#define G_TYPE_FILE_ATTRIBUTE_MATCHER (g_file_attribute_matcher_get_type ())
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
|
Reference in New Issue
Block a user