Merge lp:~tintou/scratch/filemanager into lp:~elementary-apps/scratch/scratch

Proposed by Corentin Noël
Status: Rejected
Rejected by: Zisu Andrei
Proposed branch: lp:~tintou/scratch/filemanager
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 1566 lines (+330/-994)
19 files modified
plugins/CMakeLists.txt (+0/-1)
plugins/filemanager/CMakeLists.txt (+2/-0)
plugins/filemanager/File.vala (+3/-3)
plugins/filemanager/FileItem.vala (+52/-0)
plugins/filemanager/FileManagerPlugin.vala (+68/-46)
plugins/filemanager/FileView.vala (+39/-210)
plugins/filemanager/FolderItem.vala (+154/-0)
plugins/filemanager/Settings.vala (+1/-1)
plugins/folder-manager/CMakeLists.txt (+0/-29)
plugins/folder-manager/File.vala (+0/-207)
plugins/folder-manager/FileView.vala (+0/-312)
plugins/folder-manager/FolderManagerPlugin.vala (+0/-122)
plugins/folder-manager/Settings.vala (+0/-36)
plugins/folder-manager/folder-manager.plugin (+0/-10)
plugins/outline/OutlinePlugin.vala (+4/-1)
plugins/source-tree/SourceTreePlugin.vala (+3/-1)
schemas/CMakeLists.txt (+0/-1)
schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml (+4/-4)
schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml (+0/-10)
To merge this branch: bzr merge lp:~tintou/scratch/filemanager
Reviewer Review Type Date Requested Status
Danielle Foré ux Needs Fixing
Zisu Andrei (community) Needs Fixing
Review via email: mp+304845@code.launchpad.net
To post a comment you must log in.
lp:~tintou/scratch/filemanager updated
1748. By Corentin Noël

Fix CMake warnings in the plugins

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

This branch works as advertised, but, as discussed, we need to change the root item into a folder item too so you can use the context menu to add files to it, instead of using the plus sign at the bottom.

Also maybe after creating a new file, the sidebar entry needs to be opened in rename mode so that the user can type in the desired name.

review: Needs Fixing
Revision history for this message
Corentin Noël (tintou) wrote :

Aaand it's ready for a new review.

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

Hm, unsure what the intended behavior is here. After installing this branch, the File Manager plugin appears to be completely empty and do nothing. I don't notice any changes to the Folder Manager plugin.

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

This is definitely needs fixing on UX:

* It seems like you can only add one folder at a time. I really think the button to add a folder in the headerbar needs to come back. It's simple and obvious.

* Having this welcome screen in the sidebar is really bad. Especially if you don't have a file open you can have two welcome screens side-by-side. This is a pretty big annoyance from the previous behavior where it was possible to not have any folders open. This new behavior requires turning the plugin on and off. It's really annoying.

review: Needs Fixing (ux)
lp:~tintou/scratch/filemanager updated
1749. By Corentin Noël

Unified the file manager and folder manager.

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

This is way better than it was before.

One thing I still don't like is the open folder button disappearing from the headerbar. I don't like the actions moving around like this. It means that once I perform the action I now have to go hunt to figure out how to perform that action again. The UI is not predictable.

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

Rejected because I branched and wrapped up the changes here: https://code.launchpad.net/~matzipan/scratch/filemanager/+merge/311301

Unmerged revisions

1749. By Corentin Noël

Unified the file manager and folder manager.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/CMakeLists.txt'
--- plugins/CMakeLists.txt 2016-09-03 10:30:53 +0000
+++ plugins/CMakeLists.txt 2016-09-03 22:26:31 +0000
@@ -8,7 +8,6 @@
8add_subdirectory (contractor)8add_subdirectory (contractor)
9add_subdirectory (pastebin)9add_subdirectory (pastebin)
10add_subdirectory (filemanager)10add_subdirectory (filemanager)
11add_subdirectory (folder-manager)
12add_subdirectory (terminal)11add_subdirectory (terminal)
13add_subdirectory (browser-preview)12add_subdirectory (browser-preview)
14add_subdirectory (strip-trailing-save)13add_subdirectory (strip-trailing-save)
1514
=== modified file 'plugins/filemanager/CMakeLists.txt'
--- plugins/filemanager/CMakeLists.txt 2016-09-03 10:30:53 +0000
+++ plugins/filemanager/CMakeLists.txt 2016-09-03 22:26:31 +0000
@@ -8,6 +8,8 @@
8 File.vala8 File.vala
9 Settings.vala9 Settings.vala
10 FileView.vala10 FileView.vala
11 FileItem.vala
12 FolderItem.vala
11PACKAGES13PACKAGES
12 gtk+-3.014 gtk+-3.0
13 gee-0.815 gee-0.8
1416
=== modified file 'plugins/filemanager/File.vala'
--- plugins/filemanager/File.vala 2013-07-16 15:56:38 +0000
+++ plugins/filemanager/File.vala 2016-09-03 22:26:31 +0000
@@ -23,7 +23,7 @@
23 /**23 /**
24 * Class for easily dealing with files.24 * Class for easily dealing with files.
25 */25 */
26 internal class File : GLib.Object {26 public class File : GLib.Object {
2727
28 public GLib.File file;28 public GLib.File file;
29 private GLib.FileInfo info;29 private GLib.FileInfo info;
@@ -179,13 +179,13 @@
179 }179 }
180 }180 }
181181
182 /*public void trash () {182 public void trash () {
183 try {183 try {
184 file.trash ();184 file.trash ();
185 } catch (GLib.Error error) {185 } catch (GLib.Error error) {
186 warning (error.message);186 warning (error.message);
187 }187 }
188 }*/188 }
189189
190 public void reset_cache () {190 public void reset_cache () {
191 _name = null;191 _name = null;
192192
=== added file 'plugins/filemanager/FileItem.vala'
--- plugins/filemanager/FileItem.vala 1970-01-01 00:00:00 +0000
+++ plugins/filemanager/FileItem.vala 2016-09-03 22:26:31 +0000
@@ -0,0 +1,52 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2016 elementary LLC. (https://elementary.io)
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authored by: Corentin Noël <corentin@elementary.io>
19 */
20
21public class Scratch.Plugins.FileManager.FileItem : Item {
22 public FileItem (Scratch.Plugins.FileManager.File file, Scratch.Plugins.FileManager.FileView view) requires (file.is_valid_textfile) {
23 Object (file: file, view: view);
24
25 this.selectable = true;
26 this.editable = true;
27 this.name = file.name;
28 this.icon = file.icon;
29 }
30
31 public override Gtk.Menu? get_context_menu () {
32 var menu = new Gtk.Menu ();
33 var open_item = new Gtk.MenuItem.with_label (_("Rename"));
34 open_item.activate.connect (() => view.start_editing_item (this));
35 menu.append (open_item);
36 var delete_item = new Gtk.MenuItem.with_label (_("Move to Trash"));
37 delete_item.activate.connect (() => do_remove ());
38 menu.append (delete_item);
39 menu.show_all ();
40 return menu;
41 }
42
43 public void rename (string new_name) {
44 string new_uri = file.file.get_parent ().get_uri () + "/" + new_name;
45 debug (new_uri);
46 file.rename (new_name);
47 }
48
49 private void do_remove () {
50 file.trash ();
51 }
52}
053
=== modified file 'plugins/filemanager/FileManagerPlugin.vala'
--- plugins/filemanager/FileManagerPlugin.vala 2016-09-03 11:50:58 +0000
+++ plugins/filemanager/FileManagerPlugin.vala 2016-09-03 22:26:31 +0000
@@ -24,9 +24,9 @@
24namespace Scratch.Plugins {24namespace Scratch.Plugins {
25 public class FileManagerPlugin : Peas.ExtensionBase, Peas.Activatable {25 public class FileManagerPlugin : Peas.ExtensionBase, Peas.Activatable {
26 public Scratch.Services.Interface plugins;26 public Scratch.Services.Interface plugins;
27 27 Gtk.Button button;
28 Gtk.Box box;
29 FileManager.FileView view;28 FileManager.FileView view;
29 Gtk.Grid main_grid;
3030
31 public Object object { owned get; construct; }31 public Object object { owned get; construct; }
3232
@@ -37,11 +37,19 @@
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.hook_toolbar.connect (on_hook_toolbar);
40 }41 }
4142
42 public void deactivate () {43 public void deactivate () {
43 if (box != null)44 if (main_grid != null) {
44 box.destroy();45 main_grid.destroy();
46 main_grid = null;
47 }
48
49 if (button != null) {
50 button.destroy();
51 button = null;
52 }
45 }53 }
4654
47 public void update_state () {55 public void update_state () {
@@ -49,59 +57,73 @@
49 }57 }
5058
51 void on_hook_sidebar (Gtk.Notebook notebook) {59 void on_hook_sidebar (Gtk.Notebook notebook) {
52 if (view != null)60 if (main_grid != null)
53 return;61 return;
5462
55 box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
56
57 // File View63 // File View
58 view = new FileManager.FileView ();64 view = new FileManager.FileView ();
5965 view.select.connect ((file) => plugins.open_file (file));
60 view.select.connect ((a) => {66 view.welcome_visible.connect ((visible) => {
61 var file = GLib.File.new_for_path (a);67 if (visible) {
62 plugins.open_file (file);68 button.no_show_all = false;
69 button.show_all ();
70 main_grid.parent.remove (main_grid);
71 } else if (main_grid.parent == null) {
72 button.no_show_all = true;
73 button.hide ();
74 main_grid.show_all ();
75 var icon = new Gtk.Image.from_icon_name ("folder-symbolic", Gtk.IconSize.MENU);
76 icon.tooltip_text = _("File Manager");
77 notebook.append_page (main_grid, icon);
78 }
63 });79 });
6480
65 // Toolbar
66 var toolbar = new Gtk.Toolbar ();81 var toolbar = new Gtk.Toolbar ();
67 toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);82 toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);
68 toolbar.get_style_context ().add_class ("inline-toolbar");83 toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);
69
70 var parent = new Gtk.ToolButton (null, null);
71 parent.tooltip_text = _("Go to parent");
72 parent.icon_name = "go-up-symbolic";
73 parent.clicked.connect (() => {
74 view.open_parent ();
75 parent.sensitive = !(view.folder.file.file.get_path () == "/");
76 });
77
78 var spacer = new Gtk.ToolItem ();
79 spacer.set_expand (true);
8084
81 var add = new Gtk.ToolButton (null, null);85 var add = new Gtk.ToolButton (null, null);
82 add.tooltip_text = _("Add file");86 add.tooltip_text = _("Add a folder");
83 add.icon_name = "list-add-symbolic";87 add.icon_name = "list-add-symbolic";
84 add.clicked.connect (() => {88 add.clicked.connect (() => open_dialog ());
85 view.add_file ();89
86 });90 toolbar.add (add);
8791
88 var remove = new Gtk.ToolButton (null, null);92 main_grid = new Gtk.Grid ();
89 remove.tooltip_text = _("Remove file");93 main_grid.orientation = Gtk.Orientation.VERTICAL;
90 remove.icon_name = "edit-delete-symbolic";94 main_grid.add (view);
91 remove.clicked.connect (() => {95 main_grid.add (toolbar);
92 view.remove_file ();96
93 });97 view.restore_settings ();
9498 }
95 toolbar.insert (parent, -1);99
96 toolbar.insert (spacer, -1);100 void on_hook_toolbar (Gtk.HeaderBar toolbar) {
97 toolbar.insert (add, -1);101 if (button != null)
98 toolbar.insert (remove, -1);102 return;
99103
100 box.pack_start (view, true, true, 0);104 button = new Gtk.Button.from_icon_name ("folder-saved-search", Gtk.IconSize.LARGE_TOOLBAR);
101 box.pack_start (toolbar, false, false, 0);105 button.tooltip_text = _("Open a folder");
102 box.show_all ();106 button.clicked.connect (() => open_dialog ());
103107 button.show_all ();
104 notebook.append_page (box, new Gtk.Label (_("File Manager")));108 toolbar.pack_start (button);
109 }
110
111 private void open_dialog () {
112 Gtk.Window window = plugins.manager.window;
113 Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
114 "Select a folder.", window, Gtk.FileChooserAction.SELECT_FOLDER,
115 _("_Cancel"), Gtk.ResponseType.CANCEL,
116 _("_Open"), Gtk.ResponseType.ACCEPT);
117 chooser.select_multiple = true;
118
119 if (chooser.run () == Gtk.ResponseType.ACCEPT) {
120 chooser.get_files ().foreach ((file) => {
121 var folder = new Scratch.Plugins.FileManager.File (file.get_path ());
122 view.open_folder (folder);
123 });
124 }
125
126 chooser.close ();
105 }127 }
106 }128 }
107}129}
108130
=== modified file 'plugins/filemanager/FileView.vala'
--- plugins/filemanager/FileView.vala 2016-09-03 11:50:58 +0000
+++ plugins/filemanager/FileView.vala 2016-09-03 22:26:31 +0000
@@ -24,30 +24,30 @@
24 /**24 /**
25 * SourceList that displays folders and their contents.25 * SourceList that displays folders and their contents.
26 */26 */
27 internal class FileView : Granite.Widgets.SourceList {27 public class FileView : Granite.Widgets.SourceList {
28 public FolderItem? folder = null;28 public signal void select (GLib.File file);
29 public signal void select (string file);29 public signal void welcome_visible (bool visible);
30 public FileView () {30 public FileView () {
31 this.width_request = 180;31 width_request = 180;
3232
33 this.item_selected.connect ((item) => {33 item_selected.connect ((item) => {
34 select ((item as FileItem).path);34 if (item is FileItem) {
35 select ((item as FileItem).file.file);
36 }
35 });37 });
3638
37 this.root.child_removed.connect (() => {39 root.child_removed.connect (() => {
38 this.selected = null;40 this.selected = null;
41 if (root.n_children == 0) {
42 welcome_visible (true);
43 }
44
45 write_settings ();
39 });46 });
4047
41 settings = new Settings ();48 settings = new Settings ();
42 restore_settings ();
43 }49 }
4450
45 public void open_parent () {
46 GLib.File parent = this.folder.file.file.get_parent ();
47 this.root.remove (this.folder);
48 open_folder (new File (parent.get_path ()));
49 }
50
51 public void open_folder (File folder, bool expand = true) {51 public void open_folder (File folder, bool expand = true) {
52 if (is_open (folder)) {52 if (is_open (folder)) {
53 warning ("Folder '%s' is already open.", folder.path);53 warning ("Folder '%s' is already open.", folder.path);
@@ -57,49 +57,25 @@
57 return;57 return;
58 }58 }
5959
60 // Clean the SourceList before start adding something60 var folder_item = new FolderItem (folder, this);
61 if (this.folder != null) {61 root.add (folder_item);
62 this.root.remove (this.folder);62 welcome_visible (false);
63 }63
6464 folder_item.expanded = expand;
65 this.folder = new FolderItem (folder, this);
66 this.root.add (this.folder);
67
68 this.folder.expanded = expand;
69 write_settings ();65 write_settings ();
70 }66 }
71 67
72 public void add_file () {68 public void restore_settings () {
73 string path = folder.file.file.get_path () + _("/New File");69 foreach (var folder_path in settings.opened_folders) {
74 var file = GLib.File.new_for_path (path);70 if (folder_path == null) {
75 int n = 1;71 continue;
76 while (file.query_exists ()) {72 }
77 file = GLib.File.new_for_path (path + n.to_string ());73
78 n++;74 var folder = new File (folder_path);
79 }75 if (folder.is_valid_directory) {
8076 open_folder (folder);
81 try {77 }
82 file.create (FileCreateFlags.NONE);78 }
83 } catch (Error e) {
84 warning (e.message);
85 }
86
87 var item = new FileItem (new File (file.get_path ()));
88 this.folder.add (item);
89 }
90
91 public void remove_file () {
92 if (this.selected is FileItem) {
93 var file = GLib.File.new_for_path (((FileItem)selected).file.file.get_path ());
94 try {
95 file.delete ();
96 this.root.remove (selected);
97 } catch (Error e) {
98 warning (e.message);
99 }
100 }
101
102 this.selected = null;
103 }79 }
10480
105 private bool is_open (File folder) {81 private bool is_open (File folder) {
@@ -113,24 +89,23 @@
113 }89 }
11490
115 private void write_settings () {91 private void write_settings () {
116 settings.opened_folder = this.folder.file.file.get_path ();92 string[] paths = {};
117 }93 foreach (var child in this.root.children) {
11894 if (child is FolderItem) {
119 private void restore_settings () {95 paths += ((FolderItem) child).path;
120 var folder = new File (settings.opened_folder);96 }
121 if (settings.opened_folder == "" || settings.opened_folder == null || !folder.is_valid_directory) {
122 settings.opened_folder = GLib.Environment.get_home_dir ();
123 }97 }
12498
125 open_folder (new File (settings.opened_folder));99 settings.opened_folders = paths;
126 }100 }
127 }101 }
128102
129 /**103 /**
130 * Common abstract class for normal and expandable items.104 * Common abstract class for normal and expandable items.
131 */105 */
132 internal class Item : Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {106 public class Item : Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
133 public File file { get; construct; }107 public File file { get; construct; }
108 public Scratch.Plugins.FileManager.FileView view { get; construct; }
134 public string path { get { return file.path; } }109 public string path { get { return file.path; } }
135110
136 public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {111 public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {
@@ -148,150 +123,4 @@
148 }123 }
149 }124 }
150125
151 /**
152 * Normal item in the source list, represents a textfile.
153 * TODO Remove, Rename
154 */
155 internal class FileItem : Item {
156 //Gtk.Menu menu;
157 //Gtk.MenuItem item_trash;
158 public FileItem (File file) requires (file.is_valid_textfile) {
159 Object (file: file);
160
161 this.selectable = true;
162 this.editable = true;
163 this.name = file.name;
164 this.icon = file.icon;
165 }
166
167 public void rename (string new_name) {
168 string new_uri = file.file.get_parent ().get_uri () + "/" + new_name;
169 debug (new_uri);
170 file.rename (new_name);
171 }
172
173 /*public override Gtk.Menu? get_context_menu () {
174 menu = new Gtk.Menu ();
175 item_trash = new Gtk.MenuItem.with_label (_("Move to Trash"));
176 menu.append (item_trash);
177 item_trash.activate.connect (() => { file.trash (); });
178 menu.show_all ();
179 return menu;
180 }*/
181 }
182
183 /**
184 * Expandable item in the source list, represents a folder.
185 * Monitored for changes inside the directory.
186 * TODO remove, rename, create new file
187 */
188 internal class FolderItem : Item {
189 public signal void folder_open (GLib.File folder);
190 public FileView view { get; construct; }
191
192 private GLib.FileMonitor monitor;
193 private bool children_loaded = false;
194
195 //Gtk.Menu menu;
196 //Gtk.MenuItem item_trash;
197 //Gtk.MenuItem item_create;
198
199 public FolderItem (File file, FileView view) requires (file.is_valid_directory) {
200 Object (file: file, view: view);
201
202 this.editable = false;
203 this.selectable = false;
204 this.name = file.name;
205 this.icon = file.icon;
206
207 this.add (new Granite.Widgets.SourceList.Item ("")); // dummy
208 this.toggled.connect (() => {
209 if (this.expanded && this.n_children <= 1) {
210 this.clear ();
211 this.add_children ();
212 children_loaded = true;
213 }
214 });
215
216 try {
217 monitor = file.file.monitor_directory (GLib.FileMonitorFlags.NONE);
218 monitor.changed.connect ((s,d,e) => { on_changed (s,d,e); });
219 } catch (GLib.Error e) {
220 warning (e.message);
221 }
222 }
223
224 public override Gtk.Menu? get_context_menu () {
225 if (this == this.view.root.children.to_array ()[0]) {
226 return null;
227 }
228
229 var menu = new Gtk.Menu ();
230 var item = new Gtk.MenuItem.with_label (_("Open"));
231 item.activate.connect (() => { this.folder_open (this.file.file); });
232 menu.append (item);
233 menu.show_all ();
234 return menu;
235 }
236
237 internal void add_children () {
238 foreach (var child in file.children) {
239 if (child.is_valid_directory) {
240 var item = new FolderItem (child, view);
241 item.folder_open.connect (() => {
242 this.view.open_folder (child);
243 });
244
245 add (item);
246 } else if (child.is_valid_textfile) {
247 var item = new FileItem (child);
248 add (item);
249 item.edited.connect (item.rename);
250 }
251 }
252 }
253
254 private void on_changed (GLib.File source, GLib.File? dest, GLib.FileMonitorEvent event) {
255 if (!children_loaded) {
256 this.file.reset_cache ();
257 return;
258 }
259
260 switch (event) {
261 case GLib.FileMonitorEvent.DELETED:
262 var children_tmp = new Gee.ArrayList<Granite.Widgets.SourceList.Item> ();
263 children_tmp.add_all (children);
264 foreach (var item in children_tmp) {
265 if ((item as Item).path == source.get_path ()) {
266 remove (item);
267 }
268 }
269
270 break;
271 case GLib.FileMonitorEvent.CREATED:
272 if (source.query_exists () == false) {
273 return;
274 }
275
276 var file = new File (source.get_path ());
277 var exists = false;
278 foreach (var item in children) {
279 if ((item as Item).path == file.path) {
280 exists = true;
281 }
282 }
283
284 if (!exists) {
285 if (file.is_valid_textfile) {
286 this.add (new FileItem (file));
287 } else if (file.is_valid_directory) {
288 this.add (new FolderItem (file, view));
289 }
290 }
291
292 break;
293 }
294 }
295 }
296
297}126}
298127
=== added file 'plugins/filemanager/FolderItem.vala'
--- plugins/filemanager/FolderItem.vala 1970-01-01 00:00:00 +0000
+++ plugins/filemanager/FolderItem.vala 2016-09-03 22:26:31 +0000
@@ -0,0 +1,154 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2016 elementary LLC. (https://elementary.io)
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authored by: Corentin Noël <corentin@elementary.io>
19 */
20
21public class Scratch.Plugins.FileManager.FolderItem : Item {
22 public signal void folder_open (GLib.File folder);
23
24 private GLib.FileMonitor monitor;
25 private bool children_loaded = false;
26
27 public FolderItem (Scratch.Plugins.FileManager.File file, Scratch.Plugins.FileManager.FileView view) requires (file.is_valid_directory) {
28 Object (file: file, view: view);
29
30 this.editable = false;
31 this.selectable = false;
32 this.name = file.name;
33 this.icon = file.icon;
34
35 this.add (new Granite.Widgets.SourceList.Item ("")); // dummy
36 this.toggled.connect (() => {
37 if (this.expanded && this.n_children <= 1) {
38 this.clear ();
39 this.add_children ();
40 children_loaded = true;
41 }
42 });
43
44 try {
45 monitor = file.file.monitor_directory (GLib.FileMonitorFlags.NONE);
46 monitor.changed.connect ((s,d,e) => { on_changed (s,d,e); });
47 } catch (GLib.Error e) {
48 warning (e.message);
49 }
50 }
51
52 public override Gtk.Menu? get_context_menu () {
53 var menu = new Gtk.Menu ();
54 if (this.parent == this.view.root) {
55 var item = new Gtk.MenuItem.with_label (_("Close Folder"));
56 item.activate.connect (() => {
57 monitor.cancel ();
58 parent.remove (this);
59 });
60 menu.append (item);
61 } else {
62 var item = new Gtk.MenuItem.with_label (_("Open"));
63 item.activate.connect (() => folder_open (this.file.file));
64 menu.append (item);
65 }
66
67 var new_file_item = new Gtk.MenuItem.with_label (_("Add file"));
68 new_file_item.activate.connect (() => add_file ());
69 menu.append (new_file_item);
70 menu.show_all ();
71 return menu;
72 }
73
74 internal void add_children () {
75 foreach (var child in file.children) {
76 if (child.is_valid_directory) {
77 var item = new FolderItem (child, view);
78 item.folder_open.connect (() => {
79 this.view.open_folder (child);
80 });
81
82 add (item);
83 } else if (child.is_valid_textfile) {
84 var item = new FileItem (child, view);
85 add (item);
86 item.edited.connect (item.rename);
87 }
88 }
89 }
90
91 private void on_changed (GLib.File source, GLib.File? dest, GLib.FileMonitorEvent event) {
92 if (!children_loaded) {
93 this.file.reset_cache ();
94 return;
95 }
96
97 switch (event) {
98 case GLib.FileMonitorEvent.DELETED:
99 var children_tmp = new Gee.ArrayList<Granite.Widgets.SourceList.Item> ();
100 children_tmp.add_all (children);
101 foreach (var item in children_tmp) {
102 if ((item as Item).path == source.get_path ()) {
103 remove (item);
104 }
105 }
106
107 break;
108 case GLib.FileMonitorEvent.CREATED:
109 if (source.query_exists () == false) {
110 return;
111 }
112
113 var file = new File (source.get_path ());
114 var exists = false;
115 foreach (var item in children) {
116 if ((item as Item).path == file.path) {
117 exists = true;
118 }
119 }
120
121 if (!exists) {
122 if (file.is_valid_textfile) {
123 this.add (new FileItem (file, view));
124 } else if (file.is_valid_directory) {
125 this.add (new FolderItem (file, view));
126 }
127 }
128
129 break;
130 }
131 }
132
133 private void add_file () {
134 var child = file.file.get_child (_("New File"));
135
136 int n = 1;
137 while (child.query_exists ()) {
138 child = file.file.get_child (_("New File (%d)").printf (n));
139 n++;
140 }
141
142 try {
143 child.create (FileCreateFlags.NONE);
144 } catch (Error e) {
145 warning (e.message);
146 }
147
148 if (children_loaded) {
149 var item = new FileItem (new File (child.get_path ()), view);
150 this.add (item);
151 view.start_editing_item (item);
152 }
153 }
154}
0155
=== modified file 'plugins/filemanager/Settings.vala'
--- plugins/filemanager/Settings.vala 2013-07-16 15:56:38 +0000
+++ plugins/filemanager/Settings.vala 2016-09-03 22:26:31 +0000
@@ -27,7 +27,7 @@
2727
28 private const string SCHEMA = "org.pantheon.scratch.plugins.file-manager";28 private const string SCHEMA = "org.pantheon.scratch.plugins.file-manager";
2929
30 public string opened_folder { get; set; }30 public string[] opened_folders { get; set; }
3131
32 public Settings () {32 public Settings () {
33 base (SCHEMA);33 base (SCHEMA);
3434
=== removed directory 'plugins/folder-manager'
=== removed file 'plugins/folder-manager/CMakeLists.txt'
--- plugins/folder-manager/CMakeLists.txt 2016-09-03 10:30:53 +0000
+++ plugins/folder-manager/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1add_definitions(${NORMAL_CFLAGS})
2link_directories(${NORMAL_LINK_DIRS})
3
4set (PLUGIN_NAME "folder-manager")
5
6vala_precompile(VALA_C ${PLUGIN_NAME}
7 FolderManagerPlugin.vala
8 File.vala
9 Settings.vala
10 FileView.vala
11PACKAGES
12 gtk+-3.0
13 gee-0.8
14 granite
15 scratchcore
16 libpeas-1.0
17 gtksourceview-3.0
18 ${ZEITGEIST_DEPS}
19OPTIONS
20 ${DEFAULT_PLUGIN_OPTIONS}
21)
22
23add_library(${PLUGIN_NAME} MODULE ${VALA_C})
24add_dependencies(${PLUGIN_NAME} ${LIBNAME})
25
26install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
27install(FILES ${PLUGIN_NAME}.plugin DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
28
29message("-- Folder Manager plugin will be compiled")
300
=== removed file 'plugins/folder-manager/File.vala'
--- plugins/folder-manager/File.vala 2013-06-02 13:07:08 +0000
+++ plugins/folder-manager/File.vala 1970-01-01 00:00:00 +0000
@@ -1,207 +0,0 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/***
3 BEGIN LICENSE
4
5 Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License version 3, as published
8 by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranties of
12 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>
17
18 END LICENSE
19***/
20
21namespace Scratch.Plugins.FolderManager {
22
23 /**
24 * Class for easily dealing with files.
25 */
26 internal class File : GLib.Object {
27
28 public GLib.File file;
29 private GLib.FileInfo info;
30
31 private enum Type {
32 VALID_FILE,
33 VALID_FOLDER,
34 UNKNOWN,
35 INVALID
36 }
37
38 public File (string path) {
39 file = GLib.File.new_for_path (path);
40
41 info = new FileInfo ();
42 try {
43 info = file.query_info (
44 GLib.FileAttribute.STANDARD_CONTENT_TYPE + "," +
45 GLib.FileAttribute.STANDARD_IS_BACKUP + "," +
46 GLib.FileAttribute.STANDARD_IS_HIDDEN + "," +
47 GLib.FileAttribute.STANDARD_DISPLAY_NAME + "," +
48 GLib.FileAttribute.STANDARD_TYPE,
49 FileQueryInfoFlags.NONE);
50 } catch (GLib.Error error) {
51 info = null;
52 warning (error.message);
53 }
54 }
55
56 // returns the path the file
57 string _path = null;
58 public string path {
59 get { return _path != null ? _path : _path = file.get_path (); }
60 }
61
62 // returns the basename of the file
63 string _name = null;
64 public string name {
65 get { return _name != null ? _name : _name = info.get_display_name (); }
66 }
67
68 // returns the icon of the file's content type
69 GLib.Icon _icon = null;
70 public GLib.Icon icon {
71 get {
72 if (_icon != null)
73 return _icon;
74 //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
75 var content_type = info.get_content_type ();
76 return _icon = GLib.ContentType.get_icon (content_type);
77 }
78 }
79
80 // checks if file exists
81 public bool exists {
82 get { return file.query_exists (); }
83 }
84
85 Type _type = Type.UNKNOWN;
86 // checks if we're dealing with a non-hidden, non-backup directory
87 public bool is_valid_directory {
88 get {
89 if (_type == Type.VALID_FILE)
90 return false;
91 if (_type == Type.VALID_FOLDER)
92 return true;
93 if (_type == Type.INVALID)
94 return false;
95
96 if (info.get_file_type () != FileType.DIRECTORY ||
97 info.get_is_hidden () || info.get_is_backup ()) {
98 return false;
99 }
100
101 bool has_valid_children = false;
102
103 foreach (var child in children) {
104 if (child.is_valid_textfile) {
105 _type = Type.VALID_FOLDER;
106 return has_valid_children = true;
107 }
108 }
109
110 foreach (var child in children) {
111 if (child.is_valid_directory) {
112 has_valid_children = true;
113 _type = Type.VALID_FOLDER;
114 return has_valid_children = true;
115 }
116 }
117
118 return false;
119 }
120 }
121
122 // checks if we're dealing with a textfile
123 public bool is_valid_textfile {
124 get {
125 if (_type == Type.VALID_FILE)
126 return true;
127 if (_type == Type.VALID_FOLDER)
128 return false;
129 if (_type == Type.INVALID)
130 return false;
131
132 if (info.get_file_type () == FileType.REGULAR) {
133 //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
134 var content_type = info.get_content_type ();
135 if (ContentType.is_a (content_type, "text/*") &&
136 !info.get_is_backup () &&
137 !info.get_is_hidden ()) {
138 _type = Type.VALID_FILE;
139 return true;
140 }
141 }
142
143 return false;
144 }
145 }
146
147 // returns a list of all children of a directory
148 GLib.List <File> _children = null;
149 public GLib.List <File> children {
150 get {
151 if (_children != null)
152 return _children;
153
154 var parent = GLib.File.new_for_path (file.get_path ());
155 try {
156 var enumerator = parent.enumerate_children (
157 GLib.FileAttribute.STANDARD_NAME,
158 FileQueryInfoFlags.NONE
159 );
160
161 var file_info = new FileInfo ();
162 while ((file_info = enumerator.next_file ()) != null) {
163 var child = parent.get_child (file_info.get_name ());
164 _children.append (new File (child.get_path ()));
165 }
166 } catch (GLib.Error error) {
167 warning (error.message);
168 }
169
170 return _children;
171 }
172 }
173
174 /*public void rename (string name) {
175 try {
176 file.set_display_name (name);
177 } catch (GLib.Error error) {
178 warning (error.message);
179 }
180 }
181
182 public void trash () {
183 try {
184 file.trash ();
185 } catch (GLib.Error error) {
186 warning (error.message);
187 }
188 }*/
189
190 public void reset_cache () {
191 _name = null;
192 _path = null;
193 _icon = null;
194 _children = null;
195 _type = Type.UNKNOWN;
196 }
197
198 public static int compare (File a, File b) {
199 if (a.is_valid_directory && b.is_valid_textfile)
200 return -1;
201 if (a.is_valid_textfile && b.is_valid_directory)
202 return 1;
203 return strcmp (a.path.collate_key_for_filename (),
204 b.path.collate_key_for_filename ());
205 }
206 }
207}
2080
=== removed file 'plugins/folder-manager/FileView.vala'
--- plugins/folder-manager/FileView.vala 2015-09-16 01:11:55 +0000
+++ plugins/folder-manager/FileView.vala 1970-01-01 00:00:00 +0000
@@ -1,312 +0,0 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/***
3 BEGIN LICENSE
4
5 Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License version 3, as published
8 by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranties of
12 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>
17
18 END LICENSE
19***/
20
21namespace Scratch.Plugins.FolderManager {
22 Settings settings;
23
24 /**
25 * SourceList that displays folders and their contents.
26 */
27 internal class FileView : Granite.Widgets.SourceList {
28
29 public signal void select (string file);
30
31 public FileView () {
32 this.width_request = 180;
33 this.item_selected.connect ((item) => {
34 select ((item as FileItem).path);
35 });
36
37 settings = new Settings ();
38 }
39
40 public void restore_saved_state () {
41 foreach (var path in settings.opened_folders)
42 add_folder (new File (path), false);
43 }
44
45 public void open_folder (File folder) {
46 if (is_open (folder)) {
47 warning ("Folder '%s' is already open.", folder.path);
48 return;
49 } else if (!folder.is_valid_directory) {
50 warning ("Cannot open invalid directory.");
51 return;
52 }
53
54 add_folder (folder, true);
55 write_settings ();
56 }
57
58 private void add_folder (File folder, bool expand) {
59 if (is_open (folder)) {
60 warning ("Folder '%s' is already open.", folder.path);
61 return;
62 } else if (!folder.is_valid_directory) {
63 warning ("Cannot open invalid directory.");
64 return;
65 }
66
67 var folder_root = new MainFolderItem (folder);
68 this.root.add (folder_root);
69
70 folder_root.expanded = expand;
71 folder_root.closed.connect (() => {
72 root.remove (folder_root);
73 write_settings ();
74 });
75 }
76
77 private bool is_open (File folder) {
78 foreach (var child in root.children)
79 if (folder.path == (child as Item).path)
80 return true;
81 return false;
82 }
83
84 private void write_settings () {
85 string[] to_save = {};
86
87 foreach (var main_folder in root.children) {
88 var saved = false;
89
90 foreach (var saved_folder in to_save) {
91 if ((main_folder as Item).path == saved_folder) {
92 saved = true;
93 break;
94 }
95 }
96
97 if (!saved) {
98 to_save += (main_folder as Item).path;
99 }
100 }
101
102 settings.opened_folders = to_save;
103 }
104 }
105
106 /**
107 * Common abstract class for file and filder items.
108 */
109 internal class Item: Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
110 public File file { get; construct; }
111 public string path { get { return file.path; } }
112
113 public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {
114 if (a is FolderItem && b is FileItem) {
115 return -1;
116 } else if (a is FileItem && b is FolderItem) {
117 return 1;
118 }
119
120 return File.compare ((a as Item).file, (b as Item).file);
121 }
122
123 public bool allow_dnd_sorting () {
124 return false;
125 }
126 }
127
128 /**
129 * Normal item in the source list, represents a textfile.
130 * TODO Remove, Rename
131 */
132 internal class FileItem : Item {
133
134 //Gtk.Menu menu;
135 //Gtk.MenuItem item_trash;
136
137 public FileItem (File file) requires (file.is_valid_textfile) {
138 Object (file: file);
139
140 this.selectable = true;
141 //this.editable = true;
142 this.name = file.name;
143 this.icon = file.icon;
144 }
145
146 /*public void rename (string new_name) {
147 file.rename (new_name);
148 }*/
149
150 /*public override Gtk.Menu? get_context_menu () {
151 menu = new Gtk.Menu ();
152 item_trash = new Gtk.MenuItem.with_label (_("Move to Trash"));
153 menu.append (item_trash);
154 item_trash.activate.connect (() => { file.trash (); });
155 menu.show_all ();
156 return menu;
157 }*/
158 }
159
160 /**
161 * Expandable item in the source list, represents a folder.
162 * Monitored for changes inside the directory.
163 * TODO remove, rename, create new file
164 */
165 internal class FolderItem : Item {
166
167 //Gtk.Menu menu;
168 //Gtk.MenuItem item_trash;
169 //Gtk.MenuItem item_create;
170
171 private GLib.FileMonitor monitor;
172 private bool children_loaded = false;
173
174 public FolderItem (File file) requires (file.is_valid_directory) {
175 Object (file: file);
176
177 this.editable = false;
178 this.selectable = false;
179 this.name = file.name;
180 this.icon = file.icon;
181
182 this.add (new Granite.Widgets.SourceList.Item ("")); // dummy
183 this.toggled.connect (() => {
184 if (this.expanded && this.n_children <= 1) {
185 this.clear ();
186 this.add_children ();
187 children_loaded = true;
188 }
189 });
190
191 try {
192 monitor = file.file.monitor_directory (GLib.FileMonitorFlags.NONE);
193 monitor.changed.connect ((s,d,e) => { on_changed (s,d,e); });
194 } catch (GLib.Error e) {
195 warning (e.message);
196 }
197 }
198
199 /*public override Gtk.Menu? get_context_menu () {
200 menu = new Gtk.Menu ();
201 item_trash = new Gtk.MenuItem.with_label (_("Move to Trash"));
202 item_create = new Gtk.MenuItem.with_label (_("Create new File"));
203 menu.append (item_trash);
204 menu.append (item_create);
205 item_trash.activate.connect (() => { file.trash (); });
206 item_create.activate.connect (() => {
207 var new_file = GLib.File.new_for_path (file.path + "/new File");
208
209 try {
210 FileOutputStream os = new_file.create (FileCreateFlags.NONE);
211 } catch (Error e) {
212 warning ("Error: %s\n", e.message);
213 }
214 });
215 menu.show_all ();
216 return menu;
217 }*/
218
219 internal void add_children () {
220 foreach (var child in file.children) {
221 if (child.is_valid_directory) {
222 var item = new FolderItem (child);
223 add (item);
224 } else if (child.is_valid_textfile) {
225 var item = new FileItem (child);
226 add (item);
227 //item.edited.connect (item.rename);
228 }
229 }
230 }
231
232 private void on_changed (GLib.File source, GLib.File? dest, GLib.FileMonitorEvent event) {
233
234 if (!children_loaded) {
235 this.file.reset_cache ();
236 return;
237 }
238
239 switch (event) {
240 case GLib.FileMonitorEvent.DELETED:
241 var children_tmp = new Gee.ArrayList<Granite.Widgets.SourceList.Item> ();
242 children_tmp.add_all (children);
243 foreach (var item in children_tmp) {
244 if ((item as Item).path == source.get_path ()) {
245 remove (item);
246 }
247 }
248
249 break;
250 case GLib.FileMonitorEvent.CREATED:
251 if (source.query_exists () == false) {
252 return;
253 }
254
255 var file = new File (source.get_path ());
256 var exists = false;
257 foreach (var item in children) {
258 if ((item as Item).path == file.path) {
259 exists = true;
260 break;
261 }
262 }
263
264 if (!exists) {
265 if (file.is_valid_textfile) {
266 this.add (new FileItem (file));
267 } else if (file.is_valid_directory) {
268 this.add (new FolderItem (file));
269 }
270 }
271
272 break;
273 }
274 }
275 }
276
277 /**
278 * Special root folder.
279 * TODO rename, create new file
280 */
281 internal class MainFolderItem : FolderItem {
282 public signal void closed ();
283
284 Gtk.Menu menu;
285 Gtk.MenuItem item_close;
286 //Gtk.MenuItem item_create;
287
288 public MainFolderItem (File file) requires (file.is_valid_directory) {
289 base (file);
290 }
291
292 public override Gtk.Menu? get_context_menu () {
293 menu = new Gtk.Menu ();
294 item_close = new Gtk.MenuItem.with_label (_("Close Folder"));
295 //item_create = new Gtk.MenuItem.with_label (_("Create new File"));
296 menu.append (item_close);
297 //menu.append (item_create);
298 item_close.activate.connect (() => { closed (); });
299 /*item_create.activate.connect (() => {
300 var new_file = GLib.File.new_for_path (file.path + "/new File");
301
302 try {
303 FileOutputStream os = new_file.create (FileCreateFlags.NONE);
304 } catch (Error e) {
305 warning ("Error: %s\n", e.message);
306 }
307 });*/
308 menu.show_all ();
309 return menu;
310 }
311 }
312}
3130
=== removed file 'plugins/folder-manager/FolderManagerPlugin.vala'
--- plugins/folder-manager/FolderManagerPlugin.vala 2015-12-01 11:37:53 +0000
+++ plugins/folder-manager/FolderManagerPlugin.vala 1970-01-01 00:00:00 +0000
@@ -1,122 +0,0 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/***
3 BEGIN LICENSE
4
5 Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License version 3, as published
8 by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranties of
12 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>
17
18 END LICENSE
19***/
20
21public const string NAME = _("Folder Manager");
22public const string DESCRIPTION = _("Basic folder manager with file browsing");
23
24namespace Scratch.Plugins {
25 public class FolderManagerPlugin : Peas.ExtensionBase, Peas.Activatable {
26
27 FolderManager.FileView view;
28 Gtk.ToolButton tool_button;
29
30 int index = 0;
31
32 Scratch.Services.Interface plugins;
33 public Object object { owned get; construct; }
34
35 public FolderManagerPlugin () {
36 message ("Starting Folder Manager Plugin");
37 }
38
39 public void activate () {
40 plugins = (Scratch.Services.Interface) object;
41 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
42 plugins.hook_toolbar.connect (on_hook_toolbar);
43 }
44
45 public void deactivate () {
46 if (view != null)
47 view.destroy();
48 if (tool_button != null) {
49 //(tool_button.parent as Scratch.Widgets.Toolbar).open_button.visible = true;
50 tool_button.destroy ();
51 }
52 }
53
54 public void update_state () {
55 }
56
57 void on_hook_sidebar (Gtk.Notebook notebook) {
58 if (view != null)
59 return;
60
61 view = new FolderManager.FileView ();
62
63 view.select.connect ((a) => {
64 var file = GLib.File.new_for_path (a);
65 plugins.open_file (file);
66 });
67
68 view.root.child_added.connect (() => {
69 if (view.get_n_visible_children (view.root) == 0) {
70 index = notebook.append_page (view, new Gtk.Label (_("Folders")));
71 }
72 });
73
74 view.root.child_removed.connect (() => {
75 if (view.get_n_visible_children (view.root) == 1)
76 notebook.remove_page (index);
77 });
78
79 view.restore_saved_state ();
80 }
81
82 void on_hook_toolbar (Gtk.HeaderBar toolbar) {
83 if (tool_button != null)
84 return;
85
86 //(toolbar as Scratch.Widgets.Toolbar).open_button.visible = false;
87 var icon = new Gtk.Image.from_icon_name ("folder-saved-search", Gtk.IconSize.LARGE_TOOLBAR);
88 tool_button = new Gtk.ToolButton (icon, _("Open a folder"));
89 tool_button.tooltip_text = _("Open a folder");
90 tool_button.clicked.connect (() => {
91 Gtk.Window window = plugins.manager.window;
92 Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
93 "Select a folder.", window, Gtk.FileChooserAction.SELECT_FOLDER,
94 _("_Cancel"), Gtk.ResponseType.CANCEL,
95 _("_Open"), Gtk.ResponseType.ACCEPT);
96 chooser.select_multiple = true;
97
98 if (chooser.run () == Gtk.ResponseType.ACCEPT) {
99 SList<string> uris = chooser.get_uris ();
100 foreach (unowned string uri in uris) {
101 var folder = new FolderManager.File (uri.replace ("file:///", "/"));
102 view.open_folder (folder); // emit signal
103 }
104 }
105
106 chooser.close ();
107 });
108
109 icon.show ();
110 tool_button.show ();
111
112 toolbar.pack_start (tool_button);
113 //toolbar.insert (tool_button, 1);
114 }
115 }
116}
117
118[ModuleInit]
119public void peas_register_types (GLib.TypeModule module) {
120 var objmodule = module as Peas.ObjectModule;
121 objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.FolderManagerPlugin));
122}
1230
=== removed file 'plugins/folder-manager/Settings.vala'
--- plugins/folder-manager/Settings.vala 2013-05-31 10:38:24 +0000
+++ plugins/folder-manager/Settings.vala 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/***
3 BEGIN LICENSE
4
5 Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License version 3, as published
8 by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranties of
12 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>
17
18 END LICENSE
19***/
20
21namespace Scratch.Plugins.FolderManager {
22
23 /**
24 * Class for interacting with gsettings.
25 */
26 internal class Settings : Granite.Services.Settings {
27
28 private const string SCHEMA = "org.pantheon.scratch.plugins.folder-manager";
29
30 public string[] opened_folders { get; set; }
31
32 public Settings () {
33 base (SCHEMA);
34 }
35 }
36}
370
=== removed file 'plugins/folder-manager/folder-manager.plugin'
--- plugins/folder-manager/folder-manager.plugin 2013-06-08 15:17:42 +0000
+++ plugins/folder-manager/folder-manager.plugin 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1[Plugin]
2Module=folder-manager
3Loader=C
4IAge=2
5Name=Folder Manager
6Description=Basic folder manager with file browsing
7Icon=folder-saved-search
8Authors=Julien Spautz <spautz.julien@gmail.com>
9Copyright=Copyright © 2013 Scratch Developers
10Website=http://launchpad.net/scratch
110
=== modified file 'plugins/outline/OutlinePlugin.vala'
--- plugins/outline/OutlinePlugin.vala 2016-01-14 19:33:06 +0000
+++ plugins/outline/OutlinePlugin.vala 2016-09-03 22:26:31 +0000
@@ -21,6 +21,7 @@
21public const string NAME = _("Outline");21public const string NAME = _("Outline");
22public const string DESCRIPTION = _("Outline symbols in your current file in vala");22public const string DESCRIPTION = _("Outline symbols in your current file in vala");
2323
24
24namespace Scratch.Plugins {25namespace Scratch.Plugins {
25 public class OutlinePlugin : Peas.ExtensionBase, Peas.Activatable {26 public class OutlinePlugin : Peas.ExtensionBase, Peas.Activatable {
26 public Object object { owned get; construct; }27 public Object object { owned get; construct; }
@@ -113,7 +114,9 @@
113114
114 void add_container () {115 void add_container () {
115 if (notebook.page_num (container) == -1) {116 if (notebook.page_num (container) == -1) {
116 notebook.append_page (container, new Gtk.Label (_("Symbols")));117 var icon = new Gtk.Image.from_icon_name ("view-sort-ascending-symbolic", Gtk.IconSize.MENU);
118 icon.tooltip_text = _("Outline");
119 notebook.append_page (container, icon);
117 container.show_all ();120 container.show_all ();
118 }121 }
119 }122 }
120123
=== modified file 'plugins/source-tree/SourceTreePlugin.vala'
--- plugins/source-tree/SourceTreePlugin.vala 2015-12-01 11:41:37 +0000
+++ plugins/source-tree/SourceTreePlugin.vala 2016-09-03 22:26:31 +0000
@@ -194,7 +194,9 @@
194 view.welcome_hidden.connect (() => {194 view.welcome_hidden.connect (() => {
195 this.bookmark_tool_button.visible = true;195 this.bookmark_tool_button.visible = true;
196 this.bookmark_tool_button.no_show_all = false;196 this.bookmark_tool_button.no_show_all = false;
197 this.side_notebook.append_page (this.view, new Gtk.Label (_("Source Tree")));197 var icon = new Gtk.Image.from_icon_name ("view-list-symbolic", Gtk.IconSize.MENU);
198 icon.tooltip_text = _("Source Tree");
199 this.side_notebook.append_page (this.view, icon);
198 });200 });
199 });201 });
200 202
201203
=== modified file 'schemas/CMakeLists.txt'
--- schemas/CMakeLists.txt 2015-09-10 00:54:45 +0000
+++ schemas/CMakeLists.txt 2016-09-03 22:26:31 +0000
@@ -1,6 +1,5 @@
1include(GSettings)1include(GSettings)
2add_schema("org.pantheon.scratch.gschema.xml")2add_schema("org.pantheon.scratch.gschema.xml")
3add_schema("org.pantheon.scratch.plugins.folder-manager.gschema.xml")
4add_schema("org.pantheon.scratch.plugins.file-manager.gschema.xml")3add_schema("org.pantheon.scratch.plugins.file-manager.gschema.xml")
5add_schema("org.pantheon.scratch.plugins.terminal.gschema.xml")4add_schema("org.pantheon.scratch.plugins.terminal.gschema.xml")
6add_schema("org.pantheon.scratch.plugins.spell.gschema.xml")5add_schema("org.pantheon.scratch.plugins.spell.gschema.xml")
76
=== modified file 'schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml'
--- schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml 2013-07-16 15:56:38 +0000
+++ schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml 2016-09-03 22:26:31 +0000
@@ -1,10 +1,10 @@
1<?xml version="1.0" encoding="UTF-8"?>1<?xml version="1.0" encoding="UTF-8"?>
2<schemalist>2<schemalist>
3 <schema path="/org/pantheon/scratch/plugins/file-manager/" id="org.pantheon.scratch.plugins.file-manager" gettext-domain="scratch">3 <schema path="/org/pantheon/scratch/plugins/file-manager/" id="org.pantheon.scratch.plugins.file-manager" gettext-domain="scratch">
4 <key name="opened-folder" type="s">4 <key name="opened-folders" type="as">
5 <default>''</default>5 <default>[]</default>
6 <summary>Opened folder.</summary>6 <summary>Opened folders.</summary>
7 <description>Opened folder that should be restored in startup.</description>7 <description>Opened folders that should be restored in startup.</description>
8 </key>8 </key>
9 </schema>9 </schema>
10</schemalist>10</schemalist>
1111
=== removed file 'schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml'
--- schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 2013-05-31 10:38:24 +0000
+++ schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<schemalist>
3 <schema path="/org/pantheon/scratch/plugins/folder-manager/" id="org.pantheon.scratch.plugins.folder-manager" gettext-domain="scratch">
4 <key name="opened-folders" type="as">
5 <default>[]</default>
6 <summary>Opened folders.</summary>
7 <description>Opened folders that should be restored in startup.</description>
8 </key>
9 </schema>
10</schemalist>

Subscribers

People subscribed via source and target branches