mirror of https://github.com/qarmin/czkawka
Add about dialog (#226)
parent
052590d246
commit
49ddc041ee
@ -0,0 +1,30 @@
|
|||||||
|
extern crate gtk;
|
||||||
|
use crate::gui_data::GuiData;
|
||||||
|
use gtk::prelude::*;
|
||||||
|
|
||||||
|
const SPONSOR_SITE: &str = "https://github.com/sponsors/qarmin";
|
||||||
|
const REPOSITORY_SITE: &str = "https://github.com/qarmin/czkawka";
|
||||||
|
const INSTRUCTION_SITE: &str = "https://github.com/qarmin/czkawka/blob/master/instructions/Instruction.md";
|
||||||
|
|
||||||
|
pub fn connect_about_buttons(gui_data: &GuiData) {
|
||||||
|
let button_donation = gui_data.about.button_donation.clone();
|
||||||
|
button_donation.connect_clicked(move |_| {
|
||||||
|
if open::that(SPONSOR_SITE).is_err() {
|
||||||
|
println!("Failed to open sponsor site: {}", SPONSOR_SITE)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
let button_instruction = gui_data.about.button_instruction.clone();
|
||||||
|
button_instruction.connect_clicked(move |_| {
|
||||||
|
if open::that(INSTRUCTION_SITE).is_err() {
|
||||||
|
println!("Failed to open instruction site: {}", INSTRUCTION_SITE)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
let button_repository = gui_data.about.button_repository.clone();
|
||||||
|
button_repository.connect_clicked(move |_| {
|
||||||
|
if open::that(REPOSITORY_SITE).is_err() {
|
||||||
|
println!("Failed to open repository site: {}", REPOSITORY_SITE)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
extern crate gtk;
|
||||||
|
use crate::gui_data::GuiData;
|
||||||
|
use gtk::prelude::*;
|
||||||
|
use gtk::{ResponseType, WindowPosition};
|
||||||
|
|
||||||
|
pub fn connect_button_about(gui_data: &GuiData) {
|
||||||
|
let about_dialog = gui_data.about.about_dialog.clone();
|
||||||
|
let button_app_info = gui_data.header.button_app_info.clone();
|
||||||
|
button_app_info.connect_clicked(move |_| {
|
||||||
|
about_dialog.set_position(WindowPosition::Center); // Not working
|
||||||
|
|
||||||
|
about_dialog.show();
|
||||||
|
let response = about_dialog.run();
|
||||||
|
if response != ResponseType::None {
|
||||||
|
about_dialog.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
use gtk::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct GUIAbout {
|
||||||
|
pub about_dialog: gtk::AboutDialog,
|
||||||
|
|
||||||
|
pub button_repository: gtk::Button,
|
||||||
|
pub button_donation: gtk::Button,
|
||||||
|
pub button_instruction: gtk::Button,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GUIAbout {
|
||||||
|
pub fn create_from_builder(builder: >k::Builder) -> Self {
|
||||||
|
let about_dialog: gtk::AboutDialog = builder.get_object("about_dialog").unwrap();
|
||||||
|
|
||||||
|
let button_repository: gtk::Button = builder.get_object("button_repository").unwrap();
|
||||||
|
let button_donation: gtk::Button = builder.get_object("button_donation").unwrap();
|
||||||
|
let button_instruction: gtk::Button = builder.get_object("button_instruction").unwrap();
|
||||||
|
|
||||||
|
Self {
|
||||||
|
about_dialog,
|
||||||
|
button_repository,
|
||||||
|
button_donation,
|
||||||
|
button_instruction,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
use gtk::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct GUIHeader {
|
||||||
|
pub button_settings: gtk::Button,
|
||||||
|
pub button_app_info: gtk::Button,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GUIHeader {
|
||||||
|
pub fn create_from_builder(builder: >k::Builder) -> Self {
|
||||||
|
let button_settings: gtk::Button = builder.get_object("button_settings").unwrap();
|
||||||
|
let button_app_info: gtk::Button = builder.get_object("button_app_info").unwrap();
|
||||||
|
Self { button_settings, button_app_info }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
#[derive(Clone)]
|
||||||
|
pub struct GUIOptions {}
|
||||||
|
|
||||||
|
impl GUIOptions {
|
||||||
|
pub fn create_from_builder(_builder: >k::Builder) -> Self {
|
||||||
|
// let notebook_main: gtk::Notebook = builder.get_object("notebook_main").unwrap();
|
||||||
|
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue