[gtk/file-list-get] Add getter to GdkFileList




commit 086a3044e3977fe65fbc4ac041e3f0b3224b3e8c
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Oct 8 11:41:56 2021 +0100

    Add getter to GdkFileList
    
    Language bindings don't really have any mean of accessing the list of
    files for GdkFileList.

 gdk/gdkcontentformats.c | 29 +++++++++++++++++++++++++++--
 gdk/gdkcontentformats.h | 13 ++++++++++++-
 2 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkcontentformats.c b/gdk/gdkcontentformats.c
index 662ff1b825..0cdc51fa52 100644
--- a/gdk/gdkcontentformats.c
+++ b/gdk/gdkcontentformats.c
@@ -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);
+}
+
+/* }}} */
diff --git a/gdk/gdkcontentformats.h b/gdk/gdkcontentformats.h
index 143a669340..df536ccef2 100644
--- a/gdk/gdkcontentformats.h
+++ b/gdk/gdkcontentformats.h
@@ -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
 


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