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

Proposed by Zisu Andrei
Status: Superseded
Proposed branch: lp:~matzipan/scratch/filemanager
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 2407 lines (+268/-1432)
20 files modified
plugins/CMakeLists.txt (+0/-1)
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 (+0/-29)
plugins/folder-manager/File.vala (+0/-207)
plugins/folder-manager/FileItem.vala (+55/-0)
plugins/folder-manager/FileView.vala (+0/-312)
plugins/folder-manager/FolderItem.vala (+206/-0)
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 (+0/-10)
schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml (+0/-10)
To merge this branch: bzr merge lp:~matzipan/scratch/filemanager
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+311301@code.launchpad.net

This proposal has been superseded by a proposal from 2016-11-30.

Commit message

Merge File Manager and 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 :

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 :

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

lp:~matzipan/scratch/filemanager updated
1751. By Zisu Andrei

Implement rename folder, add folder, allow empty folders to be displayed

1752. By Zisu Andrei

Move back to folder-manager. Fix issue with hidden folders

1753. By Zisu Andrei

Move back to folder-manager. Fix issue with hidden folders

1754. By Zisu Andrei

Move back to folder-manager. Fix issue with hidden folders

Unmerged revisions

1754. By Zisu Andrei

Move back to folder-manager. Fix issue with hidden folders

1753. By Zisu Andrei

Move back to folder-manager. Fix issue with hidden folders

1752. By Zisu Andrei

Move back to folder-manager. Fix issue with hidden folders

1751. By Zisu Andrei

Implement rename folder, add folder, allow empty folders to be displayed

1750. By Zisu Andrei

Keep headerbar icon always visible. Remove toolbar

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
=== added directory 'build'
=== added directory 'build/plugins'
=== modified file 'plugins/CMakeLists.txt'
--- plugins/CMakeLists.txt 2016-09-03 10:30:53 +0000
+++ plugins/CMakeLists.txt 2016-11-18 21:40:10 +0000
@@ -7,7 +7,6 @@
77
8add_subdirectory (contractor)8add_subdirectory (contractor)
9add_subdirectory (pastebin)9add_subdirectory (pastebin)
10add_subdirectory (filemanager)
11add_subdirectory (folder-manager)10add_subdirectory (folder-manager)
12add_subdirectory (terminal)11add_subdirectory (terminal)
13add_subdirectory (browser-preview)12add_subdirectory (browser-preview)
1413
=== removed directory 'plugins/filemanager'
=== removed file 'plugins/filemanager/CMakeLists.txt'
--- plugins/filemanager/CMakeLists.txt 2016-09-03 10:30:53 +0000
+++ plugins/filemanager/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 "filemanager")
5
6vala_precompile(VALA_C ${PLUGIN_NAME}
7 FileManagerPlugin.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("-- File Manager plugin will be compiled")
300
=== removed file 'plugins/filemanager/File.vala'
--- plugins/filemanager/File.vala 2013-07-16 15:56:38 +0000
+++ plugins/filemanager/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.FileManager {
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/filemanager/FileManagerPlugin.vala'
--- plugins/filemanager/FileManagerPlugin.vala 2016-09-03 11:50:58 +0000
+++ plugins/filemanager/FileManagerPlugin.vala 1970-01-01 00:00:00 +0000
@@ -1,113 +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 FileManagerPlugin : Peas.ExtensionBase, Peas.Activatable {
26 public Scratch.Services.Interface plugins;
27
28 Gtk.Box box;
29 FileManager.FileView view;
30
31 public Object object { owned get; construct; }
32
33 public FileManagerPlugin () {
34 message ("Starting File Manager Plugin");
35 }
36
37 public void activate () {
38 plugins = (Scratch.Services.Interface) object;
39 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
40 }
41
42 public void deactivate () {
43 if (box != null)
44 box.destroy();
45 }
46
47 public void update_state () {
48
49 }
50
51 void on_hook_sidebar (Gtk.Notebook notebook) {
52 if (view != null)
53 return;
54
55 box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
56
57 // File View
58 view = new FileManager.FileView ();
59
60 view.select.connect ((a) => {
61 var file = GLib.File.new_for_path (a);
62 plugins.open_file (file);
63 });
64
65 // Toolbar
66 var toolbar = new Gtk.Toolbar ();
67 toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);
68 toolbar.get_style_context ().add_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);
80
81 var add = new Gtk.ToolButton (null, null);
82 add.tooltip_text = _("Add file");
83 add.icon_name = "list-add-symbolic";
84 add.clicked.connect (() => {
85 view.add_file ();
86 });
87
88 var remove = new Gtk.ToolButton (null, null);
89 remove.tooltip_text = _("Remove file");
90 remove.icon_name = "edit-delete-symbolic";
91 remove.clicked.connect (() => {
92 view.remove_file ();
93 });
94
95 toolbar.insert (parent, -1);
96 toolbar.insert (spacer, -1);
97 toolbar.insert (add, -1);
98 toolbar.insert (remove, -1);
99
100 box.pack_start (view, true, true, 0);
101 box.pack_start (toolbar, false, false, 0);
102 box.show_all ();
103
104 notebook.append_page (box, new Gtk.Label (_("File Manager")));
105 }
106 }
107}
108
109[ModuleInit]
110public void peas_register_types (GLib.TypeModule module) {
111 var objmodule = module as Peas.ObjectModule;
112 objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.FileManagerPlugin));
113}
1140
=== removed file 'plugins/filemanager/FileView.vala'
--- plugins/filemanager/FileView.vala 2016-09-03 11:50:58 +0000
+++ plugins/filemanager/FileView.vala 1970-01-01 00:00:00 +0000
@@ -1,297 +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.FileManager {
22 Settings settings;
23
24 /**
25 * SourceList that displays folders and their contents.
26 */
27 internal class FileView : Granite.Widgets.SourceList {
28 public FolderItem? folder = null;
29 public signal void select (string file);
30 public FileView () {
31 this.width_request = 180;
32
33 this.item_selected.connect ((item) => {
34 select ((item as FileItem).path);
35 });
36
37 this.root.child_removed.connect (() => {
38 this.selected = null;
39 });
40
41 settings = new Settings ();
42 restore_settings ();
43 }
44
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) {
52 if (is_open (folder)) {
53 warning ("Folder '%s' is already open.", folder.path);
54 return;
55 } else if (!folder.is_valid_directory) {
56 warning ("Cannot open invalid directory.");
57 return;
58 }
59
60 // Clean the SourceList before start adding something
61 if (this.folder != null) {
62 this.root.remove (this.folder);
63 }
64
65 this.folder = new FolderItem (folder, this);
66 this.root.add (this.folder);
67
68 this.folder.expanded = expand;
69 write_settings ();
70 }
71
72 public void add_file () {
73 string path = folder.file.file.get_path () + _("/New File");
74 var file = GLib.File.new_for_path (path);
75 int n = 1;
76 while (file.query_exists ()) {
77 file = GLib.File.new_for_path (path + n.to_string ());
78 n++;
79 }
80
81 try {
82 file.create (FileCreateFlags.NONE);
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 }
104
105 private bool is_open (File folder) {
106 foreach (var child in root.children) {
107 if (folder.path == (child as Item).path) {
108 return true;
109 }
110 }
111
112 return false;
113 }
114
115 private void write_settings () {
116 settings.opened_folder = this.folder.file.file.get_path ();
117 }
118
119 private void restore_settings () {
120 var folder = new File (settings.opened_folder);
121 if (settings.opened_folder == "" || settings.opened_folder == null || !folder.is_valid_directory) {
122 settings.opened_folder = GLib.Environment.get_home_dir ();
123 }
124
125 open_folder (new File (settings.opened_folder));
126 }
127 }
128
129 /**
130 * Common abstract class for normal and expandable items.
131 */
132 internal class Item : Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
133 public File file { get; construct; }
134 public string path { get { return file.path; } }
135
136 public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {
137 if (a is FolderItem && b is FileItem) {
138 return -1;
139 } else if (a is FileItem && b is FolderItem) {
140 return 1;
141 }
142
143 return File.compare ((a as Item).file, (b as Item).file);
144 }
145
146 public bool allow_dnd_sorting () {
147 return false;
148 }
149 }
150
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}
2980
=== removed file 'plugins/filemanager/Settings.vala'
--- plugins/filemanager/Settings.vala 2013-07-16 15:56:38 +0000
+++ plugins/filemanager/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.FileManager {
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.file-manager";
29
30 public string opened_folder { get; set; }
31
32 public Settings () {
33 base (SCHEMA);
34 }
35 }
36}
370
=== removed file 'plugins/filemanager/filemanager.plugin'
--- plugins/filemanager/filemanager.plugin 2013-07-16 15:56:38 +0000
+++ plugins/filemanager/filemanager.plugin 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1[Plugin]
2Module=filemanager
3Loader=C
4IAge=2
5Name=File Manager
6Description=Browse files and directories
7Icon=system-file-manager
8Authors=Mario Guerriero
9Copyright=Copyright © 2013 Scratch Developers
10Website=http://launchpad.net/scratch
110
=== added directory 'plugins/folder-manager'
=== removed directory 'plugins/folder-manager'
=== added file 'plugins/folder-manager/CMakeLists.txt'
--- plugins/folder-manager/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/CMakeLists.txt 2016-11-18 21:40:10 +0000
@@ -0,0 +1,31 @@
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
11 FileItem.vala
12 FolderItem.vala
13PACKAGES
14 gtk+-3.0
15 gee-0.8
16 granite
17 scratchcore
18 libpeas-1.0
19 gtksourceview-3.0
20 ${ZEITGEIST_DEPS}
21OPTIONS
22 ${DEFAULT_PLUGIN_OPTIONS}
23)
24
25add_library(${PLUGIN_NAME} MODULE ${VALA_C})
26add_dependencies(${PLUGIN_NAME} ${LIBNAME})
27
28install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
29install(FILES ${PLUGIN_NAME}.plugin DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
30
31message("-- Folder Manager plugin will be compiled")
032
=== 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
=== added file 'plugins/folder-manager/File.vala'
--- plugins/folder-manager/File.vala 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/File.vala 2016-11-18 21:40:10 +0000
@@ -0,0 +1,209 @@
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: Julien Spautz <spautz.julien@gmail.com>, Andrei-Costin Zisu <matzipan@gmail.com>
19 */
20
21namespace Scratch.Plugins.FolderManager {
22
23 /**
24 * Class for easily dealing with files.
25 */
26 public 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 }
75
76 //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
77 var content_type = info.get_content_type ();
78 return _icon = GLib.ContentType.get_icon (content_type);
79 }
80 }
81
82 // checks if file exists
83 public bool exists {
84 get { return file.query_exists (); }
85 }
86
87 Type _type = Type.UNKNOWN;
88 // checks if we're dealing with a non-hidden, non-backup directory
89 public bool is_valid_directory {
90 get {
91 if (_type == Type.VALID_FILE) {
92 return false;
93 }
94
95 if (_type == Type.VALID_FOLDER) {
96 return true;
97 }
98
99 if (_type == Type.INVALID) {
100 return false;
101 }
102
103 if (info.get_is_hidden () || info.get_is_backup ()) {
104 return false;
105 }
106
107 if (info.get_file_type () == FileType.DIRECTORY) {
108 return true;
109 }
110
111 return false;
112 }
113 }
114
115 // checks if we're dealing with a textfile
116 public bool is_valid_textfile {
117 get {
118 if (_type == Type.VALID_FILE) {
119 return true;
120 }
121
122 if (_type == Type.VALID_FOLDER) {
123 return false;
124 }
125
126 if (_type == Type.INVALID) {
127 return false;
128 }
129
130 if (info.get_file_type () == FileType.REGULAR) {
131 var content_type = info.get_content_type ();
132 if (ContentType.is_a (content_type, "text/*") &&
133 !info.get_is_backup () &&
134 !info.get_is_hidden ()) {
135 _type = Type.VALID_FILE;
136 return true;
137 }
138 }
139
140 return false;
141 }
142 }
143
144 // returns a list of all children of a directory
145 GLib.List <File> _children = null;
146 public GLib.List <File> children {
147 get {
148 if (_children != null) {
149 return _children;
150 }
151
152 var parent = GLib.File.new_for_path (file.get_path ());
153 try {
154 var enumerator = parent.enumerate_children (
155 GLib.FileAttribute.STANDARD_NAME,
156 FileQueryInfoFlags.NONE
157 );
158
159 var file_info = new FileInfo ();
160 while ((file_info = enumerator.next_file ()) != null) {
161 var child = parent.get_child (file_info.get_name ());
162 _children.append (new File (child.get_path ()));
163 }
164 } catch (GLib.Error error) {
165 warning (error.message);
166 }
167
168 return _children;
169 }
170 }
171
172 public void rename (string name) {
173 try {
174 file.set_display_name (name);
175 } catch (GLib.Error error) {
176 warning (error.message);
177 }
178 }
179
180 public void trash () {
181 try {
182 file.trash ();
183 } catch (GLib.Error error) {
184 warning (error.message);
185 }
186 }
187
188 public void reset_cache () {
189 _name = null;
190 _path = null;
191 _icon = null;
192 _children = null;
193 _type = Type.UNKNOWN;
194 }
195
196 public static int compare (File a, File b) {
197 if (a.is_valid_directory && b.is_valid_textfile) {
198 return -1;
199 }
200
201 if (a.is_valid_textfile && b.is_valid_directory) {
202 return 1;
203 }
204
205 return strcmp (a.path.collate_key_for_filename (),
206 b.path.collate_key_for_filename ());
207 }
208 }
209}
0210
=== 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
=== added file 'plugins/folder-manager/FileItem.vala'
--- plugins/folder-manager/FileItem.vala 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/FileItem.vala 2016-11-18 21:40:10 +0000
@@ -0,0 +1,55 @@
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>, Andrei-Costin Zisu <matzipan@gmail.com>
19 */
20
21public class Scratch.Plugins.FolderManager.FileItem : Item {
22 public FileItem (Scratch.Plugins.FolderManager.File file, Scratch.Plugins.FolderManager.FileView view) requires (file.is_valid_textfile) {
23 Object (file: file, view: view);
24 }
25
26 construct {
27 selectable = true;
28 editable = true;
29 name = file.name;
30 icon = file.icon;
31 }
32
33 public override Gtk.Menu? get_context_menu () {
34 var menu = new Gtk.Menu ();
35 var rename_item = new Gtk.MenuItem.with_label (_("Rename"));
36 rename_item.activate.connect (() => view.start_editing_item (this));
37 menu.append (rename_item);
38
39 var delete_item = new Gtk.MenuItem.with_label (_("Move to Trash"));
40 delete_item.activate.connect (() => do_remove ());
41 menu.append (delete_item);
42
43 menu.show_all ();
44 return menu;
45 }
46
47 public void rename (string new_name) {
48 string new_uri = file.file.get_parent ().get_uri () + "/" + new_name;
49 file.rename (new_name);
50 }
51
52 private void do_remove () {
53 file.trash ();
54 }
55}
056
=== added file 'plugins/folder-manager/FileView.vala'
--- plugins/folder-manager/FileView.vala 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/FileView.vala 2016-11-18 21:40:10 +0000
@@ -0,0 +1,126 @@
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: Julien Spautz <spautz.julien@gmail.com>, Andrei-Costin Zisu <matzipan@gmail.com>
19 */
20
21namespace Scratch.Plugins.FolderManager {
22 Settings settings;
23
24 /**
25 * SourceList that displays folders and their contents.
26 */
27 public class FileView : Granite.Widgets.SourceList {
28 public signal void select (GLib.File file);
29 public signal void welcome_visible (bool visible);
30 public FileView () {
31 width_request = 180;
32
33 item_selected.connect ((item) => {
34 if (item is FileItem) {
35 select ((item as FileItem).file.file);
36 }
37 });
38
39 root.child_removed.connect (() => {
40 this.selected = null;
41 if (root.n_children == 0) {
42 welcome_visible (true);
43 }
44
45 write_settings ();
46 });
47
48 settings = new Settings ();
49 }
50
51 public void open_folder (File folder, bool expand = true) {
52 if (is_open (folder)) {
53 warning ("Folder '%s' is already open.", folder.path);
54 return;
55 } else if (!folder.is_valid_directory) {
56 warning ("Cannot open invalid directory.");
57 return;
58 }
59
60 var folder_item = new FolderItem (folder, this);
61 root.add (folder_item);
62 welcome_visible (false);
63
64 folder_item.expanded = expand;
65 write_settings ();
66 }
67
68 public void restore_settings () {
69 foreach (var folder_path in settings.opened_folders) {
70 if (folder_path == null) {
71 continue;
72 }
73
74 var folder = new File (folder_path);
75 if (folder.is_valid_directory) {
76 open_folder (folder);
77 }
78 }
79 }
80
81 private bool is_open (File folder) {
82 foreach (var child in root.children) {
83 if (folder.path == (child as Item).path) {
84 return true;
85 }
86 }
87
88 return false;
89 }
90
91 private void write_settings () {
92 string[] paths = {};
93 foreach (var child in this.root.children) {
94 if (child is FolderItem) {
95 paths += ((FolderItem) child).path;
96 }
97 }
98
99 settings.opened_folders = paths;
100 }
101 }
102
103 /**
104 * Common abstract class for normal and expandable items.
105 */
106 public class Item : Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
107 public File file { get; construct; }
108 public Scratch.Plugins.FolderManager.FileView view { get; construct; }
109 public string path { get { return file.path; } }
110
111 public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {
112 if (a is FolderItem && b is FileItem) {
113 return -1;
114 } else if (a is FileItem && b is FolderItem) {
115 return 1;
116 }
117
118 return File.compare ((a as Item).file, (b as Item).file);
119 }
120
121 public bool allow_dnd_sorting () {
122 return false;
123 }
124 }
125
126}
0127
=== 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
=== added file 'plugins/folder-manager/FolderItem.vala'
--- plugins/folder-manager/FolderItem.vala 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/FolderItem.vala 2016-11-18 21:40:10 +0000
@@ -0,0 +1,206 @@
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>, Andrei-Costin Zisu <matzipan@gmail.com>
19 */
20
21public class Scratch.Plugins.FolderManager.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.FolderManager.File file, Scratch.Plugins.FolderManager.FileView view) requires (file.is_valid_directory) {
28 Object (file: file, view: view);
29 }
30
31 construct {
32 selectable = true;
33 editable = true;
34 name = file.name;
35 icon = file.icon;
36
37 if (file.children.length () > 0) {
38 add (new Granite.Widgets.SourceList.Item ("")); // dummy
39 }
40
41 toggled.connect (() => {
42 if (expanded && n_children <= 1) {
43 clear ();
44 add_children ();
45 children_loaded = true;
46 }
47 });
48
49 try {
50 monitor = file.file.monitor_directory (GLib.FileMonitorFlags.NONE);
51 monitor.changed.connect ((s,d,e) => { on_changed (s,d,e); });
52 } catch (GLib.Error e) {
53 warning (e.message);
54 }
55 }
56
57 public override Gtk.Menu? get_context_menu () {
58 var menu = new Gtk.Menu ();
59 if (parent == view.root) {
60 var item = new Gtk.MenuItem.with_label (_("Close Folder"));
61 item.activate.connect (() => {
62 monitor.cancel ();
63 parent.remove (this);
64 });
65 menu.append (item);
66 } else {
67 var item = new Gtk.MenuItem.with_label (_("Open"));
68 item.activate.connect (() => folder_open (file.file));
69 menu.append (item);
70 }
71
72 var rename_item = new Gtk.MenuItem.with_label (_("Rename"));
73 rename_item.activate.connect (() => view.start_editing_item (this));
74 menu.append (rename_item);
75
76 var new_file_item = new Gtk.MenuItem.with_label (_("Add file"));
77 new_file_item.activate.connect (() => add_file ());
78 menu.append (new_file_item);
79
80 var new_folder_item = new Gtk.MenuItem.with_label (_("Add folder"));
81 new_folder_item.activate.connect(() => add_folder ());
82 menu.append (new_folder_item);
83
84 var delete_item = new Gtk.MenuItem.with_label (_("Move to Trash"));
85 delete_item.activate.connect (() => do_remove ());
86 menu.append (delete_item);
87
88 menu.show_all ();
89 return menu;
90 }
91
92 internal void add_children () {
93 foreach (var child in file.children) {
94 if (child.is_valid_directory) {
95 var item = new FolderItem (child, view);
96 item.folder_open.connect (() => {
97 view.open_folder (child);
98 });
99
100 add (item);
101 } else if (child.is_valid_textfile) {
102 var item = new FileItem (child, view);
103 add (item);
104 item.edited.connect (item.rename);
105 }
106 }
107 }
108
109 public void rename (string new_name) {
110 string new_uri = file.file.get_parent ().get_uri () + "/" + new_name;
111 file.rename (new_name);
112 }
113
114
115 private void on_changed (GLib.File source, GLib.File? dest, GLib.FileMonitorEvent event) {
116 if (!children_loaded) {
117 file.reset_cache ();
118 return;
119 }
120
121 switch (event) {
122 case GLib.FileMonitorEvent.DELETED:
123 var children_tmp = new Gee.ArrayList<Granite.Widgets.SourceList.Item> ();
124 children_tmp.add_all (children);
125 foreach (var item in children_tmp) {
126 if ((item as Item).path == source.get_path ()) {
127 remove (item);
128 }
129 }
130
131 break;
132 case GLib.FileMonitorEvent.CREATED:
133 if (source.query_exists () == false) {
134 return;
135 }
136
137 var file = new File (source.get_path ());
138 var exists = false;
139 foreach (var item in children) {
140 if ((item as Item).path == file.path) {
141 exists = true;
142 }
143 }
144
145 if (!exists) {
146 if (file.is_valid_textfile) {
147 add (new FileItem (file, view));
148 } else if (file.is_valid_directory) {
149 add (new FolderItem (file, view));
150 }
151 }
152
153 break;
154 }
155 }
156
157 private void add_folder () {
158 var child = file.file.get_child (_("New Folder"));
159
160 var n = 1;
161 while (child.query_exists ()) {
162 child = file.file.get_child (_("New Folder (%d)").printf (n));
163 n++;
164 }
165
166 try {
167 child.make_directory ();
168
169 if (children_loaded) {
170 var item = new FolderItem (new File (child.get_path ()), view);
171 add (item);
172 view.start_editing_item (item);
173 }
174 } catch (Error e) {
175 warning (e.message);
176 }
177
178
179 }
180
181 private void add_file () {
182 var child = file.file.get_child (_("New File"));
183
184 var n = 1;
185 while (child.query_exists ()) {
186 child = file.file.get_child (_("New File (%d)").printf (n));
187 n++;
188 }
189
190 try {
191 child.create (FileCreateFlags.NONE);
192
193 if (children_loaded) {
194 var item = new FileItem (new File (child.get_path ()), view);
195 add (item);
196 view.start_editing_item (item);
197 }
198 } catch (Error e) {
199 warning (e.message);
200 }
201 }
202
203 private void do_remove () {
204 file.trash ();
205 }
206}
0207
=== added file 'plugins/folder-manager/FolderManagerPlugin.vala'
--- plugins/folder-manager/FolderManagerPlugin.vala 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/FolderManagerPlugin.vala 2016-11-18 21:40:10 +0000
@@ -0,0 +1,116 @@
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 public Scratch.Services.Interface plugins;
27 Gtk.Button button;
28 FolderManager.FileView view;
29
30 public Object object { owned get; construct; }
31
32 public FolderManagerPlugin () {
33 message ("Starting Folder Manager Plugin");
34 }
35
36 public void activate () {
37 plugins = (Scratch.Services.Interface) object;
38 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
39 plugins.hook_toolbar.connect (on_hook_toolbar);
40 }
41
42 public void deactivate () {
43 if (view != null) {
44 view.destroy();
45 view = null;
46 }
47
48 if (button != null) {
49 button.destroy();
50 button = null;
51 }
52 }
53
54 public void update_state () {
55
56 }
57
58 void on_hook_sidebar (Gtk.Notebook notebook) {
59 if (view != null) {
60 return;
61 }
62
63 // File View
64 view = new FolderManager.FileView ();
65 view.select.connect ((file) => plugins.open_file (file));
66 view.welcome_visible.connect ((visible) => {
67 if (visible) {
68 view.parent.remove (view);
69 } else if (view.parent == null) {
70 view.show_all ();
71 var icon = new Gtk.Image.from_icon_name ("folder-symbolic", Gtk.IconSize.MENU);
72 icon.tooltip_text = _("File Manager");
73 notebook.append_page (view , icon);
74 }
75 });
76
77 view.restore_settings ();
78 }
79
80 void on_hook_toolbar (Gtk.HeaderBar toolbar) {
81 if (button != null) {
82 return;
83 }
84
85 button = new Gtk.Button.from_icon_name ("folder-saved-search", Gtk.IconSize.LARGE_TOOLBAR);
86 button.tooltip_text = _("Open a folder");
87 button.clicked.connect (() => open_dialog ());
88 button.show_all ();
89 toolbar.pack_start (button);
90 }
91
92 private void open_dialog () {
93 Gtk.Window window = plugins.manager.window;
94 Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
95 "Select a folder.", window, Gtk.FileChooserAction.SELECT_FOLDER,
96 _("_Cancel"), Gtk.ResponseType.CANCEL,
97 _("_Open"), Gtk.ResponseType.ACCEPT);
98 chooser.select_multiple = true;
99
100 if (chooser.run () == Gtk.ResponseType.ACCEPT) {
101 chooser.get_files ().foreach ((file) => {
102 var folder = new Scratch.Plugins.FolderManager.File (file.get_path ());
103 view.open_folder (folder);
104 });
105 }
106
107 chooser.close ();
108 }
109 }
110}
111
112[ModuleInit]
113public void peas_register_types (GLib.TypeModule module) {
114 var objmodule = module as Peas.ObjectModule;
115 objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.FolderManagerPlugin));
116}
0117
=== 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
=== added file 'plugins/folder-manager/Settings.vala'
--- plugins/folder-manager/Settings.vala 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/Settings.vala 2016-11-18 21:40:10 +0000
@@ -0,0 +1,36 @@
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}
037
=== 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
=== added file 'plugins/folder-manager/folder-manager.plugin'
--- plugins/folder-manager/folder-manager.plugin 1970-01-01 00:00:00 +0000
+++ plugins/folder-manager/folder-manager.plugin 2016-11-18 21:40:10 +0000
@@ -0,0 +1,10 @@
1[Plugin]
2Module=folder-manager
3Loader=C
4IAge=2
5Name=Folder Manager
6Description=Browse files and directories
7Icon=system-file-manager
8Authors=Mario Guerriero, Julien Spautz, Corentin Noël, Andrei Zisu
9Copyright=Copyright © 2016 elementary LLC
10Website=http://launchpad.net/scratch
011
=== 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-11-18 21:40:10 +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-11-18 21:40:10 +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-11-18 21:40:10 +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")3add_schema("org.pantheon.scratch.plugins.folder-manager.gschema.xml")
4add_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
=== removed 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 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/file-manager/" id="org.pantheon.scratch.plugins.file-manager" gettext-domain="scratch">
4 <key name="opened-folder" type="s">
5 <default>''</default>
6 <summary>Opened folder.</summary>
7 <description>Opened folder that should be restored in startup.</description>
8 </key>
9 </schema>
10</schemalist>
110
=== added file 'schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml'
--- schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 1970-01-01 00:00:00 +0000
+++ schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 2016-11-18 21:40:10 +0000
@@ -0,0 +1,10 @@
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>
011
=== 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