After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 738518 - limit the height of the userlist popover
limit the height of the userlist popover
Status: RESOLVED FIXED
Product: polari
Classification: Applications
Component: general
3.14.x
Other Linux
: Normal normal
: ---
Assigned To: Polari maintainers
Polari maintainers
Depends on:
Blocks:
 
 
Reported: 2014-10-14 11:25 UTC by Jakub Steiner
Modified: 2014-11-27 11:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
userList: Convert to ui-files (9.29 KB, patch)
2014-11-05 12:26 UTC, Jonas Danielsson
needs-work Details | Review
userList: Limit height of list popover (2.84 KB, patch)
2014-11-05 12:26 UTC, Jonas Danielsson
needs-work Details | Review
userList: Limit height of list popover (3.88 KB, patch)
2014-11-06 10:06 UTC, Jonas Danielsson
needs-work Details | Review
userList: Fix filter entry revealing (859 bytes, patch)
2014-11-06 10:06 UTC, Jonas Danielsson
reviewed Details | Review
userList: Limit height of list popover (4.56 KB, patch)
2014-11-07 09:58 UTC, Jonas Danielsson
reviewed Details | Review
userList: Fix filter entry revealing (1.19 KB, patch)
2014-11-07 09:58 UTC, Jonas Danielsson
none Details | Review
userList: Fix filter entry revealing (1.22 KB, patch)
2014-11-07 13:08 UTC, Jonas Danielsson
committed Details | Review
userList: Limit height of list popover (4.76 KB, patch)
2014-11-10 06:27 UTC, Jonas Danielsson
none Details | Review
userList: Limit height of list popover (4.75 KB, patch)
2014-11-10 06:29 UTC, Jonas Danielsson
committed Details | Review
userList: Use visible rows for content height computation (1.48 KB, patch)
2014-11-27 11:41 UTC, Florian Müllner
committed Details | Review

Description Jakub Steiner 2014-10-14 11:25:27 UTC
Currently the popover takes up all screen height, which looks off balance most of the time. Channels with fewer people get a lot of whitespace at the bottom. 

One might see some benefit in fitting as many people in there to avoid scrolling or filtering, but I see having maximum of ~8 people to be the easiest solution - you get filtering that's most likely the tool to use if you're looking for a particular person and we do have a scrollbar.
Comment 1 Jonas Danielsson 2014-11-05 12:26:09 UTC
Created attachment 290013 [details] [review]
userList: Convert to ui-files

Make UserList, UserListPopover and UserListRow use ui files to
construct their ui.
Comment 2 Jonas Danielsson 2014-11-05 12:26:13 UTC
Created attachment 290014 [details] [review]
userList: Limit height of list popover

There is filtering and a scrollbar. There is no need to grow the list
indefinetly. This patch limits users shown to eight.
Comment 3 Florian Müllner 2014-11-05 15:34:21 UTC
Review of attachment 290013 [details] [review]:

Not a big fan - adding an extra file to put a box in a popover (UserListPopover) is just overkill. UserList is not much more complex either, but I could see a point if it was ported to use templates[0]. For ListRow this makes most sense to me, but I would like to see it use templates as well.

[0] www.hadess.net/2014/09/gtk-widget-templates-now-in-javascript.html

::: data/resources/user-list-row.ui
@@ +25,3 @@
+              <object class="GtkArrow" id="user-list-row-arrow">
+                <property name="arrow_type">right</property>
+                <property name="no_show_all">True</property>

If you use UI files, I would prefer to add <property name="visible">True</property> to all the visible-by-default widgets and not stop calling show_all().
Comment 4 Florian Müllner 2014-11-05 15:34:32 UTC
Review of attachment 290014 [details] [review]:

::: src/userList.js
@@ +345,3 @@
 
+        let rowHeight = this._getRowHeight();
+        this.widget.min_content_height = NUM_USERS_SHOWN * rowHeight;

MAX_USERS_SHOWN would be better in my opinion, e.g. use Math.min(MAX_USERS_SHOWN, numUsers) - it doesn't really make sense to reserve space for 8 users if we only have 5.

@@ +355,3 @@
+
+        let row = builder.get_object('user-list-row');
+        row.show_all();

Ugh, ugly. You need at the very least destroy the widget when no longer needed.
(You also don't take changes to the row height into account, for instance when the user changes themes)
Comment 5 Jonas Danielsson 2014-11-06 10:05:03 UTC
Review of attachment 290013 [details] [review]:

Sure.

I can look into making them templates. We want the same in Maps.
Right now there is some sort of bug blocking this as one get:
(gjs-console:24118): Gtk-CRITICAL **: Unable to load resource for composite template for type 'Gjs_UserListRow': The resource at '/org/gnome/Polari/resources/user-list-row.ui' does not exist

When you try to add a template resource. Will get back to that when it has been resolved.
Comment 6 Jonas Danielsson 2014-11-06 10:05:51 UTC
Review of attachment 290014 [details] [review]:

Thanks!

::: src/userList.js
@@ +345,3 @@
 
+        let rowHeight = this._getRowHeight();
+        this.widget.min_content_height = NUM_USERS_SHOWN * rowHeight;

Sure!

@@ +355,3 @@
+
+        let row = builder.get_object('user-list-row');
+        row.show_all();

Yeah, you are right. Updated version on its way.
Comment 7 Jonas Danielsson 2014-11-06 10:06:08 UTC
Created attachment 290082 [details] [review]
userList: Limit height of list popover

There is filtering and scrollbar. There is no need to grow the lost
indefinetly. This patch limits users shown to eight.
Comment 8 Jonas Danielsson 2014-11-06 10:06:15 UTC
Created attachment 290083 [details] [review]
userList: Fix filter entry revealing

Do not call _updateEntryVisibility on map since it will
always evaluate to reveal.
Comment 9 Jonas Danielsson 2014-11-06 10:07:26 UTC
Review of attachment 290082 [details] [review]:

::: src/userList.js
@@ +390,3 @@
+
+        for (let i = 0; i < membersShown; i++)
+            height += this._list.get_row_at_index(i).get_preferred_height()[1];

Maybe should be get_allocated_height() ?
Comment 10 Florian Müllner 2014-11-06 12:14:57 UTC
Review of attachment 290082 [details] [review]:

The handling of row expansion doesn't work currently (see detailed comment below). Also some typos in the commit message:
 - s/lost/list/
 - s/indefinetly/indefinitely/

::: src/userList.js
@@ +309,3 @@
             this._cancellable = null;
         }
+        this.emit('expand-notify');

I'm not sure we need to account for expansion - the previous patch always used to height of eight *unexpanded* rows, which seemed fine to me.
If we want to take expansion into account, this here is wrong: GtkRevealer:reveal-child means the child *should* be revealed (e.g. the animations is about to start, but nothing has been expanded yet). So this is currently exactly backwards, the popover starts with space for 8 rows, keeps its size when expanded, then grows when unexpanded; expanding it again shrinks the popover.
Using GtkRevealer:child-revealed instead should do what you intend, but the size change would still be jumpy (the row expands, then when it is fully expanded, the popover jumps to the new size). So if we want to grow the popover rather than just using the unexpaned size, I think we should get fancy and animate the size change. Something like this should work:
 - expose 'reveal-child' and 'child-revealed' somehow ('animation-start/end' signals,
   animating property ...)
 - connect to row::size-allocate on animation start and call _updateContentHeight from the handler
 - disconnect the signal on animation end

@@ +371,3 @@
 
+    get numRows() {
+        return Object.keys(this._rows).length;

Should this only count visible rows?

If not, there's some existing code in _onMembersChanged and _updateHeader that should be replaced with the new property.
Comment 11 Florian Müllner 2014-11-06 12:21:37 UTC
Review of attachment 290083 [details] [review]:

This now just broken differently, no? With the patch, when switching from a room with <8 users to a room with >8, you have to open the popover *twice* to get the search entry. What do you think about just kicking that code out altogether? I think with the new height restriction, lists that don't require scrolling should be rare enough to just always show the filter entry ...
Comment 12 Jonas Danielsson 2014-11-06 12:38:56 UTC
Review of attachment 290082 [details] [review]:

::: src/userList.js
@@ +309,3 @@
             this._cancellable = null;
         }
+        this.emit('expand-notify');

The reason I added it was that it felt annoying that when you click one of the users towards the bottom of the eight you would have to scroll to see the details.

Will look into fixing it up as you say.

@@ +371,3 @@
 
+    get numRows() {
+        return Object.keys(this._rows).length;

Sure those can change as well.
Comment 13 Florian Müllner 2014-11-06 12:42:00 UTC
(In reply to comment #12)
> The reason I added it was that it felt annoying that when you click one of the
> users towards the bottom of the eight you would have to scroll to see the
> details.

Ah, good point. Another option here would be to adjust the scrolling so that the currently selected row is visible, but that's probably not any easier than growing the popup.
Comment 14 Jonas Danielsson 2014-11-07 08:04:03 UTC
Something is really fishy, the child-revealed and the reveal-child signals are arriving in the wrong order for me.

I changed the code to this to test:

 this._revealer.connect('notify::child-revealed', function() {
            log('child-revealed');
 });

this._revealer.connect('notify::reveal-child', function() {
            log('reveal-child');
});

And get the output:
Gjs-Message: JS LOG: setting reveal-child to: true
Gjs-Message: JS LOG: child-revealed
Gjs-Message: JS LOG: reveal-child
Gjs-Message: JS LOG: child-revealed
Gjs-Message: JS LOG: reveal-child
Comment 15 Jonas Danielsson 2014-11-07 09:58:39 UTC
Created attachment 290139 [details] [review]
userList: Limit height of list popover

There is filtering and scrollbar. There is no need to grow the list
indefinitely. This patch limits users shown to eight.
Comment 16 Jonas Danielsson 2014-11-07 09:58:43 UTC
Created attachment 290140 [details] [review]
userList: Fix filter entry revealing

Use the numRows property to determine visibility of the filter entry.
This is more reliable than the allocated height.
Comment 17 Jonas Danielsson 2014-11-07 10:00:07 UTC
So I didn't manage to get the animated thing to work. Partly I guess because I received the notifies in the wrong order, see above.

This version instead hooks in to the size-allocate signal of the listbox and when that changes we update the content height.

Not sure if that is the way. Can you reproduce the issue I see above?
Comment 18 Jonas Danielsson 2014-11-07 10:00:50 UTC
(In reply to comment #5)
> Review of attachment 290013 [details] [review]:
> 
> Sure.
> 
> I can look into making them templates. We want the same in Maps.
> Right now there is some sort of bug blocking this as one get:
> (gjs-console:24118): Gtk-CRITICAL **: Unable to load resource for composite
> template for type 'Gjs_UserListRow': The resource at
> '/org/gnome/Polari/resources/user-list-row.ui' does not exist
> 
> When you try to add a template resource. Will get back to that when it has been
> resolved.

Bug here:
https://bugzilla.gnome.org/show_bug.cgi?id=739739
Comment 19 Jonas Danielsson 2014-11-07 13:08:24 UTC
Created attachment 290160 [details] [review]
userList: Fix filter entry revealing

Use the UserList numRows property to determine visibility of the
filter entry. This is more reliable than the allocated height.
Comment 20 Florian Müllner 2014-11-07 19:10:26 UTC
Review of attachment 290139 [details] [review]:

This is getting really close now, thanks for working on this!

::: src/userList.js
@@ +387,3 @@
 
+    _updateContentHeight: function() {
+        Mainloop.idle_add(Lang.bind(this, function() {

There are two issues here:
I figure you are doing this to rate-limit min_content_height updates when
receiving many updates in a row (read: GtkWidget::size-allocate signals during
animation). However this does not work properly, as you are *still* running
this once per received signal. You can use the returned source id to check
whether you already queued an update and bail out early (just don't forget to
reset the property in the idle handler!).
Then you should also add an explicit "return GLib.SOURCE_REMOVE" at the end of the
handler - no return value is falsey in JS, so omitting it works (unlike in C,
where it becomes a question of luck whether the source is stopped or not!).
It is bad style nonetheless.
Comment 21 Florian Müllner 2014-11-07 19:10:31 UTC
Review of attachment 290160 [details] [review]:

Oh right, now that we have a limit on the number of rows (and know it), we can just use that. I like it!
Comment 22 Jonas Danielsson 2014-11-10 06:27:05 UTC
Created attachment 290303 [details] [review]
userList: Limit height of list popover

There is filtering and scrollbar. There is no need to grow the list
indefinitely. This patch limits users shown to eight.
Comment 23 Jonas Danielsson 2014-11-10 06:29:39 UTC
Created attachment 290304 [details] [review]
userList: Limit height of list popover

There is filtering and scrollbar. There is no need to grow the list
indefinitely. This patch limits users shown to eight.
Comment 24 Florian Müllner 2014-11-10 10:01:58 UTC
Review of attachment 290304 [details] [review]:

Looks good to me.
Comment 25 Florian Müllner 2014-11-27 11:41:27 UTC
Created attachment 291631 [details] [review]
userList: Use visible rows for content height computation

Currently the content height is calculated based on the top eight
rows, which means that the popover will only adjust its size when
expanding one of the top rows. Base the computation on the visible
rows instead, to get consistent behavior for the whole list.
Comment 26 Florian Müllner 2014-11-27 11:42:05 UTC
Comment on attachment 291631 [details] [review]
userList: Use visible rows for content height computation

Attachment 291631 [details] pushed as 1e17a7b - userList: Use visible rows for content height computation