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 676593 - In the index tree, more text could be displayed before ellipsis
In the index tree, more text could be displayed before ellipsis
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-05-22 19:52 UTC by Jacek Sieka
Modified: 2013-02-20 15:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot with an index wih several levels (24.44 KB, image/png)
2012-10-07 09:03 UTC, Germán Poo-Caamaño
  Details
Different values for max-width-chars (32.14 KB, image/png)
2013-02-15 11:21 UTC, Germán Poo-Caamaño
  Details
Test case for packed columns in a GtkTreeView (5.34 KB, text/plain)
2013-02-16 03:51 UTC, Germán Poo-Caamaño
  Details
[PATCH] shell: Show as much text as possible for index tree (2.77 KB, patch)
2013-02-16 04:27 UTC, Germán Poo-Caamaño
none Details | Review
[PATCH] shell: Show as much text as possible for index tree (2.82 KB, patch)
2013-02-16 04:31 UTC, Germán Poo-Caamaño
committed Details | Review

Description Jacek Sieka 2012-05-22 19:52:14 UTC
In a PDF file with a multi-level index, the text will be ellipsisized to fit tree and page number in the available width. 

The issue is that the maximum width before ellipsis is calculated at leaf level of the tree but applied everywhere leaving the texts near the root cut early with lots of space between ellipsis and page number.

Example:

long title here abc abc
---- long title here abc abc
---- ---- long title here abc abc

If there is space to show "long title here" on the third level, the first "abc" of the second row would also fit (more or less, modulo font), as would both "abc" on the root item, but instead the text is cut at the same point on all levels.
Comment 1 Germán Poo-Caamaño 2012-10-07 09:03:45 UTC
Created attachment 225973 [details]
Screenshot with an index wih several levels

In the screenshot attached you can see that in the same tree, some leafs are shown properly.

For instance, see: 8.4, 8.4.3, 8.7.

Maybe number '8' can slightly reproduce the behaviour you describe, but it would be a matter of pixels.  Which you also have to consider the padding and spacing for each one.

Can you show a test case where the bug is triggered?
Comment 2 José Aliste 2013-02-14 15:21:51 UTC
Confirming, Germán, please see http://www.dim.uchile.cl/~jaliste/tree_view_problem.png

where I put some background colors to the cell renderers.. You can clearly see that the top cells are shrinking, which is a bug... I am not knowledgable enough in GtkTreeView to decide if this is a GtkTreeView bug or an evince bug.
Comment 3 Germán Poo-Caamaño 2013-02-15 09:19:00 UTC
It is an evince bug.  I cooked a test case using a GtkTreeView and it works as expected.
Comment 4 Germán Poo-Caamaño 2013-02-15 10:38:58 UTC
Testing a bit more, it is a problem that happens when two columns are packed (title, page), as it happens in:

http://git.gnome.org/browse/evince/tree/shell/ev-sidebar-links.c#n420

I think it is related to: https://bugzilla.gnome.org/show_bug.cgi?id=660113

A solution could be to reduce 'max-width-chars' to something like 3 instead of 12.
Comment 5 Germán Poo-Caamaño 2013-02-15 11:21:37 UTC
Created attachment 236230 [details]
Different values for max-width-chars

The screenshot shows the behaviour with 3 different max-width-chars for the page number column.

3 is definitively to small.  6 is good enough for showing numbers from 0 to 9999.  12 seems a bit high.

The drawback of choosing a small max-width-size is the column does not expand wider than that value even if there is enough empty space.

José, in the screenshot at the right that you linked, there are 2 separated columns.  If the page number is too wide, the first column would have less space.  This is tricky in documents (books) with long page numbers (for instance, 'preface' or the one linked in bug 660113.

Another alternative is to use a custom cell layout or similar, as suggested by Carlos in https://bugzilla.gnome.org/show_bug.cgi?id=660113#c9.  However, I am not sure whether the effort is worth.

TL;DR: 6 seems like a good default.
Comment 6 José Aliste 2013-02-15 12:41:41 UTC
I am not so sure that this is a bug in evince... When everything is not expanded, the Treeview already gave enough space to all the cells on the right. There is no apparent reason why the Treeview is then giving more space to cells that were already being correctly shown before expanding an item. It seems really like a bug in Treeview to me. Other thing would be to put the cells in different columns.
Comment 7 Germán Poo-Caamaño 2013-02-16 03:51:44 UTC
Created attachment 236338 [details]
Test case for packed columns in a GtkTreeView

FWIW, before checking the packed renderers in a column it seemed to me it was a bug in Evince, maybe triggered by 'max-width-chars' and exacerbated by its default value (12).  Also I tried it with the treeview expanded, which was not the best way to reproduce the behaviour.

Anyhow, the problem seems to be in how 2 packed text renderers are drawn.  It seems the renderer width (text and page number) is calculated with the values to be shown, not the whole model.  So, when you expand the one node, the new width of each rendered is recalculated and it considers the wider value needed (or 'max-width-chars' if defined and lower).  I think this is the purpose of packing two or more renderers, that is, to be adjusted on demand and as needed.

Regardless of the width of the page number, every time a new level is expanded, the higher levels of the treeview get the equivalent of 2 extra characters (for the page number), or in other words, 2 characters less for the title.  This sounds like a bug to me, because it takes space out from the first column without requiring extra space.  Maybe this bug is related with https://bugzilla.gnome.org/show_bug.cgi?id=168654.

Once the width is set, it does not go back.  This can make the table of contents unusable (or any GtkTreeView).

Using separated columns and setting 'width-chars' in the rendered produced the expected effect.  It uses a less space as possible, and it is expanded as needed, but defining width-chars + ellipsis it does continue growing.
Comment 8 Germán Poo-Caamaño 2013-02-16 04:27:15 UTC
Created attachment 236340 [details] [review]
[PATCH] shell: Show as much text as possible for index tree

This patch makes, what I think, a good compromise between space for index text and page numbers.
Comment 9 Germán Poo-Caamaño 2013-02-16 04:31:55 UTC
Created attachment 236341 [details] [review]
[PATCH] shell: Show as much text as possible for index tree

I forgot a couple of casting.
Comment 10 Carlos Garcia Campos 2013-02-20 15:35:53 UTC
Review of attachment 236341 [details] [review]:

Pushed to git master, thanks!