Skip to content

Commit

Permalink
config: Add get config function
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed May 3, 2024
1 parent f2b9c13 commit 04d74c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,18 @@ pub fn parse_config() -> Table {
config_string.parse::<Table>().expect("Config has errors")
}
}

pub fn get_config_value<T>(
category: &'static str,
entry: &'static str,
callback: fn(&toml::value::Value) -> T,
) -> bool {
#[allow(clippy::borrow_interior_mutable_const)]
if let Some(monitor_config) = CONFIG.get(category) {
if let Some(value) = monitor_config.get(entry) {
(callback(value));
return true;
}
}
false
}
8 changes: 7 additions & 1 deletion src/utils/gtk/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use gtk::{Align, Label};
use gtk::{Align, Frame, Label, Orientation};

pub fn create_title(name: &'static str) -> Label {
Label::builder()
Expand All @@ -9,3 +9,9 @@ pub fn create_title(name: &'static str) -> Label {
.margin_bottom(10)
.build()
}

pub fn create_frame(orientation: Orientation) -> gtk::Frame {
Frame::builder()
.css_classes(vec!["resetSettingFrame"])
.build()
}

0 comments on commit 04d74c4

Please sign in to comment.