From 45338c1bf957ab71bea3e52d7280b2b7b798fa7a Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 10 Aug 2025 11:57:18 +0200 Subject: [PATCH] Expose AlbumEditor in primary menu --- data/ui/empty_page.blp | 39 +++++++++++++++++++++++-------------- data/ui/search_page.blp | 43 +++++++++++++++++++++++++---------------- src/window.rs | 20 ++++++++++++++++--- 3 files changed, 67 insertions(+), 35 deletions(-) diff --git a/data/ui/empty_page.blp b/data/ui/empty_page.blp index bee614a..1be754d 100644 --- a/data/ui/empty_page.blp +++ b/data/ui/empty_page.blp @@ -50,23 +50,32 @@ template $MusicusEmptyPage: Adw.NavigationPage { } menu primary_menu { - item { - label: _("_Import music"); - action: "win.import"; + section { + item { + label: _("_Import music"); + action: "win.import"; + } + + item { + label: _("_Create album"); + action: "win.create-album"; + } + + item { + label: _("_Library manager"); + action: "win.library"; + } } - item { - label: _("_Library manager"); - action: "win.library"; - } + section { + item { + label: _("_Preferences"); + action: "win.preferences"; + } - item { - label: _("_Preferences"); - action: "win.preferences"; - } - - item { - label: _("_About Musicus"); - action: "app.about"; + item { + label: _("_About Musicus"); + action: "app.about"; + } } } diff --git a/data/ui/search_page.blp b/data/ui/search_page.blp index 24daf4d..1cae41a 100644 --- a/data/ui/search_page.blp +++ b/data/ui/search_page.blp @@ -73,14 +73,14 @@ template $MusicusSearchPage: Adw.NavigationPage { ] } } - + Gtk.SearchEntry search_entry { placeholder-text: _("Enter composers, performers, works…"); margin-top: 24; activate => $select() swapped; styles [ - "rounded-entry" + "rounded-entry", ] } @@ -264,24 +264,33 @@ template $MusicusSearchPage: Adw.NavigationPage { } menu primary_menu { - item { - label: _("_Import music"); - action: "win.import"; + section { + item { + label: _("_Import music"); + action: "win.import"; + } + + item { + label: _("_Create album"); + action: "win.create-album"; + } + + item { + label: _("_Library manager"); + action: "win.library"; + } } - item { - label: _("_Library manager"); - action: "win.library"; - } + section { + item { + label: _("_Preferences"); + action: "win.preferences"; + } - item { - label: _("_Preferences"); - action: "win.preferences"; - } - - item { - label: _("_About Musicus"); - action: "app.about"; + item { + label: _("_About Musicus"); + action: "app.about"; + } } } diff --git a/src/window.rs b/src/window.rs index 14ef619..5a5cc61 100644 --- a/src/window.rs +++ b/src/window.rs @@ -11,7 +11,7 @@ use gtk::{gio, glib, glib::clone}; use crate::{ album_page::AlbumPage, config, - editor::tracks::TracksEditor, + editor::{album::AlbumEditor, tracks::TracksEditor}, empty_page::EmptyPage, library::{Library, LibraryQuery}, library_manager::LibraryManager, @@ -88,6 +88,16 @@ mod imp { }) .build(); + let obj = self.obj().to_owned(); + let create_album_action = gio::ActionEntry::builder("create-album") + .activate(move |_, _, _| { + if let Some(library) = &*obj.imp().library.borrow() { + let editor = AlbumEditor::new(&obj.imp().navigation_view, library, None); + obj.imp().navigation_view.push(&editor); + } + }) + .build(); + let obj = self.obj().to_owned(); let library_action = gio::ActionEntry::builder("library") .activate(move |_, _, _| { @@ -109,8 +119,12 @@ mod imp { }) .build(); - self.obj() - .add_action_entries([import_action, library_action, preferences_action]); + self.obj().add_action_entries([ + import_action, + create_album_action, + library_action, + preferences_action, + ]); let player_bar = PlayerBar::new(&self.player); self.player_bar_revealer.set_child(Some(&player_bar));