Skip to content

Commit

Permalink
feat(Timelines): bubble (#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Dec 10, 2024
1 parent c41700a commit 50d2ad5
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-police-badge2-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-clock-alt-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-quotation-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-fish-symbolic.svg</file>
<!-- <file preprocess="xml-stripblanks">icons/scalable/actions/tuba-language-symbolic.svg</file> -->

<file>gtk/help-overlay.ui</file>
Expand Down
2 changes: 2 additions & 0 deletions data/icons/scalable/actions/tuba-fish-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/API/Instance.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public class Tuba.API.Instance : Entity {
}
}

public bool supports_bubble {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.features != null) {
return "bubble_timeline" in pleroma.metadata.features;
}

return false;
}
}

public string[]? compat_supported_mime_types {
get {
if (pleroma != null && pleroma.metadata != null) {
Expand Down
4 changes: 4 additions & 0 deletions src/Services/Accounts/InstanceAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
}

public virtual signal void activated () {
bump_sidebar_items ();
gather_instance_info ();
gather_instance_custom_emojis ();
GLib.Idle.add (gather_fav_lists);
Expand Down Expand Up @@ -508,10 +509,13 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
}

app.handle_share ();
bump_sidebar_items ();
})
.exec ();
}

protected virtual void bump_sidebar_items () {}

private void gather_v2_instance_info () {
new Request.GET ("/api/v2/instance")
.with_account (this)
Expand Down
15 changes: 15 additions & 0 deletions src/Services/Accounts/Mastodon/Account.vala
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ public class Tuba.Mastodon.Account : InstanceAccount {
}
};

public static Place PLACE_BUBBLE = new Place () { // vala-lint=naming-convention

icon = "tuba-fish-symbolic",
title = "Bubble", // NOTE: Leave untranslated for now
open_func = (win) => {
win.open_view (set_as_sidebar_item (new Views.Bubble ()));
},
visible = false
};

public static Place PLACE_FEDERATED = new Place () { // vala-lint=naming-convention

icon = "tuba-globe-symbolic",
Expand Down Expand Up @@ -150,10 +160,15 @@ public class Tuba.Mastodon.Account : InstanceAccount {

PLACE_EXPLORE,
PLACE_LOCAL,
PLACE_BUBBLE,
PLACE_FEDERATED,
PLACE_LISTS
};

protected override void bump_sidebar_items () {
PLACE_BUBBLE.visible = this.instance_info != null && this.instance_info.supports_bubble;
}

public override void register_known_places (GLib.ListStore places) {
app.bind_property ("is-mobile", PLACE_NOTIFICATIONS, "visible", GLib.BindingFlags.SYNC_CREATE | GLib.BindingFlags.INVERT_BOOLEAN);
app.bind_property ("is-mobile", PLACE_CONVERSATIONS, "visible", GLib.BindingFlags.SYNC_CREATE | GLib.BindingFlags.INVERT_BOOLEAN);
Expand Down
8 changes: 8 additions & 0 deletions src/Views/Bubble.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class Tuba.Views.Bubble : Views.Timeline {
construct {
url = "/api/v1/timelines/bubble";
label = "Bubble"; // NOTE: Leave untranslated for now
icon = "tuba-fish-symbolic";
is_public = true;
}
}
10 changes: 8 additions & 2 deletions src/Views/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,14 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
// Item
[GtkTemplate (ui = "/dev/geopjr/Tuba/ui/views/sidebar/item.ui")]
protected class ItemRow : Gtk.ListBoxRow {
public Place place;
public Place place {get; set;}

[GtkChild] unowned Gtk.Image icon;
[GtkChild] unowned Gtk.Label label;
[GtkChild] unowned Gtk.Label badge;

public ItemRow (Place place) {
this.notify["visible"].connect (on_visibility_changed);
this.place = place;
place.bind_property ("title", label, "label", BindingFlags.SYNC_CREATE);
place.bind_property ("icon", icon, "icon-name", BindingFlags.SYNC_CREATE);
Expand All @@ -220,6 +221,12 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
on_attention_change ();
}

// ListBox's bind_model sets visibility of every row to true
// when the model changes. Let's do some hacking around it.
void on_visibility_changed () {
if (this.visible != this.place.visible) this.visible = this.place.visible;
}

void on_attention_change () {
if (this.place.needs_attention) {
badge.remove_css_class ("no-attention");
Expand Down Expand Up @@ -256,7 +263,6 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
}
}


void view_announcements_cb () {
app.open_announcements ();
}
Expand Down
1 change: 1 addition & 0 deletions src/Views/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sources += files(
'Announcements.vala',
'Base.vala',
'Bookmarks.vala',
'Bubble.vala',
'ContentBase.vala',
'Conversations.vala',
'DraftStatuses.vala',
Expand Down

0 comments on commit 50d2ad5

Please sign in to comment.