Skip to content

Commit 2a1b066

Browse files
authored
feat(explore): link timelines (#1113)
1 parent 7628843 commit 2a1b066

File tree

15 files changed

+243
-135
lines changed

15 files changed

+243
-135
lines changed

data/gresource.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
<file>ui/widgets/status.ui</file>
9494
<file>ui/widgets/votebox.ui</file>
9595
<file>ui/widgets/preview_card.ui</file>
96+
<file>ui/widgets/preview_card_internal.ui</file>
97+
<file>ui/widgets/preview_card_explore.ui</file>
9698
<file>ui/widgets/profile.ui</file>
9799
<file>ui/dialogs/admin_dashboard.ui</file>
98100
<file>ui/dialogs/list_edit.ui</file>

data/ui/widgets/preview_card.ui

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,74 +12,7 @@
1212
<class name="flat" />
1313
</style>
1414
<child>
15-
<object class="GtkBox" id="box">
16-
<property name="orientation">vertical</property>
17-
<child>
18-
<object class="GtkBox">
19-
<property name="orientation">vertical</property>
20-
<property name="spacing">3</property>
21-
<property name="valign">center</property>
22-
<property name="hexpand">1</property>
23-
<property name="margin-top">12</property>
24-
<property name="margin-start">12</property>
25-
<property name="margin-end">12</property>
26-
<property name="margin-bottom">12</property>
27-
<child>
28-
<object class="GtkLabel" id="author_label">
29-
<property name="ellipsize">end</property>
30-
<property name="halign">start</property>
31-
<property name="single-line-mode">1</property>
32-
<style>
33-
<class name="dim-label" />
34-
<class name="caption" />
35-
</style>
36-
</object>
37-
</child>
38-
<child>
39-
<object class="GtkLabel" id="title_label">
40-
<property name="visible">0</property>
41-
<property name="ellipsize">end</property>
42-
<property name="halign">fill</property>
43-
<property name="xalign">0</property>
44-
<property name="lines">2</property>
45-
<property name="wrap">1</property>
46-
<property name="wrap-mode">word-char</property>
47-
<style>
48-
<class name="font-bold" />
49-
</style>
50-
</object>
51-
</child>
52-
<child>
53-
<object class="GtkLabel" id="description_label">
54-
<property name="visible">0</property>
55-
<property name="ellipsize">end</property>
56-
<property name="halign">fill</property>
57-
<property name="xalign">0</property>
58-
<property name="lines">3</property>
59-
<property name="wrap">1</property>
60-
<property name="wrap-mode">word-char</property>
61-
<property name="single-line-mode">1</property>
62-
<style>
63-
<class name="caption" />
64-
</style>
65-
</object>
66-
</child>
67-
<child>
68-
<object class="GtkLabel" id="used_times_label">
69-
<property name="visible">0</property>
70-
<property name="halign">fill</property>
71-
<property name="xalign">0</property>
72-
<property name="wrap">1</property>
73-
<property name="wrap-mode">word-char</property>
74-
<style>
75-
<class name="dim-label" />
76-
<class name="caption" />
77-
</style>
78-
</object>
79-
</child>
80-
</object>
81-
</child>
82-
</object>
15+
<object class="TubaWidgetsPreviewCardInternal" id="box" />
8316
</child>
8417
</object>
8518
</child>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<interface>
3+
<requires lib="gtk" version="4.0" />
4+
<template class="TubaWidgetsPreviewCardExplore" parent="GtkListBoxRow">
5+
<style>
6+
<class name="preview_card" />
7+
<class name="explore" />
8+
</style>
9+
<child>
10+
<object class="TubaWidgetsPreviewCardInternal" id="box">
11+
<property name="orientation">horizontal</property>
12+
<property name="homogeneous">1</property>
13+
</object>
14+
</child>
15+
</template>
16+
</interface>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<interface>
3+
<requires lib="gtk" version="4.0" />
4+
<template class="TubaWidgetsPreviewCardInternal" parent="GtkBox">
5+
<property name="orientation">vertical</property>
6+
<child>
7+
<object class="GtkBox" id="internal_box">
8+
<property name="orientation">vertical</property>
9+
<property name="spacing">3</property>
10+
<property name="valign">center</property>
11+
<property name="hexpand">1</property>
12+
<property name="margin-top">12</property>
13+
<property name="margin-start">12</property>
14+
<property name="margin-end">12</property>
15+
<property name="margin-bottom">12</property>
16+
<child>
17+
<object class="GtkLabel" id="author_label">
18+
<property name="ellipsize">end</property>
19+
<property name="halign">start</property>
20+
<property name="single-line-mode">1</property>
21+
<style>
22+
<class name="dim-label" />
23+
<class name="caption" />
24+
</style>
25+
</object>
26+
</child>
27+
<child>
28+
<object class="GtkLabel" id="title_label">
29+
<property name="visible">0</property>
30+
<property name="ellipsize">end</property>
31+
<property name="halign">fill</property>
32+
<property name="xalign">0</property>
33+
<property name="lines">2</property>
34+
<property name="wrap">1</property>
35+
<property name="wrap-mode">word-char</property>
36+
<style>
37+
<class name="font-bold" />
38+
</style>
39+
</object>
40+
</child>
41+
<child>
42+
<object class="GtkLabel" id="description_label">
43+
<property name="visible">0</property>
44+
<property name="ellipsize">end</property>
45+
<property name="halign">fill</property>
46+
<property name="xalign">0</property>
47+
<property name="lines">3</property>
48+
<property name="wrap">1</property>
49+
<property name="wrap-mode">word-char</property>
50+
<property name="single-line-mode">1</property>
51+
<style>
52+
<class name="caption" />
53+
</style>
54+
</object>
55+
</child>
56+
</object>
57+
</child>
58+
</template>
59+
</interface>

src/API/Instance.vala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class Tuba.API.Instance : Entity {
1717
public Gee.ArrayList<Rule>? rules { get; set; }
1818

1919
public bool tuba_can_translate { get; set; default=false; }
20+
public int8 tuba_mastodon_version { get; set; default=0; }
2021

2122
public override Type deserialize_array_type (string prop) {
2223
switch (prop) {

src/API/InstanceV2.vala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ public class Tuba.API.InstanceV2 : Entity {
66
public Translation translation { get; set; default = null; }
77
}
88

9+
public class APIVersions : Entity {
10+
public int8 mastodon { get; set; default = 0; }
11+
}
12+
913
public Configuration configuration { get; set; default = null; }
14+
public APIVersions? api_versions { get; set; default = null; }
1015

1116
public static InstanceV2 from (Json.Node node) throws Error {
1217
return Entity.from_json (typeof (API.InstanceV2), node) as API.InstanceV2;

src/API/Status/PreviewCard.vala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
168168
}
169169

170170
public override Gtk.Widget to_widget () {
171+
if (this.kind == "link" && this.history != null) return new Widgets.PreviewCardExplore (this);
172+
171173
return new Widgets.PreviewCard (this);
172174
}
173175

src/Services/Accounts/InstanceAccount.vala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,12 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
466466
this.probably_has_notification_filters = true;
467467
var instance_v2 = API.InstanceV2.from (node);
468468

469-
if (instance_v2 != null && instance_v2.configuration != null && instance_v2.configuration.translation != null) {
470-
this.instance_info.tuba_can_translate = instance_v2.configuration.translation.enabled;
469+
if (instance_v2 != null) {
470+
if (instance_v2.configuration != null && instance_v2.configuration.translation != null)
471+
this.instance_info.tuba_can_translate = instance_v2.configuration.translation.enabled;
472+
473+
if (instance_v2.api_versions != null && instance_v2.api_versions.mastodon > 0)
474+
this.instance_info.tuba_mastodon_version = instance_v2.api_versions.mastodon;
471475
}
472476
})
473477
.exec ();

src/Views/ContentBase.vala

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,13 @@ public class Tuba.Views.ContentBase : Views.Base {
122122

123123
#if !USE_LISTVIEW
124124
Gtk.Widget widget = obj_widgetable.to_widget ();
125-
if (widget as Widgets.PreviewCard == null) {
126-
widget.add_css_class ("card");
127-
widget.add_css_class ("card-spacing");
128-
widget.focusable = true;
129-
130-
// Thread lines overflow slightly
131-
widget.overflow = Gtk.Overflow.HIDDEN;
132-
return widget;
133-
}
134-
135-
return new Gtk.ListBoxRow () {
136-
css_classes = { "card", "card-spacing" },
137-
focusable = false,
138-
overflow = Gtk.Overflow.HIDDEN,
139-
child = widget
140-
};
125+
widget.add_css_class ("card");
126+
widget.add_css_class ("card-spacing");
127+
widget.focusable = true;
128+
129+
// Thread lines overflow slightly
130+
widget.overflow = Gtk.Overflow.HIDDEN;
131+
return widget;
141132
#else
142133
return obj_widgetable.to_widget ();
143134
#endif

src/Views/Link.vala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Tuba.Views.Link : Views.Timeline {
2+
public Link (string link) {
3+
Object (
4+
url: @"/api/v1/timelines/link?url=$(Uri.escape_string (link))",
5+
label: link,
6+
icon: "tuba-globe-symbolic"
7+
);
8+
}
9+
}

0 commit comments

Comments
 (0)