mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-24 10:04:16 +00:00
remove extra actions
This commit is contained in:
parent
9b6ee0ab3b
commit
58b685ec1d
@ -49,7 +49,7 @@ pub fn new(
|
|||||||
let cancellable = cancellable.clone();
|
let cancellable = cancellable.clone();
|
||||||
let progress = progress.clone();
|
let progress = progress.clone();
|
||||||
let status = status.clone();
|
let status = status.clone();
|
||||||
move |_, button| {
|
move |button| {
|
||||||
// cancel all operations
|
// cancel all operations
|
||||||
cancellable.cancel();
|
cancellable.cancel();
|
||||||
// deactivate `spinner`
|
// deactivate `spinner`
|
||||||
@ -70,7 +70,7 @@ pub fn new(
|
|||||||
let progress = progress.clone();
|
let progress = progress.clone();
|
||||||
let status = status.clone();
|
let status = status.clone();
|
||||||
let on_choose = Rc::new(on_choose);
|
let on_choose = Rc::new(on_choose);
|
||||||
move |_, button| {
|
move |button| {
|
||||||
// lock choose button to prevent double click
|
// lock choose button to prevent double click
|
||||||
button.set_sensitive(false);
|
button.set_sensitive(false);
|
||||||
dialog.save(Window::NONE, Some(&cancellable), {
|
dialog.save(Window::NONE, Some(&cancellable), {
|
||||||
@ -116,7 +116,7 @@ pub fn new(
|
|||||||
let cancellable = cancellable.clone();
|
let cancellable = cancellable.clone();
|
||||||
let file_launcher = file_launcher.clone();
|
let file_launcher = file_launcher.clone();
|
||||||
let status = status.clone();
|
let status = status.clone();
|
||||||
move |_, button| {
|
move |button| {
|
||||||
button.set_sensitive(false); // lock
|
button.set_sensitive(false); // lock
|
||||||
file_launcher.launch(Window::NONE, Some(&cancellable), {
|
file_launcher.launch(Window::NONE, Some(&cancellable), {
|
||||||
let status = status.clone();
|
let status = status.clone();
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
use gtk::{
|
use gtk::{glib::SignalHandlerId, prelude::ButtonExt, Align, Button};
|
||||||
gio::SimpleAction,
|
|
||||||
glib::{uuid_string_random, SignalHandlerId},
|
|
||||||
prelude::ActionExt,
|
|
||||||
Align, Button,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
|
|
||||||
@ -13,7 +8,6 @@ const MARGIN: i32 = 16;
|
|||||||
|
|
||||||
/// Cancel download using shared [Cancellable](https://docs.gtk.org/gio/class.Cancellable.html)
|
/// Cancel download using shared [Cancellable](https://docs.gtk.org/gio/class.Cancellable.html)
|
||||||
pub struct Cancel {
|
pub struct Cancel {
|
||||||
pub action: SimpleAction,
|
|
||||||
pub button: Button,
|
pub button: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,31 +16,21 @@ impl Cancel {
|
|||||||
|
|
||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let action = SimpleAction::new(&uuid_string_random(), None);
|
Self {
|
||||||
|
button: Button::builder()
|
||||||
let button = Button::builder()
|
|
||||||
.action_name(action.name())
|
|
||||||
.css_classes(CSS_CLASSES)
|
.css_classes(CSS_CLASSES)
|
||||||
.halign(Align::Center)
|
.halign(Align::Center)
|
||||||
.label(LABEL)
|
.label(LABEL)
|
||||||
.margin_top(MARGIN)
|
.margin_top(MARGIN)
|
||||||
.visible(false)
|
.visible(false)
|
||||||
.build();
|
.build(),
|
||||||
|
}
|
||||||
Self { action, button }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/// Formatted action connector for external implementation
|
/// Formatted action connector for external implementation
|
||||||
pub fn on_activate(
|
pub fn on_activate(&self, callback: impl Fn(&Button) + 'static) -> SignalHandlerId {
|
||||||
&self,
|
self.button.connect_clicked(move |this| callback(this))
|
||||||
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())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
use gtk::{
|
use gtk::{glib::SignalHandlerId, prelude::ButtonExt, Align, Button};
|
||||||
gio::SimpleAction,
|
|
||||||
glib::{uuid_string_random, SignalHandlerId},
|
|
||||||
prelude::ActionExt,
|
|
||||||
Align, Button,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
|
|
||||||
@ -14,7 +9,6 @@ const MARGIN: i32 = 16;
|
|||||||
/// Choose destination [File](https://docs.gtk.org/gio/iface.File.html)
|
/// Choose destination [File](https://docs.gtk.org/gio/iface.File.html)
|
||||||
/// to write bytes on download
|
/// to write bytes on download
|
||||||
pub struct Choose {
|
pub struct Choose {
|
||||||
pub action: SimpleAction,
|
|
||||||
pub button: Button,
|
pub button: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,30 +17,20 @@ impl Choose {
|
|||||||
|
|
||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let action = SimpleAction::new(&uuid_string_random(), None);
|
Self {
|
||||||
|
button: Button::builder()
|
||||||
let button = Button::builder()
|
|
||||||
.action_name(action.name())
|
|
||||||
.css_classes(CSS_CLASSES)
|
.css_classes(CSS_CLASSES)
|
||||||
.halign(Align::Center)
|
.halign(Align::Center)
|
||||||
.label(LABEL)
|
.label(LABEL)
|
||||||
.margin_top(MARGIN)
|
.margin_top(MARGIN)
|
||||||
.build();
|
.build(),
|
||||||
|
}
|
||||||
Self { action, button }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/// Formatted action connector for external implementation
|
/// Formatted action connector for external implementation
|
||||||
pub fn on_activate(
|
pub fn on_activate(&self, callback: impl Fn(&Button) + 'static) -> SignalHandlerId {
|
||||||
&self,
|
self.button.connect_clicked(move |this| callback(this))
|
||||||
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())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
use gtk::{
|
use gtk::{glib::SignalHandlerId, prelude::ButtonExt, Align, Button};
|
||||||
gio::SimpleAction,
|
|
||||||
glib::{uuid_string_random, SignalHandlerId},
|
|
||||||
prelude::ActionExt,
|
|
||||||
Align, Button,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
|
|
||||||
@ -13,7 +8,6 @@ const MARGIN: i32 = 16;
|
|||||||
|
|
||||||
/// Open [File](https://docs.gtk.org/gio/iface.File.html) on download complete
|
/// Open [File](https://docs.gtk.org/gio/iface.File.html) on download complete
|
||||||
pub struct Open {
|
pub struct Open {
|
||||||
pub action: SimpleAction,
|
|
||||||
pub button: Button,
|
pub button: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,31 +16,21 @@ impl Open {
|
|||||||
|
|
||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let action = SimpleAction::new(&uuid_string_random(), None);
|
Self {
|
||||||
|
button: Button::builder()
|
||||||
let button = Button::builder()
|
|
||||||
.action_name(action.name())
|
|
||||||
.css_classes(CSS_CLASSES)
|
.css_classes(CSS_CLASSES)
|
||||||
.halign(Align::Center)
|
.halign(Align::Center)
|
||||||
.label(LABEL)
|
.label(LABEL)
|
||||||
.margin_top(MARGIN)
|
.margin_top(MARGIN)
|
||||||
.visible(false)
|
.visible(false)
|
||||||
.build();
|
.build(),
|
||||||
|
}
|
||||||
Self { action, button }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/// Formatted action connector for external implementation
|
/// Formatted action connector for external implementation
|
||||||
pub fn on_activate(
|
pub fn on_activate(&self, callback: impl Fn(&Button) + 'static) -> SignalHandlerId {
|
||||||
&self,
|
self.button.connect_clicked(move |this| callback(this))
|
||||||
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())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user