From e2acfa0bcd046f5add7d6145dc53346f2eafa476 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 12 Dec 2024 13:49:19 +0200 Subject: [PATCH] activate download chooser by default on widget release --- .../tab/item/page/content/status/download.rs | 2 +- .../page/content/status/download/choose.rs | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) 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 5a45b797..6bea5d01 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 @@ -43,7 +43,7 @@ pub fn new( let action = Rc::new(Action::new()); // public callback API let cancel = Rc::new(Cancel::new()); - let choose = Rc::new(Choose::new()); + let choose = Rc::new(Choose::new(true)); // @TODO optional `is_activate_on_release` value let open = Rc::new(Open::new()); let progress = Rc::new(Progress::new()); let status = Rc::new(Status::new()); 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 00c00e57..90c4c625 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,4 +1,8 @@ -use gtk::{glib::SignalHandlerId, prelude::ButtonExt, Align, Button}; +use gtk::{ + glib::SignalHandlerId, + prelude::{ButtonExt, WidgetExt}, + Align, Button, +}; // Defaults @@ -16,15 +20,21 @@ impl Choose { // Constructors /// Create new `Self` - pub fn new() -> Self { - Self { - button: Button::builder() - .css_classes(CSS_CLASSES) - .halign(Align::Center) - .label(LABEL) - .margin_top(MARGIN) - .build(), + pub fn new(is_activate_on_release: bool) -> Self { + let button = Button::builder() + .css_classes(CSS_CLASSES) + .halign(Align::Center) + .label(LABEL) + .margin_top(MARGIN) + .build(); + + if is_activate_on_release { + button.connect_realize(|this| { + this.activate(); + }); } + + Self { button } } // Actions