summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-02-26 17:07:23 +0100
committerOndrej Holy <oholy@redhat.com>2018-03-02 08:59:49 +0100
commit7bc7aa6e590c456d7cd6afdb1790d951cd5aa86b (patch)
treeb9a800d0b4dd93ccd692d7fe4c75516ad95c169a
parentb127cb0301b328089b854eaff8512b2bc5a23913 (diff)
downloadgnome-control-center-7bc7aa6e590c456d7cd6afdb1790d951cd5aa86b.tar.gz
user-accounts: Use GIO API for face images handling
GFile is needed for face widgets anyway, so let's use GFileEnumerator for dir listing instead of POSIX API. https://gitlab.gnome.org/GNOME/gnome-control-center/issues/5
-rw-r--r--panels/user-accounts/um-photo-dialog.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/panels/user-accounts/um-photo-dialog.c b/panels/user-accounts/um-photo-dialog.c
index 7fdda4180..5dbe6653d 100644
--- a/panels/user-accounts/um-photo-dialog.c
+++ b/panels/user-accounts/um-photo-dialog.c
@@ -373,11 +373,11 @@ create_face_widget (gpointer item,
static void
setup_photo_popup (UmPhotoDialog *um)
{
- GFile *face_file;
+ GFile *file, *dir;
+ GFileInfo *info;
+ GFileEnumerator *enumerator;
const gchar * const * dirs;
guint i;
- GDir *dir;
- const char *face;
gboolean added_faces;
um->faces = g_list_store_new (G_TYPE_FILE);
@@ -395,25 +395,34 @@ setup_photo_popup (UmPhotoDialog *um)
char *path;
path = g_build_filename (dirs[i], "pixmaps", "faces", NULL);
- dir = g_dir_open (path, 0, NULL);
- if (dir == NULL) {
- g_free (path);
+ dir = g_file_new_for_path (path);
+ g_free (path);
+
+ enumerator = g_file_enumerate_children (dir,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK ","
+ G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
+ if (enumerator == NULL) {
+ g_object_unref (dir);
continue;
}
- while ((face = g_dir_read_name (dir)) != NULL) {
- char *filename;
-
+ while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) {
added_faces = TRUE;
- filename = g_build_filename (path, face, NULL);
- face_file = g_file_new_for_path (filename);
- g_free (filename);
- g_list_store_append (um->faces, face_file);
+ file = g_file_get_child (dir, g_file_info_get_name (info));
+ g_list_store_append (um->faces, file);
+
+ g_object_unref (info);
}
- g_dir_close (dir);
- g_free (path);
+
+ g_file_enumerator_close (enumerator, NULL, NULL);
+ g_object_unref (enumerator);
+ g_object_unref (dir);
if (added_faces)
break;