From e98f5adb931654a3ee32c57775ad9c97c81b15f5 Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Fri, 24 Mar 2023 13:58:15 +0100 Subject: [PATCH 1/7] :lipstick: Add a subscribe button to empty feed --- data/resources/ui/feed_page.ui | 16 +++++++ src/gui/feed/feed_page.rs | 33 +++++++++++++ src/gui/subscription/subscription_page.rs | 57 ++++++++++++++++------- src/gui/window.rs | 21 +++++++++ 4 files changed, 110 insertions(+), 17 deletions(-) diff --git a/data/resources/ui/feed_page.ui b/data/resources/ui/feed_page.ui index 0b0ef98..f4ae2d8 100644 --- a/data/resources/ui/feed_page.ui +++ b/data/resources/ui/feed_page.ui @@ -69,6 +69,22 @@ Are you subscribed to channels? go-home-symbolic True + + + + + center + + + list-add-symbolic + Subscribe to a chanel + + + + + feed_list diff --git a/src/gui/feed/feed_page.rs b/src/gui/feed/feed_page.rs index 6d2d2ce..8fc1ca5 100644 --- a/src/gui/feed/feed_page.rs +++ b/src/gui/feed/feed_page.rs @@ -35,6 +35,10 @@ impl FeedPage { self.imp().joiner.replace(Some(joiner)); self.imp().setup(&self); } + + pub fn reload(&self) { + self.imp().reload(); + } } pub mod imp { @@ -47,6 +51,7 @@ pub mod imp { use gdk::glib::ParamSpec; use gdk::glib::ParamSpecBoolean; use gdk::glib::PRIORITY_DEFAULT; + use gdk_pixbuf::glib::subclass::Signal; use glib::subclass::InitializingObject; use gtk::glib; use gtk::prelude::*; @@ -73,6 +78,8 @@ pub mod imp { #[template_child] pub(super) btn_reload: TemplateChild, + #[template_child] + pub(super) btn_add_subscription: TemplateChild, #[template_child] pub(super) error_label: TemplateChild, @@ -85,6 +92,10 @@ pub mod imp { } impl FeedPage { + pub(super) fn reload(&self) { + self.btn_reload.emit_clicked(); + } + fn setup_reload(&self, obj: &super::FeedPage) { let joiner = self .joiner @@ -132,6 +143,13 @@ pub mod imp { self.joiner.replace(Some(joiner)); } + fn setup_add_subscription(&self, obj: &super::FeedPage) { + self.btn_add_subscription + .connect_clicked(clone!(@weak obj => move |_| { + obj.emit_by_name::<()>("add-subscription", &[]); + })); + } + pub(super) fn setup(&self, obj: &super::FeedPage) { self.feed_list.set_playlist_manager( self.playlist_manager @@ -140,6 +158,7 @@ pub mod imp { .expect("PlaylistManager has to be set up"), ); self.setup_reload(obj); + self.setup_add_subscription(obj); } } @@ -202,6 +221,20 @@ pub mod imp { _ => unimplemented!(), } } + + fn signals() -> &'static [Signal] { + static SIGNALS: Lazy> = Lazy::new(|| { + vec![Signal::builder( + "add-subscription", + // Types of the values which will be sent to the signal handler + &[], + // Type of the value the signal handler sends back + <()>::static_type().into(), + ) + .build()] + }); + SIGNALS.as_ref() + } } impl WidgetImpl for FeedPage {} diff --git a/src/gui/subscription/subscription_page.rs b/src/gui/subscription/subscription_page.rs index c5d36c3..5630bf5 100644 --- a/src/gui/subscription/subscription_page.rs +++ b/src/gui/subscription/subscription_page.rs @@ -32,6 +32,11 @@ gtk::glib::wrapper! { } impl SubscriptionPage { + pub fn present_subscribe(&self) { + log::trace!("Subscription page got request to present the subscription window"); + self.imp().present_subscribe(); + } + pub fn set_subscription_list( &self, subscription_list: AnySubscriptionList, @@ -67,6 +72,7 @@ pub mod imp { use gdk::glib::Object; use gdk::glib::ParamSpec; use gdk::glib::PRIORITY_DEFAULT; + use gdk_pixbuf::glib::subclass::Signal; use glib::subclass::InitializingObject; use gtk::glib; use gtk::prelude::*; @@ -116,23 +122,24 @@ pub mod imp { } impl SubscriptionPage { + pub(super) fn present_subscribe(&self) { + self.dropdown_platform.set_selected(0); + self.entry_url.set_text(""); + self.entry_name_id.set_text(""); + + // Theoretically only needs to be done once, but when setting up the page does + // not yet have a root. + let window = self.instance().window(); + self.dialog_add.set_transient_for(Some(&window)); + self.dialog_add.present(); + } + fn setup_toggle_add_subscription(&self, obj: &super::SubscriptionPage) { - self.btn_toggle_add_subscription.connect_clicked(clone!(@strong obj as s, - @strong self.dialog_add as dialog, - @strong self.entry_url as in_url, - @strong self.entry_name_id as in_name_id, - @strong self.dropdown_platform as dropdown_platform, - => move |_| { - dropdown_platform.set_selected(0); - in_url.set_text(""); - in_name_id.set_text(""); - - // Theoretically only needs to be done once, but when setting up the page does - // not yet have a root. - let window = s.window(); - dialog.set_transient_for(Some(&window)); - dialog.present(); - })); + self.btn_toggle_add_subscription + .connect_clicked(clone!(@strong obj as s, + => move |_| { + s.present_subscribe(); + })); } fn setup_platform_dropdown(&self) { @@ -203,11 +210,13 @@ pub mod imp { } }); + let obj = self.instance(); receiver.attach( None, - clone!(@strong self.any_subscription_list as list => + clone!(@strong self.any_subscription_list as list, @strong obj => move |sub| { list.borrow().as_ref().expect("SubscriptionList should be set up").add(sub); + obj.emit_by_name::<()>("subscription-added", &[]); Continue(true) } ) @@ -311,6 +320,20 @@ pub mod imp { fn property(&self, _obj: &Self::Type, _id: usize, _pspec: &glib::ParamSpec) -> glib::Value { unimplemented!() } + + fn signals() -> &'static [Signal] { + static SIGNALS: Lazy> = Lazy::new(|| { + vec![Signal::builder( + "subscription-added", + // Types of the values which will be sent to the signal handler + &[], + // Type of the value the signal handler sends back + <()>::static_type().into(), + ) + .build()] + }); + SIGNALS.as_ref() + } } impl WidgetImpl for SubscriptionPage {} diff --git a/src/gui/window.rs b/src/gui/window.rs index cc7ca67..4c55342 100644 --- a/src/gui/window.rs +++ b/src/gui/window.rs @@ -82,6 +82,7 @@ pub mod imp { use std::sync::Arc; use std::sync::Mutex; + use gdk_pixbuf::glib::clone; use glib::subclass::InitializingObject; use gtk::glib; use gtk::prelude::*; @@ -163,6 +164,16 @@ pub mod imp { } impl Window { + fn setup_feed(&self) { + self.feed_page.connect_local( + "add-subscription", + true, + clone!(@strong self.subscription_page as s => move |_| { + s.present_subscribe(); + None + }), + ); + } fn setup_watch_later(&self) { let joiner = setup_joiner(); self.joiner.replace(Some(joiner.clone())); @@ -238,6 +249,15 @@ pub mod imp { .expect("PlaylistManager should be set up"), joiner, ); + + self.subscription_page.connect_local( + "subscription-added", + true, + clone!(@strong self.feed_page as f => move |_| { + f.reload(); + None + }), + ); } fn setup_filter(&self) { @@ -296,6 +316,7 @@ pub mod imp { impl ObjectImpl for Window { fn constructed(&self, obj: &Self::Type) { self.parent_constructed(obj); + self.setup_feed(); self.setup_watch_later(); self.setup_subscriptions(); self.setup_filter(); From 846b09659677823ed2bcd8afcaffcaa26f5caeaf Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Fri, 24 Mar 2023 15:24:16 +0100 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Hari Rana --- data/resources/ui/feed_page.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/resources/ui/feed_page.ui b/data/resources/ui/feed_page.ui index f4ae2d8..36bd395 100644 --- a/data/resources/ui/feed_page.ui +++ b/data/resources/ui/feed_page.ui @@ -74,12 +74,12 @@ center - list-add-symbolic - Subscribe to a chanel + Subscribe to a Channel From 74c50e149891615513a82cebaab268155dcbbf54 Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Fri, 24 Mar 2023 15:26:02 +0100 Subject: [PATCH 3/7] Remove AdwButtonContent --- data/resources/ui/feed_page.ui | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/data/resources/ui/feed_page.ui b/data/resources/ui/feed_page.ui index 36bd395..099e8f5 100644 --- a/data/resources/ui/feed_page.ui +++ b/data/resources/ui/feed_page.ui @@ -76,12 +76,9 @@ + center - - - Subscribe to a Channel - - + Subscribe to a Channel From 103105d5e5e731a6b4d332f3376bed65365e4ed9 Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Sat, 25 Mar 2023 09:43:03 +0100 Subject: [PATCH 4/7] Update data/resources/ui/feed_page.ui Co-authored-by: Hari Rana --- data/resources/ui/feed_page.ui | 1 - 1 file changed, 1 deletion(-) diff --git a/data/resources/ui/feed_page.ui b/data/resources/ui/feed_page.ui index 099e8f5..74dbf09 100644 --- a/data/resources/ui/feed_page.ui +++ b/data/resources/ui/feed_page.ui @@ -66,7 +66,6 @@ No Videos Found - Are you subscribed to channels? go-home-symbolic True From 3c57b1034366e71ef06d7fe65a7cb4697cc577e8 Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Sun, 26 Mar 2023 12:29:55 +0200 Subject: [PATCH 5/7] :lipstick: Add buttons to empty filter- and subscription page --- data/resources/ui/filter_page.ui | 13 ++++++++- data/resources/ui/subscription_page.ui | 13 ++++++++- src/gui/filter/filter_page.rs | 33 ++++++++++++++--------- src/gui/subscription/subscription_page.rs | 7 +++++ 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/data/resources/ui/filter_page.ui b/data/resources/ui/filter_page.ui index 10a5450..22a8c64 100644 --- a/data/resources/ui/filter_page.ui +++ b/data/resources/ui/filter_page.ui @@ -44,7 +44,6 @@ No Filters - How about adding some filters? funnel-symbolic True @@ -52,6 +51,18 @@ filter_list + + + + + + center + Add a Filter + + diff --git a/data/resources/ui/subscription_page.ui b/data/resources/ui/subscription_page.ui index 85e5961..41ed594 100644 --- a/data/resources/ui/subscription_page.ui +++ b/data/resources/ui/subscription_page.ui @@ -50,7 +50,6 @@ No Subscriptions - How about subscribing to some channels? library-artists-symbolic True @@ -58,6 +57,18 @@ subscription_list + + + + + + center + Subscribe to a Channel + + diff --git a/src/gui/filter/filter_page.rs b/src/gui/filter/filter_page.rs index 75808d1..de768d1 100644 --- a/src/gui/filter/filter_page.rs +++ b/src/gui/filter/filter_page.rs @@ -77,6 +77,8 @@ pub mod imp { #[template_child] pub(super) btn_toggle_add_filter: TemplateChild, #[template_child] + pub(super) btn_add_filter: TemplateChild, + #[template_child] pub(super) entry_title: TemplateChild, #[template_child] pub(super) entry_channel: TemplateChild, @@ -88,19 +90,26 @@ pub mod imp { #[gtk::template_callbacks] impl FilterPage { + fn present_filter(&self) { + self.entry_channel.set_text(""); + self.entry_title.set_text(""); + + // Theoretically only needs to be done once, but when setting up the page does + // not yet have a root. + let window = self.instance().window(); + self.dialog_add.set_transient_for(Some(&window)); + self.dialog_add.present(); + } + fn setup_toggle_add_filter(&self, obj: &super::FilterPage) { - self.btn_toggle_add_filter.connect_clicked( - clone!(@strong obj as s, @strong self.dialog_add as dialog, @strong self.entry_title as in_title, @strong self.entry_channel as in_channel => move |_| { - in_title.set_text(""); - in_channel.set_text(""); - - // Theoretically only needs to be done once, but when setting up the page does - // not yet have a root. - let window = s.window(); - dialog.set_transient_for(Some(&window)); - dialog.present(); - }), - ); + self.btn_toggle_add_filter + .connect_clicked(clone!(@strong obj as s => move |_| { + s.imp().present_filter(); + })); + self.btn_add_filter + .connect_clicked(clone!(@strong obj as s => move |_| { + s.imp().present_filter(); + })); } #[template_callback] diff --git a/src/gui/subscription/subscription_page.rs b/src/gui/subscription/subscription_page.rs index 5630bf5..ea4b31d 100644 --- a/src/gui/subscription/subscription_page.rs +++ b/src/gui/subscription/subscription_page.rs @@ -105,6 +105,8 @@ pub mod imp { #[template_child] pub(super) btn_toggle_add_subscription: TemplateChild, #[template_child] + pub(super) btn_add_subscription: TemplateChild, + #[template_child] pub(super) dropdown_platform: TemplateChild, #[template_child] pub(super) entry_url: TemplateChild, @@ -140,6 +142,11 @@ pub mod imp { => move |_| { s.present_subscribe(); })); + self.btn_add_subscription + .connect_clicked(clone!(@strong obj as s, + => move |_| { + s.present_subscribe(); + })); } fn setup_platform_dropdown(&self) { From 9110b2a23d2bb9fe9a044c6b3430f9011119bea4 Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Mon, 27 Mar 2023 11:19:39 +0200 Subject: [PATCH 6/7] Update data/resources/ui/filter_page.ui Co-authored-by: Hari Rana --- data/resources/ui/filter_page.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/resources/ui/filter_page.ui b/data/resources/ui/filter_page.ui index 22a8c64..0138258 100644 --- a/data/resources/ui/filter_page.ui +++ b/data/resources/ui/filter_page.ui @@ -60,7 +60,7 @@ center - Add a Filter + Add Filter From 27d62d012d997d303f0675ff7a56d6ca49080048 Mon Sep 17 00:00:00 2001 From: Schmiddiii Date: Mon, 27 Mar 2023 16:36:46 +0200 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Hari Rana --- data/resources/ui/feed_page.ui | 2 +- data/resources/ui/filter_page.ui | 2 +- data/resources/ui/subscription_page.ui | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/resources/ui/feed_page.ui b/data/resources/ui/feed_page.ui index 74dbf09..3c2efb4 100644 --- a/data/resources/ui/feed_page.ui +++ b/data/resources/ui/feed_page.ui @@ -77,7 +77,7 @@ center - Subscribe to a Channel + Subscribe to a Channel… diff --git a/data/resources/ui/filter_page.ui b/data/resources/ui/filter_page.ui index 0138258..96c4ce0 100644 --- a/data/resources/ui/filter_page.ui +++ b/data/resources/ui/filter_page.ui @@ -60,7 +60,7 @@ center - Add Filter + Add Filter… diff --git a/data/resources/ui/subscription_page.ui b/data/resources/ui/subscription_page.ui index 41ed594..1cfae06 100644 --- a/data/resources/ui/subscription_page.ui +++ b/data/resources/ui/subscription_page.ui @@ -66,7 +66,7 @@ center - Subscribe to a Channel + Subscribe to a Channel…