Skip to content

Commit

Permalink
Small formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian committed Jul 12, 2024
1 parent 01dab38 commit f3bfd50
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion book/listings/actions/2/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn build_ui(app: &Application) {

// Add action "close" to `window` taking no parameter
let action_close = ActionEntry::builder("close")
.activate(clone!(#[weak] window , move |_, _, _| {
.activate(clone!(#[weak] window, move |_, _, _| {
window.close();
}))
.build();
Expand Down
4 changes: 2 additions & 2 deletions book/listings/main_event_loop/4/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn build_ui(app: &Application) {
let (sender, receiver) = async_channel::bounded(1);
// Connect to "clicked" signal of `button`
button.connect_clicked(move |_| {
glib::spawn_future_local(clone!(#[strong] sender , async move {
glib::spawn_future_local(clone!(#[strong] sender, async move {
// Deactivate the button until the operation is done
sender.send(false).await.expect("The channel needs to be open.");
glib::timeout_future_seconds(5).await;
Expand All @@ -40,7 +40,7 @@ fn build_ui(app: &Application) {
});

// The main loop executes the asynchronous block
glib::spawn_future_local(clone!(#[weak] button , async move {
glib::spawn_future_local(clone!(#[weak] button, async move {
while let Ok(enable_button) = receiver.recv().await {
button.set_sensitive(enable_button);
}
Expand Down
2 changes: 1 addition & 1 deletion book/listings/main_event_loop/5/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn build_ui(app: &Application) {
// ANCHOR: callback
// Connect to "clicked" signal of `button`
button.connect_clicked(move |button| {
glib::spawn_future_local(clone!(#[weak] button , async move {
glib::spawn_future_local(clone!(#[weak] button, async move {
// Deactivate the button until the operation is done
button.set_sensitive(false);
glib::timeout_future_seconds(5).await;
Expand Down
2 changes: 1 addition & 1 deletion book/listings/main_event_loop/6/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn build_ui(app: &Application) {
// Connect to "clicked" signal of `button`
button.connect_clicked(move |button| {
// The main loop executes the asynchronous block
glib::spawn_future_local(clone!(#[weak] button , async move {
glib::spawn_future_local(clone!(#[weak] button, async move {
// Deactivate the button until the operation is done
button.set_sensitive(false);
let enable_button = gio::spawn_blocking(move || {
Expand Down
2 changes: 1 addition & 1 deletion book/listings/main_event_loop/8/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn build_ui(app: &Application) {
// Connect to "clicked" signal of `button`
button.connect_clicked(move |_| {
// The main loop executes the asynchronous block
glib::spawn_future_local(clone!(#[strong] sender , async move {
glib::spawn_future_local(clone!(#[strong] sender, async move {
let response = reqwest::get("https://www.gtk-rs.org").await;
sender.send(response).await.expect("The channel needs to be open.");
}));
Expand Down
2 changes: 1 addition & 1 deletion book/listings/main_event_loop/9/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn build_ui(app: &Application) {
let (sender, receiver) = async_channel::bounded(1);
// Connect to "clicked" signal of `button`
button.connect_clicked(move |_| {
runtime().spawn(clone!(#[strong] sender , async move {
runtime().spawn(clone!(#[strong] sender, async move {
let response = reqwest::get("https://www.gtk-rs.org").await;
sender.send(response).await.expect("The channel needs to be open.");
}));
Expand Down
32 changes: 21 additions & 11 deletions book/listings/todo/4/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ impl Window {
// Filter model whenever the value of the key "filter" changes
self.settings().connect_changed(
Some("filter"),
clone!(#[weak(rename_to = window)] self, #[weak] filter_model , move |_, _| {
filter_model.set_filter(window.filter().as_ref());
}),
clone!(
#[weak(rename_to = window)]
self,
#[weak]
filter_model,
move |_, _| {
filter_model.set_filter(window.filter().as_ref());
}
),
);
}

Expand All @@ -126,18 +132,22 @@ impl Window {

fn setup_callbacks(&self) {
// Setup callback for activation of the entry
self.imp()
.entry
.connect_activate(clone!(#[weak(rename_to = window)] self , move |_| {
self.imp().entry.connect_activate(clone!(
#[weak(rename_to = window)]
self,
move |_| {
window.new_task();
}));
}
));

// Setup callback for clicking (and the releasing) the icon of the entry
self.imp().entry.connect_icon_release(
clone!(#[weak(rename_to = window)] self , move |_,_| {
self.imp().entry.connect_icon_release(clone!(
#[weak(rename_to = window)]
self,
move |_, _| {
window.new_task();
}),
);
}
));
}

fn new_task(&self) {
Expand Down
32 changes: 21 additions & 11 deletions book/listings/todo/5/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,15 @@ impl Window {
// Filter model whenever the value of the key "filter" changes
self.settings().connect_changed(
Some("filter"),
clone!(#[weak(rename_to = window)] self, #[weak] filter_model , move |_, _| {
filter_model.set_filter(window.filter().as_ref());
}),
clone!(
#[weak(rename_to = window)]
self,
#[weak]
filter_model,
move |_, _| {
filter_model.set_filter(window.filter().as_ref());
}
),
);
}

Expand All @@ -127,18 +133,22 @@ impl Window {

fn setup_callbacks(&self) {
// Setup callback for activation of the entry
self.imp()
.entry
.connect_activate(clone!(#[weak(rename_to = window)] self , move |_| {
self.imp().entry.connect_activate(clone!(
#[weak(rename_to = window)]
self,
move |_| {
window.new_task();
}));
}
));

// Setup callback for clicking (and the releasing) the icon of the entry
self.imp().entry.connect_icon_release(
clone!(#[weak(rename_to = window)] self , move |_,_| {
self.imp().entry.connect_icon_release(clone!(
#[weak(rename_to = window)]
self,
move |_, _| {
window.new_task();
}),
);
}
));
}

fn new_task(&self) {
Expand Down

0 comments on commit f3bfd50

Please sign in to comment.