About Dialog
This commit is contained in:
parent
4f9c65a3cf
commit
9b5fd6dd9b
|
@ -1,8 +1,10 @@
|
|||
use gdk4::gdk_pixbuf::Pixbuf;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::{Builder, Window};
|
||||
use gtk4::ImageType::Paintable;
|
||||
use gtk4::{Builder, Button, Orientation, Picture, Window};
|
||||
|
||||
use crate::flg;
|
||||
use crate::help_functions::{debug_print_widget, get_all_boxes_from_widget, get_custom_box_from_widget};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GuiAbout {
|
||||
|
@ -23,11 +25,11 @@ impl GuiAbout {
|
|||
about_dialog.set_modal(true);
|
||||
about_dialog.set_transient_for(Some(window_main));
|
||||
|
||||
// about_dialog.set_logo(Some(logo)); // TODO GTK 4
|
||||
about_dialog.set_logo(Picture::for_pixbuf(logo).paintable().as_ref());
|
||||
|
||||
// Taken from command - "git shortlog -s -n -e" - remember to remove duplicates
|
||||
// This should be updated only before releasing new version
|
||||
about_dialog.set_authors(&vec![
|
||||
about_dialog.set_authors(&[
|
||||
"Rafał Mikrut",
|
||||
"Alexis Lefebvre",
|
||||
"Thomas Andreas Jung",
|
||||
|
@ -73,10 +75,20 @@ impl GuiAbout {
|
|||
"tenninjas",
|
||||
]);
|
||||
|
||||
let button_repository: gtk4::Button = builder.object("button_repository").unwrap();
|
||||
let button_donation: gtk4::Button = builder.object("button_donation").unwrap();
|
||||
let button_instruction: gtk4::Button = builder.object("button_instruction").unwrap();
|
||||
let button_translation: gtk4::Button = builder.object("button_translation").unwrap();
|
||||
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);
|
||||
|
||||
Self {
|
||||
about_dialog,
|
||||
|
@ -86,6 +98,7 @@ impl GuiAbout {
|
|||
button_translation,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_language(&self) {
|
||||
let mut comment_text: String = "2020 - 2022 Rafał Mikrut(qarmin)\n\n".to_string();
|
||||
comment_text += &flg!("about_window_motto");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use gtk4::prelude::*;
|
||||
use gtk4::Widget;
|
||||
|
||||
use crate::help_functions::{get_custom_label_from_button_with_image, set_icon_of_button, BottomButtonsEnum};
|
||||
use crate::help_functions::{get_custom_label_from_widget, set_icon_of_button, BottomButtonsEnum};
|
||||
use crate::{
|
||||
flg, CZK_ICON_COMPARE, CZK_ICON_HARDLINK, CZK_ICON_HIDE_DOWN, CZK_ICON_HIDE_UP, CZK_ICON_MOVE, CZK_ICON_SAVE, CZK_ICON_SEARCH, CZK_ICON_SELECT, CZK_ICON_SYMLINK,
|
||||
CZK_ICON_TRASH,
|
||||
|
@ -87,13 +87,13 @@ impl GuiBottomButtons {
|
|||
}
|
||||
}
|
||||
pub fn update_language(&self) {
|
||||
get_custom_label_from_button_with_image(&self.buttons_search.clone()).set_text(&flg!("bottom_search_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_select.clone()).set_text(&flg!("bottom_select_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_delete.clone()).set_text(&flg!("bottom_delete_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_save.clone()).set_text(&flg!("bottom_save_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_symlink.clone()).set_text(&flg!("bottom_symlink_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_hardlink.clone()).set_text(&flg!("bottom_hardlink_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_move.clone()).set_text(&flg!("bottom_move_button"));
|
||||
get_custom_label_from_widget(&self.buttons_search.clone()).set_text(&flg!("bottom_search_button"));
|
||||
get_custom_label_from_widget(&self.buttons_select.clone()).set_text(&flg!("bottom_select_button"));
|
||||
get_custom_label_from_widget(&self.buttons_delete.clone()).set_text(&flg!("bottom_delete_button"));
|
||||
get_custom_label_from_widget(&self.buttons_save.clone()).set_text(&flg!("bottom_save_button"));
|
||||
get_custom_label_from_widget(&self.buttons_symlink.clone()).set_text(&flg!("bottom_symlink_button"));
|
||||
get_custom_label_from_widget(&self.buttons_hardlink.clone()).set_text(&flg!("bottom_hardlink_button"));
|
||||
get_custom_label_from_widget(&self.buttons_move.clone()).set_text(&flg!("bottom_move_button"));
|
||||
|
||||
self.buttons_search.set_tooltip_text(Some(&flg!("bottom_search_button_tooltip")));
|
||||
self.buttons_select.set_tooltip_text(Some(&flg!("bottom_select_button_tooltip")));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use gtk4::prelude::*;
|
||||
use gtk4::{Builder, EventControllerKey, Window};
|
||||
|
||||
use crate::help_functions::{get_custom_label_from_button_with_image, set_icon_of_button};
|
||||
use crate::help_functions::{get_custom_label_from_widget, set_icon_of_button};
|
||||
use crate::{flg, CZK_ICON_STOP};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -65,7 +65,7 @@ impl GuiProgressDialog {
|
|||
pub fn update_language(&self) {
|
||||
self.window_progress.set_title(Some(&flg!("window_progress_title")));
|
||||
|
||||
get_custom_label_from_button_with_image(&self.button_stop_in_dialog.clone()).set_text(&flg!("progress_stop_button"));
|
||||
get_custom_label_from_widget(&self.button_stop_in_dialog.clone()).set_text(&flg!("progress_stop_button"));
|
||||
|
||||
self.label_progress_current_stage.set_label(&flg!("progress_current_stage"));
|
||||
self.label_progress_all_stages.set_label(&flg!("progress_all_stages"));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use gtk4::prelude::*;
|
||||
use gtk4::{EventControllerKey, GestureClick, TreeView};
|
||||
|
||||
use crate::help_functions::{get_all_children, get_custom_label_from_button_with_image, set_icon_of_button};
|
||||
use crate::help_functions::{get_all_children, get_custom_label_from_widget, set_icon_of_button};
|
||||
use crate::notebook_enums::NotebookUpperEnum;
|
||||
use crate::{flg, CZK_ICON_ADD, CZK_ICON_DELETE, CZK_ICON_MANUAL_ADD};
|
||||
|
||||
|
@ -123,12 +123,12 @@ impl GuiUpperNotebook {
|
|||
self.check_button_recursive.set_label(Some(&flg!("upper_recursive_button")));
|
||||
self.check_button_recursive.set_tooltip_text(Some(&flg!("upper_recursive_button_tooltip")));
|
||||
|
||||
get_custom_label_from_button_with_image(&self.buttons_manual_add_included_directory.clone()).set_text(&flg!("upper_manual_add_included_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_add_included_directory.clone()).set_text(&flg!("upper_add_included_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_remove_included_directory.clone()).set_text(&flg!("upper_remove_included_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_manual_add_excluded_directory.clone()).set_text(&flg!("upper_manual_add_excluded_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_add_excluded_directory.clone()).set_text(&flg!("upper_add_excluded_button"));
|
||||
get_custom_label_from_button_with_image(&self.buttons_remove_excluded_directory.clone()).set_text(&flg!("upper_remove_excluded_button"));
|
||||
get_custom_label_from_widget(&self.buttons_manual_add_included_directory.clone()).set_text(&flg!("upper_manual_add_included_button"));
|
||||
get_custom_label_from_widget(&self.buttons_add_included_directory.clone()).set_text(&flg!("upper_add_included_button"));
|
||||
get_custom_label_from_widget(&self.buttons_remove_included_directory.clone()).set_text(&flg!("upper_remove_included_button"));
|
||||
get_custom_label_from_widget(&self.buttons_manual_add_excluded_directory.clone()).set_text(&flg!("upper_manual_add_excluded_button"));
|
||||
get_custom_label_from_widget(&self.buttons_add_excluded_directory.clone()).set_text(&flg!("upper_add_excluded_button"));
|
||||
get_custom_label_from_widget(&self.buttons_remove_excluded_directory.clone()).set_text(&flg!("upper_remove_excluded_button"));
|
||||
|
||||
self.buttons_manual_add_included_directory
|
||||
.set_tooltip_text(Some(&flg!("upper_manual_add_included_button_tooltip")));
|
||||
|
|
|
@ -39,8 +39,6 @@ pub const KEY_SPACE: u32 = 65;
|
|||
// pub const KEY_HOME: u32 = 115;
|
||||
// pub const KEY_END: u32 = 110;
|
||||
|
||||
pub const CHECK_GTK_EVENTS_INTERVAL: usize = 100;
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
pub enum PopoverTypes {
|
||||
All,
|
||||
|
@ -780,24 +778,9 @@ pub fn get_max_file_name(file_name: &str, max_length: usize) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
// pub fn get_custom_image_from_button_with_image(button: >k4::Button) -> gtk4::Image {
|
||||
// let internal_box = match button.child().unwrap().downcast::<gtk4::Box>() {
|
||||
// Ok(t) => t,
|
||||
// Err(wid) => {
|
||||
// return wid.downcast::<gtk4::Image>().unwrap();
|
||||
// }
|
||||
// };
|
||||
// for child in internal_box.children() {
|
||||
// if let Ok(t) = child.downcast::<gtk4::Image>() {
|
||||
// return t;
|
||||
// }
|
||||
// }
|
||||
// panic!("Button doesn't have proper custom label child");
|
||||
// }
|
||||
|
||||
// GTK 4
|
||||
pub fn get_custom_label_from_button_with_image<P: IsA<gtk4::Widget>>(button: &P) -> gtk4::Label {
|
||||
let mut widgets_to_check = vec![button.clone().upcast::<gtk4::Widget>()];
|
||||
pub fn get_custom_label_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> gtk4::Label {
|
||||
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];
|
||||
|
||||
while let Some(widget) = widgets_to_check.pop() {
|
||||
if let Ok(label) = widget.clone().downcast::<gtk4::Label>() {
|
||||
|
@ -808,8 +791,8 @@ pub fn get_custom_label_from_button_with_image<P: IsA<gtk4::Widget>>(button: &P)
|
|||
}
|
||||
panic!("Button doesn't have proper custom label child");
|
||||
}
|
||||
pub fn get_custom_image_from_button_with_image<P: IsA<gtk4::Widget>>(button: &P) -> gtk4::Image {
|
||||
let mut widgets_to_check = vec![button.clone().upcast::<gtk4::Widget>()];
|
||||
pub fn get_custom_image_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> gtk4::Image {
|
||||
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];
|
||||
|
||||
while let Some(widget) = widgets_to_check.pop() {
|
||||
if let Ok(image) = widget.clone().downcast::<gtk4::Image>() {
|
||||
|
@ -820,6 +803,45 @@ pub fn get_custom_image_from_button_with_image<P: IsA<gtk4::Widget>>(button: &P)
|
|||
}
|
||||
panic!("Button doesn't have proper custom label child");
|
||||
}
|
||||
pub fn get_custom_box_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> gtk4::Box {
|
||||
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];
|
||||
|
||||
while let Some(widget) = widgets_to_check.pop() {
|
||||
if let Ok(bbox) = widget.clone().downcast::<gtk4::Box>() {
|
||||
return bbox;
|
||||
} else {
|
||||
widgets_to_check.extend(get_all_children(&widget));
|
||||
}
|
||||
}
|
||||
panic!("Button doesn't have proper custom label child");
|
||||
}
|
||||
|
||||
pub fn debug_print_widget<P: IsA<gtk4::Widget>>(item: &P) {
|
||||
let mut widgets_to_check = vec![(0, 0, item.clone().upcast::<gtk4::Widget>())];
|
||||
|
||||
let mut next_free_number = 1;
|
||||
println!("{}, {}, {:?} ", widgets_to_check[0].0, widgets_to_check[0].1, widgets_to_check[0].2);
|
||||
|
||||
while let Some((current_number, parent_number, widget)) = widgets_to_check.pop() {
|
||||
for widget in get_all_children(&widget) {
|
||||
widgets_to_check.push((next_free_number, current_number, widget));
|
||||
next_free_number += 1;
|
||||
}
|
||||
println!("{}, {}, {:?} ", current_number, parent_number, widget);
|
||||
}
|
||||
}
|
||||
pub fn get_all_boxes_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> Vec<gtk4::Box> {
|
||||
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];
|
||||
let mut boxes = Vec::new();
|
||||
|
||||
while let Some(widget) = widgets_to_check.pop() {
|
||||
widgets_to_check.extend(get_all_children(&widget));
|
||||
if let Ok(bbox) = widget.clone().downcast::<gtk4::Box>() {
|
||||
boxes.push(bbox);
|
||||
}
|
||||
}
|
||||
boxes
|
||||
}
|
||||
|
||||
// GTK 4
|
||||
pub fn get_all_children<P: IsA<gtk4::Widget>>(wid: &P) -> Vec<gtk4::Widget> {
|
||||
|
@ -835,14 +857,14 @@ pub fn get_all_children<P: IsA<gtk4::Widget>>(wid: &P) -> Vec<gtk4::Widget> {
|
|||
}
|
||||
}
|
||||
|
||||
return vector;
|
||||
vector
|
||||
}
|
||||
|
||||
const SIZE_OF_ICON: i32 = 18;
|
||||
const TYPE_OF_INTERPOLATION: InterpType = InterpType::Tiles;
|
||||
|
||||
pub fn set_icon_of_button<P: IsA<gtk4::Widget>>(button: &P, data: &'static [u8]) {
|
||||
let image = get_custom_image_from_button_with_image(&button.clone());
|
||||
let image = get_custom_image_from_widget(&button.clone());
|
||||
let pixbuf = Pixbuf::from_read(std::io::BufReader::new(data)).unwrap();
|
||||
let pixbuf = pixbuf.scale_simple(SIZE_OF_ICON, SIZE_OF_ICON, TYPE_OF_INTERPOLATION).unwrap();
|
||||
image.set_from_pixbuf(Some(&pixbuf));
|
||||
|
|
|
@ -507,11 +507,6 @@ pub fn initialize_gui(gui_data: &mut GuiData) {
|
|||
}
|
||||
|
||||
fn connect_event_mouse(gui_data: &GuiData) {
|
||||
for tree_view in gui_data.main_notebook.get_main_tree_views() {
|
||||
// tree_view.connect_button_press_event(opening_double_click_function); // TODO GTK 4
|
||||
// tree_view.connect_button_release_event(opening_middle_mouse_function); // TODO GTK 4
|
||||
}
|
||||
|
||||
// GTK 4
|
||||
for gc in [
|
||||
gui_data.main_notebook.gc_tree_view_duplicate_finder.clone(),
|
||||
|
@ -528,6 +523,7 @@ fn connect_event_mouse(gui_data: &GuiData) {
|
|||
] {
|
||||
gc.set_button(0);
|
||||
gc.connect_pressed(opening_double_click_function);
|
||||
// tree_view.connect_button_release_event(opening_middle_mouse_function); // TODO GTK 4
|
||||
}
|
||||
|
||||
// Duplicate
|
||||
|
|
|
@ -12,59 +12,5 @@ This program is free to use and will always be.
|
|||
<property name="logo-icon-name">help-about-symbolic</property>
|
||||
<property name="program-name">Czkawka</property>
|
||||
<property name="version">4.1.0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<property name="visible">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="margin-bottom">3</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_repository">
|
||||
<property name="focusable">1</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="label" translatable="yes">Repository</property>
|
||||
<property name="receives-default">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_instruction">
|
||||
<property name="focusable">1</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="label" translatable="yes">Instruction</property>
|
||||
<property name="receives-default">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_donation">
|
||||
<property name="focusable">1</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="label" translatable="yes">Donation</property>
|
||||
<property name="receives-default">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_translation">
|
||||
<property name="focusable">1</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="label" translatable="yes">Translation</property>
|
||||
<property name="receives-default">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
Loading…
Reference in a new issue