Merge branch 'file-list-get' into 'master'

Add getter to GdkFileList

See merge request GNOME/gtk!4047
This commit is contained in:
Matthias Clasen 2021-10-19 02:44:19 +00:00
commit e946ee4040
2 changed files with 39 additions and 3 deletions

View File

@ -808,8 +808,13 @@ gdk_content_formats_builder_add_mime_type (GdkContentFormatsBuilder *builder,
builder->n_mime_types++;
}
/* G_DEFINE_BOXED wants this */
typedef gpointer GdkFileList;
/* {{{ GdkFileList */
/* We're using GdkFileList* and GSList* interchangeably, counting on the
* fact that we're just passing around gpointers; the only reason why we
* have a GdkFileList opaque type is for language bindings, because they
* can have no idea what a GSList of GFiles is.
*/
static gpointer
gdk_file_list_copy (gpointer list)
@ -824,3 +829,23 @@ gdk_file_list_free (gpointer list)
}
G_DEFINE_BOXED_TYPE (GdkFileList, gdk_file_list, gdk_file_list_copy, gdk_file_list_free)
/**
* gdk_file_list_get_files:
* @file_list: the file list
*
* Retrieves the list of files inside a `GdkFileList`.
*
* This function is meant for language bindings.
*
* Returns: (transfer container) (element-type GFile): the files inside the list
*
* Since: 4.6
*/
GSList *
gdk_file_list_get_files (GdkFileList *file_list)
{
return g_slist_copy ((GSList *) file_list);
}
/* }}} */

View File

@ -109,8 +109,19 @@ void gdk_content_formats_builder_add_gtype (GdkContentForma
/* dunno where else to put this */
#define GDK_TYPE_FILE_LIST (gdk_file_list_get_type ())
GDK_AVAILABLE_IN_ALL
GType gdk_file_list_get_type (void) G_GNUC_CONST;
GType gdk_file_list_get_type (void) G_GNUC_CONST;
/**
* GdkFileList:
*
* An opaque type representing a list of files.
*
* Since: 4.6
*/
typedef struct _GdkFileList GdkFileList;
GDK_AVAILABLE_IN_4_6
GSList * gdk_file_list_get_files (GdkFileList *file_list);
G_END_DECLS