Remove refreshing indicator from ActivitiesView

I've decided I'm going to add an indicator for when the client is
disconnected so the indicator would be pretty redundant (and it
requires a bunch of code to implement).
This commit is contained in:
Camden Dixie O'Brien 2025-03-02 14:47:19 +00:00
parent c2d81778a8
commit 10a7fe5c82
2 changed files with 5 additions and 71 deletions

View File

@ -1,38 +1,27 @@
namespace StudySystemClient { namespace StudySystemClient {
public class ActivitiesView : Gtk.Box { public class ActivitiesView : CardArea {
private Client client; private Client client;
private RefreshingIndicator refreshing_indicator;
private CardArea card_area;
public ActivitiesView(Client client) { public ActivitiesView(Client client) {
base();
this.client = client; this.client = client;
card_area = new CardArea();
var overlay = new Gtk.Overlay();
overlay.hexpand = overlay.vexpand = true;
overlay.set_child(card_area);
this.append(overlay);
refreshing_indicator = new RefreshingIndicator(overlay);
this.map.connect(refresh); this.map.connect(refresh);
} }
private async void refresh() { private async void refresh() {
refreshing_indicator.show();
try { try {
var activities = yield client.list_activities(); var activities = yield client.list_activities();
card_area.clear(); clear();
foreach (var activity in activities) { foreach (var activity in activities) {
var card = new ActivityCard(activity); var card = new ActivityCard(activity);
card.session_logged.connect(log_session); card.session_logged.connect(log_session);
card_area.add(card); add(card);
} }
} catch (ClientError e) { } catch (ClientError e) {
stderr.printf("Error refreshing activities: %s\n", stderr.printf("Error refreshing activities: %s\n",
e.message); e.message);
} }
refreshing_indicator.hide();
} }
private async void log_session(string subject, ActivityType type, private async void log_session(string subject, ActivityType type,
@ -45,42 +34,4 @@ namespace StudySystemClient {
} }
} }
} }
private class RefreshingIndicator {
private Gtk.Overlay overlay;
private Gtk.Frame frame;
public RefreshingIndicator(Gtk.Overlay overlay) {
this.overlay = overlay;
var label = new Gtk.Label("Refreshing");
label.halign = Gtk.Align.START;
var spinner = new Gtk.Spinner();
spinner.start();
var content = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
content.margin_top = content.margin_bottom
= content.margin_start = content.margin_end = 12;
content.append(label);
content.append(spinner);
frame = new Gtk.Frame(null);
frame.halign = Gtk.Align.CENTER;
frame.valign = Gtk.Align.START;
frame.add_css_class("osd");
frame.add_css_class("popdown");
frame.set_child(content);
overlay.add_overlay(frame);
}
public void show() {
frame.add_css_class("visible");
}
public void hide() {
frame.remove_css_class("visible");
}
}
} }

View File

@ -27,20 +27,3 @@
margin-top: -2px; margin-top: -2px;
margin-left: 3px; margin-left: 3px;
} }
/*
* Couldn't find a built-in way to get the common OSD overlay style of
* rounding the bottom corners but not the top ones, so doing this
* myself with this CSS rule.
*/
overlay > frame.osd {
border-radius: 0 0 8px 8px;
}
.popdown {
transition: transform 200ms ease-in-out;
transform: translateY(-100px);
}
.popdown.visible {
transform: translateY(0);
}