[baobab] Factor out method to check if the location is already there
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab] Factor out method to check if the location is already there
- Date: Mon, 30 Jul 2012 08:33:46 +0000 (UTC)
commit 9c56cf2bc3fd0ae893ec21829aee55bf73ee9c76
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jul 29 19:02:40 2012 +0200
Factor out method to check if the location is already there
src/baobab-location-list.vala | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/baobab-location-list.vala b/src/baobab-location-list.vala
index 598e41f..b4f6d31 100644
--- a/src/baobab-location-list.vala
+++ b/src/baobab-location-list.vala
@@ -102,6 +102,15 @@ namespace Baobab {
update ();
}
+ bool already_present (File file) {
+ foreach (var l in locations) {
+ if (l.file != null && l.file.equal (file)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
void populate () {
locations.append (new Location.for_main_volume ());
@@ -128,14 +137,7 @@ namespace Baobab {
break;
}
if (info.has_group ("baobab") && info.exists ()) {
- // FIXME: I do not like this hack to avoid duplucates...
- bool dup = false;
- foreach (var l in locations) {
- if (l.file != null && l.file.equal (File.new_for_uri (info.get_uri ()))) {
- dup = true;
- }
- }
- if (!dup) {
+ if (!already_present (File.new_for_uri (info.get_uri ()))) {
locations.append (new Location.for_recent_info (info));
n_recents++;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]