diff --git a/data/res/meson.build b/data/res/meson.build
index 1e0ff66..8c497f2 100644
--- a/data/res/meson.build
+++ b/data/res/meson.build
@@ -3,6 +3,7 @@ gnome = import('gnome')
blueprints = custom_target('blueprints',
input: files(
+ 'welcome_page.blp',
'window.blp'
),
output: '.',
diff --git a/data/res/musicus.gresource.xml b/data/res/musicus.gresource.xml
index 894cc3b..fbd2760 100644
--- a/data/res/musicus.gresource.xml
+++ b/data/res/musicus.gresource.xml
@@ -1,6 +1,7 @@
+ welcome_page.ui
window.ui
diff --git a/data/res/welcome_page.blp b/data/res/welcome_page.blp
new file mode 100644
index 0000000..72db0ca
--- /dev/null
+++ b/data/res/welcome_page.blp
@@ -0,0 +1,39 @@
+using Gtk 4.0;
+using Adw 1;
+
+template $MusicusWelcomePage : Adw.NavigationPage {
+ title: _("Welcome to Musicus");
+
+ Adw.ToolbarView {
+ [top]
+ Adw.HeaderBar header_bar {
+ [end]
+ MenuButton {
+ icon-name: "open-menu-symbolic";
+ menu-model: primary_menu;
+ }
+ }
+
+ Adw.StatusPage {
+ icon-name: "de.johrpan.musicus";
+ title: _("Welcome to Musicus");
+ description: _("Get started by choosing where to store your music library. Is this your first time using Musicus? If so, create a new empty folder for your library. Musicus will use this location to manage your recordings. You can also select a folder that already contains a music library created by Musicus.");
+ child: Gtk.Button choose_library_button {
+ styles ["suggested-action", "pill"]
+ halign: center;
+ label: _("Choose library folder");
+ };
+ }
+ }
+}
+
+menu primary_menu {
+ item {
+ label: _("_Preferences");
+ action: "app.preferences";
+ }
+ item {
+ label: _("_About Musicus");
+ action: "app.about";
+ }
+}
\ No newline at end of file
diff --git a/data/res/window.blp b/data/res/window.blp
index 97bd416..208ad21 100644
--- a/data/res/window.blp
+++ b/data/res/window.blp
@@ -2,35 +2,9 @@ using Gtk 4.0;
using Adw 1;
template $MusicusWindow : Adw.ApplicationWindow {
- default-width: 600;
- default-height: 300;
+ title: _("Musicus");
+ default-width: 800;
+ default-height: 600;
- Box {
- orientation: vertical;
-
- HeaderBar header_bar {
- [end]
- MenuButton {
- icon-name: "open-menu-symbolic";
- menu-model: primary_menu;
- }
- }
-
- Label label {
- label: _("Hello, World!");
- vexpand: true;
- styles ["title-1"]
- }
- }
-}
-
-menu primary_menu {
- item {
- label: _("_Preferences");
- action: "app.preferences";
- }
- item {
- label: _("_About Musicus");
- action: "app.about";
- }
+ Adw.NavigationView navigation_view {}
}
\ No newline at end of file
diff --git a/po/POTFILES b/po/POTFILES
index d5a0c89..bf7baed 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -1,4 +1,6 @@
+data/res/welcome_page.blp
+data/res/window.blp
data/de.johrpan.musicus.desktop.in
data/de.johrpan.musicus.appdata.xml.in
data/de.johrpan.musicus.gschema.xml
-src/window.blp
+src/application.rs
diff --git a/po/de.po b/po/de.po
index 89876c4..542029f 100644
--- a/po/de.po
+++ b/po/de.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2023-07-06 14:30+0200\n"
+"POT-Creation-Date: 2023-09-13 14:57+0200\n"
"PO-Revision-Date: 2023-06-28 14:58+0200\n"
"Last-Translator: \n"
"Language-Team: German \n"
@@ -18,7 +18,32 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: data/de.johrpan.musicus.desktop.in:3
+#: data/res/welcome_page.blp:5 data/res/welcome_page.blp:19
+msgid "Welcome to Musicus"
+msgstr ""
+
+#: data/res/welcome_page.blp:20
+msgid ""
+"Get started by choosing where to store your music library. Is this your "
+"first time using Musicus? If so, create a new empty folder for your library. "
+"Musicus will use this location to manage your recordings. You can also "
+"select a folder that already contains a music library created by Musicus."
+msgstr ""
+
+#: data/res/welcome_page.blp:24
+msgid "Choose library folder"
+msgstr ""
+
+#: data/res/welcome_page.blp:32
+msgid "_Preferences"
+msgstr "_Einstellungen"
+
+#: data/res/welcome_page.blp:36
+msgid "_About Musicus"
+msgstr "_Über Musicus"
+
+#: data/res/window.blp:5 data/de.johrpan.musicus.desktop.in:3
+#: src/application.rs:79
msgid "Musicus"
msgstr "Musicus"
@@ -26,14 +51,5 @@ msgstr "Musicus"
msgid "No description"
msgstr "Keine Beschreibung"
-#: src/window.blp:20
-msgid "Hello, World!"
-msgstr "Hallo, Welt!"
-
-#: src/window.blp:29
-msgid "_Preferences"
-msgstr "_Einstellungen"
-
-#: src/window.blp:33
-msgid "_About Musicus"
-msgstr "_Über Musicus"
+#~ msgid "Hello, World!"
+#~ msgstr "Hallo, Welt!"
diff --git a/po/template.pot b/po/template.pot
index fb32063..f5ce6d7 100644
--- a/po/template.pot
+++ b/po/template.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2023-07-06 14:30+0200\n"
+"POT-Creation-Date: 2023-09-13 14:57+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -17,22 +17,35 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: data/de.johrpan.musicus.desktop.in:3
+#: data/res/welcome_page.blp:5 data/res/welcome_page.blp:19
+msgid "Welcome to Musicus"
+msgstr ""
+
+#: data/res/welcome_page.blp:20
+msgid ""
+"Get started by choosing where to store your music library. Is this your "
+"first time using Musicus? If so, create a new empty folder for your library. "
+"Musicus will use this location to manage your recordings. You can also "
+"select a folder that already contains a music library created by Musicus."
+msgstr ""
+
+#: data/res/welcome_page.blp:24
+msgid "Choose library folder"
+msgstr ""
+
+#: data/res/welcome_page.blp:32
+msgid "_Preferences"
+msgstr ""
+
+#: data/res/welcome_page.blp:36
+msgid "_About Musicus"
+msgstr ""
+
+#: data/res/window.blp:5 data/de.johrpan.musicus.desktop.in:3
+#: src/application.rs:79
msgid "Musicus"
msgstr ""
#: data/de.johrpan.musicus.appdata.xml.in:7
msgid "No description"
msgstr ""
-
-#: src/window.blp:20
-msgid "Hello, World!"
-msgstr ""
-
-#: src/window.blp:29
-msgid "_Preferences"
-msgstr ""
-
-#: src/window.blp:33
-msgid "_About Musicus"
-msgstr ""
diff --git a/src/application.rs b/src/application.rs
index 5bef8c9..d1ce0f6 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -1,6 +1,6 @@
-use gtk::prelude::*;
use adw::subclass::prelude::*;
-use gtk::{gio, glib};
+use gettextrs::gettext;
+use gtk::{gio, glib, prelude::*};
use crate::config::VERSION;
use crate::MusicusWindow;
@@ -28,13 +28,9 @@ mod imp {
}
impl ApplicationImpl for MusicusApplication {
- // We connect to the activate callback to create a window when the application
- // has been launched. Additionally, this callback notifies us when the user
- // tries to launch a "second instance" of the application. When they try
- // to do that, we'll just present any existing window.
fn activate(&self) {
let application = self.obj();
- // Get the current window or create one if necessary
+
let window = if let Some(window) = application.active_window() {
window
} else {
@@ -42,7 +38,6 @@ mod imp {
window.upcast()
};
- // Ask the window manager/compositor to present the window
window.present();
}
}
@@ -69,9 +64,11 @@ impl MusicusApplication {
let quit_action = gio::ActionEntry::builder("quit")
.activate(move |app: &Self, _, _| app.quit())
.build();
+
let about_action = gio::ActionEntry::builder("about")
.activate(move |app: &Self, _, _| app.show_about())
.build();
+
self.add_action_entries([quit_action, about_action]);
}
@@ -79,12 +76,14 @@ impl MusicusApplication {
let window = self.active_window().unwrap();
let about = adw::AboutWindow::builder()
.transient_for(&window)
- .application_name("musicus")
+ .application_name(gettext("Musicus"))
.application_icon("de.johrpan.musicus")
- .developer_name("Unknown")
+ .developer_name("Elias Projahn")
.version(VERSION)
- .developers(vec!["Unknown"])
- .copyright("© 2023 Unknown")
+ .website("https://code.johrpan.de/johrpan/musicus")
+ .developers(vec!["Elias Projahn "])
+ .copyright("© 2023 Elias Projahn")
+ .license_type(gtk::License::Gpl30)
.build();
about.present();
diff --git a/src/main.rs b/src/main.rs
index 0606fb2..4316e90 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,35 +1,23 @@
mod application;
mod config;
+mod welcome_page;
mod window;
-use self::application::MusicusApplication;
-use self::window::MusicusWindow;
+use self::{application::MusicusApplication, window::MusicusWindow};
use config::{GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR};
use gettextrs::{bind_textdomain_codeset, bindtextdomain, textdomain};
-use gtk::{gio, glib};
-use gtk::prelude::*;
+use gtk::{gio, glib, prelude::*};
fn main() -> glib::ExitCode {
- // Set up gettext translations
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain");
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8")
.expect("Unable to set the text domain encoding");
textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain");
- // Load resources
let resources = gio::Resource::load(PKGDATADIR.to_owned() + "/musicus.gresource")
.expect("Could not load resources");
gio::resources_register(&resources);
- // Create a new GtkApplication. The application manages our main loop,
- // application windows, integration with the window manager/compositor, and
- // desktop features such as file opening and single-instance applications.
- let app = MusicusApplication::new("de.johrpan.musicus", &gio::ApplicationFlags::empty());
-
- // Run the application. This function will block until the application
- // exits. Upon return, we have our exit code to return to the shell. (This
- // is the code you see when you do `echo $?` after running a command in a
- // terminal.
- app.run()
+ MusicusApplication::new("de.johrpan.musicus", &gio::ApplicationFlags::empty()).run()
}
diff --git a/src/welcome_page.rs b/src/welcome_page.rs
new file mode 100644
index 0000000..4086d84
--- /dev/null
+++ b/src/welcome_page.rs
@@ -0,0 +1,43 @@
+use adw::subclass::{navigation_page::NavigationPageImpl, prelude::*};
+use gtk::glib;
+
+mod imp {
+ use super::*;
+
+ #[derive(Debug, Default, gtk::CompositeTemplate)]
+ #[template(resource = "/de/johrpan/musicus/welcome_page.ui")]
+ pub struct MusicusWelcomePage {
+ #[template_child]
+ pub choose_library_button: TemplateChild,
+ }
+
+ #[glib::object_subclass]
+ impl ObjectSubclass for MusicusWelcomePage {
+ const NAME: &'static str = "MusicusWelcomePage";
+ type Type = super::MusicusWelcomePage;
+ type ParentType = adw::NavigationPage;
+
+ fn class_init(klass: &mut Self::Class) {
+ klass.bind_template();
+ }
+
+ fn instance_init(obj: &glib::subclass::InitializingObject) {
+ obj.init_template();
+ }
+ }
+
+ impl ObjectImpl for MusicusWelcomePage {}
+ impl WidgetImpl for MusicusWelcomePage {}
+ impl NavigationPageImpl for MusicusWelcomePage {}
+}
+
+glib::wrapper! {
+ pub struct MusicusWelcomePage(ObjectSubclass)
+ @extends gtk::Widget, adw::NavigationPage;
+}
+
+impl MusicusWelcomePage {
+ pub fn new() -> Self {
+ glib::Object::new()
+ }
+}
diff --git a/src/window.rs b/src/window.rs
index 6d62f74..44affd9 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -1,3 +1,5 @@
+use crate::welcome_page::MusicusWelcomePage;
+
use adw::subclass::prelude::*;
use gtk::{gio, glib};
@@ -7,11 +9,8 @@ mod imp {
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(resource = "/de/johrpan/musicus/window.ui")]
pub struct MusicusWindow {
- // Template widgets
#[template_child]
- pub header_bar: TemplateChild,
- #[template_child]
- pub label: TemplateChild,
+ pub navigation_view: TemplateChild,
}
#[glib::object_subclass]
@@ -29,7 +28,14 @@ mod imp {
}
}
- impl ObjectImpl for MusicusWindow {}
+ impl ObjectImpl for MusicusWindow {
+ fn constructed(&self) {
+ self.parent_constructed();
+
+ self.navigation_view.add(&MusicusWelcomePage::new());
+ }
+ }
+
impl WidgetImpl for MusicusWindow {}
impl WindowImpl for MusicusWindow {}
impl ApplicationWindowImpl for MusicusWindow {}
@@ -38,7 +44,8 @@ mod imp {
glib::wrapper! {
pub struct MusicusWindow(ObjectSubclass)
- @extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, @implements gio::ActionGroup, gio::ActionMap;
+ @extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow,
+ @implements gio::ActionGroup, gio::ActionMap;
}
impl MusicusWindow {