Skip to content

Rpg sidebar tree (see #259) #1813

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

Merged
merged 4 commits into from
Jun 8, 2022
Merged

Conversation

kugel-
Copy link
Member

@kugel- kugel- commented Mar 20, 2018

Continuation of #259 since I can't push to @scriptum branch (I suggest you allow that).

I added some cleanup commits on top of @scriptum work and rebased onto 1.33.

@elextr @b4n Please give feedback (considering the history in #259). I think I'll merge this in maybe 10 days or so.

@kugel-
Copy link
Member Author

kugel- commented Mar 20, 2018

@codebrainz too

Copy link
Member

@elextr elextr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code was reviewed too, but I couldn't find anything to complain about!!! :)

files are shown as paths (similar to *Show Paths* mode). Home directory
always shortened to ``~``. If there is an active project, it makes a tree
of project documents inside project name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "project name" do you mean "project base directory"?

And what does it do with documents that are outside the project base dir?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The node in the tree view is labeled after the project. While normally folders are combined if no files in parent folders are open, this is not done for projects.

e.g. if I open document.c it shows normally as
~/dev/geany.git/src
-- document.c

If I make a project it shows as
geany
-- src
---- document.c

Documents outside the project base dir are not affected (i.e. the nodes are labeled after the paths)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ok, so if I read that right only the project base dir and below shows as a tree?

Maybe the selection should be called "Show Project Tree"

Just a final check, commonly my directory layouts look like:

/data -- the raid array mount point
    foo -- the project name
        foo -- the git tree and the project base dir in foo.geany
             src
                 foo.cpp
                 lots more source
        foo.geany
        dev_build -- out of tree build dir
              foo -- the executable
              test_output -- unit test output file
              lots more stuff the build makes

So if I had project foo open and foo.cpp and test_output open I would get

/data/foo/dev_build
      test_output
foo
     src
         foo.cpp

doc/geany.txt Outdated
Show opened documents as tree similar to directory tree, but it shows only
directories that contains opened files. Directories that doesn't contain
files are shown as paths (similar to *Show Paths* mode). Home directory
always shortened to ``~``. If there is an active project, it makes a tree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is always

@elextr
Copy link
Member

elextr commented Mar 20, 2018

@Kugel thanks for making a testable version of #259, reviewed but unfortunately I can't test ATM, maybe someone else will test in the meantime.

@kugel- kugel- force-pushed the rpg-sidebar-tree-fixed branch from d6c442c to 3ca8921 Compare March 21, 2018 15:42
@Kugel
Copy link

Kugel commented Mar 27, 2018 via email

@elextr
Copy link
Member

elextr commented Mar 27, 2018

@Kugel sorry, I meant @kugel- but your user comes up first on the autocomplete, and hey us humans make mistakes.

@Kugel
Copy link

Kugel commented Mar 27, 2018 via email

@kugel-
Copy link
Member Author

kugel- commented Mar 27, 2018 via email

@elextr
Copy link
Member

elextr commented Mar 27, 2018

all open files are tree'ified. Its just that once a project is open it is ensured that its base path gets its own tree node (labeled after the project)

Oh, ok, thats sort of unexpected, so it needs to be explained more clearly (if only so we can close issues and point people to the manual that says thats how its meant to work :)

@kugel-
Copy link
Member Author

kugel- commented Mar 27, 2018 via email

@elextr
Copy link
Member

elextr commented Mar 27, 2018

@kugel- yep, will propose something as soon as I'm happy I understand :)

But on looking at the above example again.

No, all open files are tree'ified.

But in your additional example you have shown foo/dev_build as not being expanded the way foo/src is?

@kugel-
Copy link
Member Author

kugel- commented Mar 28, 2018

But in your additional example you have shown foo/dev_build as not being expanded the way foo/src is?

foo/dev_build is one tree node because no file in foo itself is open. foo->src is two tree nodes because foo represents the project (therefore always gets its own top-level node) and src is a subdirectory (with an open file).

Might be easier if you just try the patch and see yourself, Github/mail kind of sucks for showing examples.

@elextr
Copy link
Member

elextr commented Mar 28, 2018

Might be easier if you just try the patch and see yourself, Github/mail kind of sucks for showing examples.

Two things:

  1. I said above I can't try it ATM

  2. guessing how its meant to work from experiments is a poor way of getting an explanation for users

@kugel-
Copy link
Member Author

kugel- commented Apr 3, 2018

@elextr do you need more information on how it's supposed to work?

@elextr
Copy link
Member

elextr commented Apr 3, 2018

Yes, above I said:

But on looking at the above example again.

No, all open files are tree'ified.

But in your additional example you have shown foo/dev_build as not being expanded the way foo/src is?

I had previously asked if only the project tree was expanded and you said no as quoted above, so to be clear the question is, if "all open files are treeified" then why isn't foo/dev_build expanded but foo/src is expanded?

@kugel-
Copy link
Member Author

kugel- commented Apr 4, 2018

This proves that I'm not good at documenting such things for end users :-)

There is additional confusion since your example has two foo folders and the project is named foo as well. I'll rename to illustrate:

/data -- the raid array mount point
    foo
        bar -- the git tree and the project base dir in baz.geany
             src
                 xx.cpp
                 lots more source
        baz.geany -- project name renamed from foo to baz
        dev_build -- out of tree build dir
              foo -- the executable
              test_output -- unit test output file
              lots more stuff the build makes

So accordingly, in your next example foo/src becomes bar/src.

If xx.cpp and test_output are open, then it's displayed as follows:

baz
  src
    xx.cpp
/data/foo/dev_build
  test_output

This is because of the following rules:

  • The directory of a filename is folded as much as possible
  • if two or more documents have common parents, then a tree is formed at that parent (repeat for any common parent encountered)
  • If a project is open, then the project's base path will get a separate tree node at the root (labeled after the project). This happens regardless of whether parts of the project base path has common parents with open documents outside of the project. Folding of subdirectories (below the project base path) is performed if possible.

Compare to the situation when there is no project open:

/data/foo
  bar/src
    xx.cpp
  dev_build
    test_output

@elextr
Copy link
Member

elextr commented Apr 4, 2018

This proves that I'm not good at documenting such things for end users :-)

Thats ok, thats why I'm asking all these annoying questions :-)

I think the confusion is that I understood that the difference between this option and the existing option was that all directories on the path to open files expanded, but in fact they only expand if more than one thing inside them is open.

To confirm by example, if my project src directory had three sub-directories front_end, middle_end and back_end then if only a file was open in front_end the result for the project tree would be:

baz
    src/front_end
        xxx.cpp

but if I had a file open in each of front_end and back_end the result would be:

baz
    src
        back_end
            yyy.cpp
        front_end
            xxx.cpp

with back_end and front_end sorted and middle_end not showing.

@kugel-
Copy link
Member Author

kugel- commented Apr 4, 2018

Correct

@elextr
Copy link
Member

elextr commented Apr 9, 2018

@kugel- I still can't do anything with github, so I have posted my suggested text below.

Document list views
^^^^^^^^^^^^^^^^^^^

There are three different ways to display documents on the sidebar if *Show
documents list* is active. To switch between views press the right mouse button
on documents list and select one of those radio buttons:

Documents Only
    Show only file names of open documents in sorted order.

    .. image:: ./images/sidebar_documents_only.png

Show Paths
    Show open documents as a two-level tree in which first level is the paths
    of directories containing open files and the second level is the file names of 
    the documents open in that path.  All documents with the same path are grouped 
    together under the same first level item.  Paths are in sorted order and 
    documents are sorted within each group.

    .. image:: ./images/sidebar_show_paths.png

Show Tree
    Show paths as above, but as a multiple level partial tree.  The tree is only 
    expanded at positions where two or more directory paths to open documents 
    share the same prefix.  The common prefix is shown as a parent level, and 
    the remainer of those paths are shown as child levels.  This applies 
    recursively down the paths making a tree to the file names of open documents, 
    which are grouped in sorted order as an additional level below the last path 
    segment.
    
    For convenience two common file locations are handled specifically, open 
    files below the users home directory, and open files below an open project 
    base path.  Each of these is moved to its own top level tree instead of 
    being in place in the normal tree.  The top level of these trees are each 
    labelled differently.  For the home directory tree the path of the home 
    directory is shown as ``~``, and for the project tree the path to the project
    base path is shown simply as the project name.

    .. image:: ./images/sidebar_show_tree.png

In all cases paths and file names that do not fit in the width available are ellipsised.

@kugel-
Copy link
Member Author

kugel- commented Apr 9, 2018

Works for me, thanks.

Copy link
Member

@elextr elextr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kugel-
Copy link
Member Author

kugel- commented Apr 9, 2018

I get the following warning when building the manual:

[WARNING] image.py:463 image /home/kugel/dev/geany.git/doc/./images/sidebar_documents_only.png is too tall for the frame, rescaling
[WARNING] image.py:463 image /home/kugel/dev/geany.git/doc/./images/sidebar_documents_only.png is too tall for the frame, rescaling

In the generated pdf sidebar_documents_only.png appears very small. The HTML manual is fine though. Does anyone know what to do about it?

@kugel-
Copy link
Member Author

kugel- commented Apr 11, 2018

@elextr Actually, the home directory is merely abbreviated (using ~), it doesn't get an individual root node unlike the project base path. See the doc/sidebar_show_tree.png

@elextr
Copy link
Member

elextr commented Apr 11, 2018

@kugel-, erm, ok, what happens if there are two directories open along the path to ~ eg if HOME is /file_server/home/this_user and I have the files /file_server/home/this_user/my_file.cpp, /file_server/home/this_user/a_dir/also_mine.cpp and /file_servert/home/another_user/their_file.cpp open?

~
    a_dir
        also_mine.cpp
    my_file.cpp
/file_server/home/another_user
    their_file.cpp

or

/file_server/home
    ~
        a_dir
            also_mine.cpp
        my_file.cpp
    another_user
        their_file.cpp

or no ~

/file_server/home
    this_user
        a_dir
            also_mine.cpp
        my_file.cpp
    another_user
        their_file.cpp

@elextr
Copy link
Member

elextr commented Apr 11, 2018

changed which @kugel- :)

@kugel-
Copy link
Member Author

kugel- commented Apr 11, 2018

I think the second. However, upon trying I found there is a crash (but only when there are open files of another user AND a file located in ~ itself). I'll dig into it.

On a side note, having a file of another user open seems unlikely, as Geany is a poor program for pair programming :-)

@elextr
Copy link
Member

elextr commented Apr 11, 2018

@kugel- various daemons and databases run under other users and have their config files in that home dir as another use-case. But even if we can't think of a use-case, if its at all possible, somebody will do it 😄

@kugel- kugel- force-pushed the rpg-sidebar-tree-fixed branch from 5c79661 to 6125657 Compare April 14, 2018 22:43
@kugel-
Copy link
Member Author

kugel- commented Apr 14, 2018

I amended the commit message of 7552d5f due to typos. There are no code changes, except the three new commits on top of @elextr change.

@elextr Upon looking at the code handling the home directory, I think the intention was to match your first case, and it was a bit buggy. Since I think this is the most useful behavior, so I fixed the code to match that behavior.

@kugel-
Copy link
Member Author

kugel- commented Jul 23, 2018

@elextr is your approval still valid even after my changes? I'd like to merge this finally.

@kugel- kugel- force-pushed the rpg-sidebar-tree-fixed branch from ce29af6 to 2455539 Compare April 17, 2022 21:40
@kugel- kugel- force-pushed the rpg-sidebar-tree-fixed branch from 2455539 to 2474712 Compare May 3, 2022 05:32
@kugel-
Copy link
Member Author

kugel- commented May 3, 2022

@b4n @elextr @eht16 please review. Without any further feedback I'll probably go ahead and merge in a week or so

@elextr
Copy link
Member

elextr commented May 3, 2022

@kugel- sorry, I totally lost track of this PR. Tested, some observations below, not sure if they are deliberate? But they were surprising, appeared inconsistent, and in at least one case annoying.

Initial layout:

V /data/nexciidoc/attic
    old_spec.edoc
V ~/tmpgeany/geany
    V data
        geany-3.0.css
    V src
        document.c
        > tagmanager

The V means unrolled, and > folded up, there is a file open in tagmanager but I folded it up.

Note the path starting with ~ sorts after /data which is correct because ~ is second last ASCII character

Opened ~/atest.edoc got:

V ~
    atest.edoc
    V /tmpgeany/geany
        V data
            geany-3.0.css
    V src
        document.c
        > tagmanager
V /data/nexciidoc/attic
    old_spec.edoc

Note the resorting of /data when ~ became a top level, but the previous top level path still started with ~ and sorted after /data.

When I closed ~/atest.edoc:

V ~
    V /tmpgeany/geany
        V data
            geany-3.0.css
        V src
            document.c
            > tagmanager
V /data/nexciidoc/attic
    old_spec.edoc

The ~ stayed separated even though it now had only one entry open.

When I closed geany-3.0.css:

I expected:

V ~
    V /tmpgeany/geany/src
        document.c
        > tagmanager
V /data/nexciidoc/attic
    old_spec.edoc

but got:

V ~
    > /tmpgeany/geany/src
V /data/nexciidoc/attic
    old_spec.edoc

Note /tmpgeany/geany/src folded uncommanded, that would get annoying if it kept happening.

Also ~ still doesn't recombine, but when I closed and reopened Geany it combined and sorted after /data which opened folded up even though it was unfolded, and tagmanager which was folded opened unfolded. I am not sure if you tried to save the fold state across Geany close, but its not right ATM.

@kugel-
Copy link
Member Author

kugel- commented May 10, 2022

Thanks, I'll check. It's quite hard to get GTK to do what you want. Remembering fold state is not supported by GTK directly so I have to code around it, basically using a hammer so long until it fits.

Do you have comments aside the fold state memory?

@elextr
Copy link
Member

elextr commented May 10, 2022

Do you have comments aside the fold state memory?

The resorting of ~ when it became a standalone level

@kugel-
Copy link
Member Author

kugel- commented May 11, 2022

Sorting weirdness seems to be caused by g_utf8_collate_key_for_filename() simply ignoring ~. However, I an acceptable workaround (tread ~ as . for sorting). Now I'm looking why nodes below ~ aren't merged back properly.

@elextr
Copy link
Member

elextr commented May 11, 2022

Sorting weirdness seems to be caused by g_utf8_collate_key_for_filename() simply ignoring ~.

Makes sense, it probably is intended to work on absolute filenames, or at least filenames with the same root (ie directory).

Now I'm looking why nodes below ~ aren't merged back properly.

Getting ordering and merging stable will probably make saved fold state work a lot easier.

@kugel-
Copy link
Member Author

kugel- commented May 18, 2022

@elextr I think I got this right now. Please check.

Copy link
Member

@eht16 eht16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Had only a few remarks.

@eht16
Copy link
Member

eht16 commented May 28, 2022

LGTM now! Thanks.

@kugel-
Copy link
Member Author

kugel- commented May 28, 2022

Great, thanks! I'll merge in a few days then. @elextr do you plan more tests and/or review or are you fine with this now as well?

@elextr
Copy link
Member

elextr commented May 28, 2022

@kugel- Intending to test this weekend.

@elextr
Copy link
Member

elextr commented May 30, 2022

@kugel- its better, ~ handling seems more correct, successfully recombines ~ and child when reduced from two children to one.

But folding saving doesn't seem to be right yet.

Initial state

v ~
  v old_geany/geany/src
    document.c
  > rpggeany/geany/src  // note this is folded
v /data/misc
  parser.cpp

close and re-open Geany gives

> ~                // now whole of ~ is folded
v /data/misc
  parser.cpp

set back to same initial state and close and re-open, Geany opens with everything unfolded and from then on always seemed to re-open with everything unfolded, no matter what I did.

@kugel-
Copy link
Member Author

kugel- commented May 30, 2022

Thanks for testing. I'll check.

Just leaving the note here that folding state is not stored to disk anywhere so re-opening Geany begins anew.

@elextr
Copy link
Member

elextr commented May 30, 2022

Just leaving the note here that folding state is not stored to disk anywhere so re-opening Geany begins anew.

Ok, so opening all unfolded is fine then, so the only issue is the ~ opening folded one time. Since it didn't repeat the few times I tried maybe its an uninitialised variable that is mostly the correct value, but occasionally bad.

@kugel-
Copy link
Member Author

kugel- commented May 31, 2022

I made a minor change that should fix startup (the expectation is that everything is unfolded on startup). Please check again. I couldn't reproduce your second example even without the last correction.

@elextr
Copy link
Member

elextr commented May 31, 2022

Ok, now seems consistent, can't cause any bad behaviour, always opens unfolded, ~ coalescing seems to work. :-)

To be explicit, looks ok to merge.

@kugel-
Copy link
Member Author

kugel- commented May 31, 2022

I could reproduce the your second example (all under ~ starts up folded). Depends on the order on which documents are opened. I could fix that with another minor tweak.

So if nothing comes up last minute I will merge by the weekend or so.

@elextr
Copy link
Member

elextr commented May 31, 2022

Depends on the order on which documents are opened. I could fix that with another minor tweak.

Would have been useful to detail the reproducer for testers.

Anyway I found an order that reliably reproduced the problem and your latest push seems to fix it.

So if nothing comes up last minute I will merge by the weekend or so.

As I have said before, its important to allow a whole weekend before merging, I just happened to have time today, but many people only have weekends to try anything.

kugel- added 4 commits June 8, 2022 07:42
Currently you can chose between a flat document list and a two-level
tree that groups the files by their directory.

With the new tree view the latter mode is extended to a true tree
where directory rows only represent the direct parent directory of
open documents. Except that single-child subtrees are collapsed to a single
row. See the manual for glory details.

The new mode allows to quickly close entire subtrees and is visually
close to the file system layout. As with the two-level tree, the home
directory and project base directory (if any project is open) are
treated specially and usually get a distict row
- home directory appears as "~"
- project base directory path is replaced by the project name

The new mode is the default. Existing installations will use the new
mode because a new pref is introduced.

Closes geany#259
Based on work by RPG <[email protected]>
- Move to separate file geany-gtk.m4
- Merge gthread checks into the main gtk ones
The test program checks if open documents are grouped correctly by
their parent directory. The older modes (plain document list and two-level
tree) also get a distinct test. For this to work some symbols
must become visible from libgeany.

The test uses g_strv_length() which is relatively new.
Autoconf and meson checks are added as needed.
@kugel- kugel- force-pushed the rpg-sidebar-tree-fixed branch from b4adf7e to 8932304 Compare June 8, 2022 05:55
@kugel-
Copy link
Member Author

kugel- commented Jun 8, 2022

Merging after CI is done. The last push was just a squash of the fixup (as well as splitting the unit test commit into two). No diff to the previous state.

@kugel- kugel- merged commit def1600 into geany:master Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants