diff --git a/hammond-gtk/resources/gtk/episodes_view.ui b/hammond-gtk/resources/gtk/episodes_view.ui
index 4776fd9..b3a4456 100644
--- a/hammond-gtk/resources/gtk/episodes_view.ui
+++ b/hammond-gtk/resources/gtk/episodes_view.ui
@@ -44,15 +44,50 @@
vertical
7
-
-
+
True
False
True
- 0
- in
+ vertical
-
+
True
False
- True
- none
+ start
+ Yesterday
+
+
+
+
+ False
+ True
+ 0
+
-
-
+
+
+ True
+ False
+ 0
+ in
+
+
+ True
+ False
+ none
+
+
+
+
+
+
+
+ False
+ True
+ 1
+
@@ -86,15 +148,50 @@
-
+
True
False
True
- start
- Yesterday
-
-
-
+ vertical
+
+
+ True
+ False
+ start
+ This Week
+
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ 0
+ in
+
+
+ True
+ False
+ none
+
+
+
+
+
+
+
+ False
+ True
+ 1
+
+
False
@@ -103,20 +200,49 @@
-
+
True
False
- 0
- in
+ True
+ vertical
-
+
True
False
- none
+ start
+ This Month
+
+
+
+
+ False
+ True
+ 0
+
-
-
+
+
+ True
+ False
+ 0
+ in
+
+
+ True
+ False
+ none
+
+
+
+
+
+
+
+ False
+ True
+ 1
+
@@ -126,15 +252,50 @@
-
+
True
False
True
- start
- This Week
-
-
-
+ vertical
+
+
+ True
+ False
+ start
+ This Year
+
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ 0
+ in
+
+
+ True
+ False
+ none
+
+
+
+
+
+
+
+ False
+ True
+ 1
+
+
False
@@ -143,20 +304,50 @@
-
+
True
False
- 0
- in
+ True
+ vertical
-
+
True
False
- none
+ start
+ Older than a Year
+
+
+
+
+ False
+ True
+ 0
+
-
-
+
+
+ True
+ False
+ 0
+ in
+
+
+ True
+ False
+ True
+ none
+
+
+
+
+
+
+
+ False
+ True
+ 1
+
@@ -165,46 +356,6 @@
5
-
-
- True
- False
- True
- start
- This Month
-
-
-
-
-
- False
- True
- 6
-
-
-
-
- True
- False
- 0
- in
-
-
- True
- False
- none
-
-
-
-
-
-
-
- False
- True
- 7
-
-
False
diff --git a/hammond-gtk/src/views/episodes.rs b/hammond-gtk/src/views/episodes.rs
index c711fb4..57191f1 100644
--- a/hammond-gtk/src/views/episodes.rs
+++ b/hammond-gtk/src/views/episodes.rs
@@ -16,20 +16,32 @@ enum ListSplit {
Yday,
Week,
Month,
+ Year,
+ Rest,
}
#[derive(Debug, Clone)]
pub struct EpisodesView {
pub container: gtk::Box,
frame_parent: gtk::Box,
- today_box: gtk::ListBox,
- yday_box: gtk::ListBox,
- week_box: gtk::ListBox,
- month_box: gtk::ListBox,
+ today_box: gtk::Box,
+ yday_box: gtk::Box,
+ week_box: gtk::Box,
+ month_box: gtk::Box,
+ year_box: gtk::Box,
+ rest_box: gtk::Box,
+ today_list: gtk::ListBox,
+ yday_list: gtk::ListBox,
+ week_list: gtk::ListBox,
+ month_list: gtk::ListBox,
+ year_list: gtk::ListBox,
+ rest_list: gtk::ListBox,
today_label: gtk::Label,
yday_label: gtk::Label,
week_label: gtk::Label,
month_label: gtk::Label,
+ year_label: gtk::Label,
+ rest_label: gtk::Label,
}
impl Default for EpisodesView {
@@ -37,14 +49,24 @@ impl Default for EpisodesView {
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/episodes_view.ui");
let container: gtk::Box = builder.get_object("container").unwrap();
let frame_parent: gtk::Box = builder.get_object("frame_parent").unwrap();
- let today_box: gtk::ListBox = builder.get_object("today_box").unwrap();
- let yday_box: gtk::ListBox = builder.get_object("yday_box").unwrap();
- let week_box: gtk::ListBox = builder.get_object("week_box").unwrap();
- let month_box: gtk::ListBox = builder.get_object("month_box").unwrap();
+ let today_box: gtk::Box = builder.get_object("today_box").unwrap();
+ let yday_box: gtk::Box = builder.get_object("yday_box").unwrap();
+ let week_box: gtk::Box = builder.get_object("week_box").unwrap();
+ let month_box: gtk::Box = builder.get_object("month_box").unwrap();
+ let year_box: gtk::Box = builder.get_object("year_box").unwrap();
+ let rest_box: gtk::Box = builder.get_object("rest_box").unwrap();
+ let today_list: gtk::ListBox = builder.get_object("today_list").unwrap();
+ let yday_list: gtk::ListBox = builder.get_object("yday_list").unwrap();
+ let week_list: gtk::ListBox = builder.get_object("week_list").unwrap();
+ let month_list: gtk::ListBox = builder.get_object("month_list").unwrap();
+ let year_list: gtk::ListBox = builder.get_object("year_list").unwrap();
+ let rest_list: gtk::ListBox = builder.get_object("rest_list").unwrap();
let today_label: gtk::Label = builder.get_object("today_label").unwrap();
let yday_label: gtk::Label = builder.get_object("yday_label").unwrap();
let week_label: gtk::Label = builder.get_object("week_label").unwrap();
let month_label: gtk::Label = builder.get_object("month_label").unwrap();
+ let year_label: gtk::Label = builder.get_object("year_label").unwrap();
+ let rest_label: gtk::Label = builder.get_object("rest_label").unwrap();
EpisodesView {
container,
@@ -53,10 +75,20 @@ impl Default for EpisodesView {
yday_box,
week_box,
month_box,
+ year_box,
+ rest_box,
+ today_list,
+ yday_list,
+ week_list,
+ month_list,
+ year_list,
+ rest_list,
today_label,
yday_label,
week_label,
month_label,
+ year_label,
+ rest_label,
}
}
}
@@ -76,31 +108,64 @@ impl EpisodesView {
let t = split(now_utc, ep.epoch());
match t {
ListSplit::Today => {
- view.today_box.add(&viewep.container);
- view.today_box.add(&sep)
+ view.today_list.add(&viewep.container);
+ view.today_list.add(&sep)
}
ListSplit::Yday => {
- view.yday_box.add(&viewep.container);
- view.yday_box.add(&sep)
+ view.yday_list.add(&viewep.container);
+ view.yday_list.add(&sep)
}
ListSplit::Week => {
- view.week_box.add(&viewep.container);
- view.week_box.add(&sep)
+ view.week_list.add(&viewep.container);
+ view.week_list.add(&sep)
}
- _ => {
- view.month_box.add(&viewep.container);
- view.month_box.add(&sep)
+ ListSplit::Month => {
+ view.month_list.add(&viewep.container);
+ view.month_list.add(&sep)
+ }
+ ListSplit::Year => {
+ view.year_list.add(&viewep.container);
+ view.year_list.add(&sep)
+ }
+ ListSplit::Rest => {
+ view.rest_list.add(&viewep.container);
+ view.rest_list.add(&sep)
}
}
sep.show()
});
+ if view.today_list.get_children().is_empty() {
+ view.today_box.hide();
+ }
+
+ if view.yday_list.get_children().is_empty() {
+ view.yday_box.hide();
+ }
+
+ if view.week_list.get_children().is_empty() {
+ view.week_box.hide();
+ }
+
+ if view.month_list.get_children().is_empty() {
+ view.month_box.hide();
+ }
+
+ if view.year_list.get_children().is_empty() {
+ view.year_box.hide();
+ }
+
+ if view.rest_list.get_children().is_empty() {
+ view.rest_box.hide();
+ }
+
view.container.show_all();
Rc::new(view)
}
}
+// TODO: Avoid epoch calculations, use chrono instead.
fn split(now_utc: i32, epoch: i32) -> ListSplit {
let t = now_utc - epoch;
@@ -110,8 +175,12 @@ fn split(now_utc: i32, epoch: i32) -> ListSplit {
ListSplit::Yday
} else if t < 604_800 {
ListSplit::Week
- } else {
+ } else if t < 2_419_200 {
ListSplit::Month
+ } else if t < 31_536_000 {
+ ListSplit::Year
+ } else {
+ ListSplit::Rest
}
}