Compare commits

...

5 Commits

21 changed files with 80 additions and 77 deletions

View File

@ -9,5 +9,5 @@ edition = "2021"
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
bitvec = "1.0.1"
gio = { version = "0.20.0", features = ["v2_74"] }
gtk4 = { version = "0.9.0", features = ["v4_12"] }
gtk = { version = "0.9.0", package = "gtk4", features = ["v4_12"] }
tokio = { version = "1.39.2", features = ["rt", "time", "rt-multi-thread", "macros", "sync"] }

View File

@ -1,5 +1,3 @@
use gtk4 as gtk;
use crate::{
model::{models::*, Result},
model_utils::hamming_code_seven_four::*,

View File

@ -1,5 +1,3 @@
use gtk4 as gtk;
use bitvec::{order::Lsb0, view::AsBits};
use gtk::{prelude::*, *};
use std::ops::Deref;

View File

@ -1,5 +1,4 @@
use gio::glib::Object;
use gtk4 as gtk;
use std::str::FromStr;

View File

@ -1,4 +1,4 @@
use gtk4 as gtk;
#![windows_subsystem = "windows"]
extern crate gio;

View File

@ -1,14 +1,12 @@
pub mod builder_traits;
pub mod models;
use crate::gtk::glib;
use glib::Object;
use gtk::glib::{Object, wrapper};
pub type Result<T> = core::result::Result<T, Error>;
pub type Error = std::boxed::Box<dyn std::error::Error>;
glib::wrapper! {
wrapper! {
pub struct Frequency(ObjectSubclass<models::Frequency>);
}

View File

@ -1,7 +1,5 @@
use std::cell::Cell;
use crate::gtk;
use gtk::{
glib::{self, Properties},
prelude::*,

View File

@ -1,10 +1,9 @@
use adw::HeaderBar;
use gio::{glib::Variant, SimpleAction};
use gtk4 as gtk;
use gtk::{
prelude::{BoxExt, GtkWindowExt},
AboutDialog, Box, Image, Label, Orientation, ScrolledWindow, Window,
AboutDialog, Box, Image, Label, Orientation, ScrolledWindow, Window, License, NaturalWrapMode, PolicyType
};
use std::path::Path;
@ -24,7 +23,7 @@ pub fn open_about_dialogue(_action: &SimpleAction, _var: Option<&Variant>) {
.authors(vec!["Сагиев А.Д.", "Ефимов И.П."])
.version("1.0-beta")
.program_name("Прикладная теория информаций")
.license_type(gtk4::License::Apache20)
.license_type(License::Apache20)
.logo(&logo)
.website("https://gitea.doryan04.ru/doryan/AIT")
.build()
@ -44,7 +43,7 @@ pub fn open_help_dialogue(_action: &SimpleAction, _var: Option<&Variant>) {
.width_request(400)
.max_width_chars(50)
.single_line_mode(false)
.natural_wrap_mode(gtk4::NaturalWrapMode::Word)
.natural_wrap_mode(NaturalWrapMode::Word)
.label(crate::view::resources::HELP)
.build();
@ -52,7 +51,7 @@ pub fn open_help_dialogue(_action: &SimpleAction, _var: Option<&Variant>) {
let scrollable = ScrolledWindow::builder()
.child(&help)
.hscrollbar_policy(gtk4::PolicyType::Never)
.hscrollbar_policy(PolicyType::Never)
.build();
let custom_header = HeaderBar::new();

View File

@ -1,11 +1,11 @@
use gtk4 as gtk;
use gio::glib::clone;
use std::{collections::VecDeque, sync::LazyLock};
use gtk::{
builders::{BoxBuilder, ButtonBuilder, LabelBuilder},
prelude::{BoxExt, ButtonExt, ObjectExt, WidgetExt},
Box, Button, Label, Revealer, RevealerTransitionType,
Box, Button, Label, Revealer, RevealerTransitionType
};
use crate::model::builder_traits::Product;
@ -94,20 +94,20 @@ impl InfoBarBuilder {
info_bar_box.append(&info_bar_label);
info_bar_box.append(&info_bar_close_btn);
info_bar_box.set_widget_name("info_bar");
let info_bar: &Revealer = &INFO_BAR_INSTANCE.instance;
info_bar.set_transition_type(RevealerTransitionType::SlideUp);
info_bar.set_transition_duration(200);
info_bar.set_child(Some(&info_bar_box));
info_bar.set_widget_name("infobar");
info_bar.set_css_classes(&[".warning"]);
let info_bar_to_close = info_bar.clone();
info_bar_close_btn.connect_clicked(move |_| {
info_bar_to_close.set_reveal_child(false);
});
info_bar_close_btn.connect_clicked(clone!(
#[strong]
info_bar,
move |_| info_bar.set_reveal_child(false)
));
&INFO_BAR_INSTANCE
}

View File

@ -1,5 +1,3 @@
use gtk4 as gtk;
use crate::{model::builder_traits::*, view::properties::*};
use gtk::{prelude::*, *};

View File

@ -1,7 +1,5 @@
use std::fmt::{Debug, Display};
use gtk4 as gtk;
use gio::{
glib::Variant, prelude::ActionMapExtManual, ActionEntry, Menu, SimpleAction, SimpleActionGroup,
};

View File

@ -1,8 +1,6 @@
use gtk4::{self as gtk, prelude::WidgetExt};
#[allow(unused)]
use gtk::{
prelude::{BoxExt, IsA},
prelude::{BoxExt, IsA, WidgetExt},
Box, Orientation, Stack, StackSidebar, StackSwitcher, StackTransitionType, Widget,
};

View File

@ -1,5 +1,3 @@
use gtk4 as gtk;
use super::builder_traits::*;
use gtk::{Box, Label, Notebook};

View File

@ -1,5 +1,3 @@
use gtk4 as gtk;
use crate::{
model::builder_traits::Product,
view::{

View File

@ -19,8 +19,6 @@ use gtk::{
Align, *,
};
use gtk4 as gtk;
pub fn signal_reducing_page(wrapper: &Box) {
let values = Rc::new(Cell::new(SignalReduce::default()));

View File

@ -1,5 +1,3 @@
use gtk4 as gtk;
use gtk::builders::*;
use gtk::Align;

View File

@ -1,28 +0,0 @@
#info_bar{
background-color:#F1E6D9;
padding: 5px;
font-size: 11pt;
}
#info_bar > button {
transform: scale(0.9);
background-color: transparent;
}
#info_bar > button:hover {
background-color: #00000010;
}
#info_bar > button:active {
background-color: #00000020;
}
textview {
border-radius: 7px;
padding: 7px 8px;
background: #E6E6E6;
outline-offset: 2px;
outline: 2px solid #81ABDF00;
transition-duration: .15s;
transition-timing-function: ease-in-out;
}
textview:focus-within {
outline-offset: -2px;
outline: 2px solid #81ABDF;
}

View File

@ -0,0 +1,19 @@
textview {
border-radius: 7px;
padding: 7px 8px;
background: rgba(90, 90, 90, 0.5);
outline-offset: 2px;
outline: 2px solid #81ABDF00;
transition-duration: .15s;
transition-timing-function: ease-in-out;
}
textview:focus-within {
outline-offset: -2px;
outline: 2px solid #81ABDF;
}
revealer#infobar > box {
padding: 8px;
border-spacing: 12px;
border-bottom: 1px solid lighten(darken(#f6f5f4, 10%), 5%);
background-color: #4a351b;
}

View File

@ -0,0 +1,19 @@
textview {
border-radius: 7px;
padding: 7px 8px;
background: rgba(141, 141, 141, 0.5);
outline-offset: 2px;
outline: 2px solid #81ABDF00;
transition-duration: .15s;
transition-timing-function: ease-in-out;
}
textview:focus-within {
outline-offset: -2px;
outline: 2px solid #81ABDF;
}
revealer#infobar > box {
padding: 8px;
border-spacing: 12px;
border-bottom: 1px solid lighten(darken(#f6f5f4, 18%), 5%);
background-color: #f1e6d9;
}

View File

@ -1,14 +1,25 @@
use adw::gdk::Display;
use gtk4 as gtk;
use gtk::{
style_context_add_provider_for_display, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION,
style_context_add_provider_for_display, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION, Settings
};
pub fn load_css() {
pub fn load_css(settings: &Settings) {
let style_provider = CssProvider::new();
style_provider.load_from_string(include_str!("base.css"));
let theme = settings.gtk_theme_name();
match theme {
Some(theme_type) => {
let theme_string = theme_type.to_string();
if theme_string.contains("dark") || settings.is_gtk_application_prefer_dark_theme() {
style_provider.load_from_string(include_str!("base_dark.css"));
} else {
style_provider.load_from_string(include_str!("base_light.css"));
}
},
None => eprintln!("Theme hasn't been determined."),
}
style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display"),

View File

@ -1,7 +1,6 @@
use crate::model::builder_traits::*;
use adw::HeaderBar;
use gtk4 as gtk;
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
@ -19,7 +18,14 @@ use crate::view::{
use super::{components::MenuActions, styles::load_css};
pub fn ui(application: &adw::Application) {
load_css();
let default_settings = Settings::default();
if let Some(settings) = default_settings {
settings.connect_gtk_application_prefer_dark_theme_notify(load_css);
settings.connect_gtk_theme_name_notify(load_css);
load_css(&settings);
}
let hamming_code = Box::builder()
.orientation(Orientation::Vertical)
@ -30,7 +36,7 @@ pub fn ui(application: &adw::Application) {
let info_bar = InfoBar::builder()
.set_text_label("Sample text")
.set_button_icon("close")
.set_button_icon("window-close-symbolic")
.build();
hamming_code::hamming_code_page(&hamming_code);