Skip to content

Commit 76e6927

Browse files
author
Deren Vural
committed
trunk formatting
Signed-off-by: Deren Vural <[email protected]>
1 parent 0d7e489 commit 76e6927

File tree

4 files changed

+72
-54
lines changed

4 files changed

+72
-54
lines changed

src/gpu_page/imp.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
use adwaita::{gio, glib, prelude::*, ViewStack, ViewSwitcherBar};
2323
use gio::Settings;
2424
use glib::{
25-
once_cell::sync::Lazy, once_cell::sync::OnceCell, subclass::InitializingObject, FromVariant,
26-
ParamSpec, ToValue, Value, subclass::Signal, subclass::SignalType
25+
once_cell::sync::Lazy, once_cell::sync::OnceCell, subclass::InitializingObject,
26+
subclass::Signal, subclass::SignalType, FromVariant, ParamSpec, ToValue, Value,
2727
};
2828
use gtk::{subclass::prelude::*, CompositeTemplate, TemplateChild};
2929
use std::{cell::Cell, cell::RefCell, rc::Rc};
@@ -385,12 +385,12 @@ impl ObjectImpl for GpuPage {
385385
*/
386386
fn signals() -> &'static [Signal] {
387387
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
388-
vec![
389-
Signal::builder("update-views",
390-
&[SignalType::from(i32::static_type())],
391-
SignalType::from(i32::static_type()))
392-
.build()
393-
]
388+
vec![Signal::builder(
389+
"update-views",
390+
&[SignalType::from(i32::static_type())],
391+
SignalType::from(i32::static_type()),
392+
)
393+
.build()]
394394
});
395395
SIGNALS.as_ref()
396396
}

src/gpu_page/mod.rs

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use imp::ModificationWindowContainer;
2424
// Imports
2525
use adwaita::{gio, glib, Application, ViewStack};
2626
use gio::Settings;
27-
use glib::{clone, translate::FromGlib, Object, SourceId, closure_local, closure};
27+
use glib::{clone, closure, closure_local, translate::FromGlib, Object, SourceId};
2828
use gtk::{prelude::*, subclass::prelude::*, Align, Button, Grid, Label, LayoutChild, Orientation};
2929
use std::{cell::RefMut, sync::Arc, sync::Mutex, sync::MutexGuard};
3030

@@ -902,28 +902,39 @@ impl GpuPage {
902902

903903
// Connect closure to re-load (now updated) stored views when a modification window is closed
904904
//NOTE: expected return value seems to be broken - look at imp.rs:395
905-
self.connect_closure("update-views", false, closure!(move |gpage: GpuPage, current_view: i32| {
906-
// println!("closure parameter: `{}`", current_view); //TEST
907-
908-
// Reload views
909-
// println!("reloading views.."); //TEST
910-
gpage.load_views();
911-
// println!("views reloaded.."); //TEST
912-
913-
// If and edit is made (and not a delete)
914-
if current_view != -1 {
915-
// println!("switching to page: `{}`", current_view); //TEST
916-
917-
// Set to correct view
918-
gpage.imp().view_switcher.stack().unwrap().set_visible_child_name((current_view.to_string() + "_stack_item").as_str());
919-
}
905+
self.connect_closure(
906+
"update-views",
907+
false,
908+
closure!(move |gpage: GpuPage, current_view: i32| {
909+
// println!("closure parameter: `{}`", current_view); //TEST
910+
911+
// Reload views
912+
// println!("reloading views.."); //TEST
913+
gpage.load_views();
914+
// println!("views reloaded.."); //TEST
915+
916+
// If and edit is made (and not a delete)
917+
if current_view != -1 {
918+
// println!("switching to page: `{}`", current_view); //TEST
919+
920+
// Set to correct view
921+
gpage
922+
.imp()
923+
.view_switcher
924+
.stack()
925+
.unwrap()
926+
.set_visible_child_name(
927+
(current_view.to_string() + "_stack_item").as_str(),
928+
);
929+
}
920930

921-
// Return final value
922-
//0.to_value() // "Invalid return value: expected (), got gint",
923-
0 // "Invalid return value: expected (), got gint",
924-
//() // 'Closure returned no value but the caller expected a value of type gint'
925-
// // 'Closure returned no value but the caller expected a value of type gint'
926-
}));
931+
// Return final value
932+
//0.to_value() // "Invalid return value: expected (), got gint",
933+
0 // "Invalid return value: expected (), got gint",
934+
//() // 'Closure returned no value but the caller expected a value of type gint'
935+
// // 'Closure returned no value but the caller expected a value of type gint'
936+
}),
937+
);
927938
}
928939
}
929940

src/modificationwindow/imp.rs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use adwaita::{gio, glib, prelude::*, subclass::prelude::*, ActionRow};
2222
use gio::Settings;
2323
use glib::{
2424
once_cell::sync::Lazy, once_cell::sync::OnceCell, signal::Inhibit,
25-
subclass::InitializingObject, FromVariant, ParamSpec, Value
25+
subclass::InitializingObject, FromVariant, ParamSpec, Value,
2626
};
2727
use gtk::{
2828
subclass::prelude::*, Button, CompositeTemplate, DropDown, Entry, ListBox, SpinButton,
@@ -31,12 +31,12 @@ use gtk::{
3131
use std::{cell::Cell, cell::RefCell, rc::Rc};
3232

3333
// Modules
34-
use crate::{gpu_page::GpuPage};
34+
use crate::gpu_page::GpuPage;
3535

3636
/// Structure for storing a SettingsWindow object and any related information
3737
#[derive(Default)]
3838
pub struct ParentContainer {
39-
pub window: Option<GpuPage>
39+
pub window: Option<GpuPage>,
4040
}
4141

4242
/// Structure for storing a View item data
@@ -187,7 +187,6 @@ impl ModificationWindow {
187187
self.update_setting::<Vec<String>>("viewconfigs", stored_views_data);
188188
// println!("viewconfig updated.."); //TEST
189189

190-
191190
// Delete associated viewcomponentconfigs
192191
// println!("Initial components list: `{:?}`", stored_views_components); //TEST
193192
let mut to_remove: Vec<i32> = vec![];
@@ -218,11 +217,14 @@ impl ModificationWindow {
218217
// println!("Final components list: `{:?}`", stored_views_components);
219218

220219
// Update stored viewcomponentconfigs
221-
self.update_setting::<Vec<String>>("viewcomponentconfigs", stored_views_components);
220+
self.update_setting::<Vec<String>>(
221+
"viewcomponentconfigs",
222+
stored_views_components,
223+
);
222224
// println!("saving changes.."); //TEST
223-
}// else {
224-
// println!("no changes.."); //TEST
225-
// }
225+
} // else {
226+
// println!("no changes.."); //TEST
227+
// }
226228
}
227229
}
228230
}
@@ -449,7 +451,8 @@ impl ModificationWindow {
449451
// Check if old version exists
450452
for old_index in 0..old_components_list.len() {
451453
// Split current viewcomponentconfig
452-
let sub_items: Vec<&str> = old_components_list[old_index].split(':').collect();
454+
let sub_items: Vec<&str> =
455+
old_components_list[old_index].split(':').collect();
453456

454457
match (
455458
current_components[new_index].name == sub_items[3],
@@ -526,19 +529,19 @@ impl ModificationWindow {
526529
if !component_modified {
527530
// Create new viewcomponentconfig
528531
let new_viewcomponentconfig: String = uuid.clone()
529-
+ ":"
530-
+ &old_view_title
531-
+ ":"
532-
+ &current_components[new_index].position.to_string()
533-
+ ":"
534-
+ &current_components[new_index].name;
532+
+ ":"
533+
+ &old_view_title
534+
+ ":"
535+
+ &current_components[new_index].position.to_string()
536+
+ ":"
537+
+ &current_components[new_index].name;
535538

536539
// Add to updated list of stored viewcomponentconfigs
537540
new_components_list.push(new_viewcomponentconfig);
538541
// println!("FINAL new component!"); //TEST
539542
} // else {
540-
// println!("FINAL component modified!"); //TEST
541-
// }
543+
// println!("FINAL component modified!"); //TEST
544+
// }
542545
}
543546

544547
// Combine new/modified list with other views
@@ -683,8 +686,8 @@ impl ModificationWindow {
683686
// println!("NEW NAME VALID..");
684687
self.new_view_title.set(new_title);
685688
} // else {
686-
// println!("NEW NAME INVALID..");
687-
// }
689+
// println!("NEW NAME INVALID..");
690+
// }
688691
}
689692
/**
690693
* Name:
@@ -787,8 +790,8 @@ impl ModificationWindow {
787790
// Modify view component list
788791
components.push(new_item);
789792
} // else if new_amount == components.len() {
790-
// // Same as previous
791-
// // println!("=="); //TEST
793+
// // Same as previous
794+
// // println!("=="); //TEST
792795

793796
// // TODO: ???
794797
// }

src/modificationwindow/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ use gtk::{Adjustment, DropDown, StringList};
2828
use std::cell::RefMut;
2929

3030
// Modules
31-
use crate::{modificationwindow::imp::ViewComponent, modificationwindow::imp::ParentContainer, APP_ID, gpu_page::GpuPage};
31+
use crate::{
32+
gpu_page::GpuPage, modificationwindow::imp::ParentContainer,
33+
modificationwindow::imp::ViewComponent, APP_ID,
34+
};
3235

3336
// GObject wrapper for ModificationWindow
3437
glib::wrapper! {
@@ -75,7 +78,7 @@ impl ModificationWindow {
7578
app: &adwaita::Application,
7679
view_id: i32,
7780
uuid: &str,
78-
parent_window: &GpuPage
81+
parent_window: &GpuPage,
7982
) -> Self {
8083
let obj: ModificationWindow = Object::new(&[("application", app)])
8184
.expect("`ModificationWindow` should be instantiable.");
@@ -87,7 +90,8 @@ impl ModificationWindow {
8790

8891
// Set ref to parent
8992
{
90-
let mut modification_window_container: RefMut<ParentContainer> = obj.imp().parent_window.borrow_mut();
93+
let mut modification_window_container: RefMut<ParentContainer> =
94+
obj.imp().parent_window.borrow_mut();
9195
modification_window_container.window = Some(parent_window.to_owned());
9296
}
9397

0 commit comments

Comments
 (0)