[connections/turn-db-object-into-singleton: 3/3] application: Centralize connection creation/deletion in Database singleton
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [connections/turn-db-object-into-singleton: 3/3] application: Centralize connection creation/deletion in Database singleton
- Date: Mon, 3 May 2021 11:59:17 +0000 (UTC)
commit 5a3fa64b194335811ee503c969bff1bff0ab8d84
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Apr 20 15:11:03 2021 +0200
application: Centralize connection creation/deletion in Database singleton
src/application.vala | 2 +-
src/connection.vala | 4 ----
src/database.vala | 21 +++++++++++----------
3 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/src/application.vala b/src/application.vala
index f1880e2..9dc7e5c 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -145,7 +145,7 @@ namespace Connections {
Notification.DismissFunc really_remove = () => {
debug ("User did not cancel deletion. Deleting now...");
- connection.delete ();
+ Database.get_default ().delete_connection (connection);
};
for (int i = 0; i < model.get_n_items (); i++) {
diff --git a/src/connection.vala b/src/connection.vala
index 93ea9f1..b9b4d06 100644
--- a/src/connection.vala
+++ b/src/connection.vala
@@ -193,10 +193,6 @@ namespace Connections {
need_username);
}
- public void delete () {
- config.delete ();
- }
-
public void save () {
config.save ();
}
diff --git a/src/database.vala b/src/database.vala
index df7b475..4b3829b 100644
--- a/src/database.vala
+++ b/src/database.vala
@@ -47,16 +47,6 @@ namespace Connections {
save_keyfile ();
}
-
- public void delete () {
- load_keyfile ();
- try {
- keyfile.remove_group (connection.uuid);
- } catch (GLib.Error error) {
- }
-
- save_keyfile ();
- }
}
private class Database : Object {
@@ -181,5 +171,16 @@ namespace Connections {
return connection;
}
+
+ public void delete_connection (Connection connection) {
+ load_keyfile ();
+ try {
+ keyfile.remove_group (connection.uuid);
+ } catch (GLib.Error error) {
+ warning ("Failed to delete '%s': %s", connection.uuid, error.message);
+ }
+
+ save_keyfile ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]