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
=== modified file 'plugins/filemanager/FileManagerPlugin.vala'
--- plugins/filemanager/FileManagerPlugin.vala 2016-09-03 11:50:58 +0000
+++ plugins/filemanager/FileManagerPlugin.vala 2017-02-16 13:41:47 +0000
@@ -37,6 +37,7 @@
37 public void activate () {37 public void activate () {
38 plugins = (Scratch.Services.Interface) object;38 plugins = (Scratch.Services.Interface) object;
39 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);39 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
40 plugins.request_open_folder.connect (on_request_open_folder);
40 }41 }
4142
42 public void deactivate () {43 public void deactivate () {
@@ -103,6 +104,10 @@
103104
104 notebook.append_page (box, new Gtk.Label (_("File Manager")));105 notebook.append_page (box, new Gtk.Label (_("File Manager")));
105 }106 }
107
108 void on_request_open_folder (File file) {
109 view.open_folder (new FileManager.File (file.get_path ()));
110 }
106 }111 }
107}112}
108113
109114
=== modified file 'src/MainWindow.vala'
--- src/MainWindow.vala 2017-01-06 17:11:40 +0000
+++ src/MainWindow.vala 2017-02-16 13:41:47 +0000
@@ -506,6 +506,10 @@
506 }506 }
507 }507 }
508508
509 public void open_folder (File file) {
510 plugins.plugin_iface.request_open_folder (file);
511 }
512
509 // Return true if there are no documents513 // Return true if there are no documents
510 public bool is_empty () {514 public bool is_empty () {
511 return split_view.is_empty ();515 return split_view.is_empty ();
512516
=== modified file 'src/Scratch.vala'
--- src/Scratch.vala 2016-12-13 02:06:39 +0000
+++ src/Scratch.vala 2017-02-16 13:41:47 +0000
@@ -194,12 +194,16 @@
194 case FileType.SYMBOLIC_LINK:194 case FileType.SYMBOLIC_LINK:
195 files += file;195 files += file;
196 break;196 break;
197 case FileType.DIRECTORY:
198 var window = get_last_window ();
199 if (window != null) {
200 window.open_folder (file);
201 }
202
203 break;
197 case FileType.MOUNTABLE:204 case FileType.MOUNTABLE:
198 reason = _("It is a mountable location.");205 reason = _("It is a mountable location.");
199 break;206 break;
200 case FileType.DIRECTORY:
201 reason = _("It is a directory.");
202 break;
203 case FileType.SPECIAL:207 case FileType.SPECIAL:
204 reason = _("It is a \"special\" file such as a socket,\n fifo, block device, or character device.");208 reason = _("It is a \"special\" file such as a socket,\n fifo, block device, or character device.");
205 break;209 break;
206210
=== modified file 'src/Services/PluginManager.vala'
--- src/Services/PluginManager.vala 2014-04-13 16:12:53 +0000
+++ src/Services/PluginManager.vala 2017-02-16 13:41:47 +0000
@@ -36,6 +36,8 @@
36 public signal void hook_document (Scratch.Services.Document doc);36 public signal void hook_document (Scratch.Services.Document doc);
37 public signal void hook_preferences_dialog (Scratch.Dialogs.Preferences dialog);37 public signal void hook_preferences_dialog (Scratch.Dialogs.Preferences dialog);
38 38
39 public signal void request_open_folder (File file);
40
39 public Scratch.TemplateManager template_manager { private set; get; }41 public Scratch.TemplateManager template_manager { private set; get; }
40 42
41 public Interface (PluginsManager manager) {43 public Interface (PluginsManager manager) {

Subscribers

People subscribed via source and target branches