merge stable version #2

Merged
doryan merged 97 commits from experimental into main 2024-08-28 18:54:00 +03:00
2 changed files with 24 additions and 7 deletions
Showing only changes of commit c211f3002a - Show all commits

View File

@ -1,14 +1,25 @@
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, 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(); 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( style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display"), &Display::default().expect("Could not connect to a display"),

View File

@ -1,7 +1,6 @@
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, *};
@ -19,7 +18,14 @@ 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)
@ -30,7 +36,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("close") .set_button_icon("window-close-symbolic")
.build(); .build();
hamming_code::hamming_code_page(&hamming_code); hamming_code::hamming_code_page(&hamming_code);