aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-10-23 23:18:06 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-10-23 23:26:10 +0200
commit5ad6cbc9208e0e9490ca6311513b1f7f315c284a (patch)
tree7e1cceb475a39907edcf02bf5046c2a0e8817e95 /src
parent00030570c0bb5f960f0b8759d3dcd265f6f27376 (diff)
downloadarctica-greeter-5ad6cbc9208e0e9490ca6311513b1f7f315c284a.tar.gz
arctica-greeter-5ad6cbc9208e0e9490ca6311513b1f7f315c284a.tar.bz2
arctica-greeter-5ad6cbc9208e0e9490ca6311513b1f7f315c284a.zip
src/user-list.vala: Use directory enumerator for getting a random number of background image. Check if the returned directory entry is not a sub-directory. If so, then skip it.
Diffstat (limited to 'src')
-rw-r--r--src/user-list.vala21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/user-list.vala b/src/user-list.vala
index 319e833..82ebc73 100644
--- a/src/user-list.vala
+++ b/src/user-list.vala
@@ -1179,18 +1179,25 @@ public class UserList : GreeterList
test_backgrounds = new List<string> ();
try
{
- var dir = Dir.open ("/usr/share/backgrounds/");
- while (true)
- {
- var bg = dir.read_name ();
- if (bg == null)
- break;
- test_backgrounds.append ("/usr/share/backgrounds/" + bg);
+
+ var directory = File.new_for_path ("/usr/share/backgrounds");
+
+ var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
+
+ FileInfo file_info;
+ while ((file_info = enumerator.next_file ()) != null) {
+ if(file_info.get_file_type() != FileType.DIRECTORY)
+ {
+ test_backgrounds.append ("/usr/share/backgrounds/" + file_info.get_name());
+ }
}
}
catch (FileError e)
{
}
+ catch (GLib.Error e)
+ {
+ }
if (!ArcticaGreeter.singleton.hide_users_hint())
while (add_test_entry ());