diff --git a/Cargo.lock b/Cargo.lock
index 1b05d24..e753eff 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6,6 +6,7 @@ version = 3
name = "audrey"
version = "0.1.0"
dependencies = [
+ "glib-build-tools",
"gtk4",
"libadwaita",
"libc",
@@ -307,6 +308,15 @@ dependencies = [
"smallvec",
]
+[[package]]
+name = "glib-build-tools"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7029c2651d9b5d5a3eea93ec8a1995665c6d3a69ce9bf6042ad9064d134736d8"
+dependencies = [
+ "gio 0.20.4",
+]
+
[[package]]
name = "glib-macros"
version = "0.19.9"
diff --git a/Cargo.toml b/Cargo.toml
index 6a12f5b..b3f1ebc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,3 +8,6 @@ adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
libc = "0.2.161"
libsecret = { version = "0.5.0", features = ["v0_21"] }
+
+[build-dependencies]
+glib-build-tools = "0.20.0"
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..e316884
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,11 @@
+fn main() {
+ let meson_build_root = std::env::var("MESON_BUILD_ROOT").unwrap();
+ glib_build_tools::compile_resources(
+ &[
+ "resources",
+ &format!("{meson_build_root}/resources"),
+ ],
+ "resources/audrey.gresource.xml",
+ "audrey.gresource",
+ );
+}
diff --git a/meson.build b/meson.build
index 6d377f6..e7f626f 100644
--- a/meson.build
+++ b/meson.build
@@ -37,8 +37,9 @@ add_project_arguments(
)
subdir('data')
-subdir('src')
subdir('po')
+subdir('resources')
+subdir('src')
cargo = find_program('cargo')
# TODO: cargo release build
@@ -46,12 +47,16 @@ custom_target(
'cargo-build',
build_by_default: true,
build_always_stale: true,
- depends: audrey_c,
+ depends: [
+ audrey_c,
+ blueprints,
+ ],
output: meson.project_name(),
command: [
'env',
'CARGO_HOME=' + meson.project_build_root() / 'cargo-home',
'RUSTFLAGS=-L ' + fs.parent(audrey_c.full_path()),
+ 'MESON_BUILD_ROOT=' + meson.project_build_root(),
cargo,
'build',
'--manifest-path', meson.project_source_root() / 'Cargo.toml',
diff --git a/resources/audrey.gresource.xml b/resources/audrey.gresource.xml
new file mode 100644
index 0000000..12dffca
--- /dev/null
+++ b/resources/audrey.gresource.xml
@@ -0,0 +1,12 @@
+
+
+
+ style.css
+ gtk/help-overlay.ui
+ play_queue.ui
+ play_queue_song.ui
+ playbar.ui
+ setup.ui
+ window.ui
+
+
diff --git a/src/gtk/help-overlay.ui b/resources/gtk/help-overlay.ui
similarity index 100%
rename from src/gtk/help-overlay.ui
rename to resources/gtk/help-overlay.ui
diff --git a/src/ui/meson.build b/resources/meson.build
similarity index 100%
rename from src/ui/meson.build
rename to resources/meson.build
diff --git a/src/ui/play_queue.blp b/resources/play_queue.blp
similarity index 100%
rename from src/ui/play_queue.blp
rename to resources/play_queue.blp
diff --git a/src/ui/play_queue_song.blp b/resources/play_queue_song.blp
similarity index 100%
rename from src/ui/play_queue_song.blp
rename to resources/play_queue_song.blp
diff --git a/src/ui/playbar.blp b/resources/playbar.blp
similarity index 100%
rename from src/ui/playbar.blp
rename to resources/playbar.blp
diff --git a/src/ui/setup.blp b/resources/setup.blp
similarity index 100%
rename from src/ui/setup.blp
rename to resources/setup.blp
diff --git a/src/style.css b/resources/style.css
similarity index 100%
rename from src/style.css
rename to resources/style.css
diff --git a/src/ui/window.blp b/resources/window.blp
similarity index 100%
rename from src/ui/window.blp
rename to resources/window.blp
diff --git a/src/audrey.gresource.xml b/src/audrey.gresource.xml
deleted file mode 100644
index f676199..0000000
--- a/src/audrey.gresource.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- style.css
- gtk/help-overlay.ui
- ui/play_queue.ui
- ui/play_queue_song.ui
- ui/playbar.ui
- ui/setup.ui
- ui/window.ui
-
-
diff --git a/src/main.rs b/src/main.rs
index fc1b90f..643a360 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,6 @@
+use gtk::gio;
+
extern crate adw;
-extern crate gtk;
extern crate libsecret;
#[link(name = "audrey")]
@@ -9,12 +10,12 @@ extern crate libsecret;
#[link(name = "soup-3.0")]
extern {
fn c_main(argc: libc::c_int, argv: *mut *mut libc::c_char) -> libc::c_int;
- fn audrey_get_resource() -> *mut ();
}
fn main() {
+ gio::resources_register_include!("audrey.gresource").expect("could not register resources");
+
unsafe {
- audrey_get_resource();
std::process::exit(c_main(0, std::ptr::null_mut()))
}
}
diff --git a/src/meson.build b/src/meson.build
index 9f1157f..e8c845e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -21,37 +21,6 @@ audrey_deps = [
dependency('mpv', version: '>= 2.3'),
]
-subdir('ui')
-
-audrey_sources += gnome.compile_resources(
- 'audrey-resources',
- 'audrey.gresource.xml',
- c_name: 'audrey',
- dependencies: blueprints,
- # this is a huge hack, as by default only src/ui to the 'blueprints' dep
- # and ../src is passed, which means the ui/xyz.ui prefix will not be found
- # anywhere, as src/ui already has the ui in the path.
- # the reason we have to put blp in its own ui folder, is because:
- # - blueprint-compiler batch-compile outputs in the same directory structure,
- # i.e. if you pass ui/x.blp outdir foo, it will create foo/ui/x.ui,
- # - meson doesn't support output:[] with dir/ prefix
- # .. which means, all the files are always dirty; meson will try find 'src/x.ui'
- # as an output for dirty tracking, but blp is outputting src/ui/x.ui
- # because of the directory structure.
- # using manual blueprint-compiler invocations to put the output in the
- # 'correct' tracked place doesn't work either,
- # since then it will be in this dir and not in ui/ and so all the ui/ prefixes
- # in gresources won't find it, and we can't put it in a ui/ output from the
- # current dir due to the above and meson not letting you.
- #so since we use ui/ prefix, we need a meson.build in ui/ and then this hack
- # to ensure compile sees the ui/ prefix starting from this src/ dir still,
- # despite the dependency normally doing this for you
- # note that the 'documented' way to use blp is with outdir:[.] which is
- # fundamentally broken as then nothing is tracked except the dirs existence, which
- # is racy as the dependency is satistfied before anything is compiled
- extra_args: ['--sourcedir', 'src'],
-)
-
audrey_c = static_library(
'audrey',
audrey_sources,
diff --git a/src/ui/play_queue.c b/src/ui/play_queue.c
index 9b4c2a0..118895c 100644
--- a/src/ui/play_queue.c
+++ b/src/ui/play_queue.c
@@ -1056,7 +1056,7 @@ ui_play_queue_song_class_init (UiPlayQueueSongClass * klass,
#line 4 "../src/ui/play_queue.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_PLAY_QUEUE_SONG_SONG_PROPERTY, ui_play_queue_song_properties[UI_PLAY_QUEUE_SONG_SONG_PROPERTY] = g_param_spec_object ("song", "song", "song", TYPE_PLAYBIN_SONG, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 4 "../src/ui/play_queue.vala"
- gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/play_queue_song.ui");
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/play_queue_song.ui");
#line 4 "../src/ui/play_queue.vala"
gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "format_duration", G_CALLBACK(ui_play_queue_song_format_duration));
#line 4 "../src/ui/play_queue.vala"
@@ -1633,7 +1633,7 @@ ui_play_queue_class_init (UiPlayQueueClass * klass,
#line 115 "../src/ui/play_queue.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_PLAY_QUEUE_CAN_CLEAR_ALL_PROPERTY, ui_play_queue_properties[UI_PLAY_QUEUE_CAN_CLEAR_ALL_PROPERTY] = g_param_spec_boolean ("can-clear-all", "can-clear-all", "can-clear-all", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
#line 115 "../src/ui/play_queue.vala"
- gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/play_queue.ui");
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/play_queue.ui");
#line 115 "../src/ui/play_queue.vala"
gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_song_list_setup", G_CALLBACK(_ui_play_queue_on_song_list_setup_gtk_signal_list_item_factory_setup));
#line 115 "../src/ui/play_queue.vala"
diff --git a/src/ui/playbar.c b/src/ui/playbar.c
index 7be2706..0bf224b 100644
--- a/src/ui/playbar.c
+++ b/src/ui/playbar.c
@@ -950,7 +950,7 @@ ui_playbar_class_init (UiPlaybarClass * klass,
#line 2 "../src/ui/playbar.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_PLAYBAR_VOLUME_PROPERTY, ui_playbar_properties[UI_PLAYBAR_VOLUME_PROPERTY] = g_param_spec_int ("volume", "volume", "volume", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 2 "../src/ui/playbar.vala"
- gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/playbar.ui");
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/playbar.ui");
#line 2 "../src/ui/playbar.vala"
gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "format_timestamp", G_CALLBACK(ui_playbar_format_timestamp));
#line 2 "../src/ui/playbar.vala"
diff --git a/src/ui/setup.c b/src/ui/setup.c
index 20565e5..c991a02 100644
--- a/src/ui/setup.c
+++ b/src/ui/setup.c
@@ -1268,7 +1268,7 @@ ui_setup_class_init (UiSetupClass * klass,
#line 20 "../src/ui/setup.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_SETUP_PASSWORD_PROPERTY, ui_setup_properties[UI_SETUP_PASSWORD_PROPERTY] = g_param_spec_string ("password", "password", "password", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 20 "../src/ui/setup.vala"
- gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/setup.ui");
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/setup.ui");
#line 20 "../src/ui/setup.vala"
ui_setup_signals[UI_SETUP_CONNECTED_SIGNAL] = g_signal_new ("connected", UI_TYPE_SETUP, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, SUBSONIC_TYPE_CLIENT);
#line 34 "../src/ui/setup.vala"
diff --git a/src/ui/window.c b/src/ui/window.c
index 8d98289..829765a 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1376,7 +1376,7 @@ ui_window_class_init (UiWindowClass * klass,
#line 2 "../src/ui/window.vala"
g_object_class_install_property (G_OBJECT_CLASS (klass), UI_WINDOW_CAN_CLICK_SHUFFLE_ALL_PROPERTY, ui_window_properties[UI_WINDOW_CAN_CLICK_SHUFFLE_ALL_PROPERTY] = g_param_spec_boolean ("can-click-shuffle-all", "can-click-shuffle-all", "can-click-shuffle-all", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
#line 2 "../src/ui/window.vala"
- gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/ui/window.ui");
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/eu/callcc/audrey/window.ui");
#line 2 "../src/ui/window.vala"
gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "play_queue", FALSE, G_STRUCT_OFFSET (UiWindow, play_queue));
#line 2 "../src/ui/window.vala"