Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
💄 Add status pages (#107)
Browse files Browse the repository at this point in the history
* 💄 Add status pages

* Fix spelling

Co-authored-by: Hari Rana <[email protected]>

Co-authored-by: Hari Rana <[email protected]>
  • Loading branch information
Schmiddiii and TheEvilSkeleton authored Nov 13, 2022
1 parent 6660c18 commit a294dab
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 8 deletions.
20 changes: 20 additions & 0 deletions data/resources/ui/feed_page.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@
</child>
<child>
<object class="TFFeedList" id="feed_list">
<binding name="visible">
<closure function="not" type="gboolean">
<lookup name="is-empty">
feed_list
</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="AdwStatusPage">
<property name="title" translatable="yes">No Videos Found</property>
<property name="description" translatable="yes">Are you subscribed to channels?</property>
<property name="icon-name">go-home-symbolic</property>
<property name="vexpand">True</property>
<binding name="visible">
<lookup name="is-empty">
feed_list
</lookup>
</binding>
</object>
</child>
</object>
Expand Down
20 changes: 20 additions & 0 deletions data/resources/ui/filter_page.ui
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@
</child>
<child>
<object class="TFFilterList" id="filter_list">
<binding name="visible">
<closure function="not" type="gboolean">
<lookup name="is-empty">
filter_list
</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="AdwStatusPage">
<property name="title" translatable="yes">No Filters</property>
<property name="description" translatable="yes">How about adding some filters?</property>
<property name="icon-name">funnel-symbolic</property>
<property name="vexpand">True</property>
<binding name="visible">
<lookup name="is-empty">
filter_list
</lookup>
</binding>
</object>
</child>
</object>
Expand Down
20 changes: 20 additions & 0 deletions data/resources/ui/subscription_page.ui
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@
<child>
<object class="TFSubscriptionList" id="subscription_list">
<signal name="go-to-videos" handler="handle_go_to_videos_page" swapped="true"/>
<binding name="visible">
<closure function="not" type="gboolean">
<lookup name="is-empty">
subscription_list
</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="AdwStatusPage">
<property name="title" translatable="yes">No Subscriptions</property>
<property name="description" translatable="yes">How about subscribing to some channels?</property>
<property name="icon-name">library-artists-symbolic</property>
<property name="vexpand">True</property>
<binding name="visible">
<lookup name="is-empty">
subscription_list
</lookup>
</binding>
</object>
</child>
</object>
Expand Down
20 changes: 20 additions & 0 deletions data/resources/ui/watch_later.ui
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
</child>
<child>
<object class="TFFeedList" id="feed_page">
<binding name="visible">
<closure function="not" type="gboolean">
<lookup name="is-empty">
feed_page
</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="AdwStatusPage">
<property name="title" translatable="yes">Everything Watched</property>
<property name="description" translatable="yes">How about going outside?</property>
<property name="icon-name">alarm-symbolic</property>
<property name="vexpand">True</property>
<binding name="visible">
<lookup name="is-empty">
feed_page
</lookup>
</binding>
</object>
</child>
</object>
Expand Down
27 changes: 20 additions & 7 deletions src/gui/feed/feed_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl FeedList {
let _ = self.activate_action("feed.more", None);

self.set_more_available();
self.notify("is-empty");
}

pub fn prepend(&self, new_item: VideoObject) {
Expand All @@ -90,6 +91,7 @@ impl FeedList {
loaded_count.set(loaded_count.get() + 1);

self.set_more_available();
self.notify("is-empty");
}

pub fn remove(&self, new_item: VideoObject) {
Expand All @@ -111,6 +113,7 @@ impl FeedList {
}

self.set_more_available();
self.notify("is-empty");
}

pub fn set_playlist_manager(&self, playlist_manager: PlaylistManager<String, AnyVideo>) {
Expand Down Expand Up @@ -228,13 +231,22 @@ pub mod imp {

fn properties() -> &'static [ParamSpec] {
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
vec![ParamSpecBoolean::new(
"more-available",
"more-available",
"more-available",
false,
ParamFlags::READWRITE,
)]
vec![
ParamSpecBoolean::new(
"more-available",
"more-available",
"more-available",
false,
ParamFlags::READWRITE,
),
ParamSpecBoolean::new(
"is-empty",
"is-empty",
"is-empty",
false,
ParamFlags::READABLE,
),
]
});
PROPERTIES.as_ref()
}
Expand All @@ -254,6 +266,7 @@ pub mod imp {
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"more-available" => self.more_available.get().to_value(),
"is-empty" => (self.model.borrow().n_items() == 0).to_value(),
_ => unimplemented!(),
}
}
Expand Down
33 changes: 33 additions & 0 deletions src/gui/filter/filter_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use gdk::{
prelude::{Cast, ListModelExtManual},
subclass::prelude::ObjectSubclassIsExt,
};
use gdk_pixbuf::prelude::ObjectExt;
use tf_filter::FilterGroup;
use tf_join::AnyVideoFilter;

Expand All @@ -43,13 +44,15 @@ impl FilterList {

model.remove_all();
model.splice(0, 0, &items);
self.notify("is-empty");
}

pub fn add(&self, new_item: FilterObject) {
let imp = self.imp();
let model = &imp.model;

model.borrow_mut().insert(0, &new_item);
self.notify("is-empty");
}

pub fn remove(&self, new_item: FilterObject) {
Expand All @@ -64,6 +67,7 @@ impl FilterList {
}) {
model.remove(idx as u32);
}
self.notify("is-empty");
}

pub fn set_filter_group(&self, filter_group: Arc<Mutex<FilterGroup<AnyVideoFilter>>>) {
Expand All @@ -82,6 +86,10 @@ pub mod imp {
use gdk::glib::MainContext;
use gdk::glib::Sender;
use gdk::glib::PRIORITY_DEFAULT;
use gdk_pixbuf::glib::ParamFlags;
use gdk_pixbuf::glib::ParamSpec;
use gdk_pixbuf::glib::ParamSpecBoolean;
use gdk_pixbuf::glib::Value;
use glib::subclass::InitializingObject;
use gtk::glib;
use gtk::prelude::*;
Expand All @@ -90,6 +98,7 @@ pub mod imp {
use gtk::Widget;

use gtk::CompositeTemplate;
use once_cell::sync::Lazy;
use tf_filter::FilterEvent;
use tf_filter::FilterGroup;
use tf_join::AnyVideoFilter;
Expand Down Expand Up @@ -200,6 +209,30 @@ pub mod imp {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
}

fn properties() -> &'static [ParamSpec] {
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
vec![ParamSpecBoolean::new(
"is-empty",
"is-empty",
"is-empty",
false,
ParamFlags::READABLE,
)]
});
PROPERTIES.as_ref()
}

fn set_property(&self, _obj: &Self::Type, _id: usize, _value: &Value, _pspec: &ParamSpec) {
unimplemented!()
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"is-empty" => (self.model.borrow().n_items() == 0).to_value(),
_ => unimplemented!(),
}
}
}

impl WidgetImpl for FilterList {}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/filter/filter_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub mod imp {
use tf_join::AnyVideoFilter;

use crate::gui::filter::filter_list::FilterList;
use crate::gui::utility::Utility;

#[derive(CompositeTemplate, Default)]
#[template(resource = "/ui/filter_page.ui")]
Expand Down Expand Up @@ -140,6 +141,7 @@ pub mod imp {

fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Utility::bind_template_callbacks(klass);
}

fn instance_init(obj: &InitializingObject<Self>) {
Expand Down
34 changes: 33 additions & 1 deletion src/gui/subscription/subscription_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use gdk::{
prelude::{Cast, ListModelExtManual},
subclass::prelude::ObjectSubclassIsExt,
};
use gdk_pixbuf::prelude::ObjectExt;
use gtk::{traits::SorterExt, SorterChange};
use tf_join::{AnySubscription, AnySubscriptionList};

Expand All @@ -41,6 +42,7 @@ impl SubscriptionList {

model.remove_all();
model.splice(0, 0, &items);
self.notify("is-empty");
}

pub fn add(&self, new_item: SubscriptionObject) {
Expand All @@ -53,7 +55,8 @@ impl SubscriptionList {
.borrow()
.as_ref()
.expect("`Sorter` to be set up")
.changed(SorterChange::Different)
.changed(SorterChange::Different);
self.notify("is-empty");
}

pub fn remove(&self, new_item: SubscriptionObject) {
Expand All @@ -68,6 +71,7 @@ impl SubscriptionList {
}) {
model.remove(idx as u32);
}
self.notify("is-empty");
}

pub fn update(&self, sub: AnySubscription) {
Expand Down Expand Up @@ -104,6 +108,10 @@ pub mod imp {
use gdk::glib::Sender;
use gdk::glib::PRIORITY_DEFAULT;
use gdk_pixbuf::glib::subclass::Signal;
use gdk_pixbuf::glib::ParamFlags;
use gdk_pixbuf::glib::ParamSpec;
use gdk_pixbuf::glib::ParamSpecBoolean;
use gdk_pixbuf::glib::Value;
use glib::subclass::InitializingObject;
use gtk::glib;
use gtk::prelude::*;
Expand Down Expand Up @@ -275,6 +283,30 @@ pub mod imp {
self.parent_constructed(obj);
}

fn properties() -> &'static [ParamSpec] {
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
vec![ParamSpecBoolean::new(
"is-empty",
"is-empty",
"is-empty",
false,
ParamFlags::READABLE,
)]
});
PROPERTIES.as_ref()
}

fn set_property(&self, _obj: &Self::Type, _id: usize, _value: &Value, _pspec: &ParamSpec) {
unimplemented!()
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"is-empty" => (self.model.borrow().n_items() == 0).to_value(),
_ => unimplemented!(),
}
}

fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
vec![Signal::builder(
Expand Down
2 changes: 2 additions & 0 deletions src/gui/subscription/subscription_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub mod imp {
use crate::gui::subscription::platform::PlatformObject;
use crate::gui::subscription::subscription_item_object::SubscriptionObject;
use crate::gui::subscription::subscription_list::SubscriptionList;
use crate::gui::utility::Utility;

#[derive(CompositeTemplate, Default)]
#[template(resource = "/ui/subscription_page.ui")]
Expand Down Expand Up @@ -257,6 +258,7 @@ pub mod imp {
fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Self::bind_template_callbacks(klass);
Utility::bind_template_callbacks(klass);
}

fn instance_init(obj: &InitializingObject<Self>) {
Expand Down
2 changes: 2 additions & 0 deletions src/gui/watch_later.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub mod imp {

use crate::gui::feed::feed_item_object::VideoObject;
use crate::gui::feed::feed_list::FeedList;
use crate::gui::utility::Utility;

#[derive(CompositeTemplate, Default)]
#[template(resource = "/ui/watch_later.ui")]
Expand Down Expand Up @@ -127,6 +128,7 @@ pub mod imp {

fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Utility::bind_template_callbacks(klass);
}

fn instance_init(obj: &InitializingObject<Self>) {
Expand Down

0 comments on commit a294dab

Please sign in to comment.