filechooserutils: Add helper to get GFile from info
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Sun, 9 Oct 2022 20:41:33 +0000 (17:41 -0300)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 21 Oct 2022 02:34:40 +0000 (22:34 -0400)
This will be used extensively starting from next commit!

gtk/gtkfilechooserutils.c
gtk/gtkfilechooserutils.h

index 1722ced87b8aeef179bd82f458f50ee7585844c1..d75a12b0b417201a0bd7bb9c3f99d9d1b7659c16 100644 (file)
@@ -479,3 +479,12 @@ _gtk_file_info_get_icon (GFileInfo    *info,
   icon = g_themed_icon_new ("text-x-generic");
   return icon;
 }
+
+GFile *
+_gtk_file_info_get_file (GFileInfo *info)
+{
+  g_assert (G_IS_FILE_INFO (info));
+  g_assert (g_file_info_has_attribute (info, "standard::file"));
+
+  return G_FILE (g_file_info_get_attribute_object (info, "standard::file"));
+}
index 9481704ad98c80f53610fb3f062474b2e94a148d..3a41403802647873dc5cdcf6fee232e9fda8cde5 100644 (file)
@@ -58,6 +58,8 @@ GIcon *         _gtk_file_info_get_icon    (GFileInfo    *info,
                                             int           scale,
                                             GtkIconTheme *icon_theme);
 
+GFile *         _gtk_file_info_get_file (GFileInfo *info);
+
 G_END_DECLS
 
 #endif /* __GTK_FILE_CHOOSER_UTILS_H__ */