summaryrefslogtreecommitdiff
path: root/libwindow-settings
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-11-25 18:15:56 +0100
committerVictor Kareh <[email protected]>2020-12-11 07:58:36 -0500
commit3fab839c77d6b7ab5e5dd1cb33997773154dd763 (patch)
tree7f4ef39753bf69bea4ee17421313f59300829cb0 /libwindow-settings
parentc69edad250ac1e98d68b2c7a2d2e4bc54d4bd46e (diff)
downloadmate-control-center-3fab839c77d6b7ab5e5dd1cb33997773154dd763.tar.bz2
mate-control-center-3fab839c77d6b7ab5e5dd1cb33997773154dd763.tar.xz
marco-window-manager: do not use dirent.h
Diffstat (limited to 'libwindow-settings')
-rw-r--r--libwindow-settings/marco-window-manager.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/libwindow-settings/marco-window-manager.c b/libwindow-settings/marco-window-manager.c
index d57be74b..2340ae27 100644
--- a/libwindow-settings/marco-window-manager.c
+++ b/libwindow-settings/marco-window-manager.c
@@ -24,8 +24,6 @@
*/
#include <config.h>
-#include <sys/types.h>
-#include <dirent.h>
#include <string.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
@@ -103,57 +101,59 @@ window_manager_new (int expected_interface_version)
static GList *
add_themes_from_dir (GList *current_list, const char *path)
{
- DIR *theme_dir;
- struct dirent *entry;
+ GDir *theme_dir;
+ const gchar *entry;
char *theme_file_path;
GList *node;
gboolean found = FALSE;
+ GError *error = NULL;
if (!(g_file_test (path, G_FILE_TEST_EXISTS) && g_file_test (path, G_FILE_TEST_IS_DIR))) {
return current_list;
}
- theme_dir = opendir (path);
- /* If this is NULL, then we couldn't open ~/.themes. The test above
- * only checks existence, not wether we can really read it.*/
- if (theme_dir == NULL)
+ theme_dir = g_dir_open (path, 0, &error);
+
+ if (error) {
+ g_debug ("Could not open the folder: %s", error->message);
+ g_error_free (error);
return current_list;
+ }
- for (entry = readdir (theme_dir); entry != NULL; entry = readdir (theme_dir)) {
- theme_file_path = g_build_filename (path, entry->d_name, "metacity-1/metacity-theme-2.xml", NULL);
+ while ((entry = g_dir_read_name (theme_dir)) != NULL) {
+ theme_file_path = g_build_filename (path, entry, "metacity-1/metacity-theme-2.xml", NULL);
if (g_file_test (theme_file_path, G_FILE_TEST_EXISTS)) {
for (node = current_list; (node != NULL) && (!found); node = node->next) {
- found = (strcmp (node->data, entry->d_name) == 0);
+ found = (strcmp (node->data, entry) == 0);
}
if (!found) {
- current_list = g_list_prepend (current_list, g_strdup (entry->d_name));
+ current_list = g_list_prepend (current_list, g_strdup (entry));
}
}
else {
g_free (theme_file_path);
- theme_file_path = g_build_filename (path, entry->d_name, "metacity-1/metacity-theme-1.xml", NULL);
+ theme_file_path = g_build_filename (path, entry, "metacity-1/metacity-theme-1.xml", NULL);
if (g_file_test (theme_file_path, G_FILE_TEST_EXISTS)) {
for (node = current_list; (node != NULL) && (!found); node = node->next) {
- found = (strcmp (node->data, entry->d_name) == 0);
+ found = (strcmp (node->data, entry) == 0);
}
if (!found) {
- current_list = g_list_prepend (current_list, g_strdup (entry->d_name));
+ current_list = g_list_prepend (current_list, g_strdup (entry));
}
}
}
found = FALSE;
- /*g_free (entry);*/
g_free (theme_file_path);
}
- closedir (theme_dir);
+ g_dir_close (theme_dir);
return current_list;
}