Skip to content

feat: ListBox => ListView #1301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions build-aux/dev.geopjr.Tuba.Stack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"app-id": "dev.geopjr.Tuba",
"runtime": "org.gnome.Platform",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
"command": "dev.geopjr.Tuba",
"finish-args": [
"--device=dri",
"--share=ipc",
"--share=network",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=pulseaudio"
],
"cleanup": [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"/share/vala",
"*.la",
"*.a"
],
"modules": [
{
"name": "libsass",
"buildsystem": "meson",
"cleanup": [
"*"
],
"sources": [
{
"type": "git",
"url": "https://github.com/lazka/libsass.git",
"commit": "302397c0c8ae2d7ab02f45ea461c2c3d768f248e"
}
]
},
{
"name": "sassc",
"buildsystem": "meson",
"cleanup": [
"*"
],
"sources": [
{
"type": "git",
"url": "https://github.com/lazka/sassc.git",
"commit": "82803377c33247265d779af034eceb5949e78354"
}
]
},
{
"name": "gtk",
"buildsystem": "meson",
"config-opts": [
"-Dbuildtype=release",
"-Dprint-cups=disabled",
"-Dbuild-demos=false",
"-Dbuild-testsuite=false",
"-Dbuild-examples=false",
"-Dbuild-tests=false"
],
"cleanup": [
"/bin/gtk*"
],
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/gtk.git",
"tag": "4.17.2"
},
{
"type": "patch",
"path": "listview_lower_min_recycler.patch"
}
]
},
{
"name": "libspelling",
"buildsystem": "meson",
"config-opts": [
"-Ddocs=false"
],
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libspelling.git",
"tag": "0.4.5"
}
]
},
{
"name": "tuba",
"builddir": true,
"buildsystem": "meson",
"config-opts": [
"-Ddevel=true",
"--libdir=lib"
],
"sources": [
{
"type": "dir",
"path": "../"
}
]
}
],
"build-options": {
"env": {}
}
}
14 changes: 14 additions & 0 deletions build-aux/listview_lower_min_recycler.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
--- gtk/gtklistview.c
+++ gtk/gtklistview.c
@@ -33,9 +33,9 @@
/* Maximum number of list items created by the listview.
* For debugging, you can set this to G_MAXUINT to ensure
* there's always a list item for every row.
*/
-#define GTK_LIST_VIEW_MAX_LIST_ITEMS 200
+#define GTK_LIST_VIEW_MAX_LIST_ITEMS 20

/* Extra items to keep above + below every tracker */
#define GTK_LIST_VIEW_EXTRA_ITEMS 2

60 changes: 31 additions & 29 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ headerbar.flat.no-title .title {
}

.small .ttl-profile-cover>.content {
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
border-radius: 0px;
}

.ttl-box-no-shadow>revealer>box {
Expand Down Expand Up @@ -523,67 +522,70 @@ video > overlay > revealer > controls, .audio-controls {
box-shadow: none;
}

/* .ttl-view .content row:first-child { */
.ttl-view .fake-content row:first-child {
.ttl-view .contentbase row:first-child {
/* .ttl-view .fake-content row:first-child { */
margin-top: 0px;
}

/* .ttl-view .content row:last-child { */
.ttl-view .fake-content row:last-child {
.ttl-view .contentbase row:last-child {
/* .ttl-view .fake-content row:last-child { */
margin-bottom: 0px;
}

/* .ttl-view:not(.large-view) .content .card { */
.ttl-view:not(.large-view) .fake-content .card,
.ttl-view:not(.large-view) .fake-content .toggle-group-17 {
.ttl-view:not(.large-view) .contentbase .card,
.ttl-view:not(.large-view) .contentbase .toggle-group-17 {
/* .ttl-view:not(.large-view) .fake-content .card,
.ttl-view:not(.large-view) .fake-content .toggle-group-17 { */
border-left: none;
border-right: none;
border-radius: 0px;
}

/* .ttl-view:not(.large-view) .content { */
.ttl-view:not(.large-view) .fake-content {
.ttl-view:not(.large-view) .contentbase {
/* .ttl-view:not(.large-view) .fake-content { */
padding: 0px;
}

/* .ttl-view .content row:not(.ttl-post) { */
.ttl-view .fake-content row:not(.ttl-post):not(.toggle-group-17) {
.ttl-view .contentbase row:not(.ttl-post):not(.toggle-group-17) {
/* .ttl-view .fake-content row:not(.ttl-post):not(.toggle-group-17) { */
padding: 0px;
}

.card-spacing {
/* .card-spacing {
background-color: var(--card-bg-color);
}
} */

.ttl-profile-cover > .content {
.ttl-profile-cover > .contentbase {
background: none;
}

/* .ttl-view .content { */
.ttl-view .fake-content {
.ttl-view .contentbase {
/* .ttl-view .fake-content { */
transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ttl-view.large-view .fake-content:first-child {
.ttl-view.large-view .contentbase:first-child {
/* .ttl-view.large-view .fake-content:first-child { */
padding-top: 32px;
}

.ttl-view.large-view .fake-content:last-child {
.ttl-view.large-view .contentbase:last-child {
/* .ttl-view.large-view .fake-content:last-child { */
padding-bottom: 32px;
}

/* .ttl-view:not(.large-view) .content .card { */
.ttl-view:not(.large-view) .fake-content .card {
.ttl-view:not(.large-view) .contentbase .card {
/* .ttl-view:not(.large-view) .fake-content .card { */
border-bottom: 1px var(--border-color) solid;
}

/* .ttl-view:not(.large-view) .content .card:first-child { */
.ttl-view:not(.large-view) .fake-content .card:first-child {
.ttl-view:not(.large-view) .contentbase .card:first-child {
/* .ttl-view:not(.large-view) .fake-content .card:first-child { */
border-top: 1px var(--border-color) solid;
}

/* .ttl-view:not(.large-view) .content .card { */
.ttl-view:not(.large-view) .fake-content .card {
.ttl-view:not(.large-view) .contentbase .card {
/* .ttl-view:not(.large-view) .fake-content .card { */
box-shadow: none;
}

Expand All @@ -599,8 +601,8 @@ video > overlay > revealer > controls, .audio-controls {
border-radius: 12px;
}

/* .ttl-view:not(.large-view) .content .card.card-spacing { */
.ttl-view:not(.large-view) .fake-content .card.card-spacing {
.ttl-view:not(.large-view) .contentbase .card-spacing:not(.keep-margin) {
/* .ttl-view:not(.large-view) .fake-content .card.card-spacing { */
margin: 0px;
}

Expand All @@ -612,7 +614,7 @@ video > overlay > revealer > controls, .audio-controls {
padding: 3px 14px;
}

.ttl-view.large-view .fake-content {
.ttl-view.large-view .contentbase {
padding-left: 0;
padding-right: 0;
margin-left: 18px;
Expand Down
4 changes: 2 additions & 2 deletions data/ui/views/base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
<property name="vexpand">1</property>
<property name="hscrollbar_policy">never</property>
<property name="child">
<!-- <object class="AdwClampScrollable" id="content_box"> -->
<object class="AdwClamp" id="content_box">
<object class="AdwClampScrollable" id="content_box">
<!-- <object class="AdwClamp" id="content_box"> -->
<property name="vexpand">1</property>
<property name="visible">True</property>
<property name="maximum_size">670</property>
Expand Down
1 change: 1 addition & 0 deletions data/ui/views/profile_header.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<object class="GtkListBox" id="info">
<property name="selection_mode">none</property>
<property name="activate_on_single_click">0</property>
<property name="overflow">hidden</property>
<style>
<class name="content" />
<class name="uniform-border-color" />
Expand Down
4 changes: 2 additions & 2 deletions data/ui/widgets/status.ui
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0" />
<!-- <template class="TubaWidgetsStatus" parent="AdwBin"> -->
<template class="TubaWidgetsStatus" parent="GtkListBoxRow">
<template class="TubaWidgetsStatus" parent="AdwBin">
<!-- <template class="TubaWidgetsStatus" parent="GtkListBoxRow"> -->
<accessibility>
<relation name="described-by">content</relation>
</accessibility>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(
],
)

# add_project_arguments(['--define=USE_LISTVIEW'], language: 'vala')
add_project_arguments(['--define=USE_LISTVIEW'], language: 'vala')

# https://gitlab.gnome.org/GNOME/vala/-/issues/1413#note_1707480
if meson.get_compiler ('c').get_id () == 'clang'
Expand Down
4 changes: 3 additions & 1 deletion src/Dialogs/Admin/Report.vala
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ public class Tuba.Dialogs.Admin.Report : Dialogs.Admin.Base {
widget.add_css_class ("card-spacing");
widget.actions.visible = false;
widget.menu_button.visible = false;
widget.activatable = false;
#if !USE_LISTVIEW
widget.activatable = false;
#endif
widget.filter_stack.can_focus = false;
widget.filter_stack.can_target = false;
widget.filter_stack.focusable = false;
Expand Down
4 changes: 3 additions & 1 deletion src/Dialogs/AnnualReport.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public class Tuba.Dialogs.AnnualReport : Adw.Dialog {
var widg = status.to_widget () as Widgets.Status;
widg.actions.visible = false;
widg.menu_button.visible = false;
widg.activatable = false;
#if !USE_LISTVIEW
widg.activatable = false;
#endif
widg.filter_stack.can_focus = false;
widg.filter_stack.can_target = false;
widg.filter_stack.focusable = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Network/Streamable.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public abstract interface Tuba.Streamable : Object {
public interface Tuba.Streamable : Object {

public struct Event {
public string type;
Expand Down
2 changes: 1 addition & 1 deletion src/Views/Admin/Timelines/PaginationTimeline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Tuba.Views.Admin.Timeline.PaginationTimeline : Gtk.Box {

content = new Gtk.ListBox () {
selection_mode = Gtk.SelectionMode.NONE,
css_classes = { "fake-content", "background" }
css_classes = { "content", "background" }
};
content.row_activated.connect (on_content_item_activated);

Expand Down
13 changes: 5 additions & 8 deletions src/Views/ContentBase.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public class Tuba.Views.ContentBase : Views.Base {
protected Gtk.ListView content;
#else
protected Gtk.ListBox content;
protected signal void reached_close_to_top ();
#endif
protected signal void reached_close_to_top ();
public GLib.ListStore model;
private bool bottom_reached_locked = false;

Expand All @@ -21,17 +21,17 @@ public class Tuba.Views.ContentBase : Views.Base {
signallistitemfactory.bind.connect (bind_listitem_cb);

content = new Gtk.ListView (new Gtk.NoSelection (model), signallistitemfactory) {
css_classes = { "content", "background" },
css_classes = { "contentbase", "content", "background" },
single_click_activate = true
};

content.activate.connect (on_content_item_activated);
model.items_changed.connect (on_content_changed);
#else
model.items_changed.connect (on_content_changed);

content = new Gtk.ListBox () {
selection_mode = Gtk.SelectionMode.NONE,
css_classes = { "fake-content", "background" }
css_classes = { "content", "background" }
};

content.row_activated.connect (on_content_item_activated);
Expand Down Expand Up @@ -61,9 +61,7 @@ public class Tuba.Views.ContentBase : Views.Base {
&& scrolled.vadjustment.value + scrolled.vadjustment.page_size + 100 < scrolled.vadjustment.upper
);

#if !USE_LISTVIEW
if (is_close_to_top) reached_close_to_top ();
#endif
if (is_close_to_top) reached_close_to_top ();
}

protected void set_scroll_to_top_reveal_child (bool reveal) {
Expand Down Expand Up @@ -129,7 +127,6 @@ public class Tuba.Views.ContentBase : Views.Base {
if (obj_widgetable == null)
Process.exit (0);
try {

#if !USE_LISTVIEW
Gtk.Widget widget = obj_widgetable.to_widget ();
widget.add_css_class ("card");
Expand Down
12 changes: 9 additions & 3 deletions src/Views/NotificationRequests.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ public class Tuba.Views.NotificationRequests : Views.Timeline {
.exec ();
}

public override void on_content_item_activated (Gtk.ListBoxRow row) {
((Widgets.NotificationRequest) row).open ();
}
#if USE_LISTVIEW
public override void on_content_item_activated (uint pos) {
((Widgetizable) ((ListModel) content.model).get_item (pos)).open ();
}
#else
public override void on_content_item_activated (Gtk.ListBoxRow row) {
((Widgets.NotificationRequest) row).open ();
}
#endif
}
Loading
Loading