diff --git a/meson.build b/meson.build index 52e9f4f..b929d2d 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/src/main.vala b/src/main.vala index 19461e0..488d057 100644 --- a/src/main.vala +++ b/src/main.vala @@ -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); diff --git a/vapi/config.vapi b/vapi/config.vapi index d1ddf7d..1a86a5c 100644 --- a/vapi/config.vapi +++ b/vapi/config.vapi @@ -1,4 +1,5 @@ [CCode (cheader_filename = "config.h", lower_case_cprefix = "")] namespace Config { public const string DATADIR; + public const string WS; }