Skip to content

Commit 906abb0

Browse files
author
Alain M
committed
Add Environment.get_user_data_dir ()
1 parent 2766743 commit 906abb0

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/Application.vala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ public class Planner : Gtk.Application {
4848

4949
// Dir to Database
5050
utils = new Utils ();
51-
utils.create_dir_with_parents ("/.local/share/com.github.alainm23.planner");
52-
utils.create_dir_with_parents ("/.local/share/com.github.alainm23.planner/avatars");
51+
utils.create_dir_with_parents ("/com.github.alainm23.planner");
52+
utils.create_dir_with_parents ("/com.github.alainm23.planner/avatars");
53+
54+
print ("URL: %s".printf (Environment.get_user_data_dir ()));
5355

5456
// Services
5557
settings = new Settings ("com.github.alainm23.planner");

src/Services/Database.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class Services.Database : GLib.Object {
5151

5252
public Database () {
5353
int rc = 0;
54-
db_path = Environment.get_home_dir () + "/.local/share/com.github.alainm23.planner/database.db";
54+
db_path = Environment.get_user_data_dir () + "/com.github.alainm23.planner/database.db";
5555

5656
if (create_tables () != Sqlite.OK) {
5757
stderr.printf ("Error creating db table: %d, %s\n", rc, db.errmsg ());

src/Utils.vala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ public class Utils : GLib.Object {
1313
public signal void magic_button_activated (int64 project_id, int64 section_id, int is_todoist, bool last, int index = 0);
1414

1515
public Utils () {
16-
APP_FOLDER = GLib.Path.build_filename (Environment.get_home_dir () + "/.local/share/", "com.github.alainm23.planner");
16+
//APP_FOLDER = GLib.Path.build_filename (Environment.get_home_dir () + "/.local/share/", "com.github.alainm23.planner");
17+
APP_FOLDER = GLib.Path.build_filename (Environment.get_user_data_dir (), "com.github.alainm23.planner");
1718
AVATARS_FOLDER = GLib.Path.build_filename (APP_FOLDER, "avatars");
1819
}
1920

2021
public void create_dir_with_parents (string dir) {
21-
string path = Environment.get_home_dir () + dir;
22+
string path = Environment.get_user_data_dir () + dir;
2223
File tmp = File.new_for_path (path);
2324
if (tmp.query_file_type (0) != FileType.DIRECTORY) {
2425
GLib.DirUtils.create_with_parents (path, 0775);

0 commit comments

Comments
 (0)