Merge lp://qastaging/~matzipan/scratch/folder-manager-improvement into lp://qastaging/~elementary-apps/scratch/scratch

Proposed by Zisu Andrei
Status: Needs review
Proposed branch: lp://qastaging/~matzipan/scratch/folder-manager-improvement
Merge into: lp://qastaging/~elementary-apps/scratch/scratch
Diff against target: 2056 lines (+647/-1169)
17 files modified
plugins/CMakeLists.txt (+1/-2)
plugins/filemanager/CMakeLists.txt (+0/-29)
plugins/filemanager/File.vala (+0/-207)
plugins/filemanager/FileManagerPlugin.vala (+0/-113)
plugins/filemanager/FileView.vala (+0/-297)
plugins/filemanager/Settings.vala (+0/-36)
plugins/filemanager/filemanager.plugin (+0/-10)
plugins/folder-manager/CMakeLists.txt (+3/-0)
plugins/folder-manager/File.vala (+112/-112)
plugins/folder-manager/FileItem.vala (+39/-0)
plugins/folder-manager/FileView.vala (+125/-292)
plugins/folder-manager/FolderItem.vala (+245/-0)
plugins/folder-manager/FolderManagerPlugin.vala (+49/-56)
plugins/folder-manager/Item.vala (+69/-0)
plugins/folder-manager/folder-manager.plugin (+4/-4)
schemas/CMakeLists.txt (+0/-1)
schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml (+0/-10)
To merge this branch: bzr merge lp://qastaging/~matzipan/scratch/folder-manager-improvement
Reviewer Review Type Date Requested Status
Jeremy Wootten code, function Approve
Zisu Andrei (community) Needs Resubmitting
Danielle Foré Pending
Review via email: mp+312195@code.qastaging.launchpad.net

This proposal supersedes a proposal from 2016-11-18.

Commit message

Merge File Manager into Folder Manager and improve usability.

Description of the change

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote : Posted in a previous version of this proposal

This LGTM. My only slight concern is that folder manager is currently a default plugin. So perhaps we should have this replace that instead of the file manager plugin. That way we don't have to monkey around with the defaults and people can upgrade to the new plugin seamlessly.

Revision history for this message
Zisu Andrei (matzipan) wrote : Posted in a previous version of this proposal

I just realized there's no "add folder" button either. I'll see what I can do about your comments too

Revision history for this message
Danielle Foré (danrabbit) wrote :

Couple code style comments. If you're checking the same variable more than twice, make sure to use a switch/case statement :) https://elementary.io/docs/code/reference#indentation

1779. By Zisu Andrei

Simplify file/folder validity check. Move common construct/rename/trash code into superclass. GObject constructor for File

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

On compiling there is a warning:
"warning: method `Scratch.Plugins.FolderManager.File.reset_cache' never used".

See also inline comments.

Function review to follow.

review: Needs Fixing (code)
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

There are some issues in function - All but the first two may be considered outside the scope of this branch:

This branch:
1) rename a file causes another document to load because cursor does not follow (and, if open, file in document view not updated with new name)
2) Second opened folder saved in settings but not restored (removed on restarting)

Others?:
3) "New Folder" different from Files "untitled folder"
4) "New File" different from Files "new file".
5) Expanded status not saved in settings.

review: Needs Fixing (function)
Revision history for this message
Zisu Andrei (matzipan) wrote :

For 1 I have a nother branch [1] which fixes the issue, however, there is a limitation in Granite.SourceList which prevents elements from being sorted when they are being renamed in the list. I don't want to code a workaround in this branch since it will be fixed anyway.

Investigating 2.

5 would be outside of the scope of this branch. I believe trunk didn't do that either.

[1] https://code.launchpad.net/~matzipan/scratch/use-rename-event/+merge/312213

Revision history for this message
Zisu Andrei (matzipan) wrote :

One response to your comment inline. I basically just copied the code over from the original implementation. I will address it.

1780. By Zisu Andrei

Address raised issues and some slight refactoring on the open folder mechanism

Revision history for this message
Zisu Andrei (matzipan) wrote :

Issues were addressed.

review: Needs Resubmitting
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Some further comments on the code (not necessarily blocking):

1) The class "Scratch.Plugins.FolderManager.Item" is described as abstract but not defined as such and it would be better if a public class had its own file.

2) The reference to "view" is not really required in "Item", only in "FolderItem" (and is it necessary to have a back reference to the Item's parent?).

3) The function "on_child_removed" is not currently used

Revision history for this message
Zisu Andrei (matzipan) wrote :

Also discovered an issue with deleting an opened folder (it doesn't remove the sidebar entry, it only trashes the file).

And there seems to be a problem with opening empty folders.

1781. By Zisu Andrei

Move Item to its own file

1782. By Zisu Andrei

Fix unused method warning

1783. By Zisu Andrei

Write settings on folder removal

Revision history for this message
Zisu Andrei (matzipan) wrote :

Addressed 1 and 3.

2 isn't true. FileItem uses view for view.start_editing_item (this).

I know it's bad practice, but I don't want to make it this branches' scope to refactor everything. I just wanted to get the basic usecases working.

I also fixed an issue where it wouldn't save to settings when the folder is closed.

Current problems:
* when a new folder or file is created, it only shows the editable entry for a short time.
* there seems to be a problem with opening empty folders.

1784. By Zisu Andrei

Remove folder on trash

1785. By Zisu Andrei

Stop selecting other items after deleting an item

1786. By Zisu Andrei

Files doesn't use brackets

1787. By Zisu Andrei

Add warning about files with no valid files

1788. By Zisu Andrei

Add break to make it more efficient

1789. By Zisu Andrei

Add new keyword to overriding function

1790. By Zisu Andrei

Fix FolderItems not editable after creation

Revision history for this message
Zisu Andrei (matzipan) wrote :

Just realized that SourceList headers are not visible when they have no children. I don't think there's anything I can change about that.

I will add a check against this.

I've spent 3 hours on the issue "when a new folder or file is created, it only shows the editable entry for a short time.". I could not tell why this is happening. I added a Idle.add() workaround and it worked like this.

Dan thinks this merge request is too large. Unfortunately, I don't think I can break this down into smaller chunks - I don't wanna be committing something I know wouldn't work. And I cannot get it smaller.

review: Needs Resubmitting
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I agree that it is not easy to split this kind of branch, and you are saving 500 lines of code so it is worth the extra effort of checking for regressions.

The comment about back references is not critical and can be disregarded at least in the branch.

One of the revisions added the "new" keyword. Is there a reason you did this rather than mark the corresponding function in the abstract class "Item" as virtual?

There are still some issues with folder items that have just been created (using the folder manager plugin):

A
 1) Create a folder item in the root folder
 2) Immediately create another folder within that new folder

 Two subfolder items appear even though only one subfolder is created on disk. Deleting one of them causes both to disappear.

B
 1) Create a folder item in the root folder
 2) Immediately create a new file within that new folder - two file entries appear
 3) Delete one file entry - both disappear
 4) Create a new folder - one folder entry and one file entry appear
 5) Delete the file entry - only the file entry disappears.

review: Needs Fixing (function)
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

The double creation effect is due to the FileMonitor detecting the creation and adding another item. You need to block the monitor while creating an item internally.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Ignore last comment - it seems that is not the problem

Revision history for this message
Zisu Andrei (matzipan) wrote :

> One of the revisions added the "new" keyword. Is there a reason you did this rather than mark the corresponding function in the abstract class "Item" as virtual?

Initially I used "override", however, it seems "override" in Vala is not the same as in Java, so I removed it, and then the compiler noticed my declaration is shadowing a function in the parent class, and suggested I add "new" if this is intentional.

1791. By Zisu Andrei

Fix double creation on empty folder loading

Revision history for this message
Zisu Andrei (matzipan) wrote :

It's ready for review again.

I jotted down 2 future improvements here: https://bugs.launchpad.net/scratch/+bug/1646924

review: Needs Resubmitting
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

The last revisions fixes the duplicate creation problem. There is a small bug - the "newly_created_path" variable should be nulled after it has served its purpose. If not, if you create a new file/folder with the folder-manager and then delete it and recreate it with Files, both Files and the folder-manager go into edit mode. Better to check whether it is null before using it in an equality.

I have confirmed the future improvement bug.

review: Needs Fixing (code)
1792. By Zisu Andrei

Null the newly_created_path after it has been processed

Revision history for this message
Zisu Andrei (matzipan) wrote :

Thanks for catching that one. That's how I was intending to do it, but between my brain and my hands something got lost.

I believe the null check is not necessary. It seems to be running alright on my end.

review: Needs Resubmitting
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I agree Vala does not mind nulls in equalities - it just felt wrong - and it may be a little more efficient to avoid invoking source.get_path () but it is not critical.

I'll give it another test tomorrow but it is looking good now.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

If the "execute" permission is removed from a folder then the "add file" and "add folder" options are still active. If these are chosen then scratch hangs while maxing out a core. (Under these circumstances, Files gives a "permission denied" error dialog. However, if the folder is set to "read only" but has "execute" permission, attempting to add a file fails silently (with a error message in the terminal). Under these circumstances Files does not offer to create a file in the context menu.

I also notices that "Move to trash" is offered for all folders including the user home folder. Hopefully this would fail but I did not feel like trying it (!).

Revision history for this message
Zisu Andrei (matzipan) wrote :

I discovered one more issue, if I compile a C++ file with g++ bla.c, a.out shows up (unexpected). If I close Scratch and open it back up, the file doesn't show up anymore (expected).

Also if I click the a.out entry, it freezes my editor.

It's not clear to me why this happens.

review: Needs Fixing
1793. By Zisu Andrei

Check if folder is executable to avoid infinite loop

Revision history for this message
Zisu Andrei (matzipan) wrote :

Ok, so the above commit checks if the folder is executable before checking for file existence to avoid infinite looping.

However, there is much more involved work necessary to allow all files to track their attributes, like File does. For this, I have created the bug report [1].

For the "move to trash issue" I added a note in [2].

[1] https://bugs.launchpad.net/scratch/+bug/1650902
[2] https://bugs.launchpad.net/scratch/+bug/1646924

Revision history for this message
Zisu Andrei (matzipan) wrote :

Ok, I notice the a.out issue I reported above is a regression in trunk too, so I'll file a bug for this, since it's outside the scope of this branch.

review: Needs Resubmitting
Revision history for this message
Zisu Andrei (matzipan) wrote :

Found an issue: when you create a folder in Files, it gets created in Scratch just fine. If you create a file in that folder in Files, the folder should be marked as expandable in Scratch, but that does not happen.

review: Needs Fixing
1794. By Zisu Andrei

Monitor files and update unloaded folders

Revision history for this message
Zisu Andrei (matzipan) wrote :

Fixed.

review: Needs Resubmitting
1795. By Zisu Andrei

Move menu items case

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I get a crash under the following conditions:

1. Open Scratch with the folder manager showing a folder.

2. Using Files, copy another folder in the folder that is open in Scratch.

3. Scratch crashes.

review: Needs Fixing (function)
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Note: The crash mention above does not occur if the folder is empty or contains an empty folder.

1796. By Zisu Andrei

Fix segmentation fault on unloaded folder monitor event

1797. By Zisu Andrei

Only add valid files and directories to children and update unloaded directories better

Revision history for this message
Zisu Andrei (matzipan) wrote :

I have fixed the raised issue. It was introduced in my last commit, I didn't check everything - sorry for that.

I also added some improvements for unloaded folders and folder children validity.

review: Needs Resubmitting
Revision history for this message
Ralph Plawetzki (purejava) wrote :

Yeah, I also tested it. The issue described in https://code.launchpad.net/~matzipan/scratch/folder-manager-improvement/+merge/312195/comments/814590 is fixed with r 1797.

Another question: is it intended that one has to select both plugins (file manager and folder manager) in the plugins menu to activate the side bar?

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

The lastest revisions fix the crash previously noted, so I think this now good to go :)

The "File Manager" extension will be no longer needed once this is merged but will still be installed on some users systems and therefore will still appear in the extension list. I am not sure whether an update can uninstall this extension or whether it will need to be "blacklisted" so that it does not show. That can be done in another branch.

review: Approve (code, function)
Revision history for this message
Zisu Andrei (matzipan) wrote :

@Ralph: this is a caused because the old plugin that was merged into this one was never deleted upon install. I'm not sure how to deal with this. Maybe Dan or Cody can suggest.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

@Ralph: You should be able to safely delete (or move elsewhere if you want to be able to reverse it) the folder "filemanager" in /usr/lib/x86_64-linux-gnu/scratch/plugins/ once it is no longer needed. You will need to be root.

This will remove the plugin from the list of available plugins in Scratch.

Unmerged revisions

1797. By Zisu Andrei

Only add valid files and directories to children and update unloaded directories better

1796. By Zisu Andrei

Fix segmentation fault on unloaded folder monitor event

1795. By Zisu Andrei

Move menu items case

1794. By Zisu Andrei

Monitor files and update unloaded folders

1793. By Zisu Andrei

Check if folder is executable to avoid infinite loop

1792. By Zisu Andrei

Null the newly_created_path after it has been processed

1791. By Zisu Andrei

Fix double creation on empty folder loading

1790. By Zisu Andrei

Fix FolderItems not editable after creation

1789. By Zisu Andrei

Add new keyword to overriding function

1788. By Zisu Andrei

Add break to make it more efficient

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches