Compare commits
No commits in common. "c211f3002a80cd0939dfc91cf73e0f433d3115c3" and "21bc19e893db6fc6176904650c65ee0b714b89eb" have entirely different histories.
c211f3002a
...
21bc19e893
|
@ -9,5 +9,5 @@ edition = "2021"
|
||||||
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
|
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
|
||||||
bitvec = "1.0.1"
|
bitvec = "1.0.1"
|
||||||
gio = { version = "0.20.0", features = ["v2_74"] }
|
gio = { version = "0.20.0", features = ["v2_74"] }
|
||||||
gtk = { version = "0.9.0", package = "gtk4", features = ["v4_12"] }
|
gtk4 = { version = "0.9.0", features = ["v4_12"] }
|
||||||
tokio = { version = "1.39.2", features = ["rt", "time", "rt-multi-thread", "macros", "sync"] }
|
tokio = { version = "1.39.2", features = ["rt", "time", "rt-multi-thread", "macros", "sync"] }
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
model::{models::*, Result},
|
model::{models::*, Result},
|
||||||
model_utils::hamming_code_seven_four::*,
|
model_utils::hamming_code_seven_four::*,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use bitvec::{order::Lsb0, view::AsBits};
|
use bitvec::{order::Lsb0, view::AsBits};
|
||||||
use gtk::{prelude::*, *};
|
use gtk::{prelude::*, *};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use gio::glib::Object;
|
use gio::glib::Object;
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![windows_subsystem = "windows"]
|
use gtk4 as gtk;
|
||||||
|
|
||||||
extern crate gio;
|
extern crate gio;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
pub mod builder_traits;
|
pub mod builder_traits;
|
||||||
pub mod models;
|
pub mod models;
|
||||||
|
|
||||||
use gtk::glib::{Object, wrapper};
|
use crate::gtk::glib;
|
||||||
|
|
||||||
|
use glib::Object;
|
||||||
|
|
||||||
pub type Result<T> = core::result::Result<T, Error>;
|
pub type Result<T> = core::result::Result<T, Error>;
|
||||||
pub type Error = std::boxed::Box<dyn std::error::Error>;
|
pub type Error = std::boxed::Box<dyn std::error::Error>;
|
||||||
|
|
||||||
wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Frequency(ObjectSubclass<models::Frequency>);
|
pub struct Frequency(ObjectSubclass<models::Frequency>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
|
use crate::gtk;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
glib::{self, Properties},
|
glib::{self, Properties},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use adw::HeaderBar;
|
use adw::HeaderBar;
|
||||||
use gio::{glib::Variant, SimpleAction};
|
use gio::{glib::Variant, SimpleAction};
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
prelude::{BoxExt, GtkWindowExt},
|
prelude::{BoxExt, GtkWindowExt},
|
||||||
AboutDialog, Box, Image, Label, Orientation, ScrolledWindow, Window, License, NaturalWrapMode, PolicyType
|
AboutDialog, Box, Image, Label, Orientation, ScrolledWindow, Window,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -23,7 +24,7 @@ pub fn open_about_dialogue(_action: &SimpleAction, _var: Option<&Variant>) {
|
||||||
.authors(vec!["Сагиев А.Д.", "Ефимов И.П."])
|
.authors(vec!["Сагиев А.Д.", "Ефимов И.П."])
|
||||||
.version("1.0-beta")
|
.version("1.0-beta")
|
||||||
.program_name("Прикладная теория информаций")
|
.program_name("Прикладная теория информаций")
|
||||||
.license_type(License::Apache20)
|
.license_type(gtk4::License::Apache20)
|
||||||
.logo(&logo)
|
.logo(&logo)
|
||||||
.website("https://gitea.doryan04.ru/doryan/AIT")
|
.website("https://gitea.doryan04.ru/doryan/AIT")
|
||||||
.build()
|
.build()
|
||||||
|
@ -43,7 +44,7 @@ pub fn open_help_dialogue(_action: &SimpleAction, _var: Option<&Variant>) {
|
||||||
.width_request(400)
|
.width_request(400)
|
||||||
.max_width_chars(50)
|
.max_width_chars(50)
|
||||||
.single_line_mode(false)
|
.single_line_mode(false)
|
||||||
.natural_wrap_mode(NaturalWrapMode::Word)
|
.natural_wrap_mode(gtk4::NaturalWrapMode::Word)
|
||||||
.label(crate::view::resources::HELP)
|
.label(crate::view::resources::HELP)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ pub fn open_help_dialogue(_action: &SimpleAction, _var: Option<&Variant>) {
|
||||||
|
|
||||||
let scrollable = ScrolledWindow::builder()
|
let scrollable = ScrolledWindow::builder()
|
||||||
.child(&help)
|
.child(&help)
|
||||||
.hscrollbar_policy(PolicyType::Never)
|
.hscrollbar_policy(gtk4::PolicyType::Never)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let custom_header = HeaderBar::new();
|
let custom_header = HeaderBar::new();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use gio::glib::clone;
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use std::{collections::VecDeque, sync::LazyLock};
|
use std::{collections::VecDeque, sync::LazyLock};
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
builders::{BoxBuilder, ButtonBuilder, LabelBuilder},
|
builders::{BoxBuilder, ButtonBuilder, LabelBuilder},
|
||||||
prelude::{BoxExt, ButtonExt, ObjectExt, WidgetExt},
|
prelude::{BoxExt, ButtonExt, ObjectExt, WidgetExt},
|
||||||
Box, Button, Label, Revealer, RevealerTransitionType
|
Box, Button, Label, Revealer, RevealerTransitionType,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::model::builder_traits::Product;
|
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_label);
|
||||||
info_bar_box.append(&info_bar_close_btn);
|
info_bar_box.append(&info_bar_close_btn);
|
||||||
|
info_bar_box.set_widget_name("info_bar");
|
||||||
|
|
||||||
let info_bar: &Revealer = &INFO_BAR_INSTANCE.instance;
|
let info_bar: &Revealer = &INFO_BAR_INSTANCE.instance;
|
||||||
|
|
||||||
info_bar.set_transition_type(RevealerTransitionType::SlideUp);
|
info_bar.set_transition_type(RevealerTransitionType::SlideUp);
|
||||||
info_bar.set_transition_duration(200);
|
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"]);
|
|
||||||
|
|
||||||
info_bar_close_btn.connect_clicked(clone!(
|
info_bar.set_child(Some(&info_bar_box));
|
||||||
#[strong]
|
|
||||||
info_bar,
|
let info_bar_to_close = info_bar.clone();
|
||||||
move |_| info_bar.set_reveal_child(false)
|
|
||||||
));
|
info_bar_close_btn.connect_clicked(move |_| {
|
||||||
|
info_bar_to_close.set_reveal_child(false);
|
||||||
|
});
|
||||||
|
|
||||||
&INFO_BAR_INSTANCE
|
&INFO_BAR_INSTANCE
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use crate::{model::builder_traits::*, view::properties::*};
|
use crate::{model::builder_traits::*, view::properties::*};
|
||||||
use gtk::{prelude::*, *};
|
use gtk::{prelude::*, *};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
|
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use gio::{
|
use gio::{
|
||||||
glib::Variant, prelude::ActionMapExtManual, ActionEntry, Menu, SimpleAction, SimpleActionGroup,
|
glib::Variant, prelude::ActionMapExtManual, ActionEntry, Menu, SimpleAction, SimpleActionGroup,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
use gtk4::{self as gtk, prelude::WidgetExt};
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
use gtk::{
|
use gtk::{
|
||||||
prelude::{BoxExt, IsA, WidgetExt},
|
prelude::{BoxExt, IsA},
|
||||||
Box, Orientation, Stack, StackSidebar, StackSwitcher, StackTransitionType, Widget,
|
Box, Orientation, Stack, StackSidebar, StackSwitcher, StackTransitionType, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use super::builder_traits::*;
|
use super::builder_traits::*;
|
||||||
use gtk::{Box, Label, Notebook};
|
use gtk::{Box, Label, Notebook};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
model::builder_traits::Product,
|
model::builder_traits::Product,
|
||||||
view::{
|
view::{
|
||||||
|
|
|
@ -19,6 +19,8 @@ use gtk::{
|
||||||
Align, *,
|
Align, *,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
pub fn signal_reducing_page(wrapper: &Box) {
|
pub fn signal_reducing_page(wrapper: &Box) {
|
||||||
let values = Rc::new(Cell::new(SignalReduce::default()));
|
let values = Rc::new(Cell::new(SignalReduce::default()));
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use gtk::builders::*;
|
use gtk::builders::*;
|
||||||
use gtk::Align;
|
use gtk::Align;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#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;
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
|
@ -1,25 +1,14 @@
|
||||||
use adw::gdk::Display;
|
use adw::gdk::Display;
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
style_context_add_provider_for_display, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION, Settings
|
style_context_add_provider_for_display, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn load_css(settings: &Settings) {
|
pub fn load_css() {
|
||||||
let style_provider = CssProvider::new();
|
let style_provider = CssProvider::new();
|
||||||
|
|
||||||
let theme = settings.gtk_theme_name();
|
style_provider.load_from_string(include_str!("base.css"));
|
||||||
|
|
||||||
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(
|
style_context_add_provider_for_display(
|
||||||
&Display::default().expect("Could not connect to a display"),
|
&Display::default().expect("Could not connect to a display"),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::model::builder_traits::*;
|
use crate::model::builder_traits::*;
|
||||||
|
|
||||||
use adw::HeaderBar;
|
use adw::HeaderBar;
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
|
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
|
||||||
|
|
||||||
|
@ -18,14 +19,7 @@ use crate::view::{
|
||||||
use super::{components::MenuActions, styles::load_css};
|
use super::{components::MenuActions, styles::load_css};
|
||||||
|
|
||||||
pub fn ui(application: &adw::Application) {
|
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()
|
let hamming_code = Box::builder()
|
||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Vertical)
|
||||||
|
@ -36,7 +30,7 @@ pub fn ui(application: &adw::Application) {
|
||||||
|
|
||||||
let info_bar = InfoBar::builder()
|
let info_bar = InfoBar::builder()
|
||||||
.set_text_label("Sample text")
|
.set_text_label("Sample text")
|
||||||
.set_button_icon("window-close-symbolic")
|
.set_button_icon("close")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
hamming_code::hamming_code_page(&hamming_code);
|
hamming_code::hamming_code_page(&hamming_code);
|
||||||
|
|
Loading…
Reference in New Issue