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
1=== added directory 'build'
2=== added directory 'build/plugins'
3=== modified file 'plugins/CMakeLists.txt'
4--- plugins/CMakeLists.txt 2016-09-03 10:30:53 +0000
5+++ plugins/CMakeLists.txt 2016-11-18 21:40:10 +0000
6@@ -7,7 +7,6 @@
7
8 add_subdirectory (contractor)
9 add_subdirectory (pastebin)
10-add_subdirectory (filemanager)
11 add_subdirectory (folder-manager)
12 add_subdirectory (terminal)
13 add_subdirectory (browser-preview)
14
15=== removed directory 'plugins/filemanager'
16=== removed file 'plugins/filemanager/CMakeLists.txt'
17--- plugins/filemanager/CMakeLists.txt 2016-09-03 10:30:53 +0000
18+++ plugins/filemanager/CMakeLists.txt 1970-01-01 00:00:00 +0000
19@@ -1,29 +0,0 @@
20-add_definitions(${NORMAL_CFLAGS})
21-link_directories(${NORMAL_LINK_DIRS})
22-
23-set (PLUGIN_NAME "filemanager")
24-
25-vala_precompile(VALA_C ${PLUGIN_NAME}
26- FileManagerPlugin.vala
27- File.vala
28- Settings.vala
29- FileView.vala
30-PACKAGES
31- gtk+-3.0
32- gee-0.8
33- granite
34- scratchcore
35- libpeas-1.0
36- gtksourceview-3.0
37- ${ZEITGEIST_DEPS}
38-OPTIONS
39- ${DEFAULT_PLUGIN_OPTIONS}
40-)
41-
42-add_library(${PLUGIN_NAME} MODULE ${VALA_C})
43-add_dependencies(${PLUGIN_NAME} ${LIBNAME})
44-
45-install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
46-install(FILES ${PLUGIN_NAME}.plugin DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
47-
48-message("-- File Manager plugin will be compiled")
49
50=== removed file 'plugins/filemanager/File.vala'
51--- plugins/filemanager/File.vala 2013-07-16 15:56:38 +0000
52+++ plugins/filemanager/File.vala 1970-01-01 00:00:00 +0000
53@@ -1,207 +0,0 @@
54-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
55-/***
56- BEGIN LICENSE
57-
58- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
59- This program is free software: you can redistribute it and/or modify it
60- under the terms of the GNU Lesser General Public License version 3, as published
61- by the Free Software Foundation.
62-
63- This program is distributed in the hope that it will be useful, but
64- WITHOUT ANY WARRANTY; without even the implied warranties of
65- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
66- PURPOSE. See the GNU General Public License for more details.
67-
68- You should have received a copy of the GNU General Public License along
69- with this program. If not, see <http://www.gnu.org/licenses/>
70-
71- END LICENSE
72-***/
73-
74-namespace Scratch.Plugins.FileManager {
75-
76- /**
77- * Class for easily dealing with files.
78- */
79- internal class File : GLib.Object {
80-
81- public GLib.File file;
82- private GLib.FileInfo info;
83-
84- private enum Type {
85- VALID_FILE,
86- VALID_FOLDER,
87- UNKNOWN,
88- INVALID
89- }
90-
91- public File (string path) {
92- file = GLib.File.new_for_path (path);
93-
94- info = new FileInfo ();
95- try {
96- info = file.query_info (
97- GLib.FileAttribute.STANDARD_CONTENT_TYPE + "," +
98- GLib.FileAttribute.STANDARD_IS_BACKUP + "," +
99- GLib.FileAttribute.STANDARD_IS_HIDDEN + "," +
100- GLib.FileAttribute.STANDARD_DISPLAY_NAME + "," +
101- GLib.FileAttribute.STANDARD_TYPE,
102- FileQueryInfoFlags.NONE);
103- } catch (GLib.Error error) {
104- info = null;
105- warning (error.message);
106- }
107- }
108-
109- // returns the path the file
110- string _path = null;
111- public string path {
112- get { return _path != null ? _path : _path = file.get_path (); }
113- }
114-
115- // returns the basename of the file
116- string _name = null;
117- public string name {
118- get { return _name != null ? _name : _name = info.get_display_name (); }
119- }
120-
121- // returns the icon of the file's content type
122- GLib.Icon _icon = null;
123- public GLib.Icon icon {
124- get {
125- if (_icon != null)
126- return _icon;
127- //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
128- var content_type = info.get_content_type ();
129- return _icon = GLib.ContentType.get_icon (content_type);
130- }
131- }
132-
133- // checks if file exists
134- public bool exists {
135- get { return file.query_exists (); }
136- }
137-
138- Type _type = Type.UNKNOWN;
139- // checks if we're dealing with a non-hidden, non-backup directory
140- public bool is_valid_directory {
141- get {
142- if (_type == Type.VALID_FILE)
143- return false;
144- if (_type == Type.VALID_FOLDER)
145- return true;
146- if (_type == Type.INVALID)
147- return false;
148-
149- if (info.get_file_type () != FileType.DIRECTORY ||
150- info.get_is_hidden () || info.get_is_backup ()) {
151- return false;
152- }
153-
154- bool has_valid_children = false;
155-
156- foreach (var child in children) {
157- if (child.is_valid_textfile) {
158- _type = Type.VALID_FOLDER;
159- return has_valid_children = true;
160- }
161- }
162-
163- foreach (var child in children) {
164- if (child.is_valid_directory) {
165- has_valid_children = true;
166- _type = Type.VALID_FOLDER;
167- return has_valid_children = true;
168- }
169- }
170-
171- return false;
172- }
173- }
174-
175- // checks if we're dealing with a textfile
176- public bool is_valid_textfile {
177- get {
178- if (_type == Type.VALID_FILE)
179- return true;
180- if (_type == Type.VALID_FOLDER)
181- return false;
182- if (_type == Type.INVALID)
183- return false;
184-
185- if (info.get_file_type () == FileType.REGULAR) {
186- //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
187- var content_type = info.get_content_type ();
188- if (ContentType.is_a (content_type, "text/*") &&
189- !info.get_is_backup () &&
190- !info.get_is_hidden ()) {
191- _type = Type.VALID_FILE;
192- return true;
193- }
194- }
195-
196- return false;
197- }
198- }
199-
200- // returns a list of all children of a directory
201- GLib.List <File> _children = null;
202- public GLib.List <File> children {
203- get {
204- if (_children != null)
205- return _children;
206-
207- var parent = GLib.File.new_for_path (file.get_path ());
208- try {
209- var enumerator = parent.enumerate_children (
210- GLib.FileAttribute.STANDARD_NAME,
211- FileQueryInfoFlags.NONE
212- );
213-
214- var file_info = new FileInfo ();
215- while ((file_info = enumerator.next_file ()) != null) {
216- var child = parent.get_child (file_info.get_name ());
217- _children.append (new File (child.get_path ()));
218- }
219- } catch (GLib.Error error) {
220- warning (error.message);
221- }
222-
223- return _children;
224- }
225- }
226-
227- public void rename (string name) {
228- try {
229- file.set_display_name (name);
230- } catch (GLib.Error error) {
231- warning (error.message);
232- }
233- }
234-
235- /*public void trash () {
236- try {
237- file.trash ();
238- } catch (GLib.Error error) {
239- warning (error.message);
240- }
241- }*/
242-
243- public void reset_cache () {
244- _name = null;
245- _path = null;
246- _icon = null;
247- _children = null;
248- _type = Type.UNKNOWN;
249- }
250-
251- public static int compare (File a, File b) {
252- if (a.is_valid_directory && b.is_valid_textfile)
253- return -1;
254- if (a.is_valid_textfile && b.is_valid_directory)
255- return 1;
256- return strcmp (a.path.collate_key_for_filename (),
257- b.path.collate_key_for_filename ());
258- }
259- }
260-}
261
262=== removed file 'plugins/filemanager/FileManagerPlugin.vala'
263--- plugins/filemanager/FileManagerPlugin.vala 2016-09-03 11:50:58 +0000
264+++ plugins/filemanager/FileManagerPlugin.vala 1970-01-01 00:00:00 +0000
265@@ -1,113 +0,0 @@
266-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
267-/***
268- BEGIN LICENSE
269-
270- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
271- This program is free software: you can redistribute it and/or modify it
272- under the terms of the GNU Lesser General Public License version 3, as published
273- by the Free Software Foundation.
274-
275- This program is distributed in the hope that it will be useful, but
276- WITHOUT ANY WARRANTY; without even the implied warranties of
277- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
278- PURPOSE. See the GNU General Public License for more details.
279-
280- You should have received a copy of the GNU General Public License along
281- with this program. If not, see <http://www.gnu.org/licenses/>
282-
283- END LICENSE
284-***/
285-
286-public const string NAME = _("Folder Manager");
287-public const string DESCRIPTION = _("Basic folder manager with file browsing");
288-
289-namespace Scratch.Plugins {
290- public class FileManagerPlugin : Peas.ExtensionBase, Peas.Activatable {
291- public Scratch.Services.Interface plugins;
292-
293- Gtk.Box box;
294- FileManager.FileView view;
295-
296- public Object object { owned get; construct; }
297-
298- public FileManagerPlugin () {
299- message ("Starting File Manager Plugin");
300- }
301-
302- public void activate () {
303- plugins = (Scratch.Services.Interface) object;
304- plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
305- }
306-
307- public void deactivate () {
308- if (box != null)
309- box.destroy();
310- }
311-
312- public void update_state () {
313-
314- }
315-
316- void on_hook_sidebar (Gtk.Notebook notebook) {
317- if (view != null)
318- return;
319-
320- box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
321-
322- // File View
323- view = new FileManager.FileView ();
324-
325- view.select.connect ((a) => {
326- var file = GLib.File.new_for_path (a);
327- plugins.open_file (file);
328- });
329-
330- // Toolbar
331- var toolbar = new Gtk.Toolbar ();
332- toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);
333- toolbar.get_style_context ().add_class ("inline-toolbar");
334-
335- var parent = new Gtk.ToolButton (null, null);
336- parent.tooltip_text = _("Go to parent");
337- parent.icon_name = "go-up-symbolic";
338- parent.clicked.connect (() => {
339- view.open_parent ();
340- parent.sensitive = !(view.folder.file.file.get_path () == "/");
341- });
342-
343- var spacer = new Gtk.ToolItem ();
344- spacer.set_expand (true);
345-
346- var add = new Gtk.ToolButton (null, null);
347- add.tooltip_text = _("Add file");
348- add.icon_name = "list-add-symbolic";
349- add.clicked.connect (() => {
350- view.add_file ();
351- });
352-
353- var remove = new Gtk.ToolButton (null, null);
354- remove.tooltip_text = _("Remove file");
355- remove.icon_name = "edit-delete-symbolic";
356- remove.clicked.connect (() => {
357- view.remove_file ();
358- });
359-
360- toolbar.insert (parent, -1);
361- toolbar.insert (spacer, -1);
362- toolbar.insert (add, -1);
363- toolbar.insert (remove, -1);
364-
365- box.pack_start (view, true, true, 0);
366- box.pack_start (toolbar, false, false, 0);
367- box.show_all ();
368-
369- notebook.append_page (box, new Gtk.Label (_("File Manager")));
370- }
371- }
372-}
373-
374-[ModuleInit]
375-public void peas_register_types (GLib.TypeModule module) {
376- var objmodule = module as Peas.ObjectModule;
377- objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.FileManagerPlugin));
378-}
379
380=== removed file 'plugins/filemanager/FileView.vala'
381--- plugins/filemanager/FileView.vala 2016-09-03 11:50:58 +0000
382+++ plugins/filemanager/FileView.vala 1970-01-01 00:00:00 +0000
383@@ -1,297 +0,0 @@
384-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
385-/***
386- BEGIN LICENSE
387-
388- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
389- This program is free software: you can redistribute it and/or modify it
390- under the terms of the GNU Lesser General Public License version 3, as published
391- by the Free Software Foundation.
392-
393- This program is distributed in the hope that it will be useful, but
394- WITHOUT ANY WARRANTY; without even the implied warranties of
395- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
396- PURPOSE. See the GNU General Public License for more details.
397-
398- You should have received a copy of the GNU General Public License along
399- with this program. If not, see <http://www.gnu.org/licenses/>
400-
401- END LICENSE
402-***/
403-
404-namespace Scratch.Plugins.FileManager {
405- Settings settings;
406-
407- /**
408- * SourceList that displays folders and their contents.
409- */
410- internal class FileView : Granite.Widgets.SourceList {
411- public FolderItem? folder = null;
412- public signal void select (string file);
413- public FileView () {
414- this.width_request = 180;
415-
416- this.item_selected.connect ((item) => {
417- select ((item as FileItem).path);
418- });
419-
420- this.root.child_removed.connect (() => {
421- this.selected = null;
422- });
423-
424- settings = new Settings ();
425- restore_settings ();
426- }
427-
428- public void open_parent () {
429- GLib.File parent = this.folder.file.file.get_parent ();
430- this.root.remove (this.folder);
431- open_folder (new File (parent.get_path ()));
432- }
433-
434- public void open_folder (File folder, bool expand = true) {
435- if (is_open (folder)) {
436- warning ("Folder '%s' is already open.", folder.path);
437- return;
438- } else if (!folder.is_valid_directory) {
439- warning ("Cannot open invalid directory.");
440- return;
441- }
442-
443- // Clean the SourceList before start adding something
444- if (this.folder != null) {
445- this.root.remove (this.folder);
446- }
447-
448- this.folder = new FolderItem (folder, this);
449- this.root.add (this.folder);
450-
451- this.folder.expanded = expand;
452- write_settings ();
453- }
454-
455- public void add_file () {
456- string path = folder.file.file.get_path () + _("/New File");
457- var file = GLib.File.new_for_path (path);
458- int n = 1;
459- while (file.query_exists ()) {
460- file = GLib.File.new_for_path (path + n.to_string ());
461- n++;
462- }
463-
464- try {
465- file.create (FileCreateFlags.NONE);
466- } catch (Error e) {
467- warning (e.message);
468- }
469-
470- var item = new FileItem (new File (file.get_path ()));
471- this.folder.add (item);
472- }
473-
474- public void remove_file () {
475- if (this.selected is FileItem) {
476- var file = GLib.File.new_for_path (((FileItem)selected).file.file.get_path ());
477- try {
478- file.delete ();
479- this.root.remove (selected);
480- } catch (Error e) {
481- warning (e.message);
482- }
483- }
484-
485- this.selected = null;
486- }
487-
488- private bool is_open (File folder) {
489- foreach (var child in root.children) {
490- if (folder.path == (child as Item).path) {
491- return true;
492- }
493- }
494-
495- return false;
496- }
497-
498- private void write_settings () {
499- settings.opened_folder = this.folder.file.file.get_path ();
500- }
501-
502- private void restore_settings () {
503- var folder = new File (settings.opened_folder);
504- if (settings.opened_folder == "" || settings.opened_folder == null || !folder.is_valid_directory) {
505- settings.opened_folder = GLib.Environment.get_home_dir ();
506- }
507-
508- open_folder (new File (settings.opened_folder));
509- }
510- }
511-
512- /**
513- * Common abstract class for normal and expandable items.
514- */
515- internal class Item : Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
516- public File file { get; construct; }
517- public string path { get { return file.path; } }
518-
519- public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {
520- if (a is FolderItem && b is FileItem) {
521- return -1;
522- } else if (a is FileItem && b is FolderItem) {
523- return 1;
524- }
525-
526- return File.compare ((a as Item).file, (b as Item).file);
527- }
528-
529- public bool allow_dnd_sorting () {
530- return false;
531- }
532- }
533-
534- /**
535- * Normal item in the source list, represents a textfile.
536- * TODO Remove, Rename
537- */
538- internal class FileItem : Item {
539- //Gtk.Menu menu;
540- //Gtk.MenuItem item_trash;
541- public FileItem (File file) requires (file.is_valid_textfile) {
542- Object (file: file);
543-
544- this.selectable = true;
545- this.editable = true;
546- this.name = file.name;
547- this.icon = file.icon;
548- }
549-
550- public void rename (string new_name) {
551- string new_uri = file.file.get_parent ().get_uri () + "/" + new_name;
552- debug (new_uri);
553- file.rename (new_name);
554- }
555-
556- /*public override Gtk.Menu? get_context_menu () {
557- menu = new Gtk.Menu ();
558- item_trash = new Gtk.MenuItem.with_label (_("Move to Trash"));
559- menu.append (item_trash);
560- item_trash.activate.connect (() => { file.trash (); });
561- menu.show_all ();
562- return menu;
563- }*/
564- }
565-
566- /**
567- * Expandable item in the source list, represents a folder.
568- * Monitored for changes inside the directory.
569- * TODO remove, rename, create new file
570- */
571- internal class FolderItem : Item {
572- public signal void folder_open (GLib.File folder);
573- public FileView view { get; construct; }
574-
575- private GLib.FileMonitor monitor;
576- private bool children_loaded = false;
577-
578- //Gtk.Menu menu;
579- //Gtk.MenuItem item_trash;
580- //Gtk.MenuItem item_create;
581-
582- public FolderItem (File file, FileView view) requires (file.is_valid_directory) {
583- Object (file: file, view: view);
584-
585- this.editable = false;
586- this.selectable = false;
587- this.name = file.name;
588- this.icon = file.icon;
589-
590- this.add (new Granite.Widgets.SourceList.Item ("")); // dummy
591- this.toggled.connect (() => {
592- if (this.expanded && this.n_children <= 1) {
593- this.clear ();
594- this.add_children ();
595- children_loaded = true;
596- }
597- });
598-
599- try {
600- monitor = file.file.monitor_directory (GLib.FileMonitorFlags.NONE);
601- monitor.changed.connect ((s,d,e) => { on_changed (s,d,e); });
602- } catch (GLib.Error e) {
603- warning (e.message);
604- }
605- }
606-
607- public override Gtk.Menu? get_context_menu () {
608- if (this == this.view.root.children.to_array ()[0]) {
609- return null;
610- }
611-
612- var menu = new Gtk.Menu ();
613- var item = new Gtk.MenuItem.with_label (_("Open"));
614- item.activate.connect (() => { this.folder_open (this.file.file); });
615- menu.append (item);
616- menu.show_all ();
617- return menu;
618- }
619-
620- internal void add_children () {
621- foreach (var child in file.children) {
622- if (child.is_valid_directory) {
623- var item = new FolderItem (child, view);
624- item.folder_open.connect (() => {
625- this.view.open_folder (child);
626- });
627-
628- add (item);
629- } else if (child.is_valid_textfile) {
630- var item = new FileItem (child);
631- add (item);
632- item.edited.connect (item.rename);
633- }
634- }
635- }
636-
637- private void on_changed (GLib.File source, GLib.File? dest, GLib.FileMonitorEvent event) {
638- if (!children_loaded) {
639- this.file.reset_cache ();
640- return;
641- }
642-
643- switch (event) {
644- case GLib.FileMonitorEvent.DELETED:
645- var children_tmp = new Gee.ArrayList<Granite.Widgets.SourceList.Item> ();
646- children_tmp.add_all (children);
647- foreach (var item in children_tmp) {
648- if ((item as Item).path == source.get_path ()) {
649- remove (item);
650- }
651- }
652-
653- break;
654- case GLib.FileMonitorEvent.CREATED:
655- if (source.query_exists () == false) {
656- return;
657- }
658-
659- var file = new File (source.get_path ());
660- var exists = false;
661- foreach (var item in children) {
662- if ((item as Item).path == file.path) {
663- exists = true;
664- }
665- }
666-
667- if (!exists) {
668- if (file.is_valid_textfile) {
669- this.add (new FileItem (file));
670- } else if (file.is_valid_directory) {
671- this.add (new FolderItem (file, view));
672- }
673- }
674-
675- break;
676- }
677- }
678- }
679-
680-}
681
682=== removed file 'plugins/filemanager/Settings.vala'
683--- plugins/filemanager/Settings.vala 2013-07-16 15:56:38 +0000
684+++ plugins/filemanager/Settings.vala 1970-01-01 00:00:00 +0000
685@@ -1,36 +0,0 @@
686-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
687-/***
688- BEGIN LICENSE
689-
690- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
691- This program is free software: you can redistribute it and/or modify it
692- under the terms of the GNU Lesser General Public License version 3, as published
693- by the Free Software Foundation.
694-
695- This program is distributed in the hope that it will be useful, but
696- WITHOUT ANY WARRANTY; without even the implied warranties of
697- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
698- PURPOSE. See the GNU General Public License for more details.
699-
700- You should have received a copy of the GNU General Public License along
701- with this program. If not, see <http://www.gnu.org/licenses/>
702-
703- END LICENSE
704-***/
705-
706-namespace Scratch.Plugins.FileManager {
707-
708- /**
709- * Class for interacting with gsettings.
710- */
711- internal class Settings : Granite.Services.Settings {
712-
713- private const string SCHEMA = "org.pantheon.scratch.plugins.file-manager";
714-
715- public string opened_folder { get; set; }
716-
717- public Settings () {
718- base (SCHEMA);
719- }
720- }
721-}
722
723=== removed file 'plugins/filemanager/filemanager.plugin'
724--- plugins/filemanager/filemanager.plugin 2013-07-16 15:56:38 +0000
725+++ plugins/filemanager/filemanager.plugin 1970-01-01 00:00:00 +0000
726@@ -1,10 +0,0 @@
727-[Plugin]
728-Module=filemanager
729-Loader=C
730-IAge=2
731-Name=File Manager
732-Description=Browse files and directories
733-Icon=system-file-manager
734-Authors=Mario Guerriero
735-Copyright=Copyright © 2013 Scratch Developers
736-Website=http://launchpad.net/scratch
737
738=== added directory 'plugins/folder-manager'
739=== removed directory 'plugins/folder-manager'
740=== added file 'plugins/folder-manager/CMakeLists.txt'
741--- plugins/folder-manager/CMakeLists.txt 1970-01-01 00:00:00 +0000
742+++ plugins/folder-manager/CMakeLists.txt 2016-11-18 21:40:10 +0000
743@@ -0,0 +1,31 @@
744+add_definitions(${NORMAL_CFLAGS})
745+link_directories(${NORMAL_LINK_DIRS})
746+
747+set (PLUGIN_NAME "folder-manager")
748+
749+vala_precompile(VALA_C ${PLUGIN_NAME}
750+ FolderManagerPlugin.vala
751+ File.vala
752+ Settings.vala
753+ FileView.vala
754+ FileItem.vala
755+ FolderItem.vala
756+PACKAGES
757+ gtk+-3.0
758+ gee-0.8
759+ granite
760+ scratchcore
761+ libpeas-1.0
762+ gtksourceview-3.0
763+ ${ZEITGEIST_DEPS}
764+OPTIONS
765+ ${DEFAULT_PLUGIN_OPTIONS}
766+)
767+
768+add_library(${PLUGIN_NAME} MODULE ${VALA_C})
769+add_dependencies(${PLUGIN_NAME} ${LIBNAME})
770+
771+install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
772+install(FILES ${PLUGIN_NAME}.plugin DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
773+
774+message("-- Folder Manager plugin will be compiled")
775
776=== removed file 'plugins/folder-manager/CMakeLists.txt'
777--- plugins/folder-manager/CMakeLists.txt 2016-09-03 10:30:53 +0000
778+++ plugins/folder-manager/CMakeLists.txt 1970-01-01 00:00:00 +0000
779@@ -1,29 +0,0 @@
780-add_definitions(${NORMAL_CFLAGS})
781-link_directories(${NORMAL_LINK_DIRS})
782-
783-set (PLUGIN_NAME "folder-manager")
784-
785-vala_precompile(VALA_C ${PLUGIN_NAME}
786- FolderManagerPlugin.vala
787- File.vala
788- Settings.vala
789- FileView.vala
790-PACKAGES
791- gtk+-3.0
792- gee-0.8
793- granite
794- scratchcore
795- libpeas-1.0
796- gtksourceview-3.0
797- ${ZEITGEIST_DEPS}
798-OPTIONS
799- ${DEFAULT_PLUGIN_OPTIONS}
800-)
801-
802-add_library(${PLUGIN_NAME} MODULE ${VALA_C})
803-add_dependencies(${PLUGIN_NAME} ${LIBNAME})
804-
805-install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
806-install(FILES ${PLUGIN_NAME}.plugin DESTINATION ${PLUGINDIR}/${PLUGIN_NAME})
807-
808-message("-- Folder Manager plugin will be compiled")
809
810=== added file 'plugins/folder-manager/File.vala'
811--- plugins/folder-manager/File.vala 1970-01-01 00:00:00 +0000
812+++ plugins/folder-manager/File.vala 2016-11-18 21:40:10 +0000
813@@ -0,0 +1,209 @@
814+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
815+/*-
816+ * Copyright (c) 2016 elementary LLC. (https://elementary.io)
817+ *
818+ * This program is free software: you can redistribute it and/or modify
819+ * it under the terms of the GNU General Public License as published by
820+ * the Free Software Foundation, either version 3 of the License, or
821+ * (at your option) any later version.
822+ *
823+ * This program is distributed in the hope that it will be useful,
824+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
825+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
826+ * GNU General Public License for more details.
827+ *
828+ * You should have received a copy of the GNU General Public License
829+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
830+ *
831+ * Authored by: Julien Spautz <spautz.julien@gmail.com>, Andrei-Costin Zisu <matzipan@gmail.com>
832+ */
833+
834+namespace Scratch.Plugins.FolderManager {
835+
836+ /**
837+ * Class for easily dealing with files.
838+ */
839+ public class File : GLib.Object {
840+
841+ public GLib.File file;
842+ private GLib.FileInfo info;
843+
844+ private enum Type {
845+ VALID_FILE,
846+ VALID_FOLDER,
847+ UNKNOWN,
848+ INVALID
849+ }
850+
851+ public File (string path) {
852+ file = GLib.File.new_for_path (path);
853+
854+ info = new FileInfo ();
855+ try {
856+ info = file.query_info (
857+ GLib.FileAttribute.STANDARD_CONTENT_TYPE + "," +
858+ GLib.FileAttribute.STANDARD_IS_BACKUP + "," +
859+ GLib.FileAttribute.STANDARD_IS_HIDDEN + "," +
860+ GLib.FileAttribute.STANDARD_DISPLAY_NAME + "," +
861+ GLib.FileAttribute.STANDARD_TYPE,
862+ FileQueryInfoFlags.NONE);
863+ } catch (GLib.Error error) {
864+ info = null;
865+ warning (error.message);
866+ }
867+ }
868+
869+ // returns the path the file
870+ string _path = null;
871+ public string path {
872+ get { return _path != null ? _path : _path = file.get_path (); }
873+ }
874+
875+ // returns the basename of the file
876+ string _name = null;
877+ public string name {
878+ get { return _name != null ? _name : _name = info.get_display_name (); }
879+ }
880+
881+ // returns the icon of the file's content type
882+ GLib.Icon _icon = null;
883+ public GLib.Icon icon {
884+ get {
885+ if (_icon != null) {
886+ return _icon;
887+ }
888+
889+ //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
890+ var content_type = info.get_content_type ();
891+ return _icon = GLib.ContentType.get_icon (content_type);
892+ }
893+ }
894+
895+ // checks if file exists
896+ public bool exists {
897+ get { return file.query_exists (); }
898+ }
899+
900+ Type _type = Type.UNKNOWN;
901+ // checks if we're dealing with a non-hidden, non-backup directory
902+ public bool is_valid_directory {
903+ get {
904+ if (_type == Type.VALID_FILE) {
905+ return false;
906+ }
907+
908+ if (_type == Type.VALID_FOLDER) {
909+ return true;
910+ }
911+
912+ if (_type == Type.INVALID) {
913+ return false;
914+ }
915+
916+ if (info.get_is_hidden () || info.get_is_backup ()) {
917+ return false;
918+ }
919+
920+ if (info.get_file_type () == FileType.DIRECTORY) {
921+ return true;
922+ }
923+
924+ return false;
925+ }
926+ }
927+
928+ // checks if we're dealing with a textfile
929+ public bool is_valid_textfile {
930+ get {
931+ if (_type == Type.VALID_FILE) {
932+ return true;
933+ }
934+
935+ if (_type == Type.VALID_FOLDER) {
936+ return false;
937+ }
938+
939+ if (_type == Type.INVALID) {
940+ return false;
941+ }
942+
943+ if (info.get_file_type () == FileType.REGULAR) {
944+ var content_type = info.get_content_type ();
945+ if (ContentType.is_a (content_type, "text/*") &&
946+ !info.get_is_backup () &&
947+ !info.get_is_hidden ()) {
948+ _type = Type.VALID_FILE;
949+ return true;
950+ }
951+ }
952+
953+ return false;
954+ }
955+ }
956+
957+ // returns a list of all children of a directory
958+ GLib.List <File> _children = null;
959+ public GLib.List <File> children {
960+ get {
961+ if (_children != null) {
962+ return _children;
963+ }
964+
965+ var parent = GLib.File.new_for_path (file.get_path ());
966+ try {
967+ var enumerator = parent.enumerate_children (
968+ GLib.FileAttribute.STANDARD_NAME,
969+ FileQueryInfoFlags.NONE
970+ );
971+
972+ var file_info = new FileInfo ();
973+ while ((file_info = enumerator.next_file ()) != null) {
974+ var child = parent.get_child (file_info.get_name ());
975+ _children.append (new File (child.get_path ()));
976+ }
977+ } catch (GLib.Error error) {
978+ warning (error.message);
979+ }
980+
981+ return _children;
982+ }
983+ }
984+
985+ public void rename (string name) {
986+ try {
987+ file.set_display_name (name);
988+ } catch (GLib.Error error) {
989+ warning (error.message);
990+ }
991+ }
992+
993+ public void trash () {
994+ try {
995+ file.trash ();
996+ } catch (GLib.Error error) {
997+ warning (error.message);
998+ }
999+ }
1000+
1001+ public void reset_cache () {
1002+ _name = null;
1003+ _path = null;
1004+ _icon = null;
1005+ _children = null;
1006+ _type = Type.UNKNOWN;
1007+ }
1008+
1009+ public static int compare (File a, File b) {
1010+ if (a.is_valid_directory && b.is_valid_textfile) {
1011+ return -1;
1012+ }
1013+
1014+ if (a.is_valid_textfile && b.is_valid_directory) {
1015+ return 1;
1016+ }
1017+
1018+ return strcmp (a.path.collate_key_for_filename (),
1019+ b.path.collate_key_for_filename ());
1020+ }
1021+ }
1022+}
1023
1024=== removed file 'plugins/folder-manager/File.vala'
1025--- plugins/folder-manager/File.vala 2013-06-02 13:07:08 +0000
1026+++ plugins/folder-manager/File.vala 1970-01-01 00:00:00 +0000
1027@@ -1,207 +0,0 @@
1028-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
1029-/***
1030- BEGIN LICENSE
1031-
1032- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
1033- This program is free software: you can redistribute it and/or modify it
1034- under the terms of the GNU Lesser General Public License version 3, as published
1035- by the Free Software Foundation.
1036-
1037- This program is distributed in the hope that it will be useful, but
1038- WITHOUT ANY WARRANTY; without even the implied warranties of
1039- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1040- PURPOSE. See the GNU General Public License for more details.
1041-
1042- You should have received a copy of the GNU General Public License along
1043- with this program. If not, see <http://www.gnu.org/licenses/>
1044-
1045- END LICENSE
1046-***/
1047-
1048-namespace Scratch.Plugins.FolderManager {
1049-
1050- /**
1051- * Class for easily dealing with files.
1052- */
1053- internal class File : GLib.Object {
1054-
1055- public GLib.File file;
1056- private GLib.FileInfo info;
1057-
1058- private enum Type {
1059- VALID_FILE,
1060- VALID_FOLDER,
1061- UNKNOWN,
1062- INVALID
1063- }
1064-
1065- public File (string path) {
1066- file = GLib.File.new_for_path (path);
1067-
1068- info = new FileInfo ();
1069- try {
1070- info = file.query_info (
1071- GLib.FileAttribute.STANDARD_CONTENT_TYPE + "," +
1072- GLib.FileAttribute.STANDARD_IS_BACKUP + "," +
1073- GLib.FileAttribute.STANDARD_IS_HIDDEN + "," +
1074- GLib.FileAttribute.STANDARD_DISPLAY_NAME + "," +
1075- GLib.FileAttribute.STANDARD_TYPE,
1076- FileQueryInfoFlags.NONE);
1077- } catch (GLib.Error error) {
1078- info = null;
1079- warning (error.message);
1080- }
1081- }
1082-
1083- // returns the path the file
1084- string _path = null;
1085- public string path {
1086- get { return _path != null ? _path : _path = file.get_path (); }
1087- }
1088-
1089- // returns the basename of the file
1090- string _name = null;
1091- public string name {
1092- get { return _name != null ? _name : _name = info.get_display_name (); }
1093- }
1094-
1095- // returns the icon of the file's content type
1096- GLib.Icon _icon = null;
1097- public GLib.Icon icon {
1098- get {
1099- if (_icon != null)
1100- return _icon;
1101- //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
1102- var content_type = info.get_content_type ();
1103- return _icon = GLib.ContentType.get_icon (content_type);
1104- }
1105- }
1106-
1107- // checks if file exists
1108- public bool exists {
1109- get { return file.query_exists (); }
1110- }
1111-
1112- Type _type = Type.UNKNOWN;
1113- // checks if we're dealing with a non-hidden, non-backup directory
1114- public bool is_valid_directory {
1115- get {
1116- if (_type == Type.VALID_FILE)
1117- return false;
1118- if (_type == Type.VALID_FOLDER)
1119- return true;
1120- if (_type == Type.INVALID)
1121- return false;
1122-
1123- if (info.get_file_type () != FileType.DIRECTORY ||
1124- info.get_is_hidden () || info.get_is_backup ()) {
1125- return false;
1126- }
1127-
1128- bool has_valid_children = false;
1129-
1130- foreach (var child in children) {
1131- if (child.is_valid_textfile) {
1132- _type = Type.VALID_FOLDER;
1133- return has_valid_children = true;
1134- }
1135- }
1136-
1137- foreach (var child in children) {
1138- if (child.is_valid_directory) {
1139- has_valid_children = true;
1140- _type = Type.VALID_FOLDER;
1141- return has_valid_children = true;
1142- }
1143- }
1144-
1145- return false;
1146- }
1147- }
1148-
1149- // checks if we're dealing with a textfile
1150- public bool is_valid_textfile {
1151- get {
1152- if (_type == Type.VALID_FILE)
1153- return true;
1154- if (_type == Type.VALID_FOLDER)
1155- return false;
1156- if (_type == Type.INVALID)
1157- return false;
1158-
1159- if (info.get_file_type () == FileType.REGULAR) {
1160- //var content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE);
1161- var content_type = info.get_content_type ();
1162- if (ContentType.is_a (content_type, "text/*") &&
1163- !info.get_is_backup () &&
1164- !info.get_is_hidden ()) {
1165- _type = Type.VALID_FILE;
1166- return true;
1167- }
1168- }
1169-
1170- return false;
1171- }
1172- }
1173-
1174- // returns a list of all children of a directory
1175- GLib.List <File> _children = null;
1176- public GLib.List <File> children {
1177- get {
1178- if (_children != null)
1179- return _children;
1180-
1181- var parent = GLib.File.new_for_path (file.get_path ());
1182- try {
1183- var enumerator = parent.enumerate_children (
1184- GLib.FileAttribute.STANDARD_NAME,
1185- FileQueryInfoFlags.NONE
1186- );
1187-
1188- var file_info = new FileInfo ();
1189- while ((file_info = enumerator.next_file ()) != null) {
1190- var child = parent.get_child (file_info.get_name ());
1191- _children.append (new File (child.get_path ()));
1192- }
1193- } catch (GLib.Error error) {
1194- warning (error.message);
1195- }
1196-
1197- return _children;
1198- }
1199- }
1200-
1201- /*public void rename (string name) {
1202- try {
1203- file.set_display_name (name);
1204- } catch (GLib.Error error) {
1205- warning (error.message);
1206- }
1207- }
1208-
1209- public void trash () {
1210- try {
1211- file.trash ();
1212- } catch (GLib.Error error) {
1213- warning (error.message);
1214- }
1215- }*/
1216-
1217- public void reset_cache () {
1218- _name = null;
1219- _path = null;
1220- _icon = null;
1221- _children = null;
1222- _type = Type.UNKNOWN;
1223- }
1224-
1225- public static int compare (File a, File b) {
1226- if (a.is_valid_directory && b.is_valid_textfile)
1227- return -1;
1228- if (a.is_valid_textfile && b.is_valid_directory)
1229- return 1;
1230- return strcmp (a.path.collate_key_for_filename (),
1231- b.path.collate_key_for_filename ());
1232- }
1233- }
1234-}
1235
1236=== added file 'plugins/folder-manager/FileItem.vala'
1237--- plugins/folder-manager/FileItem.vala 1970-01-01 00:00:00 +0000
1238+++ plugins/folder-manager/FileItem.vala 2016-11-18 21:40:10 +0000
1239@@ -0,0 +1,55 @@
1240+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
1241+/*-
1242+ * Copyright (c) 2016 elementary LLC. (https://elementary.io)
1243+ *
1244+ * This program is free software: you can redistribute it and/or modify
1245+ * it under the terms of the GNU General Public License as published by
1246+ * the Free Software Foundation, either version 3 of the License, or
1247+ * (at your option) any later version.
1248+ *
1249+ * This program is distributed in the hope that it will be useful,
1250+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1251+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1252+ * GNU General Public License for more details.
1253+ *
1254+ * You should have received a copy of the GNU General Public License
1255+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1256+ *
1257+ * Authored by: Corentin Noël <corentin@elementary.io>, Andrei-Costin Zisu <matzipan@gmail.com>
1258+ */
1259+
1260+public class Scratch.Plugins.FolderManager.FileItem : Item {
1261+ public FileItem (Scratch.Plugins.FolderManager.File file, Scratch.Plugins.FolderManager.FileView view) requires (file.is_valid_textfile) {
1262+ Object (file: file, view: view);
1263+ }
1264+
1265+ construct {
1266+ selectable = true;
1267+ editable = true;
1268+ name = file.name;
1269+ icon = file.icon;
1270+ }
1271+
1272+ public override Gtk.Menu? get_context_menu () {
1273+ var menu = new Gtk.Menu ();
1274+ var rename_item = new Gtk.MenuItem.with_label (_("Rename"));
1275+ rename_item.activate.connect (() => view.start_editing_item (this));
1276+ menu.append (rename_item);
1277+
1278+ var delete_item = new Gtk.MenuItem.with_label (_("Move to Trash"));
1279+ delete_item.activate.connect (() => do_remove ());
1280+ menu.append (delete_item);
1281+
1282+ menu.show_all ();
1283+ return menu;
1284+ }
1285+
1286+ public void rename (string new_name) {
1287+ string new_uri = file.file.get_parent ().get_uri () + "/" + new_name;
1288+ file.rename (new_name);
1289+ }
1290+
1291+ private void do_remove () {
1292+ file.trash ();
1293+ }
1294+}
1295
1296=== added file 'plugins/folder-manager/FileView.vala'
1297--- plugins/folder-manager/FileView.vala 1970-01-01 00:00:00 +0000
1298+++ plugins/folder-manager/FileView.vala 2016-11-18 21:40:10 +0000
1299@@ -0,0 +1,126 @@
1300+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
1301+/*-
1302+ * Copyright (c) 2016 elementary LLC. (https://elementary.io)
1303+ *
1304+ * This program is free software: you can redistribute it and/or modify
1305+ * it under the terms of the GNU General Public License as published by
1306+ * the Free Software Foundation, either version 3 of the License, or
1307+ * (at your option) any later version.
1308+ *
1309+ * This program is distributed in the hope that it will be useful,
1310+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1311+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1312+ * GNU General Public License for more details.
1313+ *
1314+ * You should have received a copy of the GNU General Public License
1315+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1316+ *
1317+ * Authored by: Julien Spautz <spautz.julien@gmail.com>, Andrei-Costin Zisu <matzipan@gmail.com>
1318+ */
1319+
1320+namespace Scratch.Plugins.FolderManager {
1321+ Settings settings;
1322+
1323+ /**
1324+ * SourceList that displays folders and their contents.
1325+ */
1326+ public class FileView : Granite.Widgets.SourceList {
1327+ public signal void select (GLib.File file);
1328+ public signal void welcome_visible (bool visible);
1329+ public FileView () {
1330+ width_request = 180;
1331+
1332+ item_selected.connect ((item) => {
1333+ if (item is FileItem) {
1334+ select ((item as FileItem).file.file);
1335+ }
1336+ });
1337+
1338+ root.child_removed.connect (() => {
1339+ this.selected = null;
1340+ if (root.n_children == 0) {
1341+ welcome_visible (true);
1342+ }
1343+
1344+ write_settings ();
1345+ });
1346+
1347+ settings = new Settings ();
1348+ }
1349+
1350+ public void open_folder (File folder, bool expand = true) {
1351+ if (is_open (folder)) {
1352+ warning ("Folder '%s' is already open.", folder.path);
1353+ return;
1354+ } else if (!folder.is_valid_directory) {
1355+ warning ("Cannot open invalid directory.");
1356+ return;
1357+ }
1358+
1359+ var folder_item = new FolderItem (folder, this);
1360+ root.add (folder_item);
1361+ welcome_visible (false);
1362+
1363+ folder_item.expanded = expand;
1364+ write_settings ();
1365+ }
1366+
1367+ public void restore_settings () {
1368+ foreach (var folder_path in settings.opened_folders) {
1369+ if (folder_path == null) {
1370+ continue;
1371+ }
1372+
1373+ var folder = new File (folder_path);
1374+ if (folder.is_valid_directory) {
1375+ open_folder (folder);
1376+ }
1377+ }
1378+ }
1379+
1380+ private bool is_open (File folder) {
1381+ foreach (var child in root.children) {
1382+ if (folder.path == (child as Item).path) {
1383+ return true;
1384+ }
1385+ }
1386+
1387+ return false;
1388+ }
1389+
1390+ private void write_settings () {
1391+ string[] paths = {};
1392+ foreach (var child in this.root.children) {
1393+ if (child is FolderItem) {
1394+ paths += ((FolderItem) child).path;
1395+ }
1396+ }
1397+
1398+ settings.opened_folders = paths;
1399+ }
1400+ }
1401+
1402+ /**
1403+ * Common abstract class for normal and expandable items.
1404+ */
1405+ public class Item : Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
1406+ public File file { get; construct; }
1407+ public Scratch.Plugins.FolderManager.FileView view { get; construct; }
1408+ public string path { get { return file.path; } }
1409+
1410+ public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {
1411+ if (a is FolderItem && b is FileItem) {
1412+ return -1;
1413+ } else if (a is FileItem && b is FolderItem) {
1414+ return 1;
1415+ }
1416+
1417+ return File.compare ((a as Item).file, (b as Item).file);
1418+ }
1419+
1420+ public bool allow_dnd_sorting () {
1421+ return false;
1422+ }
1423+ }
1424+
1425+}
1426
1427=== removed file 'plugins/folder-manager/FileView.vala'
1428--- plugins/folder-manager/FileView.vala 2015-09-16 01:11:55 +0000
1429+++ plugins/folder-manager/FileView.vala 1970-01-01 00:00:00 +0000
1430@@ -1,312 +0,0 @@
1431-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
1432-/***
1433- BEGIN LICENSE
1434-
1435- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
1436- This program is free software: you can redistribute it and/or modify it
1437- under the terms of the GNU Lesser General Public License version 3, as published
1438- by the Free Software Foundation.
1439-
1440- This program is distributed in the hope that it will be useful, but
1441- WITHOUT ANY WARRANTY; without even the implied warranties of
1442- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1443- PURPOSE. See the GNU General Public License for more details.
1444-
1445- You should have received a copy of the GNU General Public License along
1446- with this program. If not, see <http://www.gnu.org/licenses/>
1447-
1448- END LICENSE
1449-***/
1450-
1451-namespace Scratch.Plugins.FolderManager {
1452- Settings settings;
1453-
1454- /**
1455- * SourceList that displays folders and their contents.
1456- */
1457- internal class FileView : Granite.Widgets.SourceList {
1458-
1459- public signal void select (string file);
1460-
1461- public FileView () {
1462- this.width_request = 180;
1463- this.item_selected.connect ((item) => {
1464- select ((item as FileItem).path);
1465- });
1466-
1467- settings = new Settings ();
1468- }
1469-
1470- public void restore_saved_state () {
1471- foreach (var path in settings.opened_folders)
1472- add_folder (new File (path), false);
1473- }
1474-
1475- public void open_folder (File folder) {
1476- if (is_open (folder)) {
1477- warning ("Folder '%s' is already open.", folder.path);
1478- return;
1479- } else if (!folder.is_valid_directory) {
1480- warning ("Cannot open invalid directory.");
1481- return;
1482- }
1483-
1484- add_folder (folder, true);
1485- write_settings ();
1486- }
1487-
1488- private void add_folder (File folder, bool expand) {
1489- if (is_open (folder)) {
1490- warning ("Folder '%s' is already open.", folder.path);
1491- return;
1492- } else if (!folder.is_valid_directory) {
1493- warning ("Cannot open invalid directory.");
1494- return;
1495- }
1496-
1497- var folder_root = new MainFolderItem (folder);
1498- this.root.add (folder_root);
1499-
1500- folder_root.expanded = expand;
1501- folder_root.closed.connect (() => {
1502- root.remove (folder_root);
1503- write_settings ();
1504- });
1505- }
1506-
1507- private bool is_open (File folder) {
1508- foreach (var child in root.children)
1509- if (folder.path == (child as Item).path)
1510- return true;
1511- return false;
1512- }
1513-
1514- private void write_settings () {
1515- string[] to_save = {};
1516-
1517- foreach (var main_folder in root.children) {
1518- var saved = false;
1519-
1520- foreach (var saved_folder in to_save) {
1521- if ((main_folder as Item).path == saved_folder) {
1522- saved = true;
1523- break;
1524- }
1525- }
1526-
1527- if (!saved) {
1528- to_save += (main_folder as Item).path;
1529- }
1530- }
1531-
1532- settings.opened_folders = to_save;
1533- }
1534- }
1535-
1536- /**
1537- * Common abstract class for file and filder items.
1538- */
1539- internal class Item: Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
1540- public File file { get; construct; }
1541- public string path { get { return file.path; } }
1542-
1543- public int compare (Granite.Widgets.SourceList.Item a, Granite.Widgets.SourceList.Item b) {
1544- if (a is FolderItem && b is FileItem) {
1545- return -1;
1546- } else if (a is FileItem && b is FolderItem) {
1547- return 1;
1548- }
1549-
1550- return File.compare ((a as Item).file, (b as Item).file);
1551- }
1552-
1553- public bool allow_dnd_sorting () {
1554- return false;
1555- }
1556- }
1557-
1558- /**
1559- * Normal item in the source list, represents a textfile.
1560- * TODO Remove, Rename
1561- */
1562- internal class FileItem : Item {
1563-
1564- //Gtk.Menu menu;
1565- //Gtk.MenuItem item_trash;
1566-
1567- public FileItem (File file) requires (file.is_valid_textfile) {
1568- Object (file: file);
1569-
1570- this.selectable = true;
1571- //this.editable = true;
1572- this.name = file.name;
1573- this.icon = file.icon;
1574- }
1575-
1576- /*public void rename (string new_name) {
1577- file.rename (new_name);
1578- }*/
1579-
1580- /*public override Gtk.Menu? get_context_menu () {
1581- menu = new Gtk.Menu ();
1582- item_trash = new Gtk.MenuItem.with_label (_("Move to Trash"));
1583- menu.append (item_trash);
1584- item_trash.activate.connect (() => { file.trash (); });
1585- menu.show_all ();
1586- return menu;
1587- }*/
1588- }
1589-
1590- /**
1591- * Expandable item in the source list, represents a folder.
1592- * Monitored for changes inside the directory.
1593- * TODO remove, rename, create new file
1594- */
1595- internal class FolderItem : Item {
1596-
1597- //Gtk.Menu menu;
1598- //Gtk.MenuItem item_trash;
1599- //Gtk.MenuItem item_create;
1600-
1601- private GLib.FileMonitor monitor;
1602- private bool children_loaded = false;
1603-
1604- public FolderItem (File file) requires (file.is_valid_directory) {
1605- Object (file: file);
1606-
1607- this.editable = false;
1608- this.selectable = false;
1609- this.name = file.name;
1610- this.icon = file.icon;
1611-
1612- this.add (new Granite.Widgets.SourceList.Item ("")); // dummy
1613- this.toggled.connect (() => {
1614- if (this.expanded && this.n_children <= 1) {
1615- this.clear ();
1616- this.add_children ();
1617- children_loaded = true;
1618- }
1619- });
1620-
1621- try {
1622- monitor = file.file.monitor_directory (GLib.FileMonitorFlags.NONE);
1623- monitor.changed.connect ((s,d,e) => { on_changed (s,d,e); });
1624- } catch (GLib.Error e) {
1625- warning (e.message);
1626- }
1627- }
1628-
1629- /*public override Gtk.Menu? get_context_menu () {
1630- menu = new Gtk.Menu ();
1631- item_trash = new Gtk.MenuItem.with_label (_("Move to Trash"));
1632- item_create = new Gtk.MenuItem.with_label (_("Create new File"));
1633- menu.append (item_trash);
1634- menu.append (item_create);
1635- item_trash.activate.connect (() => { file.trash (); });
1636- item_create.activate.connect (() => {
1637- var new_file = GLib.File.new_for_path (file.path + "/new File");
1638-
1639- try {
1640- FileOutputStream os = new_file.create (FileCreateFlags.NONE);
1641- } catch (Error e) {
1642- warning ("Error: %s\n", e.message);
1643- }
1644- });
1645- menu.show_all ();
1646- return menu;
1647- }*/
1648-
1649- internal void add_children () {
1650- foreach (var child in file.children) {
1651- if (child.is_valid_directory) {
1652- var item = new FolderItem (child);
1653- add (item);
1654- } else if (child.is_valid_textfile) {
1655- var item = new FileItem (child);
1656- add (item);
1657- //item.edited.connect (item.rename);
1658- }
1659- }
1660- }
1661-
1662- private void on_changed (GLib.File source, GLib.File? dest, GLib.FileMonitorEvent event) {
1663-
1664- if (!children_loaded) {
1665- this.file.reset_cache ();
1666- return;
1667- }
1668-
1669- switch (event) {
1670- case GLib.FileMonitorEvent.DELETED:
1671- var children_tmp = new Gee.ArrayList<Granite.Widgets.SourceList.Item> ();
1672- children_tmp.add_all (children);
1673- foreach (var item in children_tmp) {
1674- if ((item as Item).path == source.get_path ()) {
1675- remove (item);
1676- }
1677- }
1678-
1679- break;
1680- case GLib.FileMonitorEvent.CREATED:
1681- if (source.query_exists () == false) {
1682- return;
1683- }
1684-
1685- var file = new File (source.get_path ());
1686- var exists = false;
1687- foreach (var item in children) {
1688- if ((item as Item).path == file.path) {
1689- exists = true;
1690- break;
1691- }
1692- }
1693-
1694- if (!exists) {
1695- if (file.is_valid_textfile) {
1696- this.add (new FileItem (file));
1697- } else if (file.is_valid_directory) {
1698- this.add (new FolderItem (file));
1699- }
1700- }
1701-
1702- break;
1703- }
1704- }
1705- }
1706-
1707- /**
1708- * Special root folder.
1709- * TODO rename, create new file
1710- */
1711- internal class MainFolderItem : FolderItem {
1712- public signal void closed ();
1713-
1714- Gtk.Menu menu;
1715- Gtk.MenuItem item_close;
1716- //Gtk.MenuItem item_create;
1717-
1718- public MainFolderItem (File file) requires (file.is_valid_directory) {
1719- base (file);
1720- }
1721-
1722- public override Gtk.Menu? get_context_menu () {
1723- menu = new Gtk.Menu ();
1724- item_close = new Gtk.MenuItem.with_label (_("Close Folder"));
1725- //item_create = new Gtk.MenuItem.with_label (_("Create new File"));
1726- menu.append (item_close);
1727- //menu.append (item_create);
1728- item_close.activate.connect (() => { closed (); });
1729- /*item_create.activate.connect (() => {
1730- var new_file = GLib.File.new_for_path (file.path + "/new File");
1731-
1732- try {
1733- FileOutputStream os = new_file.create (FileCreateFlags.NONE);
1734- } catch (Error e) {
1735- warning ("Error: %s\n", e.message);
1736- }
1737- });*/
1738- menu.show_all ();
1739- return menu;
1740- }
1741- }
1742-}
1743
1744=== added file 'plugins/folder-manager/FolderItem.vala'
1745--- plugins/folder-manager/FolderItem.vala 1970-01-01 00:00:00 +0000
1746+++ plugins/folder-manager/FolderItem.vala 2016-11-18 21:40:10 +0000
1747@@ -0,0 +1,206 @@
1748+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
1749+/*-
1750+ * Copyright (c) 2016 elementary LLC. (https://elementary.io)
1751+ *
1752+ * This program is free software: you can redistribute it and/or modify
1753+ * it under the terms of the GNU General Public License as published by
1754+ * the Free Software Foundation, either version 3 of the License, or
1755+ * (at your option) any later version.
1756+ *
1757+ * This program is distributed in the hope that it will be useful,
1758+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1759+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1760+ * GNU General Public License for more details.
1761+ *
1762+ * You should have received a copy of the GNU General Public License
1763+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1764+ *
1765+ * Authored by: Corentin Noël <corentin@elementary.io>, Andrei-Costin Zisu <matzipan@gmail.com>
1766+ */
1767+
1768+public class Scratch.Plugins.FolderManager.FolderItem : Item {
1769+ public signal void folder_open (GLib.File folder);
1770+
1771+ private GLib.FileMonitor monitor;
1772+ private bool children_loaded = false;
1773+
1774+ public FolderItem (Scratch.Plugins.FolderManager.File file, Scratch.Plugins.FolderManager.FileView view) requires (file.is_valid_directory) {
1775+ Object (file: file, view: view);
1776+ }
1777+
1778+ construct {
1779+ selectable = true;
1780+ editable = true;
1781+ name = file.name;
1782+ icon = file.icon;
1783+
1784+ if (file.children.length () > 0) {
1785+ add (new Granite.Widgets.SourceList.Item ("")); // dummy
1786+ }
1787+
1788+ toggled.connect (() => {
1789+ if (expanded && n_children <= 1) {
1790+ clear ();
1791+ add_children ();
1792+ children_loaded = true;
1793+ }
1794+ });
1795+
1796+ try {
1797+ monitor = file.file.monitor_directory (GLib.FileMonitorFlags.NONE);
1798+ monitor.changed.connect ((s,d,e) => { on_changed (s,d,e); });
1799+ } catch (GLib.Error e) {
1800+ warning (e.message);
1801+ }
1802+ }
1803+
1804+ public override Gtk.Menu? get_context_menu () {
1805+ var menu = new Gtk.Menu ();
1806+ if (parent == view.root) {
1807+ var item = new Gtk.MenuItem.with_label (_("Close Folder"));
1808+ item.activate.connect (() => {
1809+ monitor.cancel ();
1810+ parent.remove (this);
1811+ });
1812+ menu.append (item);
1813+ } else {
1814+ var item = new Gtk.MenuItem.with_label (_("Open"));
1815+ item.activate.connect (() => folder_open (file.file));
1816+ menu.append (item);
1817+ }
1818+
1819+ var rename_item = new Gtk.MenuItem.with_label (_("Rename"));
1820+ rename_item.activate.connect (() => view.start_editing_item (this));
1821+ menu.append (rename_item);
1822+
1823+ var new_file_item = new Gtk.MenuItem.with_label (_("Add file"));
1824+ new_file_item.activate.connect (() => add_file ());
1825+ menu.append (new_file_item);
1826+
1827+ var new_folder_item = new Gtk.MenuItem.with_label (_("Add folder"));
1828+ new_folder_item.activate.connect(() => add_folder ());
1829+ menu.append (new_folder_item);
1830+
1831+ var delete_item = new Gtk.MenuItem.with_label (_("Move to Trash"));
1832+ delete_item.activate.connect (() => do_remove ());
1833+ menu.append (delete_item);
1834+
1835+ menu.show_all ();
1836+ return menu;
1837+ }
1838+
1839+ internal void add_children () {
1840+ foreach (var child in file.children) {
1841+ if (child.is_valid_directory) {
1842+ var item = new FolderItem (child, view);
1843+ item.folder_open.connect (() => {
1844+ view.open_folder (child);
1845+ });
1846+
1847+ add (item);
1848+ } else if (child.is_valid_textfile) {
1849+ var item = new FileItem (child, view);
1850+ add (item);
1851+ item.edited.connect (item.rename);
1852+ }
1853+ }
1854+ }
1855+
1856+ public void rename (string new_name) {
1857+ string new_uri = file.file.get_parent ().get_uri () + "/" + new_name;
1858+ file.rename (new_name);
1859+ }
1860+
1861+
1862+ private void on_changed (GLib.File source, GLib.File? dest, GLib.FileMonitorEvent event) {
1863+ if (!children_loaded) {
1864+ file.reset_cache ();
1865+ return;
1866+ }
1867+
1868+ switch (event) {
1869+ case GLib.FileMonitorEvent.DELETED:
1870+ var children_tmp = new Gee.ArrayList<Granite.Widgets.SourceList.Item> ();
1871+ children_tmp.add_all (children);
1872+ foreach (var item in children_tmp) {
1873+ if ((item as Item).path == source.get_path ()) {
1874+ remove (item);
1875+ }
1876+ }
1877+
1878+ break;
1879+ case GLib.FileMonitorEvent.CREATED:
1880+ if (source.query_exists () == false) {
1881+ return;
1882+ }
1883+
1884+ var file = new File (source.get_path ());
1885+ var exists = false;
1886+ foreach (var item in children) {
1887+ if ((item as Item).path == file.path) {
1888+ exists = true;
1889+ }
1890+ }
1891+
1892+ if (!exists) {
1893+ if (file.is_valid_textfile) {
1894+ add (new FileItem (file, view));
1895+ } else if (file.is_valid_directory) {
1896+ add (new FolderItem (file, view));
1897+ }
1898+ }
1899+
1900+ break;
1901+ }
1902+ }
1903+
1904+ private void add_folder () {
1905+ var child = file.file.get_child (_("New Folder"));
1906+
1907+ var n = 1;
1908+ while (child.query_exists ()) {
1909+ child = file.file.get_child (_("New Folder (%d)").printf (n));
1910+ n++;
1911+ }
1912+
1913+ try {
1914+ child.make_directory ();
1915+
1916+ if (children_loaded) {
1917+ var item = new FolderItem (new File (child.get_path ()), view);
1918+ add (item);
1919+ view.start_editing_item (item);
1920+ }
1921+ } catch (Error e) {
1922+ warning (e.message);
1923+ }
1924+
1925+
1926+ }
1927+
1928+ private void add_file () {
1929+ var child = file.file.get_child (_("New File"));
1930+
1931+ var n = 1;
1932+ while (child.query_exists ()) {
1933+ child = file.file.get_child (_("New File (%d)").printf (n));
1934+ n++;
1935+ }
1936+
1937+ try {
1938+ child.create (FileCreateFlags.NONE);
1939+
1940+ if (children_loaded) {
1941+ var item = new FileItem (new File (child.get_path ()), view);
1942+ add (item);
1943+ view.start_editing_item (item);
1944+ }
1945+ } catch (Error e) {
1946+ warning (e.message);
1947+ }
1948+ }
1949+
1950+ private void do_remove () {
1951+ file.trash ();
1952+ }
1953+}
1954
1955=== added file 'plugins/folder-manager/FolderManagerPlugin.vala'
1956--- plugins/folder-manager/FolderManagerPlugin.vala 1970-01-01 00:00:00 +0000
1957+++ plugins/folder-manager/FolderManagerPlugin.vala 2016-11-18 21:40:10 +0000
1958@@ -0,0 +1,116 @@
1959+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
1960+/***
1961+ BEGIN LICENSE
1962+
1963+ Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
1964+ This program is free software: you can redistribute it and/or modify it
1965+ under the terms of the GNU Lesser General Public License version 3, as published
1966+ by the Free Software Foundation.
1967+
1968+ This program is distributed in the hope that it will be useful, but
1969+ WITHOUT ANY WARRANTY; without even the implied warranties of
1970+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1971+ PURPOSE. See the GNU General Public License for more details.
1972+
1973+ You should have received a copy of the GNU General Public License along
1974+ with this program. If not, see <http://www.gnu.org/licenses/>
1975+
1976+ END LICENSE
1977+***/
1978+
1979+public const string NAME = _("Folder Manager");
1980+public const string DESCRIPTION = _("Basic folder manager with file browsing");
1981+
1982+namespace Scratch.Plugins {
1983+ public class FolderManagerPlugin : Peas.ExtensionBase, Peas.Activatable {
1984+ public Scratch.Services.Interface plugins;
1985+ Gtk.Button button;
1986+ FolderManager.FileView view;
1987+
1988+ public Object object { owned get; construct; }
1989+
1990+ public FolderManagerPlugin () {
1991+ message ("Starting Folder Manager Plugin");
1992+ }
1993+
1994+ public void activate () {
1995+ plugins = (Scratch.Services.Interface) object;
1996+ plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
1997+ plugins.hook_toolbar.connect (on_hook_toolbar);
1998+ }
1999+
2000+ public void deactivate () {
2001+ if (view != null) {
2002+ view.destroy();
2003+ view = null;
2004+ }
2005+
2006+ if (button != null) {
2007+ button.destroy();
2008+ button = null;
2009+ }
2010+ }
2011+
2012+ public void update_state () {
2013+
2014+ }
2015+
2016+ void on_hook_sidebar (Gtk.Notebook notebook) {
2017+ if (view != null) {
2018+ return;
2019+ }
2020+
2021+ // File View
2022+ view = new FolderManager.FileView ();
2023+ view.select.connect ((file) => plugins.open_file (file));
2024+ view.welcome_visible.connect ((visible) => {
2025+ if (visible) {
2026+ view.parent.remove (view);
2027+ } else if (view.parent == null) {
2028+ view.show_all ();
2029+ var icon = new Gtk.Image.from_icon_name ("folder-symbolic", Gtk.IconSize.MENU);
2030+ icon.tooltip_text = _("File Manager");
2031+ notebook.append_page (view , icon);
2032+ }
2033+ });
2034+
2035+ view.restore_settings ();
2036+ }
2037+
2038+ void on_hook_toolbar (Gtk.HeaderBar toolbar) {
2039+ if (button != null) {
2040+ return;
2041+ }
2042+
2043+ button = new Gtk.Button.from_icon_name ("folder-saved-search", Gtk.IconSize.LARGE_TOOLBAR);
2044+ button.tooltip_text = _("Open a folder");
2045+ button.clicked.connect (() => open_dialog ());
2046+ button.show_all ();
2047+ toolbar.pack_start (button);
2048+ }
2049+
2050+ private void open_dialog () {
2051+ Gtk.Window window = plugins.manager.window;
2052+ Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
2053+ "Select a folder.", window, Gtk.FileChooserAction.SELECT_FOLDER,
2054+ _("_Cancel"), Gtk.ResponseType.CANCEL,
2055+ _("_Open"), Gtk.ResponseType.ACCEPT);
2056+ chooser.select_multiple = true;
2057+
2058+ if (chooser.run () == Gtk.ResponseType.ACCEPT) {
2059+ chooser.get_files ().foreach ((file) => {
2060+ var folder = new Scratch.Plugins.FolderManager.File (file.get_path ());
2061+ view.open_folder (folder);
2062+ });
2063+ }
2064+
2065+ chooser.close ();
2066+ }
2067+ }
2068+}
2069+
2070+[ModuleInit]
2071+public void peas_register_types (GLib.TypeModule module) {
2072+ var objmodule = module as Peas.ObjectModule;
2073+ objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.FolderManagerPlugin));
2074+}
2075
2076=== removed file 'plugins/folder-manager/FolderManagerPlugin.vala'
2077--- plugins/folder-manager/FolderManagerPlugin.vala 2015-12-01 11:37:53 +0000
2078+++ plugins/folder-manager/FolderManagerPlugin.vala 1970-01-01 00:00:00 +0000
2079@@ -1,122 +0,0 @@
2080-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2081-/***
2082- BEGIN LICENSE
2083-
2084- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
2085- This program is free software: you can redistribute it and/or modify it
2086- under the terms of the GNU Lesser General Public License version 3, as published
2087- by the Free Software Foundation.
2088-
2089- This program is distributed in the hope that it will be useful, but
2090- WITHOUT ANY WARRANTY; without even the implied warranties of
2091- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2092- PURPOSE. See the GNU General Public License for more details.
2093-
2094- You should have received a copy of the GNU General Public License along
2095- with this program. If not, see <http://www.gnu.org/licenses/>
2096-
2097- END LICENSE
2098-***/
2099-
2100-public const string NAME = _("Folder Manager");
2101-public const string DESCRIPTION = _("Basic folder manager with file browsing");
2102-
2103-namespace Scratch.Plugins {
2104- public class FolderManagerPlugin : Peas.ExtensionBase, Peas.Activatable {
2105-
2106- FolderManager.FileView view;
2107- Gtk.ToolButton tool_button;
2108-
2109- int index = 0;
2110-
2111- Scratch.Services.Interface plugins;
2112- public Object object { owned get; construct; }
2113-
2114- public FolderManagerPlugin () {
2115- message ("Starting Folder Manager Plugin");
2116- }
2117-
2118- public void activate () {
2119- plugins = (Scratch.Services.Interface) object;
2120- plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
2121- plugins.hook_toolbar.connect (on_hook_toolbar);
2122- }
2123-
2124- public void deactivate () {
2125- if (view != null)
2126- view.destroy();
2127- if (tool_button != null) {
2128- //(tool_button.parent as Scratch.Widgets.Toolbar).open_button.visible = true;
2129- tool_button.destroy ();
2130- }
2131- }
2132-
2133- public void update_state () {
2134- }
2135-
2136- void on_hook_sidebar (Gtk.Notebook notebook) {
2137- if (view != null)
2138- return;
2139-
2140- view = new FolderManager.FileView ();
2141-
2142- view.select.connect ((a) => {
2143- var file = GLib.File.new_for_path (a);
2144- plugins.open_file (file);
2145- });
2146-
2147- view.root.child_added.connect (() => {
2148- if (view.get_n_visible_children (view.root) == 0) {
2149- index = notebook.append_page (view, new Gtk.Label (_("Folders")));
2150- }
2151- });
2152-
2153- view.root.child_removed.connect (() => {
2154- if (view.get_n_visible_children (view.root) == 1)
2155- notebook.remove_page (index);
2156- });
2157-
2158- view.restore_saved_state ();
2159- }
2160-
2161- void on_hook_toolbar (Gtk.HeaderBar toolbar) {
2162- if (tool_button != null)
2163- return;
2164-
2165- //(toolbar as Scratch.Widgets.Toolbar).open_button.visible = false;
2166- var icon = new Gtk.Image.from_icon_name ("folder-saved-search", Gtk.IconSize.LARGE_TOOLBAR);
2167- tool_button = new Gtk.ToolButton (icon, _("Open a folder"));
2168- tool_button.tooltip_text = _("Open a folder");
2169- tool_button.clicked.connect (() => {
2170- Gtk.Window window = plugins.manager.window;
2171- Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
2172- "Select a folder.", window, Gtk.FileChooserAction.SELECT_FOLDER,
2173- _("_Cancel"), Gtk.ResponseType.CANCEL,
2174- _("_Open"), Gtk.ResponseType.ACCEPT);
2175- chooser.select_multiple = true;
2176-
2177- if (chooser.run () == Gtk.ResponseType.ACCEPT) {
2178- SList<string> uris = chooser.get_uris ();
2179- foreach (unowned string uri in uris) {
2180- var folder = new FolderManager.File (uri.replace ("file:///", "/"));
2181- view.open_folder (folder); // emit signal
2182- }
2183- }
2184-
2185- chooser.close ();
2186- });
2187-
2188- icon.show ();
2189- tool_button.show ();
2190-
2191- toolbar.pack_start (tool_button);
2192- //toolbar.insert (tool_button, 1);
2193- }
2194- }
2195-}
2196-
2197-[ModuleInit]
2198-public void peas_register_types (GLib.TypeModule module) {
2199- var objmodule = module as Peas.ObjectModule;
2200- objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.FolderManagerPlugin));
2201-}
2202
2203=== added file 'plugins/folder-manager/Settings.vala'
2204--- plugins/folder-manager/Settings.vala 1970-01-01 00:00:00 +0000
2205+++ plugins/folder-manager/Settings.vala 2016-11-18 21:40:10 +0000
2206@@ -0,0 +1,36 @@
2207+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2208+/***
2209+ BEGIN LICENSE
2210+
2211+ Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
2212+ This program is free software: you can redistribute it and/or modify it
2213+ under the terms of the GNU Lesser General Public License version 3, as published
2214+ by the Free Software Foundation.
2215+
2216+ This program is distributed in the hope that it will be useful, but
2217+ WITHOUT ANY WARRANTY; without even the implied warranties of
2218+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2219+ PURPOSE. See the GNU General Public License for more details.
2220+
2221+ You should have received a copy of the GNU General Public License along
2222+ with this program. If not, see <http://www.gnu.org/licenses/>
2223+
2224+ END LICENSE
2225+***/
2226+
2227+namespace Scratch.Plugins.FolderManager {
2228+
2229+ /**
2230+ * Class for interacting with gsettings.
2231+ */
2232+ internal class Settings : Granite.Services.Settings {
2233+
2234+ private const string SCHEMA = "org.pantheon.scratch.plugins.folder-manager";
2235+
2236+ public string[] opened_folders { get; set; }
2237+
2238+ public Settings () {
2239+ base (SCHEMA);
2240+ }
2241+ }
2242+}
2243
2244=== removed file 'plugins/folder-manager/Settings.vala'
2245--- plugins/folder-manager/Settings.vala 2013-05-31 10:38:24 +0000
2246+++ plugins/folder-manager/Settings.vala 1970-01-01 00:00:00 +0000
2247@@ -1,36 +0,0 @@
2248-// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2249-/***
2250- BEGIN LICENSE
2251-
2252- Copyright (C) 2013 Julien Spautz <spautz.julien@gmail.com>
2253- This program is free software: you can redistribute it and/or modify it
2254- under the terms of the GNU Lesser General Public License version 3, as published
2255- by the Free Software Foundation.
2256-
2257- This program is distributed in the hope that it will be useful, but
2258- WITHOUT ANY WARRANTY; without even the implied warranties of
2259- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2260- PURPOSE. See the GNU General Public License for more details.
2261-
2262- You should have received a copy of the GNU General Public License along
2263- with this program. If not, see <http://www.gnu.org/licenses/>
2264-
2265- END LICENSE
2266-***/
2267-
2268-namespace Scratch.Plugins.FolderManager {
2269-
2270- /**
2271- * Class for interacting with gsettings.
2272- */
2273- internal class Settings : Granite.Services.Settings {
2274-
2275- private const string SCHEMA = "org.pantheon.scratch.plugins.folder-manager";
2276-
2277- public string[] opened_folders { get; set; }
2278-
2279- public Settings () {
2280- base (SCHEMA);
2281- }
2282- }
2283-}
2284
2285=== added file 'plugins/folder-manager/folder-manager.plugin'
2286--- plugins/folder-manager/folder-manager.plugin 1970-01-01 00:00:00 +0000
2287+++ plugins/folder-manager/folder-manager.plugin 2016-11-18 21:40:10 +0000
2288@@ -0,0 +1,10 @@
2289+[Plugin]
2290+Module=folder-manager
2291+Loader=C
2292+IAge=2
2293+Name=Folder Manager
2294+Description=Browse files and directories
2295+Icon=system-file-manager
2296+Authors=Mario Guerriero, Julien Spautz, Corentin Noël, Andrei Zisu
2297+Copyright=Copyright © 2016 elementary LLC
2298+Website=http://launchpad.net/scratch
2299
2300=== removed file 'plugins/folder-manager/folder-manager.plugin'
2301--- plugins/folder-manager/folder-manager.plugin 2013-06-08 15:17:42 +0000
2302+++ plugins/folder-manager/folder-manager.plugin 1970-01-01 00:00:00 +0000
2303@@ -1,10 +0,0 @@
2304-[Plugin]
2305-Module=folder-manager
2306-Loader=C
2307-IAge=2
2308-Name=Folder Manager
2309-Description=Basic folder manager with file browsing
2310-Icon=folder-saved-search
2311-Authors=Julien Spautz <spautz.julien@gmail.com>
2312-Copyright=Copyright © 2013 Scratch Developers
2313-Website=http://launchpad.net/scratch
2314
2315=== modified file 'plugins/outline/OutlinePlugin.vala'
2316--- plugins/outline/OutlinePlugin.vala 2016-01-14 19:33:06 +0000
2317+++ plugins/outline/OutlinePlugin.vala 2016-11-18 21:40:10 +0000
2318@@ -21,6 +21,7 @@
2319 public const string NAME = _("Outline");
2320 public const string DESCRIPTION = _("Outline symbols in your current file in vala");
2321
2322+
2323 namespace Scratch.Plugins {
2324 public class OutlinePlugin : Peas.ExtensionBase, Peas.Activatable {
2325 public Object object { owned get; construct; }
2326@@ -113,7 +114,9 @@
2327
2328 void add_container () {
2329 if (notebook.page_num (container) == -1) {
2330- notebook.append_page (container, new Gtk.Label (_("Symbols")));
2331+ var icon = new Gtk.Image.from_icon_name ("view-sort-ascending-symbolic", Gtk.IconSize.MENU);
2332+ icon.tooltip_text = _("Outline");
2333+ notebook.append_page (container, icon);
2334 container.show_all ();
2335 }
2336 }
2337
2338=== modified file 'plugins/source-tree/SourceTreePlugin.vala'
2339--- plugins/source-tree/SourceTreePlugin.vala 2015-12-01 11:41:37 +0000
2340+++ plugins/source-tree/SourceTreePlugin.vala 2016-11-18 21:40:10 +0000
2341@@ -194,7 +194,9 @@
2342 view.welcome_hidden.connect (() => {
2343 this.bookmark_tool_button.visible = true;
2344 this.bookmark_tool_button.no_show_all = false;
2345- this.side_notebook.append_page (this.view, new Gtk.Label (_("Source Tree")));
2346+ var icon = new Gtk.Image.from_icon_name ("view-list-symbolic", Gtk.IconSize.MENU);
2347+ icon.tooltip_text = _("Source Tree");
2348+ this.side_notebook.append_page (this.view, icon);
2349 });
2350 });
2351
2352
2353=== modified file 'schemas/CMakeLists.txt'
2354--- schemas/CMakeLists.txt 2015-09-10 00:54:45 +0000
2355+++ schemas/CMakeLists.txt 2016-11-18 21:40:10 +0000
2356@@ -1,6 +1,5 @@
2357 include(GSettings)
2358 add_schema("org.pantheon.scratch.gschema.xml")
2359 add_schema("org.pantheon.scratch.plugins.folder-manager.gschema.xml")
2360-add_schema("org.pantheon.scratch.plugins.file-manager.gschema.xml")
2361 add_schema("org.pantheon.scratch.plugins.terminal.gschema.xml")
2362 add_schema("org.pantheon.scratch.plugins.spell.gschema.xml")
2363
2364=== removed file 'schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml'
2365--- schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml 2013-07-16 15:56:38 +0000
2366+++ schemas/org.pantheon.scratch.plugins.file-manager.gschema.xml 1970-01-01 00:00:00 +0000
2367@@ -1,10 +0,0 @@
2368-<?xml version="1.0" encoding="UTF-8"?>
2369-<schemalist>
2370- <schema path="/org/pantheon/scratch/plugins/file-manager/" id="org.pantheon.scratch.plugins.file-manager" gettext-domain="scratch">
2371- <key name="opened-folder" type="s">
2372- <default>''</default>
2373- <summary>Opened folder.</summary>
2374- <description>Opened folder that should be restored in startup.</description>
2375- </key>
2376- </schema>
2377-</schemalist>
2378
2379=== added file 'schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml'
2380--- schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 1970-01-01 00:00:00 +0000
2381+++ schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 2016-11-18 21:40:10 +0000
2382@@ -0,0 +1,10 @@
2383+<?xml version="1.0" encoding="UTF-8"?>
2384+<schemalist>
2385+ <schema path="/org/pantheon/scratch/plugins/folder-manager/" id="org.pantheon.scratch.plugins.folder-manager" gettext-domain="scratch">
2386+ <key name="opened-folders" type="as">
2387+ <default>[]</default>
2388+ <summary>Opened folders.</summary>
2389+ <description>Opened folders that should be restored in startup.</description>
2390+ </key>
2391+ </schema>
2392+</schemalist>
2393
2394=== removed file 'schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml'
2395--- schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 2013-05-31 10:38:24 +0000
2396+++ schemas/org.pantheon.scratch.plugins.folder-manager.gschema.xml 1970-01-01 00:00:00 +0000
2397@@ -1,10 +0,0 @@
2398-<?xml version="1.0" encoding="UTF-8"?>
2399-<schemalist>
2400- <schema path="/org/pantheon/scratch/plugins/folder-manager/" id="org.pantheon.scratch.plugins.folder-manager" gettext-domain="scratch">
2401- <key name="opened-folders" type="as">
2402- <default>[]</default>
2403- <summary>Opened folders.</summary>
2404- <description>Opened folders that should be restored in startup.</description>
2405- </key>
2406- </schema>
2407-</schemalist>

Subscribers

People subscribed via source and target branches