Skip to content

Commit

Permalink
implement AboutDialog as trait
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Feb 5, 2025
1 parent 6f52d19 commit 00877ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/app/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use widget::Widget;
use window::Window;

use crate::Profile;
use adw::{prelude::AdwDialogExt, AboutDialog};
use gtk::{
gio::{Cancellable, File},
prelude::{GtkWindowExt, IsA},
Expand Down Expand Up @@ -59,7 +60,7 @@ impl Browser {
// Connect events
action.about.connect_activate({
let window = window.clone();
move || About::new().present(Some(&window.g_box))
move || AboutDialog::about().present(Some(&window.g_box))
});

action.close.connect_activate({
Expand Down
34 changes: 7 additions & 27 deletions src/app/browser/about.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
use adw::{prelude::AdwDialogExt, AboutDialog};
use gtk::{prelude::IsA, License};

pub struct About {
gobject: AboutDialog,
}

impl Default for About {
fn default() -> Self {
Self::new()
}
pub trait About {
fn about() -> Self;
}

impl About {
// Construct
pub fn new() -> Self {
// Collect debug info
impl About for adw::AboutDialog {
fn about() -> Self {
let debug = &[
format!(
"Adwaita {}.{}.{}",
Expand All @@ -38,22 +27,13 @@ impl About {
// @TODO
];

// Init gobject
let gobject = AboutDialog::builder()
adw::AboutDialog::builder()
.application_name(env!("CARGO_PKG_NAME"))
.debug_info(debug.join("\n"))
.developer_name(env!("CARGO_PKG_DESCRIPTION"))
.issue_url(env!("CARGO_PKG_REPOSITORY"))
.license_type(License::MitX11)
.license_type(gtk::License::MitX11)
.version(env!("CARGO_PKG_VERSION"))
.build();

// Return new struct
Self { gobject }
}

// Actions
pub fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
self.gobject.present(parent);
.build()
}
}

0 comments on commit 00877ee

Please sign in to comment.