commit 7a6cc84448327a6f5510200cfc5ae13825c11d34
parent 59623e9bbebfab9b9741cfdcab422fc30a72bf06
Author: MTRNord <mtrnord1@gmail.com>
Date: Sun, 19 Feb 2023 23:14:07 +0100
Add about dialog and settings menu button
Diffstat:
4 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/build-aux/de.nordgedanken.Email.Devel.yaml b/build-aux/de.nordgedanken.Email.Devel.yaml
@@ -12,9 +12,9 @@ finish-args:
- --device=dri
- --share=network
- --socket=session-bus
- - --env=RUST_LOG=debug
- #- --env=RUST_LOG=mail_client=debug
- #- --env=G_MESSAGES_DEBUG=none
+ - --env=GTK_DEBUG=interactive
+ - --env=RUST_LOG=mail_client=debug
+ - --env=G_MESSAGES_DEBUG=none
- --env=RUST_BACKTRACE=1
build-options:
append-path: /usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm14/bin
diff --git a/data/dev.nordgedanken.Email.gresource.xml b/data/dev.nordgedanken.Email.gresource.xml
@@ -7,5 +7,6 @@
<gresource prefix="/dev/nordgedanken/Email/icons">
<file compressed="true" preprocess="xml-stripblanks" alias="mail-symbolic.svg">icons/mail-symbolic.svg</file>
<file compressed="true" preprocess="xml-stripblanks" alias="inbox-symbolic.svg">icons/inbox-symbolic.svg</file>
+ <file compressed="true" preprocess="xml-stripblanks" alias="settings-symbolic.svg">icons/settings-symbolic.svg</file>
</gresource>
</gresources>
\ No newline at end of file
diff --git a/data/icons/settings-symbolic.svg b/data/icons/settings-symbolic.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3.34 17a10.018 10.018 0 0 1-.978-2.326 3 3 0 0 0 .002-5.347A9.99 9.99 0 0 1 4.865 4.99a3 3 0 0 0 4.631-2.674 9.99 9.99 0 0 1 5.007.002 3 3 0 0 0 4.632 2.672c.579.59 1.093 1.261 1.525 2.01.433.749.757 1.53.978 2.326a3 3 0 0 0-.002 5.347 9.99 9.99 0 0 1-2.501 4.337 3 3 0 0 0-4.631 2.674 9.99 9.99 0 0 1-5.007-.002 3 3 0 0 0-4.632-2.672A10.018 10.018 0 0 1 3.34 17zm5.66.196a4.993 4.993 0 0 1 2.25 2.77c.499.047 1 .048 1.499.001A4.993 4.993 0 0 1 15 17.197a4.993 4.993 0 0 1 3.525-.565c.29-.408.54-.843.748-1.298A4.993 4.993 0 0 1 18 12c0-1.26.47-2.437 1.273-3.334a8.126 8.126 0 0 0-.75-1.298A4.993 4.993 0 0 1 15 6.804a4.993 4.993 0 0 1-2.25-2.77c-.499-.047-1-.048-1.499-.001A4.993 4.993 0 0 1 9 6.803a4.993 4.993 0 0 1-3.525.565 7.99 7.99 0 0 0-.748 1.298A4.993 4.993 0 0 1 6 12c0 1.26-.47 2.437-1.273 3.334a8.126 8.126 0 0 0 .75 1.298A4.993 4.993 0 0 1 9 17.196zM12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" fill="rgba(0,0,0,1)"/></svg>
+\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
@@ -1,5 +1,6 @@
use folder_view::MailboxesView;
use gtk::{gdk::Display, gio, prelude::*, Application};
+use relm4::actions::{RelmAction, RelmActionGroup};
use relm4::prelude::*;
use std::convert::identity;
@@ -10,6 +11,20 @@ mod config;
mod folder_view;
+pub fn show_about_dialog(window: >k::ApplicationWindow) {
+ gtk::show_about_dialog(
+ Some(window),
+ &[
+ ("authors", &vec![String::from("MTRNord")]),
+ ("website-label", &"Github repository"),
+ ("website", &"https://github.com/erooster-mail/email-client"),
+ ("comments", &"A Rust GTK4 email client"),
+ ("copyright", &"Licensed AGPL-v3.0-or-later license"),
+ ("program-name", &"Email Client"),
+ ],
+ );
+}
+
struct App {
mailboxes: Controller<MailboxesView>,
}
@@ -25,7 +40,8 @@ impl Component for App {
type CommandOutput = Msg;
view! {
- gtk::ApplicationWindow {
+ #[root]
+ main_window = gtk::ApplicationWindow {
set_title: Some("Email"),
set_default_size: (1280, 720),
@@ -46,6 +62,15 @@ impl Component for App {
gtk::Button {
set_margin_all: 8,
set_label: "Write"
+ },
+
+ gtk::MenuButton {
+ set_margin_all: 8,
+ set_halign: gtk::Align::End,
+ set_hexpand: true,
+ set_icon_name: "settings-symbolic",
+ #[wrap(Some)]
+ set_popover = >k::PopoverMenu::from_model(Some(&settings_menu)) {},
}
},
@@ -97,6 +122,13 @@ impl Component for App {
}
}
+ // Settingsmenu
+ menu! {
+ settings_menu: {
+ "About" => AboutAction,
+ }
+ }
+
fn init(
_: Self::Init,
root: &Self::Root,
@@ -118,6 +150,21 @@ impl Component for App {
let model = App { mailboxes };
let widgets = view_output!();
+ let group = RelmActionGroup::<WindowActionGroup>::new();
+ let weak_main_window = widgets.main_window.downgrade();
+ let action: RelmAction<AboutAction> = {
+ RelmAction::new_stateless(move |_| {
+ let main_window = weak_main_window.upgrade().unwrap();
+ show_about_dialog(&main_window);
+ })
+ };
+ group.add_action(&action);
+
+ let actions = group.into_action_group();
+ widgets
+ .main_window
+ .insert_action_group("win", Some(&actions));
+
ComponentParts { model, widgets }
}
}
@@ -160,3 +207,6 @@ fn load_css() {
);
}
}
+
+relm4::new_action_group!(WindowActionGroup, "win");
+relm4::new_stateless_action!(AboutAction, WindowActionGroup, "about");