Skip to content

Commit fdac526

Browse files
author
Deren Vural
committed
trunk formatting
Signed-off-by: Deren Vural <[email protected]>
1 parent 6302669 commit fdac526

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ mod settingswindow;
3030

3131
// Imports
3232
use adwaita::prelude::*;
33-
use adwaita::{
34-
/* Libraries */ gio,
35-
/* Application */ Application,
36-
};
33+
use adwaita::{gio, Application};
34+
use gdk::Display;
35+
use gio::resources_register_include;
3736
use gtk::{CssProvider, StyleContext};
38-
use gio::{resources_register_include};
39-
use gdk::{Display};
4037

4138
// Constants
4239
const APP_ID: &str = "com.gtk_d.NvidiaMonitorRust";

src/mainwindow/imp.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
// Imports
2222
use adwaita::{gio, glib, prelude::*, subclass::prelude::*};
2323
use gio::Settings;
24-
use glib::{
25-
once_cell::sync::OnceCell, signal::Inhibit,
26-
subclass::InitializingObject,
27-
};
24+
use glib::{once_cell::sync::OnceCell, signal::Inhibit, subclass::InitializingObject};
2825
use gtk::{subclass::prelude::*, CompositeTemplate}; //, Entry, ListBox, TemplateChild};
2926
use std::{cell::Cell, cell::RefCell, rc::Rc};
3027

src/settingswindow/imp.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use adwaita::{gio, glib, prelude::*, subclass::prelude::*, ComboRow};
2323
use gio::Settings;
2424
use glib::{once_cell::sync::OnceCell, signal::Inhibit, subclass::InitializingObject};
25-
use gtk::{subclass::prelude::*, CompositeTemplate, TemplateChild, SpinButton, CheckButton};
25+
use gtk::{subclass::prelude::*, CheckButton, CompositeTemplate, SpinButton, TemplateChild};
2626

2727
// Modules
2828
//use crate::utils::data_path;
@@ -86,7 +86,9 @@ impl SettingsWindow {
8686

8787
// Set refresh rate property
8888
let settings = self.settings.get().expect("..Cannot retrieve settings");
89-
settings.set_int("refreshrate", new_value).expect("..Cannot set `tempformat` setting");
89+
settings
90+
.set_int("refreshrate", new_value)
91+
.expect("..Cannot set `tempformat` setting");
9092
}
9193

9294
#[template_callback]
@@ -99,24 +101,31 @@ impl SettingsWindow {
99101
// Check if current button active
100102
if current_button.is_active() {
101103
// Get new unit
102-
let unit: String = button.label().expect("..Could not fetch contents of temperature unit button label").to_string();
104+
let unit: String = button
105+
.label()
106+
.expect("..Could not fetch contents of temperature unit button label")
107+
.to_string();
103108

104109
// Set appropriate setting
105110
match unit.as_str() {
106111
"Celcius (C)" => {
107112
// Set temperature unit as C
108113
let settings = self.settings.get().expect("..Cannot retrieve settings");
109-
settings.set_int("tempformat", 0).expect("..Cannot set `tempformat` setting");
110-
},
114+
settings
115+
.set_int("tempformat", 0)
116+
.expect("..Cannot set `tempformat` setting");
117+
}
111118
"Fahrenheit (F)" => {
112119
// Set temperature unit as F
113120
let settings = self.settings.get().expect("..Cannot retrieve settings");
114-
settings.set_int("tempformat", 1).expect("..Cannot set `tempformat` setting");
115-
},
121+
settings
122+
.set_int("tempformat", 1)
123+
.expect("..Cannot set `tempformat` setting");
124+
}
116125
_ => {
117126
// Display error message
118127
panic!("..Unexpected temperature unit");
119-
},
128+
}
120129
}
121130
}
122131
}
@@ -235,7 +244,6 @@ impl WindowImpl for SettingsWindow {
235244
*/
236245
impl AdwWindowImpl for SettingsWindow {}
237246

238-
239247
/*
240248
* Trait Name:
241249
* ApplicationWindowImpl

src/settingswindow/mod.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod imp;
2323

2424
// Imports
2525
use adwaita::{gio, glib, prelude::*, subclass::prelude::*, ComboRow};
26-
use gio::{Settings};
26+
use gio::Settings;
2727
use glib::{clone, Object};
2828
use gtk::{Adjustment, CheckButton, StringList};
2929

@@ -140,36 +140,33 @@ impl SettingsWindow {
140140
*
141141
*/
142142
fn setup_widgets(&self) {
143-
144-
145143
// Create adjustment settings for refresh rate SpinButton
146144
let current_refresh_rate: f64 = self.settings().int("refreshrate").into();
147-
let adjustment: Adjustment = Adjustment::new(current_refresh_rate, 1.0, 20.0, 1.0, 5.0, 0.0);
145+
let adjustment: Adjustment =
146+
Adjustment::new(current_refresh_rate, 1.0, 20.0, 1.0, 5.0, 0.0);
148147
self.imp()
149148
.refreshrate_input
150149
.configure(Some(&adjustment), 1.0, 0);
151150

152151
// Group together Temp-Unit CheckButtons
153152
let group: &CheckButton = &self.imp().temp_unit_f;
154-
self.imp()
155-
.temp_unit_c
156-
.set_group(Some(group));
153+
self.imp().temp_unit_c.set_group(Some(group));
157154

158155
// Retrieve temperature unit from settings
159156
match self.settings().int("tempformat") {
160157
0 => {
161158
self.imp().temp_unit_c.set_active(true);
162159
self.imp().temp_unit_f.set_active(false);
163-
},
160+
}
164161
1 => {
165162
self.imp().temp_unit_f.set_active(true);
166163
self.imp().temp_unit_c.set_active(false);
167-
},
164+
}
168165
_ => panic!("..Unknown temp unit in settings"),
169166
}
170167

171168
// Set options for provider
172-
let items: [&str; 4] = [
169+
let items: [&str; 4] = [
173170
"Nvidia Settings and Nvidia SMI",
174171
"Nvidia Settings",
175172
"Nvidia SMI",
@@ -182,16 +179,16 @@ impl SettingsWindow {
182179
match self.settings().int("provider") {
183180
0 => {
184181
self.imp().provider_input.set_selected(0);
185-
},
182+
}
186183
1 => {
187184
self.imp().provider_input.set_selected(1);
188-
},
185+
}
189186
2 => {
190187
self.imp().provider_input.set_selected(2);
191-
},
188+
}
192189
3 => {
193190
self.imp().provider_input.set_selected(3);
194-
},
191+
}
195192
_ => panic!("..Unknown provider value in settings"),
196193
}
197194
}

style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
/* SPDX-License-Identifier: GPL-3.0-or-later */
33

44
listview row box label {
5-
min-width: 195px;
5+
min-width: 195px;
66
}

0 commit comments

Comments
 (0)