Skip to content

Commit 7e53f3c

Browse files
author
Deren Vural
committed
trunk formatting
Signed-off-by: Deren Vural <[email protected]>
1 parent 33aaa89 commit 7e53f3c

File tree

3 files changed

+44
-59
lines changed

3 files changed

+44
-59
lines changed

src/gpu_page/imp.rs

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
*/
2020

2121
// Imports
22-
use std::{cell::Ref, cell::Cell, cell::RefCell, rc::Rc};
22+
use adwaita::{gio, glib, prelude::*};
2323
use gio::Settings;
24-
use glib::{once_cell::sync::OnceCell, once_cell::sync::Lazy, ParamSpec, ToValue, Value, subclass::InitializingObject};
24+
use glib::{
25+
once_cell::sync::Lazy, once_cell::sync::OnceCell, subclass::InitializingObject, ParamSpec,
26+
ToValue, Value,
27+
};
2528
use gtk::{subclass::prelude::*, CompositeTemplate};
26-
use adwaita::{glib, gio, prelude::*};
29+
use std::{cell::Cell, cell::Ref, cell::RefCell, rc::Rc};
2730

2831
// Modules
29-
use crate::{provider::Provider};
32+
use crate::provider::Provider;
3033

3134
/// Object holding the State and any Template Children
3235
#[derive(CompositeTemplate, Default)]
@@ -195,31 +198,25 @@ impl ObjectImpl for GpuPage {
195198
// println!("N: `{}`", x);
196199

197200
match pspec.name() {
198-
"uuid" => {
199-
match value.get() {
200-
Ok(input_uuid) => {
201-
self.uuid.replace(input_uuid);
202-
},
203-
Err(_) => panic!("The value needs to be of type `String`."),
201+
"uuid" => match value.get() {
202+
Ok(input_uuid) => {
203+
self.uuid.replace(input_uuid);
204204
}
205-
}
206-
"name" => {
207-
match value.get() {
208-
Ok(input_name) => {
209-
self.name.replace(input_name);
210-
},
211-
Err(_) => panic!("The value needs to be of type `String`."),
205+
Err(_) => panic!("The value needs to be of type `String`."),
206+
},
207+
"name" => match value.get() {
208+
Ok(input_name) => {
209+
self.name.replace(input_name);
212210
}
213-
}
214-
"provider" => {
215-
match value.get() {
216-
Ok(input_provider_property) => {
217-
self.provider.replace(input_provider_property);
218-
},
219-
Err(_) => panic!("The value needs to be of type `Provider`."),
211+
Err(_) => panic!("The value needs to be of type `String`."),
212+
},
213+
"provider" => match value.get() {
214+
Ok(input_provider_property) => {
215+
self.provider.replace(input_provider_property);
220216
}
221-
}
222-
_ => panic!("Property `{}` does not exist..", pspec.name())
217+
Err(_) => panic!("The value needs to be of type `Provider`."),
218+
},
219+
_ => panic!("Property `{}` does not exist..", pspec.name()),
223220
}
224221

225222
// let x: String = self.uuid.take();
@@ -273,7 +270,7 @@ impl ObjectImpl for GpuPage {
273270

274271
value.to_value()
275272
}
276-
_ => panic!("Property `{}` does not exist..", pspec.name())
273+
_ => panic!("Property `{}` does not exist..", pspec.name()),
277274
}
278275
}
279276
}
@@ -313,4 +310,3 @@ impl WidgetImpl for GpuPage {}
313310
*
314311
*/
315312
impl GridImpl for GpuPage {}
316-

src/gpu_page/mod.rs

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@
1717
* Notes:
1818
*
1919
*/
20-
2120
// Custom GObjects
2221
mod imp;
2322

2423
// Imports
25-
use glib::Object;
24+
use adwaita::{gio, glib};
2625
use gio::Settings;
27-
use adwaita::{glib, gio};
28-
use gtk::{subclass::prelude::*, prelude::*, Label, Orientation::Horizontal, Box, LayoutChild, Button};
29-
use std::{sync::MutexGuard, sync::Arc, sync::Mutex};
26+
use glib::Object;
27+
use gtk::{
28+
prelude::*, subclass::prelude::*, Box, Button, Label, LayoutChild, Orientation::Horizontal,
29+
};
30+
use std::{sync::Arc, sync::Mutex, sync::MutexGuard};
3031

3132
// Modules
32-
use crate::{APP_ID, provider::Provider};
33+
use crate::{provider::Provider, APP_ID};
3334

3435
// GObject wrapper for GpuPage
3536
glib::wrapper! {
@@ -170,38 +171,32 @@ impl GpuPage {
170171
"memory_usage",
171172
"memory_total",
172173
"fan_speed",
173-
"power_usage"
174+
"power_usage",
174175
];
175176
let statistics_store: Arc<Mutex<Vec<&str>>> = Arc::new(Mutex::new(statistics_data));
176177

177178
// Edit button
178-
let edit_button: Button = Button::builder()
179-
.build();
179+
let edit_button: Button = Button::builder().build();
180180
self.attach(&edit_button, 3, 0, 24, 24);
181181

182182
// Set layout properties of button
183183
let child_manager: LayoutChild = grid_manager.layout_child(&edit_button);
184184
child_manager.set_property("row-span", 2);
185185
child_manager.set_property("column-span", 2);
186186

187-
188187
// For each Statistic
189188
let mut labels: Vec<Label> = Vec::new();
190189
for statistic in Arc::clone(&statistics_store).lock().unwrap().iter() {
191190
//==BUILD==
192191
// Build label & add to grid
193192
let new_title: String = String::from(statistic.to_owned()) + "_label";
194-
let new_title_label: Label = Label::builder()
195-
.label(statistic)
196-
.name(&new_title)
197-
.build();
193+
let new_title_label: Label =
194+
Label::builder().label(statistic).name(&new_title).build();
198195

199196
// Build label & add to grid
200197
let new_content: String = String::from(statistic.to_owned());
201-
let new_content_label: Label = Label::builder()
202-
.label("")
203-
.name(&new_content)
204-
.build();
198+
let new_content_label: Label =
199+
Label::builder().label("").name(&new_content).build();
205200

206201
// Create box for 2 labels
207202
let new_box_name: String = String::from(statistic.to_owned()) + "_box";
@@ -218,7 +213,6 @@ impl GpuPage {
218213
child_manager.set_property("row-span", 2);
219214
child_manager.set_property("column-span", 2);
220215

221-
222216
//==SHOW==
223217
// Show new labels & box
224218
new_box.show();
@@ -243,12 +237,7 @@ impl GpuPage {
243237
let uuid: String = uuid_lock.lock().unwrap().as_str().to_owned();
244238

245239
// Create provider for scanning gpu data
246-
let provider: Provider = Provider::new(
247-
|| {
248-
vec![]
249-
},
250-
0,
251-
);
240+
let provider: Provider = Provider::new(Vec::new, 0);
252241

253242
// For each Statistic
254243
for statistic in statistics.iter() {
@@ -258,21 +247,21 @@ impl GpuPage {
258247
// For each output label of the page
259248
for label in &labels {
260249
// Check if correct label
261-
if String::from(statistic.to_owned()) == String::from(label.widget_name()) {
250+
if *statistic.to_owned() == label.widget_name() {
262251
label.set_label(&stat);
263252
}
264253
}
265254
}
266255
Err(err) => {
267256
println!("panicked when fetching gpu data: `{}`", err);
268-
return Continue(false)
257+
return Continue(false);
269258
}
270259
}
271260
}
272261

273-
return Continue(true)
262+
Continue(true)
274263
});
275-
},
264+
}
276265
None => panic!("Cannot fetch layout manager of grid.."),
277266
}
278267
}

src/mainwindow/imp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl MainWindow {
437437
*/
438438
fn create_gpu_page(&self, uuid: &str, name: &str, provider: &Provider) {
439439
// Create new GpuPage object
440-
let new_page: GpuPage = GpuPage::new(&uuid, &name, &provider);
440+
let new_page: GpuPage = GpuPage::new(uuid, name, provider);
441441

442442
// Add to list of pages
443443
let mut gpu_page_list: RefMut<Vec<GpuPage>> = self.gpu_pages.borrow_mut();
@@ -451,7 +451,7 @@ impl MainWindow {
451451
scrolled_window.set_child(Some(new_page_ref));
452452

453453
// Append new ListBoxRow object to GtkListBox
454-
self.gpu_stack.add_titled(&scrolled_window, Some(&uuid), &name);
454+
self.gpu_stack.add_titled(&scrolled_window, Some(uuid), name);
455455
}
456456

457457
/**

0 commit comments

Comments
 (0)