1
0
Fork 0
mirror of synced 2024-05-15 01:42:27 +12:00
czkawka/czkawka_gui/src/gui_structs/gui_about.rs

117 lines
4 KiB
Rust
Raw Normal View History

2022-05-22 20:59:09 +12:00
use gdk4::gdk_pixbuf::Pixbuf;
use gtk4::prelude::*;
use gtk4::{Builder, Button, Orientation, Picture, Window};
2021-01-25 00:01:02 +13:00
use crate::flg;
2022-05-22 20:59:09 +12:00
use crate::help_functions::get_all_boxes_from_widget;
2021-01-25 00:01:02 +13:00
#[derive(Clone)]
2021-03-28 01:14:02 +13:00
pub struct GuiAbout {
2022-05-22 20:59:09 +12:00
pub about_dialog: gtk4::AboutDialog,
2021-01-25 00:01:02 +13:00
2022-06-01 03:52:55 +12:00
pub button_repository: Button,
pub button_donation: Button,
pub button_instruction: Button,
pub button_translation: Button,
2021-01-25 00:01:02 +13:00
}
2021-03-28 01:14:02 +13:00
impl GuiAbout {
2022-01-04 09:02:56 +13:00
pub fn create_from_builder(window_main: &Window, logo: &Pixbuf) -> Self {
let glade_src = include_str!("../../ui/about_dialog.ui").to_string();
2021-07-08 07:13:36 +12:00
let builder = Builder::from_string(glade_src.as_str());
2022-05-22 20:59:09 +12:00
let about_dialog: gtk4::AboutDialog = builder.object("about_dialog").unwrap();
about_dialog.set_modal(true);
about_dialog.set_transient_for(Some(window_main));
2021-01-25 00:01:02 +13:00
2022-05-22 20:59:09 +12:00
about_dialog.set_logo(Picture::for_pixbuf(logo).paintable().as_ref());
2022-01-04 09:02:56 +13:00
2022-01-04 07:14:37 +13:00
// Taken from command - "git shortlog -s -n -e" - remember to remove duplicates
// This should be updated only before releasing new version
2022-05-22 20:59:09 +12:00
about_dialog.set_authors(&[
2022-01-04 07:14:37 +13:00
"Rafał Mikrut",
"Alexis Lefebvre",
"Thomas Andreas Jung",
"Peter Blackson",
"TheEvilSkeleton",
2022-01-04 07:14:37 +13:00
"Ben Bodenmiller",
"Dan Dascalescu",
"Igor",
"Kerfuffle",
2022-01-04 07:14:37 +13:00
"Shriraj Hegde",
"krzysdz",
"0xflotus",
"Adam Boguszewski",
"Caduser2020",
"ChihWei Wang",
2022-01-04 07:14:37 +13:00
"Danny Kirkham",
"Dariusz Niedoba",
"Douman",
"Elazar Fine",
"Farmadupe",
"Gitoffthelawn",
"Ivan Habernal",
2022-01-04 07:14:37 +13:00
"Jan Jurec",
"Jona",
"Jonathan Hult",
2022-01-04 07:14:37 +13:00
"Meir Klemfner",
"Mek101",
"Michael Grigoryan",
"Nikita Karamov",
"Sbgodin",
"Spirit",
"Stefan Seering",
"Syfaro",
"Yuri Slobodyanyuk",
"bakeromso",
2022-01-04 07:14:37 +13:00
"bellrise",
"cyqsimon",
2022-01-04 07:14:37 +13:00
"endolith",
"jann",
"kamilek96",
"kuskov",
"tecome",
"tenninjas",
]);
2022-05-22 20:59:09 +12:00
let custom_box = get_all_boxes_from_widget(&about_dialog)[2].clone(); // TODO may not be stable enough between GTK versions
let new_box = gtk4::Box::new(Orientation::Horizontal, 5);
let button_repository = Button::builder().label("Repository").build();
let button_donation = Button::builder().label("Donation").build();
let button_instruction = Button::builder().label("Instruction").build();
let button_translation = Button::builder().label("Translation").build();
new_box.append(&button_repository);
new_box.append(&button_donation);
new_box.append(&button_instruction);
new_box.append(&button_translation);
custom_box.append(&new_box);
2021-01-25 00:01:02 +13:00
Self {
about_dialog,
button_repository,
button_donation,
button_instruction,
2021-12-27 18:11:45 +13:00
button_translation,
2021-01-25 00:01:02 +13:00
}
}
2022-05-22 20:59:09 +12:00
pub fn update_language(&self) {
2022-01-04 07:14:37 +13:00
let mut comment_text: String = "2020 - 2022 Rafał Mikrut(qarmin)\n\n".to_string();
comment_text += &flg!("about_window_motto");
self.about_dialog.set_comments(Some(&comment_text));
self.button_repository.set_tooltip_text(Some(&flg!("about_repository_button_tooltip")));
self.button_donation.set_tooltip_text(Some(&flg!("about_donation_button_tooltip")));
self.button_instruction.set_tooltip_text(Some(&flg!("about_instruction_button_tooltip")));
self.button_translation.set_tooltip_text(Some(&flg!("about_translation_button_tooltip")));
self.button_repository.set_label(&flg!("about_repository_button"));
self.button_donation.set_label(&flg!("about_donation_button"));
self.button_instruction.set_label(&flg!("about_instruction_button"));
self.button_translation.set_label(&flg!("about_translation_button"));
}
2021-01-25 00:01:02 +13:00
}