Merge lp:~donadigo/scratch/open-dir-sidebar into lp:~elementary-apps/scratch/scratch

Proposed by Adam Bieńkowski
Status: Work in progress
Proposed branch: lp:~donadigo/scratch/open-dir-sidebar
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 74 lines (+18/-3)
4 files modified
plugins/filemanager/FileManagerPlugin.vala (+5/-0)
src/MainWindow.vala (+4/-0)
src/Scratch.vala (+7/-3)
src/Services/PluginManager.vala (+2/-0)
To merge this branch: bzr merge lp:~donadigo/scratch/open-dir-sidebar
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+317472@code.launchpad.net

Commit message

* Passing directory will now open it in the sidebar

Description of the change

This branch fixes bug #1570661: "Open directory in sidebar if passed a directory".

If given a directory, Scratch will no longer throw an error, instead it will pass the file through the new "request_open_folder" signal to inform plugins that a directory was opened.

I still don't feel really confident about this solution, and if there should be other changes in the code to perhaps improve handling other directories / arguments etc. Please feel free to ping me on Slack or tell me in a review.

To post a comment you must log in.
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Will this work or conflict with lp:~matzipan/scratch/folder-manager-improvement?

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

jeremywootten: I don't think so, it completely removes the filemanager plugin so it will conflict. I guess this branch shouldn't be merged then, and we should just wait until the other one gets merged so this one can get updated.

Unmerged revisions

1821. By Adam Bieńkowski

Opening directory will now open it in the sidebar

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/filemanager/FileManagerPlugin.vala'
2--- plugins/filemanager/FileManagerPlugin.vala 2016-09-03 11:50:58 +0000
3+++ plugins/filemanager/FileManagerPlugin.vala 2017-02-16 13:41:47 +0000
4@@ -37,6 +37,7 @@
5 public void activate () {
6 plugins = (Scratch.Services.Interface) object;
7 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
8+ plugins.request_open_folder.connect (on_request_open_folder);
9 }
10
11 public void deactivate () {
12@@ -103,6 +104,10 @@
13
14 notebook.append_page (box, new Gtk.Label (_("File Manager")));
15 }
16+
17+ void on_request_open_folder (File file) {
18+ view.open_folder (new FileManager.File (file.get_path ()));
19+ }
20 }
21 }
22
23
24=== modified file 'src/MainWindow.vala'
25--- src/MainWindow.vala 2017-01-06 17:11:40 +0000
26+++ src/MainWindow.vala 2017-02-16 13:41:47 +0000
27@@ -506,6 +506,10 @@
28 }
29 }
30
31+ public void open_folder (File file) {
32+ plugins.plugin_iface.request_open_folder (file);
33+ }
34+
35 // Return true if there are no documents
36 public bool is_empty () {
37 return split_view.is_empty ();
38
39=== modified file 'src/Scratch.vala'
40--- src/Scratch.vala 2016-12-13 02:06:39 +0000
41+++ src/Scratch.vala 2017-02-16 13:41:47 +0000
42@@ -194,12 +194,16 @@
43 case FileType.SYMBOLIC_LINK:
44 files += file;
45 break;
46+ case FileType.DIRECTORY:
47+ var window = get_last_window ();
48+ if (window != null) {
49+ window.open_folder (file);
50+ }
51+
52+ break;
53 case FileType.MOUNTABLE:
54 reason = _("It is a mountable location.");
55 break;
56- case FileType.DIRECTORY:
57- reason = _("It is a directory.");
58- break;
59 case FileType.SPECIAL:
60 reason = _("It is a \"special\" file such as a socket,\n fifo, block device, or character device.");
61 break;
62
63=== modified file 'src/Services/PluginManager.vala'
64--- src/Services/PluginManager.vala 2014-04-13 16:12:53 +0000
65+++ src/Services/PluginManager.vala 2017-02-16 13:41:47 +0000
66@@ -36,6 +36,8 @@
67 public signal void hook_document (Scratch.Services.Document doc);
68 public signal void hook_preferences_dialog (Scratch.Dialogs.Preferences dialog);
69
70+ public signal void request_open_folder (File file);
71+
72 public Scratch.TemplateManager template_manager { private set; get; }
73
74 public Interface (PluginsManager manager) {

Subscribers

People subscribed via source and target branches