Open files in a folder in data (original) (raw)
GTK4 / libadwata 1.7 / python.
Making an application that might have many configuration files. I want to load all of them, not just a select few.
These files will be in a folder under data/
. So data/extensions/
.
But I couldn’t find a way to load a folder (file). I tried looking at Gio andGFile
, but these don’t quite match what I want to do.
I think my issue lies in that: I don’t know what the path is. Where is it? From where should I load? I’m confused, since GNOME Builder seems to make a setup for flatpak paths, but I can’t find a tutorial about this.
monster (Jamie Gravendeel) May 14, 2025, 6:33pm 2
Files in your data/
folder need to be installed via the folder’s meson.build
.
You can use GLib.get_user_data_dir to get the user’s data directory.
If you have more details, maybe I can help you more.
Mas May 15, 2025, 3:36pm 3
After some debugging on the matrix channels:
- First, the files that were in
data/extensions/
should instead be in a data folder - so, not accessed directly through the project’s path. - To do so, I added a line in the
meson.build
file underdata/
- The path is relative to the meson file, andinstall_dir
is required. - This will add the files in either.var/app/
or wherever your flatpaks are. Particularly, in the data folder.
install_subdir('extensions', install_dir: get_option('datadir'))
- Then, we can access it by getting the folder at
/app/share/extensions/
with Gio
Gio.File.new_for_path("/app/share/collections")
And then, to get the files, it’s something to do with gio.enumerate_children
.
system (system) Closed June 14, 2025, 3:37pm 4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.