diff --git a/data/meson.build b/data/meson.build index 7bbcc4b..88fde1e 100644 --- a/data/meson.build +++ b/data/meson.build @@ -6,7 +6,7 @@ desktop_conf.set('EXEC', meson.project_name()) # Desktop file configure_file( - input: '@0@.desktop.in'.format(application_id), + input: '@0@.desktop.in'.format(base_id), output: '@BASENAME@', install: true, configuration: desktop_conf, diff --git a/meson.build b/meson.build index 0f5ff27..b385931 100644 --- a/meson.build +++ b/meson.build @@ -8,6 +8,7 @@ project( gnome = import('gnome') +# application_id can contain the -devel extension base_id = 'com.lemmygtk.lemoa' version = meson.project_version() diff --git a/src/config.rs b/src/config.rs index ea7d279..ec1efe1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,4 @@ -pub const APP_ID: &str = "com.lemmygtk.lemoa"; -pub const PKGDATADIR: &str = "/usr/local/share/lemoa"; -pub const VERSION: &str = "0.1.0"; +pub const NAME: &str = "lemoa"; +pub const APP_ID: &str = "com.lemmygtk.lemoa.Devel"; +pub const PKGDATADIR: &str = "/app/share/lemoa"; +pub const VERSION: &str = "0.1.0-8e019361"; diff --git a/src/config.rs.in b/src/config.rs.in index 5fd5d51..ad8f0c0 100644 --- a/src/config.rs.in +++ b/src/config.rs.in @@ -1,3 +1,4 @@ +pub const NAME: &str = @NAME@; pub const APP_ID: &str = @APP_ID@; pub const PKGDATADIR: &str = @PKGDATADIR@; pub const VERSION: &str = @VERSION@; diff --git a/src/dialogs/about.rs b/src/dialogs/about.rs new file mode 100644 index 0000000..40f6a70 --- /dev/null +++ b/src/dialogs/about.rs @@ -0,0 +1,46 @@ +use crate::config; +use gtk::prelude::GtkWindowExt; +use relm4::{gtk, ComponentParts, ComponentSender, SimpleComponent}; + +pub struct AboutDialog {} + +pub struct Widgets { + main_window: gtk::Window, +} + +impl SimpleComponent for AboutDialog { + type Input = (); + type Output = (); + type Init = gtk::Window; + type Root = (); + type Widgets = Widgets; + + fn init_root() -> Self::Root {} + + fn init( + main_window: Self::Init, + _root: &Self::Root, + _sender: ComponentSender, + ) -> ComponentParts { + let model = Self {}; + + let widgets = Widgets { main_window }; + + ComponentParts { model, widgets } + } + + fn update_view(&self, widgets: &mut Self::Widgets, _sender: ComponentSender) { + let dialog = gtk::AboutDialog::builder() + .icon_name(config::APP_ID) + .name(config::NAME) + .authors(["Bnyro"]) + .copyright("© 2023 Lemoa contributors") + .license_type(gtk::License::Gpl30) + .version(config::VERSION) + .modal(true) + .transient_for(&widgets.main_window) + .artists(["Bnyro "]) + .build(); + dialog.present(); + } +} diff --git a/src/dialogs/mod.rs b/src/dialogs/mod.rs index 0769981..ff1266e 100644 --- a/src/dialogs/mod.rs +++ b/src/dialogs/mod.rs @@ -1 +1,2 @@ +pub mod about; pub mod editor; diff --git a/src/main.rs b/src/main.rs index 5f41cda..e914841 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ use components::{ post_row::PostRow, profile_page::{self, ProfilePage}, }; +use dialogs::about::AboutDialog; use gtk::prelude::*; use lemmy_api_common::{ community::GetCommunityResponse, @@ -64,6 +65,7 @@ struct App { current_communities_page: i64, current_posts_page: i64, community_search_buffer: gtk::EntryBuffer, + about_dialog: Controller, } #[derive(Debug, Clone)] @@ -87,6 +89,7 @@ pub enum AppMsg { DoneFetchPost(GetPostResponse), OpenInbox, PopBackStack, + ShowAbout, } #[relm4::component] @@ -332,7 +335,8 @@ impl SimpleComponent for App { "Choose Instance" => ChangeInstanceAction, "Profile" => ProfileAction, "Login" => LoginAction, - "Logout" => LogoutAction + "Logout" => LogoutAction, + "About" => AboutAction } } @@ -366,6 +370,9 @@ impl SimpleComponent for App { .launch(()) .forward(sender.input_sender(), |msg| msg); let community_search_buffer = gtk::EntryBuffer::builder().build(); + let about_dialog = AboutDialog::builder() + .launch(root.toplevel_window().unwrap()) + .detach(); let model = App { state, @@ -383,6 +390,7 @@ impl SimpleComponent for App { current_communities_page: 1, current_posts_page: 1, community_search_buffer, + about_dialog, }; // fetch posts if that's the initial page @@ -420,12 +428,19 @@ impl SimpleComponent for App { let logout_action: RelmAction = RelmAction::new_stateless(move |_| { sender.input(AppMsg::Logout); }); + let about_action = { + let sender = model.about_dialog.sender().clone(); + RelmAction::::new_stateless(move |_| { + sender.send(()).unwrap_or_default(); + }) + }; let mut group = RelmActionGroup::::new(); group.add_action(instance_action); group.add_action(profile_action); group.add_action(login_action); group.add_action(logout_action); + group.add_action(about_action); group.register_for_widget(&widgets.main_window); ComponentParts { model, widgets } @@ -628,6 +643,7 @@ impl SimpleComponent for App { self.back_queue.remove(self.back_queue.len() - 1); } } + AppMsg::ShowAbout => {} } } } @@ -637,6 +653,7 @@ relm4::new_stateless_action!(ChangeInstanceAction, WindowActionGroup, "instance" relm4::new_stateless_action!(ProfileAction, WindowActionGroup, "profile"); relm4::new_stateless_action!(LoginAction, WindowActionGroup, "login"); relm4::new_stateless_action!(LogoutAction, WindowActionGroup, "logout"); +relm4::new_stateless_action!(AboutAction, WindowActionGroup, "about"); fn main() { let app = RelmApp::new(config::APP_ID); diff --git a/src/meson.build b/src/meson.build index 3a26732..c74c0eb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,6 @@ # Configuration file conf = configuration_data() +conf.set_quoted('NAME', meson.projet_name()) conf.set_quoted('APP_ID', application_id) conf.set_quoted('PKGDATADIR', pkgdatadir) conf.set_quoted('VERSION', version + version_suffix)