Add application about dialog

This commit is contained in:
burnintuna 2026-07-22 03:17:18 +09:00
parent 1b3783b795
commit b139395067

View file

@ -49,6 +49,8 @@ impl ComicWindow {
let header = gtk::HeaderBar::new();
header.set_title_widget(Some(&gtk::Label::new(Some("Comicviewer"))));
let about_button = gtk::Button::with_label("정보");
header.pack_end(&about_button);
window.set_titlebar(Some(&header));
let root = gtk::Box::new(gtk::Orientation::Vertical, 8);
@ -125,6 +127,7 @@ impl ComicWindow {
let controller = Rc::new(BrowserController {
window,
about_button,
location_dropdown,
edit_location_button,
delete_location_button,
@ -189,6 +192,7 @@ struct BrowserState {
struct BrowserController {
window: gtk::ApplicationWindow,
about_button: gtk::Button,
location_dropdown: gtk::DropDown,
edit_location_button: gtk::Button,
delete_location_button: gtk::Button,
@ -227,6 +231,9 @@ impl BrowserController {
let controller = Rc::clone(self);
add_location_button.connect_clicked(move |_| controller.show_location_dialog(None));
let controller = Rc::clone(self);
self.about_button
.connect_clicked(move |_| controller.show_about_dialog());
let controller = Rc::clone(self);
self.edit_location_button.connect_clicked(move |_| {
if let Some(index) = controller.selected_config_index() {
controller.show_location_dialog(Some(index));
@ -1153,6 +1160,36 @@ impl BrowserController {
(index < self.config.borrow().locations.len()).then_some(index)
}
fn show_about_dialog(&self) {
let dialog = gtk::Window::builder()
.title("Comicviewer 정보")
.transient_for(&self.window)
.modal(true)
.resizable(false)
.default_width(360)
.build();
let content = gtk::Box::new(gtk::Orientation::Vertical, 14);
content.set_margin_top(24);
content.set_margin_bottom(16);
content.set_margin_start(24);
content.set_margin_end(24);
let name = gtk::Label::new(Some(&format!(
"Comicviewer ({})",
env!("CARGO_PKG_VERSION")
)));
name.add_css_class("title-2");
let contact = gtk::Label::new(Some("개발자 연락처 : burningtuna@gmail.com"));
let close_button = gtk::Button::with_label("닫기");
close_button.set_halign(gtk::Align::End);
let dialog_to_close = dialog.clone();
close_button.connect_clicked(move |_| dialog_to_close.close());
content.append(&name);
content.append(&contact);
content.append(&close_button);
dialog.set_child(Some(&content));
dialog.present();
}
fn show_location_dialog(self: &Rc<Self>, edit_index: Option<usize>) {
let existing =
edit_index.and_then(|index| self.config.borrow().locations.get(index).cloned());