Add an about dialog and meson fixes
This commit is contained in:
parent
8e019361f4
commit
eb8a01c27e
|
@ -6,7 +6,7 @@ desktop_conf.set('EXEC', meson.project_name())
|
||||||
|
|
||||||
# Desktop file
|
# Desktop file
|
||||||
configure_file(
|
configure_file(
|
||||||
input: '@0@.desktop.in'.format(application_id),
|
input: '@0@.desktop.in'.format(base_id),
|
||||||
output: '@BASENAME@',
|
output: '@BASENAME@',
|
||||||
install: true,
|
install: true,
|
||||||
configuration: desktop_conf,
|
configuration: desktop_conf,
|
||||||
|
|
|
@ -8,6 +8,7 @@ project(
|
||||||
|
|
||||||
gnome = import('gnome')
|
gnome = import('gnome')
|
||||||
|
|
||||||
|
# application_id can contain the -devel extension
|
||||||
base_id = 'com.lemmygtk.lemoa'
|
base_id = 'com.lemmygtk.lemoa'
|
||||||
version = meson.project_version()
|
version = meson.project_version()
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
pub const APP_ID: &str = "com.lemmygtk.lemoa";
|
pub const NAME: &str = "lemoa";
|
||||||
pub const PKGDATADIR: &str = "/usr/local/share/lemoa";
|
pub const APP_ID: &str = "com.lemmygtk.lemoa.Devel";
|
||||||
pub const VERSION: &str = "0.1.0";
|
pub const PKGDATADIR: &str = "/app/share/lemoa";
|
||||||
|
pub const VERSION: &str = "0.1.0-8e019361";
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
pub const NAME: &str = @NAME@;
|
||||||
pub const APP_ID: &str = @APP_ID@;
|
pub const APP_ID: &str = @APP_ID@;
|
||||||
pub const PKGDATADIR: &str = @PKGDATADIR@;
|
pub const PKGDATADIR: &str = @PKGDATADIR@;
|
||||||
pub const VERSION: &str = @VERSION@;
|
pub const VERSION: &str = @VERSION@;
|
||||||
|
|
|
@ -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<Self>,
|
||||||
|
) -> ComponentParts<Self> {
|
||||||
|
let model = Self {};
|
||||||
|
|
||||||
|
let widgets = Widgets { main_window };
|
||||||
|
|
||||||
|
ComponentParts { model, widgets }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_view(&self, widgets: &mut Self::Widgets, _sender: ComponentSender<Self>) {
|
||||||
|
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 <bnyro@tutanota.com>"])
|
||||||
|
.build();
|
||||||
|
dialog.present();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1,2 @@
|
||||||
|
pub mod about;
|
||||||
pub mod editor;
|
pub mod editor;
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -14,6 +14,7 @@ use components::{
|
||||||
post_row::PostRow,
|
post_row::PostRow,
|
||||||
profile_page::{self, ProfilePage},
|
profile_page::{self, ProfilePage},
|
||||||
};
|
};
|
||||||
|
use dialogs::about::AboutDialog;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::GetCommunityResponse,
|
community::GetCommunityResponse,
|
||||||
|
@ -64,6 +65,7 @@ struct App {
|
||||||
current_communities_page: i64,
|
current_communities_page: i64,
|
||||||
current_posts_page: i64,
|
current_posts_page: i64,
|
||||||
community_search_buffer: gtk::EntryBuffer,
|
community_search_buffer: gtk::EntryBuffer,
|
||||||
|
about_dialog: Controller<AboutDialog>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -87,6 +89,7 @@ pub enum AppMsg {
|
||||||
DoneFetchPost(GetPostResponse),
|
DoneFetchPost(GetPostResponse),
|
||||||
OpenInbox,
|
OpenInbox,
|
||||||
PopBackStack,
|
PopBackStack,
|
||||||
|
ShowAbout,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[relm4::component]
|
#[relm4::component]
|
||||||
|
@ -332,7 +335,8 @@ impl SimpleComponent for App {
|
||||||
"Choose Instance" => ChangeInstanceAction,
|
"Choose Instance" => ChangeInstanceAction,
|
||||||
"Profile" => ProfileAction,
|
"Profile" => ProfileAction,
|
||||||
"Login" => LoginAction,
|
"Login" => LoginAction,
|
||||||
"Logout" => LogoutAction
|
"Logout" => LogoutAction,
|
||||||
|
"About" => AboutAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,6 +370,9 @@ impl SimpleComponent for App {
|
||||||
.launch(())
|
.launch(())
|
||||||
.forward(sender.input_sender(), |msg| msg);
|
.forward(sender.input_sender(), |msg| msg);
|
||||||
let community_search_buffer = gtk::EntryBuffer::builder().build();
|
let community_search_buffer = gtk::EntryBuffer::builder().build();
|
||||||
|
let about_dialog = AboutDialog::builder()
|
||||||
|
.launch(root.toplevel_window().unwrap())
|
||||||
|
.detach();
|
||||||
|
|
||||||
let model = App {
|
let model = App {
|
||||||
state,
|
state,
|
||||||
|
@ -383,6 +390,7 @@ impl SimpleComponent for App {
|
||||||
current_communities_page: 1,
|
current_communities_page: 1,
|
||||||
current_posts_page: 1,
|
current_posts_page: 1,
|
||||||
community_search_buffer,
|
community_search_buffer,
|
||||||
|
about_dialog,
|
||||||
};
|
};
|
||||||
|
|
||||||
// fetch posts if that's the initial page
|
// fetch posts if that's the initial page
|
||||||
|
@ -420,12 +428,19 @@ impl SimpleComponent for App {
|
||||||
let logout_action: RelmAction<LogoutAction> = RelmAction::new_stateless(move |_| {
|
let logout_action: RelmAction<LogoutAction> = RelmAction::new_stateless(move |_| {
|
||||||
sender.input(AppMsg::Logout);
|
sender.input(AppMsg::Logout);
|
||||||
});
|
});
|
||||||
|
let about_action = {
|
||||||
|
let sender = model.about_dialog.sender().clone();
|
||||||
|
RelmAction::<AboutAction>::new_stateless(move |_| {
|
||||||
|
sender.send(()).unwrap_or_default();
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
let mut group = RelmActionGroup::<WindowActionGroup>::new();
|
let mut group = RelmActionGroup::<WindowActionGroup>::new();
|
||||||
group.add_action(instance_action);
|
group.add_action(instance_action);
|
||||||
group.add_action(profile_action);
|
group.add_action(profile_action);
|
||||||
group.add_action(login_action);
|
group.add_action(login_action);
|
||||||
group.add_action(logout_action);
|
group.add_action(logout_action);
|
||||||
|
group.add_action(about_action);
|
||||||
group.register_for_widget(&widgets.main_window);
|
group.register_for_widget(&widgets.main_window);
|
||||||
|
|
||||||
ComponentParts { model, widgets }
|
ComponentParts { model, widgets }
|
||||||
|
@ -628,6 +643,7 @@ impl SimpleComponent for App {
|
||||||
self.back_queue.remove(self.back_queue.len() - 1);
|
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!(ProfileAction, WindowActionGroup, "profile");
|
||||||
relm4::new_stateless_action!(LoginAction, WindowActionGroup, "login");
|
relm4::new_stateless_action!(LoginAction, WindowActionGroup, "login");
|
||||||
relm4::new_stateless_action!(LogoutAction, WindowActionGroup, "logout");
|
relm4::new_stateless_action!(LogoutAction, WindowActionGroup, "logout");
|
||||||
|
relm4::new_stateless_action!(AboutAction, WindowActionGroup, "about");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let app = RelmApp::new(config::APP_ID);
|
let app = RelmApp::new(config::APP_ID);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Configuration file
|
# Configuration file
|
||||||
conf = configuration_data()
|
conf = configuration_data()
|
||||||
|
conf.set_quoted('NAME', meson.projet_name())
|
||||||
conf.set_quoted('APP_ID', application_id)
|
conf.set_quoted('APP_ID', application_id)
|
||||||
conf.set_quoted('PKGDATADIR', pkgdatadir)
|
conf.set_quoted('PKGDATADIR', pkgdatadir)
|
||||||
conf.set_quoted('VERSION', version + version_suffix)
|
conf.set_quoted('VERSION', version + version_suffix)
|
||||||
|
|
Loading…
Reference in New Issue