diff --git a/src/app/browser/window/tab/item/page/content/status/download.rs b/src/app/browser/window/tab/item/page/content/status/download.rs index 846ee0bb..bf2fe8fc 100644 --- a/src/app/browser/window/tab/item/page/content/status/download.rs +++ b/src/app/browser/window/tab/item/page/content/status/download.rs @@ -49,7 +49,7 @@ pub fn new( let cancellable = cancellable.clone(); let progress = progress.clone(); let status = status.clone(); - move |_, button| { + move |button| { // cancel all operations cancellable.cancel(); // deactivate `spinner` @@ -70,7 +70,7 @@ pub fn new( let progress = progress.clone(); let status = status.clone(); let on_choose = Rc::new(on_choose); - move |_, button| { + move |button| { // lock choose button to prevent double click button.set_sensitive(false); dialog.save(Window::NONE, Some(&cancellable), { @@ -116,7 +116,7 @@ pub fn new( let cancellable = cancellable.clone(); let file_launcher = file_launcher.clone(); let status = status.clone(); - move |_, button| { + move |button| { button.set_sensitive(false); // lock file_launcher.launch(Window::NONE, Some(&cancellable), { let status = status.clone(); diff --git a/src/app/browser/window/tab/item/page/content/status/download/cancel.rs b/src/app/browser/window/tab/item/page/content/status/download/cancel.rs index 1308fffa..7a18d742 100644 --- a/src/app/browser/window/tab/item/page/content/status/download/cancel.rs +++ b/src/app/browser/window/tab/item/page/content/status/download/cancel.rs @@ -1,9 +1,4 @@ -use gtk::{ - gio::SimpleAction, - glib::{uuid_string_random, SignalHandlerId}, - prelude::ActionExt, - Align, Button, -}; +use gtk::{glib::SignalHandlerId, prelude::ButtonExt, Align, Button}; // Defaults @@ -13,7 +8,6 @@ const MARGIN: i32 = 16; /// Cancel download using shared [Cancellable](https://docs.gtk.org/gio/class.Cancellable.html) pub struct Cancel { - pub action: SimpleAction, pub button: Button, } @@ -22,31 +16,21 @@ impl Cancel { /// Create new `Self` pub fn new() -> Self { - let action = SimpleAction::new(&uuid_string_random(), None); - - let button = Button::builder() - .action_name(action.name()) - .css_classes(CSS_CLASSES) - .halign(Align::Center) - .label(LABEL) - .margin_top(MARGIN) - .visible(false) - .build(); - - Self { action, button } + Self { + button: Button::builder() + .css_classes(CSS_CLASSES) + .halign(Align::Center) + .label(LABEL) + .margin_top(MARGIN) + .visible(false) + .build(), + } } // Actions /// Formatted action connector for external implementation - pub fn on_activate( - &self, - callback: impl Fn(SimpleAction, Button) + 'static, - ) -> SignalHandlerId { - self.action.connect_activate({ - let action = self.action.clone(); - let button = self.button.clone(); - move |_, _| callback(action.clone(), button.clone()) - }) + pub fn on_activate(&self, callback: impl Fn(&Button) + 'static) -> SignalHandlerId { + self.button.connect_clicked(move |this| callback(this)) } } diff --git a/src/app/browser/window/tab/item/page/content/status/download/choose.rs b/src/app/browser/window/tab/item/page/content/status/download/choose.rs index e5e226a8..f2bbcd0b 100644 --- a/src/app/browser/window/tab/item/page/content/status/download/choose.rs +++ b/src/app/browser/window/tab/item/page/content/status/download/choose.rs @@ -1,9 +1,4 @@ -use gtk::{ - gio::SimpleAction, - glib::{uuid_string_random, SignalHandlerId}, - prelude::ActionExt, - Align, Button, -}; +use gtk::{glib::SignalHandlerId, prelude::ButtonExt, Align, Button}; // Defaults @@ -14,7 +9,6 @@ const MARGIN: i32 = 16; /// Choose destination [File](https://docs.gtk.org/gio/iface.File.html) /// to write bytes on download pub struct Choose { - pub action: SimpleAction, pub button: Button, } @@ -23,30 +17,20 @@ impl Choose { /// Create new `Self` pub fn new() -> Self { - let action = SimpleAction::new(&uuid_string_random(), None); - - let button = Button::builder() - .action_name(action.name()) - .css_classes(CSS_CLASSES) - .halign(Align::Center) - .label(LABEL) - .margin_top(MARGIN) - .build(); - - Self { action, button } + Self { + button: Button::builder() + .css_classes(CSS_CLASSES) + .halign(Align::Center) + .label(LABEL) + .margin_top(MARGIN) + .build(), + } } // Actions /// Formatted action connector for external implementation - pub fn on_activate( - &self, - callback: impl Fn(SimpleAction, Button) + 'static, - ) -> SignalHandlerId { - self.action.connect_activate({ - let action = self.action.clone(); - let button = self.button.clone(); - move |_, _| callback(action.clone(), button.clone()) - }) + pub fn on_activate(&self, callback: impl Fn(&Button) + 'static) -> SignalHandlerId { + self.button.connect_clicked(move |this| callback(this)) } } diff --git a/src/app/browser/window/tab/item/page/content/status/download/open.rs b/src/app/browser/window/tab/item/page/content/status/download/open.rs index 021092e2..0f367261 100644 --- a/src/app/browser/window/tab/item/page/content/status/download/open.rs +++ b/src/app/browser/window/tab/item/page/content/status/download/open.rs @@ -1,9 +1,4 @@ -use gtk::{ - gio::SimpleAction, - glib::{uuid_string_random, SignalHandlerId}, - prelude::ActionExt, - Align, Button, -}; +use gtk::{glib::SignalHandlerId, prelude::ButtonExt, Align, Button}; // Defaults @@ -13,7 +8,6 @@ const MARGIN: i32 = 16; /// Open [File](https://docs.gtk.org/gio/iface.File.html) on download complete pub struct Open { - pub action: SimpleAction, pub button: Button, } @@ -22,31 +16,21 @@ impl Open { /// Create new `Self` pub fn new() -> Self { - let action = SimpleAction::new(&uuid_string_random(), None); - - let button = Button::builder() - .action_name(action.name()) - .css_classes(CSS_CLASSES) - .halign(Align::Center) - .label(LABEL) - .margin_top(MARGIN) - .visible(false) - .build(); - - Self { action, button } + Self { + button: Button::builder() + .css_classes(CSS_CLASSES) + .halign(Align::Center) + .label(LABEL) + .margin_top(MARGIN) + .visible(false) + .build(), + } } // Actions /// Formatted action connector for external implementation - pub fn on_activate( - &self, - callback: impl Fn(SimpleAction, Button) + 'static, - ) -> SignalHandlerId { - self.action.connect_activate({ - let action = self.action.clone(); - let button = self.button.clone(); - move |_, _| callback(action.clone(), button.clone()) - }) + pub fn on_activate(&self, callback: impl Fn(&Button) + 'static) -> SignalHandlerId { + self.button.connect_clicked(move |this| callback(this)) } }