Skip to content

Commit ea32f43

Browse files
committed
cargo fmt
1 parent f27f0f6 commit ea32f43

25 files changed

+252
-224
lines changed

src/application.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ use adw::prelude::*;
2525
use adw::subclass::prelude::*;
2626
use gtk::{gio, glib};
2727

28+
use crate::DistroShelfWindow;
2829
use crate::config;
2930
use crate::distrobox::{Distrobox, DistroboxCommandRunnerResponse, FlatpakCommandRunner};
3031
use crate::fakers::{CommandRunner, RealCommandRunner};
3132
use crate::root_store::RootStore;
32-
use crate::DistroShelfWindow;
3333

3434
#[derive(Debug, Copy, Clone, PartialEq, Eq, glib::Enum, Default)]
3535
#[enum_type(name = "DistroboxStoreTy")]

src/container.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
use crate::{
2-
distrobox::{ContainerInfo, CreateArgs, CreateArgName, ExportableApp, Status},
2+
distrobox::{ContainerInfo, CreateArgName, CreateArgs, ExportableApp, Status},
33
distrobox_task::DistroboxTask,
4+
fakers::Command,
45
fakers::CommandRunner,
56
gtk_utils::TypedListStore,
6-
known_distros::{known_distro_by_image, KnownDistro},
7+
known_distros::{KnownDistro, known_distro_by_image},
78
query::Query,
89
root_store::RootStore,
9-
fakers::Command
1010
};
1111

12-
use gtk::{
13-
glib::{derived_properties, BoxedAnyObject, Properties},
14-
};
12+
use gtk::glib::{BoxedAnyObject, Properties, derived_properties};
1513

1614
use adw::prelude::*;
1715
use glib::subclass::prelude::*;
@@ -54,26 +52,26 @@ mod imp {
5452
image: RefCell::new(String::new()),
5553
distro: RefCell::new(None),
5654

57-
// Fetching apps often fails when the container is not running and distrobox has to start it,
55+
// Fetching apps often fails when the container is not running and distrobox has to start it,
5856
// so we add retries
59-
apps: Query::new("apps".into(), || async {
60-
Ok(TypedListStore::new())
61-
})
62-
.with_timeout(Duration::from_secs(1))
63-
.with_retry_strategy(|n| if n < 3 {
64-
Some(Duration::from_secs(n as u64))
65-
} else {
66-
None
67-
}),
68-
binaries: Query::new("binaries".into(), || async {
69-
Ok(TypedListStore::new())
70-
})
71-
.with_timeout(Duration::from_secs(1))
72-
.with_retry_strategy(|n| if n < 3 {
73-
Some(Duration::from_secs(n as u64))
74-
} else {
75-
None
76-
}),
57+
apps: Query::new("apps".into(), || async { Ok(TypedListStore::new()) })
58+
.with_timeout(Duration::from_secs(1))
59+
.with_retry_strategy(|n| {
60+
if n < 3 {
61+
Some(Duration::from_secs(n as u64))
62+
} else {
63+
None
64+
}
65+
}),
66+
binaries: Query::new("binaries".into(), || async { Ok(TypedListStore::new()) })
67+
.with_timeout(Duration::from_secs(1))
68+
.with_retry_strategy(|n| {
69+
if n < 3 {
70+
Some(Duration::from_secs(n as u64))
71+
} else {
72+
None
73+
}
74+
}),
7775
}
7876
}
7977
}
@@ -112,7 +110,8 @@ impl Container {
112110
.list_apps(&this.name())
113111
.await?;
114112

115-
let apps_list: TypedListStore<BoxedAnyObject> = TypedListStore::from_iter(apps.into_iter().map(BoxedAnyObject::new));
113+
let apps_list: TypedListStore<BoxedAnyObject> =
114+
TypedListStore::from_iter(apps.into_iter().map(BoxedAnyObject::new));
116115

117116
// Listing the apps starts the container, we need to update its status
118117
this.root_store().load_containers();
@@ -130,7 +129,8 @@ impl Container {
130129
.get_exported_binaries(&this.name())
131130
.await?;
132131

133-
let binaries_list: TypedListStore<BoxedAnyObject> = TypedListStore::from_iter(binaries.into_iter().map(BoxedAnyObject::new));
132+
let binaries_list: TypedListStore<BoxedAnyObject> =
133+
TypedListStore::from_iter(binaries.into_iter().map(BoxedAnyObject::new));
134134

135135
// Listing the binaries starts the container, we need to update its status
136136
this.root_store().load_containers();

src/dialogs/create_distrobox_dialog.rs

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ use gtk::gio::File;
44
use gtk::{gio, glib};
55
use tracing::error;
66

7+
use crate::container::Container;
78
use crate::distrobox::{self, CreateArgName, CreateArgs, Error};
89
use crate::root_store::RootStore;
9-
use crate::container::Container;
1010
use crate::sidebar_row::SidebarRow;
1111

1212
use std::path::PathBuf;
1313
use std::{cell::RefCell, rc::Rc};
1414

1515
use crate::{distro_icon, image_row_item};
1616
use glib::clone;
17-
use gtk::glib::{derived_properties, Properties};
17+
use gtk::glib::{Properties, derived_properties};
1818

1919
pub enum FileRowSelection {
2020
File,
@@ -73,7 +73,7 @@ mod imp {
7373
// insert at the top of the cloning_content box
7474
self.cloning_content.append(&sidebar_row);
7575
self.clone_sidebar.replace(Some(sidebar_row));
76-
76+
7777
// Show warning if container is running
7878
if container.is_running() {
7979
self.clone_warning_banner.set_revealed(true);
@@ -110,9 +110,9 @@ mod imp {
110110
self.content.set_spacing(12);
111111
self.content.set_orientation(gtk::Orientation::Vertical);
112112

113-
114113
// Create cloning_content box with header and sidebar
115-
self.cloning_content.set_orientation(gtk::Orientation::Vertical);
114+
self.cloning_content
115+
.set_orientation(gtk::Orientation::Vertical);
116116
self.cloning_content.set_spacing(12);
117117
self.cloning_content.set_visible(false);
118118

@@ -128,12 +128,13 @@ mod imp {
128128
cloning_header.append(&cloning_label);
129129

130130
self.cloning_content.append(&cloning_header);
131-
131+
132132
// Add warning banner for running containers
133-
self.clone_warning_banner.set_title("Cloning the container requires stopping it first");
133+
self.clone_warning_banner
134+
.set_title("Cloning the container requires stopping it first");
134135
self.clone_warning_banner.set_revealed(false);
135136
self.cloning_content.append(&self.clone_warning_banner);
136-
137+
137138
self.content.append(&self.cloning_content);
138139

139140
let preferences_group = adw::PreferencesGroup::new();
@@ -143,8 +144,9 @@ mod imp {
143144
self.image_row.set_title("Base Image");
144145
self.image_row.set_subtitle("Select an image...");
145146
self.image_row.set_activatable(true);
146-
self.image_row.add_suffix(&gtk::Image::from_icon_name("go-next-symbolic"));
147-
147+
self.image_row
148+
.add_suffix(&gtk::Image::from_icon_name("go-next-symbolic"));
149+
148150
let obj = self.obj().clone();
149151
self.image_row.connect_activated(clone!(
150152
#[weak]
@@ -209,8 +211,7 @@ mod imp {
209211
// If cloning from a source, delegate to clone_container, otherwise create normally
210212
if let Some(src) = obj.clone_src() {
211213
src.stop();
212-
obj.root_store()
213-
.clone_container(&src.name(), create_args);
214+
obj.root_store().clone_container(&src.name(), create_args);
214215
} else {
215216
obj.root_store().create_container(create_args);
216217
}
@@ -331,7 +332,6 @@ mod imp {
331332
view_stack.add_titled(&assemble_page, Some("assemble-file"), "From File");
332333
view_stack.add_titled(&url_page, Some("assemble-url"), "From URL");
333334

334-
335335
// Create a box to hold the view switcher and content
336336
let content_box = gtk::Box::new(gtk::Orientation::Vertical, 0);
337337

@@ -382,9 +382,7 @@ impl CreateDistroboxDialog {
382382
.property("root-store", root_store)
383383
.build();
384384

385-
this.root_store()
386-
.images_query()
387-
.connect_success(clone!(
385+
this.root_store().images_query().connect_success(clone!(
388386
#[weak]
389387
this,
390388
move |images| {
@@ -477,14 +475,14 @@ impl CreateDistroboxDialog {
477475

478476
pub fn build_image_picker_view(&self) -> adw::NavigationPage {
479477
let view = adw::ToolbarView::new();
480-
478+
481479
let header = adw::HeaderBar::new();
482480
view.add_top_bar(&header);
483481

484482
let search_entry = gtk::SearchEntry::new();
485483
search_entry.set_placeholder_text(Some("Search image..."));
486484
search_entry.set_hexpand(true);
487-
485+
488486
header.set_title_widget(Some(&search_entry));
489487

490488
let model = self.imp().images_model.clone();
@@ -498,12 +496,15 @@ impl CreateDistroboxDialog {
498496
.match_mode(gtk::StringFilterMatchMode::Substring)
499497
.ignore_case(true)
500498
.build();
501-
502-
search_entry.bind_property("text", &filter, "search").sync_create().build();
503-
499+
500+
search_entry
501+
.bind_property("text", &filter, "search")
502+
.sync_create()
503+
.build();
504+
504505
let filter_model = gtk::FilterListModel::new(Some(model), Some(filter));
505506
let selection_model = gtk::SingleSelection::new(Some(filter_model.clone()));
506-
507+
507508
let factory = gtk::SignalListItemFactory::new();
508509
factory.connect_setup(|_, item| {
509510
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
@@ -518,33 +519,32 @@ impl CreateDistroboxDialog {
518519
.unwrap()
519520
.string();
520521
let child = item.child();
521-
let child: &image_row_item::ImageRowItem =
522-
child.and_downcast_ref().unwrap();
522+
let child: &image_row_item::ImageRowItem = child.and_downcast_ref().unwrap();
523523
child.set_image(&image);
524524
});
525525

526526
let list_view = gtk::ListView::new(Some(selection_model), Some(factory));
527527
list_view.add_css_class("navigation-sidebar");
528528
list_view.set_single_click_activate(true);
529-
529+
530530
let scrolled_window = gtk::ScrolledWindow::new();
531531
scrolled_window.set_child(Some(&list_view));
532532
scrolled_window.set_vexpand(true);
533-
533+
534534
let stack = gtk::Stack::new();
535535
stack.add_named(&scrolled_window, Some("list"));
536536

537537
let empty_page = gtk::Box::new(gtk::Orientation::Vertical, 4);
538-
538+
539539
let custom_list = gtk::ListBox::new();
540540
custom_list.add_css_class("navigation-sidebar");
541541
custom_list.set_selection_mode(gtk::SelectionMode::None);
542-
542+
543543
let custom_row_item = image_row_item::ImageRowItem::new();
544544
distro_icon::remove_color(&custom_row_item.imp().icon);
545-
545+
546546
custom_list.append(&custom_row_item);
547-
547+
548548
empty_page.append(&custom_list);
549549
stack.add_named(&empty_page, Some("empty"));
550550

@@ -559,10 +559,10 @@ impl CreateDistroboxDialog {
559559
stack_clone.set_visible_child_name("empty");
560560
}
561561
});
562-
562+
563563
// Initial state check
564564
if filter_model.n_items() == 0 {
565-
stack.set_visible_child_name("empty");
565+
stack.set_visible_child_name("empty");
566566
}
567567

568568
// Update custom row
@@ -574,16 +574,16 @@ impl CreateDistroboxDialog {
574574
move |entry| {
575575
let text = entry.text();
576576
if text.is_empty() {
577-
custom_list.set_sensitive(false);
577+
custom_list.set_sensitive(false);
578578
} else {
579-
custom_list.set_sensitive(true);
580-
custom_row_item.set_image(&text);
579+
custom_list.set_sensitive(true);
580+
custom_row_item.set_image(&text);
581581
}
582582
}
583583
));
584584
// Initial button state
585585
if search_entry.text().is_empty() {
586-
custom_list.set_sensitive(false);
586+
custom_list.set_sensitive(false);
587587
}
588588

589589
// Handle custom image selection
@@ -601,16 +601,20 @@ impl CreateDistroboxDialog {
601601
}
602602
}
603603
));
604-
604+
605605
// Handle selection
606606
list_view.connect_activate(clone!(
607607
#[weak(rename_to=this)]
608608
self,
609609
move |list_view, position| {
610610
let model = list_view.model().unwrap(); // SingleSelection
611-
let item = model.item(position).unwrap().downcast::<gtk::StringObject>().unwrap();
611+
let item = model
612+
.item(position)
613+
.unwrap()
614+
.downcast::<gtk::StringObject>()
615+
.unwrap();
612616
let image = item.string();
613-
617+
614618
this.imp().selected_image.replace(image.to_string());
615619
this.imp().image_row.set_subtitle(&image);
616620
this.imp().navigation_view.pop();
@@ -624,7 +628,10 @@ impl CreateDistroboxDialog {
624628
let imp = self.imp();
625629
let image = imp.selected_image.borrow().clone();
626630
if image.is_empty() {
627-
return Err(Error::InvalidField("image".into(), "No image selected".into()));
631+
return Err(Error::InvalidField(
632+
"image".into(),
633+
"No image selected".into(),
634+
));
628635
}
629636
let volumes = imp
630637
.volume_rows

0 commit comments

Comments
 (0)