Adding windows support for paths.

This commit is contained in:
sergiotarxz 2022-06-30 10:21:45 +02:00
parent 7cced990e7
commit 0491f28146
3 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,10 @@
project('me.sergiotarxz.recuento', 'vala')
compiler = meson.get_compiler('c')
ws = '/'
if compiler.has_header('windows.h')
ws = '\\'
endif
vapidir = meson.project_source_root() / 'vapi'
recuentodeps = [
@ -14,12 +20,14 @@ sources = [
'src/main.vala',
]
datadir = get_option('prefix') + '/' + get_option('datadir')
datadir_unix = get_option('prefix') + '/' + get_option('datadir')
datadir = get_option('prefix') + ws + get_option('datadir')
config_h = configure_file (
output : 'config.h',
configuration : {
'DATADIR' : f'"@datadir@"',
'WS': f'"@ws@"',
},
)
@ -28,7 +36,7 @@ preloaded_images_files = [ 'psoe.jpg', 'pp.jpg', 'vox.jpg' ]
foreach i : preloaded_images_files
install_data(
'resources/preloaded_images' / i,
install_dir: datadir / 'recuento/preloaded_images/',
install_dir: datadir_unix / 'recuento/preloaded_images/',
)
endforeach

View File

@ -1,8 +1,9 @@
const string SQLITE_PATH = ".config/recuento.sqlite";
const string PRELOADED_IMAGES_PATH = Config.DATADIR + "/recuento/preloaded_images";
const string PSOE_IMAGE = PRELOADED_IMAGES_PATH + "/psoe.jpg";
const string PP_IMAGE = PRELOADED_IMAGES_PATH + "/pp.jpg";
const string VOX_IMAGE = PRELOADED_IMAGES_PATH + "/vox.jpg";
const string S = Config.WS;
const string SQLITE_PATH = ".config" + S + "recuento.sqlite";
const string PRELOADED_IMAGES_PATH = Config.DATADIR + S + "recuento" + S + "preloaded_images";
const string PSOE_IMAGE = PRELOADED_IMAGES_PATH + S + "psoe.jpg";
const string PP_IMAGE = PRELOADED_IMAGES_PATH + S + "pp.jpg";
const string VOX_IMAGE = PRELOADED_IMAGES_PATH + S + "vox.jpg";
const string[] MIGRATIONS = {
"CREATE TABLE options (key TEXT PRIMARY KEY, value TEXT);",
"CREATE TABLE parties (" +
@ -267,7 +268,7 @@ void create_select_party_image_button (Gtk.Picture picture, Gtk.Box input_fields
Sqlite.Database get_db () {
Sqlite.Database db;
string home = GLib.Environment.get_home_dir ();
string final_sqlite_path = @"$home/$SQLITE_PATH";
string final_sqlite_path = @"$home$S$SQLITE_PATH";
print(final_sqlite_path);
int rc = Sqlite.Database.open (final_sqlite_path, out db);
apply_migrations (db);

View File

@ -1,4 +1,5 @@
[CCode (cheader_filename = "config.h", lower_case_cprefix = "")]
namespace Config {
public const string DATADIR;
public const string WS;
}