Merge lp:~matzipan/scratch/select-file-in-sidebar into lp:~elementary-apps/scratch/scratch

Proposed by Zisu Andrei
Status: Work in progress
Proposed branch: lp:~matzipan/scratch/select-file-in-sidebar
Merge into: lp:~elementary-apps/scratch/scratch
Prerequisite: lp:~matzipan/scratch/folder-manager-improvement
Diff against target: 623 lines (+175/-44) (has conflicts)
19 files modified
plugins/brackets-completion/brackets-completion.vala (+1/-1)
plugins/browser-preview/browser-preview.vala (+1/-5)
plugins/contractor/contractor.vala (+1/-1)
plugins/detect-indent/detect-indent.vala (+1/-1)
plugins/folder-manager/FileView.vala (+79/-8)
plugins/folder-manager/FolderManagerPlugin.vala (+33/-4)
plugins/highlight-word-selection/highlight-word-selection.vala (+1/-1)
plugins/open-with/open-with.vala (+1/-1)
plugins/outline/OutlinePlugin.vala (+2/-2)
plugins/pastebin/pastebin.vala (+1/-1)
plugins/preserve-indent/preserve-indent.vala (+1/-1)
plugins/source-tree/SourceTreePlugin.vala (+2/-2)
plugins/spell/spell.vala (+1/-1)
plugins/vim-emulation/vim-emulation.vala (+1/-1)
plugins/word-completion/plugin.vala (+1/-1)
src/MainWindow.vala (+4/-2)
src/Services/PluginManager.vala (+9/-4)
src/Widgets/DocumentView.vala (+20/-2)
src/Widgets/SplitView.vala (+15/-5)
Text conflict in src/Widgets/DocumentView.vala
To merge this branch: bzr merge lp:~matzipan/scratch/select-file-in-sidebar
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+313838@code.launchpad.net

Description of the change

To post a comment you must log in.

Unmerged revisions

1798. By Zisu Andrei

Add opened/changed signal and select items in sidebar accordingly

1797. By Zisu Andrei

Only add valid files and directories to children and update unloaded directories better

1796. By Zisu Andrei

Fix segmentation fault on unloaded folder monitor event

1795. By Zisu Andrei

Move menu items case

1794. By Zisu Andrei

Monitor files and update unloaded folders

1793. By Zisu Andrei

Check if folder is executable to avoid infinite loop

1792. By Zisu Andrei

Null the newly_created_path after it has been processed

1791. By Zisu Andrei

Fix double creation on empty folder loading

1790. By Zisu Andrei

Fix FolderItems not editable after creation

1789. By Zisu Andrei

Add new keyword to overriding function

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/brackets-completion/brackets-completion.vala'
2--- plugins/brackets-completion/brackets-completion.vala 2015-12-01 11:31:09 +0000
3+++ plugins/brackets-completion/brackets-completion.vala 2016-12-23 13:57:34 +0000
4@@ -50,7 +50,7 @@
5 this.brackets.set ("\"", "\"");
6
7 plugins = (Scratch.Services.Interface) object;
8- plugins.hook_document.connect ((doc) => {
9+ plugins.hook_document_changed.connect ((doc) => {
10 var buf = doc.source_view.buffer;
11 buf.insert_text.disconnect (on_insert_text);
12 buf.insert_text.connect (on_insert_text);
13
14=== modified file 'plugins/browser-preview/browser-preview.vala'
15--- plugins/browser-preview/browser-preview.vala 2015-12-01 11:32:14 +0000
16+++ plugins/browser-preview/browser-preview.vala 2016-12-23 13:57:34 +0000
17@@ -45,13 +45,9 @@
18 plugins.hook_window.connect ((w) => {
19 this.doc = w.get_current_document ();
20 });
21-
22- plugins.hook_document.connect (set_current_document);
23-
24+ plugins.hook_document_changed.connect (set_current_document);
25 plugins.hook_split_view.connect (on_hook_split_view);
26-
27 plugins.hook_notebook_context.connect (on_hook_context);
28-
29 plugins.hook_toolbar.connect (on_hook_toolbar);
30 }
31
32
33=== modified file 'plugins/contractor/contractor.vala'
34--- plugins/contractor/contractor.vala 2015-12-01 11:33:59 +0000
35+++ plugins/contractor/contractor.vala 2016-12-23 13:57:34 +0000
36@@ -71,7 +71,7 @@
37 }
38
39 private void on_hook (Gtk.Menu menu) {
40- plugins.hook_document.connect ((doc) => {
41+ plugins.hook_document_changed.connect ((doc) => {
42 // Remove old contracts
43 foreach (var item in list) {
44 var parent = item.get_parent ();
45
46=== modified file 'plugins/detect-indent/detect-indent.vala'
47--- plugins/detect-indent/detect-indent.vala 2016-06-09 09:26:12 +0000
48+++ plugins/detect-indent/detect-indent.vala 2016-12-23 13:57:34 +0000
49@@ -13,7 +13,7 @@
50 public void activate () {
51 plugins = (Scratch.Services.Interface) object;
52
53- plugins.hook_document.connect ((d) => {
54+ plugins.hook_document_changed.connect ((d) => {
55 var view = d.source_view;
56
57 if (!view.get_editable ()) {
58
59=== modified file 'plugins/folder-manager/FileView.vala'
60--- plugins/folder-manager/FileView.vala 2016-12-23 13:57:34 +0000
61+++ plugins/folder-manager/FileView.vala 2016-12-23 13:57:34 +0000
62@@ -6,12 +6,12 @@
63 * it under the terms of the GNU General Public License as published by
64 * the Free Software Foundation, either version 3 of the License, or
65 * (at your option) any later version.
66- *
67+ *
68 * This program is distributed in the hope that it will be useful,
69 * but WITHOUT ANY WARRANTY; without even the implied warranty of
70 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
71 * GNU General Public License for more details.
72- *
73+ *
74 * You should have received a copy of the GNU General Public License
75 * along with this program. If not, see <http://www.gnu.org/licenses/>.
76 *
77@@ -28,10 +28,10 @@
78 public signal void select (GLib.File file);
79 public signal void welcome_visible (bool visible);
80
81- // This is a workaround for SourceList silliness: you cannot remove an item
82+ // This is a workaround for SourceList silliness: you cannot remove an item
83 // without it automatically selecting another one.
84 public bool ignore_next_select = false;
85-
86+
87 construct {
88 width_request = 180;
89
90@@ -41,7 +41,7 @@
91 }
92
93 private void on_item_selected (Granite.Widgets.SourceList.Item? item) {
94- // This is a workaround for SourceList silliness: you cannot remove an item
95+ // This is a workaround for SourceList silliness: you cannot remove an item
96 // without it automatically selecting another one.
97 if (ignore_next_select) {
98 ignore_next_select = false;
99@@ -63,7 +63,7 @@
100 var folder = child as FolderItem;
101
102 if (folder != null && folder.path == folder_path) {
103- // This is a workaround for SourceList silliness: you cannot remove an item
104+ // This is a workaround for SourceList silliness: you cannot remove an item
105 // without it automatically selecting another one.
106 ignore_next_select = true;
107 root.remove(folder);
108@@ -85,7 +85,7 @@
109 } else if (is_open (folder_path)) {
110 warning ("Folder '%s' is already open.", folder_path);
111 return;
112- }
113+ }
114
115 var folder = new File(folder_path);
116
117@@ -95,7 +95,7 @@
118 }
119
120 bool has_valid_children = false;
121-
122+
123 foreach (var child in folder.children) {
124 if (child.is_valid_textfile || child.is_valid_directory) {
125 has_valid_children = true;
126@@ -131,6 +131,77 @@
127 return false;
128 }
129
130+ public void deselect_file_path (string path) {
131+ var selected_file = selected as FileItem;
132+ if (selected_file != null && selected_file.path == path) {
133+ selected = null;
134+ }
135+ }
136+
137+ public void select_item_for_path (string path) {
138+ var selected_file = selected as FileItem;
139+
140+ if (selected_file == null || (selected_file != null && selected_file.path != path)) {
141+ var file = new File (path);
142+
143+ var best_matching_length = 0;
144+ FolderItem? best_matching_candidate = null;
145+
146+ // Find the root folder which is closest to the path we're looking for
147+ foreach (var candidate in root.children) {
148+ var candidate_folder = candidate as FolderItem;
149+
150+ if (candidate_folder != null &&
151+ file.path.has_prefix(candidate_folder.path + GLib.Path.DIR_SEPARATOR_S) &&
152+ candidate_folder.path.length > best_matching_length) {
153+
154+ best_matching_candidate = candidate_folder;
155+ best_matching_length = candidate_folder.path.length;
156+ }
157+ }
158+
159+ if (best_matching_candidate == null) {
160+ warning("No parent item has been found for the current file");
161+ return;
162+ }
163+
164+ var match = best_matching_candidate;
165+ match.expanded = true; //@TODO check setting if parents should be expanded, if not, and is not expanded, just break and select the folder (Atom)
166+
167+ // Recursively walk folders
168+ while(true) {
169+ foreach (var candidate in match.children) {
170+ var candidate_folder = candidate as FolderItem;
171+
172+ if (candidate_folder != null &&
173+ file.path.has_prefix(candidate_folder.path + GLib.Path.DIR_SEPARATOR_S)) {
174+
175+ match = candidate_folder;
176+ break;
177+ }
178+ }
179+
180+ //@TODO check setting if parents should be expanded, if not, and is not expanded, just break and select the folder (Atom)
181+ match.expanded = true;
182+
183+ if (match.path == file.file.get_parent ().get_path ()) {
184+ break;
185+ }
186+ }
187+
188+ // Select the matching file
189+ foreach (var candidate in match.children) {
190+ var candidate_file = candidate as FileItem;
191+
192+ if (candidate_file != null && candidate_file.path == file.path) {
193+ selected = candidate_file;
194+ break;
195+ }
196+ }
197+ }
198+ }
199+
200+
201 private void write_settings () {
202 string[] paths = {};
203 foreach (var child in root.children) {
204
205=== modified file 'plugins/folder-manager/FolderManagerPlugin.vala'
206--- plugins/folder-manager/FolderManagerPlugin.vala 2016-12-23 13:57:34 +0000
207+++ plugins/folder-manager/FolderManagerPlugin.vala 2016-12-23 13:57:34 +0000
208@@ -26,6 +26,7 @@
209 public Scratch.Services.Interface plugins;
210 Gtk.Button button;
211 FolderManager.FileView view;
212+ private Gee.TreeSet <Scratch.Services.Document> docs;
213
214 public Object object { owned get; construct; }
215
216@@ -37,6 +38,8 @@
217 plugins = (Scratch.Services.Interface) object;
218 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
219 plugins.hook_toolbar.connect (on_hook_toolbar);
220+ plugins.hook_document_changed.connect (on_hook_document_changed);
221+ plugins.hook_document_opened.connect (on_hook_document_opened);
222 }
223
224 public void deactivate () {
225@@ -49,13 +52,22 @@
226 button.destroy();
227 button = null;
228 }
229+
230+ foreach (var doc in docs) {
231+ docs.remove (doc);
232+ doc.doc_closed.disconnect (on_doc_closed);
233+ }
234+
235+ plugins.hook_notebook_sidebar.disconnect (on_hook_sidebar);
236+ plugins.hook_toolbar.disconnect (on_hook_toolbar);
237+ plugins.hook_document_changed.disconnect (on_hook_document_changed);
238 }
239
240 public void update_state () {
241-
242+
243 }
244
245- void on_hook_sidebar (Gtk.Notebook notebook) {
246+ private void on_hook_sidebar (Gtk.Notebook notebook) {
247 if (view != null) {
248 return;
249 }
250@@ -77,7 +89,7 @@
251 view.restore_settings ();
252 }
253
254- void on_hook_toolbar (Gtk.HeaderBar toolbar) {
255+ private void on_hook_toolbar (Gtk.HeaderBar toolbar) {
256 if (button != null) {
257 return;
258 }
259@@ -88,7 +100,24 @@
260 button.show_all ();
261 toolbar.pack_start (button);
262 }
263-
264+
265+ private void on_hook_document_opened (Scratch.Services.Document doc) {
266+ if (!docs.contains (doc)) { // @TODO does this work with Splitview/opening multiple views of the same file
267+ docs.add (doc); //@TODO is this needed?
268+ doc.doc_closed.connect (on_doc_closed);
269+ }
270+ }
271+
272+ private void on_hook_document_changed (Scratch.Services.Document doc) {
273+ // @TODO check setting if items should be autoselected, if not, just set selected to null
274+ view.select_item_for_path (doc.file.get_path ());
275+ }
276+
277+ private void on_doc_closed (Scratch.Services.Document doc) {
278+ docs.remove (doc);
279+ view.deselect_file_path (doc.file.get_path ());
280+ }
281+
282 private void open_dialog () {
283 Gtk.Window window = plugins.manager.window;
284 Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
285
286=== modified file 'plugins/highlight-word-selection/highlight-word-selection.vala'
287--- plugins/highlight-word-selection/highlight-word-selection.vala 2015-12-01 11:38:39 +0000
288+++ plugins/highlight-word-selection/highlight-word-selection.vala 2016-12-23 13:57:34 +0000
289@@ -43,7 +43,7 @@
290 this.search_contexts = new Gee.HashMap<Scratch.Widgets.SourceView, Gtk.SourceSearchContext> ();
291
292 plugins = (Scratch.Services.Interface) object;
293- plugins.hook_document.connect ((doc) => {
294+ plugins.hook_document_changed.connect ((doc) => {
295 var src = doc.source_view;
296 src.deselected.disconnect (on_deselection);
297 src.deselected.connect (on_deselection);
298
299=== modified file 'plugins/open-with/open-with.vala'
300--- plugins/open-with/open-with.vala 2015-12-01 11:39:11 +0000
301+++ plugins/open-with/open-with.vala 2016-12-23 13:57:34 +0000
302@@ -42,7 +42,7 @@
303 }
304
305 private void on_hook (Gtk.Menu menu) {
306- plugins.hook_document.connect ((doc) => {
307+ plugins.hook_document_changed.connect ((doc) => {
308 // Remove old item
309 if (item != null)
310 item.destroy ();
311
312=== modified file 'plugins/outline/OutlinePlugin.vala'
313--- plugins/outline/OutlinePlugin.vala 2016-01-14 19:33:06 +0000
314+++ plugins/outline/OutlinePlugin.vala 2016-12-23 13:57:34 +0000
315@@ -41,7 +41,7 @@
316
317 public void activate () {
318 scratch_interface = (Scratch.Services.Interface)object;
319- scratch_interface.hook_document.connect (on_hook_document);
320+ scratch_interface.hook_document_changed.connect (on_hook_document_changed);
321 scratch_interface.hook_notebook_sidebar.connect (on_hook_sidebar);
322 }
323
324@@ -64,7 +64,7 @@
325 container.visible = false;
326 }
327
328- void on_hook_document (Scratch.Services.Document doc) {
329+ void on_hook_document_changed (Scratch.Services.Document doc) {
330 if (current_view != null && current_view.doc == doc)
331 return;
332
333
334=== modified file 'plugins/pastebin/pastebin.vala'
335--- plugins/pastebin/pastebin.vala 2015-12-01 11:40:30 +0000
336+++ plugins/pastebin/pastebin.vala 2016-12-23 13:57:34 +0000
337@@ -128,7 +128,7 @@
338 }
339
340 void on_hook (Gtk.Menu menu) {
341- plugins.hook_document.connect ((doc) => {
342+ plugins.hook_document_changed.connect ((doc) => {
343 if (menuitem != null)
344 menuitem.destroy ();
345 menuitem = new Gtk.MenuItem.with_label (_("Upload to Pastebin"));
346
347=== modified file 'plugins/preserve-indent/preserve-indent.vala'
348--- plugins/preserve-indent/preserve-indent.vala 2015-12-01 11:41:01 +0000
349+++ plugins/preserve-indent/preserve-indent.vala 2016-12-23 13:57:34 +0000
350@@ -38,7 +38,7 @@
351 this.documents = new Gee.TreeSet<weak Services.Document> ();
352 plugins = (Scratch.Services.Interface) object;
353
354- plugins.hook_document.connect ((d) => {
355+ plugins.hook_document_changed.connect ((d) => {
356 this.active_document = d;
357
358 if( documents.add (d)) {
359
360=== modified file 'plugins/source-tree/SourceTreePlugin.vala'
361--- plugins/source-tree/SourceTreePlugin.vala 2015-12-01 11:41:37 +0000
362+++ plugins/source-tree/SourceTreePlugin.vala 2016-12-23 13:57:34 +0000
363@@ -166,7 +166,7 @@
364 public void activate () {
365 plugins = (Scratch.Services.Interface) object;
366 plugins.hook_notebook_sidebar.connect (on_hook_sidebar);
367- plugins.hook_document.connect (on_hook_document);
368+ plugins.hook_document_changed.connect (on_hook_document_changed);
369 plugins.hook_toolbar.connect ((toolbar) => {
370 MainWindow window = plugins.manager.window;
371 if (this.bookmark_tool_button != null && this.new_button != null)
372@@ -257,7 +257,7 @@
373
374 }
375
376- void on_hook_document (Scratch.Services.Document doc) {
377+ void on_hook_document_changed (Scratch.Services.Document doc) {
378 scratch_notebook = (doc.get_parent () as Gtk.Notebook);
379 scratch_notebook.set_show_tabs (!HIDE_TOOLBAR);
380
381
382=== modified file 'plugins/spell/spell.vala'
383--- plugins/spell/spell.vala 2015-12-19 21:21:20 +0000
384+++ plugins/spell/spell.vala 2016-12-23 13:57:34 +0000
385@@ -49,7 +49,7 @@
386 settings.changed.connect (settings_changed);
387
388 plugins = (Scratch.Services.Interface) object;
389- plugins.hook_document.connect ((d) => {
390+ plugins.hook_document_changed.connect ((d) => {
391 var view = d.source_view;
392
393 // Create spell object
394
395=== modified file 'plugins/vim-emulation/vim-emulation.vala'
396--- plugins/vim-emulation/vim-emulation.vala 2015-12-01 11:43:48 +0000
397+++ plugins/vim-emulation/vim-emulation.vala 2016-12-23 13:57:34 +0000
398@@ -50,7 +50,7 @@
399
400 public void activate () {
401 plugins = (Scratch.Services.Interface) object;
402- plugins.hook_document.connect ((doc) => {
403+ plugins.hook_document_changed.connect ((doc) => {
404 this.view = doc.source_view;
405 this.view.key_press_event.disconnect (handle_key_press);
406 this.view.key_press_event.connect (handle_key_press);
407
408=== modified file 'plugins/word-completion/plugin.vala'
409--- plugins/word-completion/plugin.vala 2016-12-05 06:31:55 +0000
410+++ plugins/word-completion/plugin.vala 2016-12-23 13:57:34 +0000
411@@ -54,7 +54,7 @@
412 this.main_window = w;
413 });
414
415- plugins.hook_document.connect (on_new_source_view);
416+ plugins.hook_document_changed.connect (on_new_source_view);
417 }
418
419 public void deactivate () {
420
421=== modified file 'src/MainWindow.vala'
422--- src/MainWindow.vala 2016-12-13 02:06:39 +0000
423+++ src/MainWindow.vala 2016-12-23 13:57:34 +0000
424@@ -175,7 +175,7 @@
425 set_widgets_sensitive (true);
426 });
427
428- this.split_view.document_change.connect ((doc) => {
429+ this.split_view.document_changed.connect ((doc) => {
430 this.search_manager.set_text_view (doc.source_view);
431 // Update MainWindow title
432 if (doc != null && doc.file != null) {
433@@ -271,7 +271,8 @@
434 this.split_view.show_welcome ();
435 }
436
437- this.split_view.document_change.connect ((doc) => { plugins.hook_document (doc); });
438+ this.split_view.document_changed.connect ((doc) => { plugins.hook_document_changed (doc); });
439+ this.split_view.document_opened.connect ((doc) => { plugins.hook_document_opened (doc); });
440
441 // Plugins hook
442 HookFunc hook_func = () => {
443@@ -473,6 +474,7 @@
444
445 if (this.split_view.is_empty ()) {
446 view = split_view.add_view ();
447+
448 view.open_document (doc);
449 } else {
450 if (view == null) {
451
452=== modified file 'src/Services/PluginManager.vala'
453--- src/Services/PluginManager.vala 2014-04-13 16:12:53 +0000
454+++ src/Services/PluginManager.vala 2016-12-23 13:57:34 +0000
455@@ -33,7 +33,8 @@
456 public signal void hook_notebook_context (Gtk.Notebook notebook);
457 public signal void hook_notebook_bottom (Gtk.Notebook notebook);
458 public signal void hook_split_view (Scratch.Widgets.SplitView view);
459- public signal void hook_document (Scratch.Services.Document doc);
460+ public signal void hook_document_opened (Scratch.Services.Document doc);
461+ public signal void hook_document_changed (Scratch.Services.Document doc);
462 public signal void hook_preferences_dialog (Scratch.Dialogs.Preferences dialog);
463
464 public Scratch.TemplateManager template_manager { private set; get; }
465@@ -80,7 +81,8 @@
466 public signal void hook_notebook_context (Gtk.Notebook notebook);
467 public signal void hook_notebook_bottom (Gtk.Notebook notebook);
468 public signal void hook_split_view (Scratch.Widgets.SplitView view);
469- public signal void hook_document (Scratch.Services.Document doc);
470+ public signal void hook_document_changed (Scratch.Services.Document doc);
471+ public signal void hook_document_opened (Scratch.Services.Document doc);
472 public signal void hook_preferences_dialog (Scratch.Dialogs.Preferences dialog);
473
474 public signal void extension_added (Peas.PluginInfo info);
475@@ -163,8 +165,11 @@
476 this.hook_split_view.connect ((v) => {
477 plugin_iface.hook_split_view (v);
478 });
479- this.hook_document.connect ((d) => {
480- plugin_iface.hook_document (d);
481+ this.hook_document_changed.connect ((d) => {
482+ plugin_iface.hook_document_changed (d);
483+ });
484+ this.hook_document_opened.connect ((d) => {
485+ plugin_iface.hook_document_opened (d);
486 });
487 this.hook_preferences_dialog.connect ((d) => {
488 plugin_iface.hook_preferences_dialog (d);
489
490=== modified file 'src/Widgets/DocumentView.vala'
491--- src/Widgets/DocumentView.vala 2016-12-13 02:06:39 +0000
492+++ src/Widgets/DocumentView.vala 2016-12-23 13:57:34 +0000
493@@ -40,7 +40,9 @@
494 public bool is_closing = false;
495
496 // Signals
497- public signal void document_change (Services.Document? document);
498+ public signal void document_changed (Services.Document? document);
499+ public signal void document_opened (Services.Document? document);
500+
501 public signal void empty ();
502
503 public DocumentView (MainWindow window) {
504@@ -72,8 +74,12 @@
505 });
506
507 this.notebook.tab_switched.connect ((old_tab, new_tab) => {
508+<<<<<<< TREE
509 document_change (new_tab as Services.Document);
510 save_current_file (new_tab as Services.Document);
511+=======
512+ document_changed (new_tab as Services.Document);
513+>>>>>>> MERGE-SOURCE
514 });
515
516 this.notebook.tab_restored.connect ((label, restore_data, icon) => {
517@@ -105,6 +111,8 @@
518 var doc = new Services.Document (window.main_actions, file);
519 doc.create_page ();
520
521+ document_opened (doc);
522+
523 this.notebook.insert_tab (doc, -1);
524 this.notebook.current = doc;
525
526@@ -125,6 +133,8 @@
527 var doc = new Services.Document (window.main_actions, file);
528 doc.create_page ();
529
530+ document_opened (doc);
531+
532 this.notebook.insert_tab (doc, -1);
533 this.notebook.current = doc;
534
535@@ -149,8 +159,12 @@
536 }
537
538 doc.create_page ();
539+
540+ document_opened (doc);
541+
542 this.notebook.insert_tab (doc, -1);
543 this.notebook.current = doc;
544+
545 doc.focus ();
546 }
547
548@@ -162,10 +176,14 @@
549
550 var doc = new Services.Document (window.main_actions, file);
551 doc.create_page ();
552+
553+ document_opened (doc);
554+
555 string s;
556 doc.file.replace_contents (original.source_view.buffer.text.data, null, false, 0, out s);
557 this.notebook.insert_tab (doc, -1);
558 this.notebook.current = doc;
559+
560 doc.focus ();
561 } catch (Error e) {
562 warning ("Cannot copy \"%s\": %s", original.get_basename (), e.message);
563@@ -283,7 +301,7 @@
564 if (doc == null) {
565 warning ("Focus event callback cannot get current document");
566 } else {
567- document_change (doc);
568+ document_changed (doc);
569 }
570
571 return true;
572
573=== modified file 'src/Widgets/SplitView.vala'
574--- src/Widgets/SplitView.vala 2016-12-13 02:06:39 +0000
575+++ src/Widgets/SplitView.vala 2016-12-23 13:57:34 +0000
576@@ -32,7 +32,8 @@
577 // Signals
578 public signal void welcome_shown ();
579 public signal void welcome_hidden ();
580- public signal void document_change (Scratch.Services.Document document);
581+ public signal void document_changed (Scratch.Services.Document document);
582+ public signal void document_opened (Scratch.Services.Document document);
583 public signal void views_changed (uint count);
584
585 private weak MainWindow window;
586@@ -109,7 +110,8 @@
587 hidden_views.remove (view);
588 }
589
590- view.document_change.connect (on_document_changed);
591+ view.document_changed.connect (on_document_changed);
592+ view.document_opened.connect (on_document_opened);
593 view.vexpand = true;
594
595 if (views.length () < 1)
596@@ -163,7 +165,8 @@
597 }
598
599 this.views.remove (view);
600- view.document_change.disconnect (on_document_changed);
601+ view.document_changed.disconnect (on_document_changed);
602+ view.document_opened.disconnect (on_document_opened);
603 view.visible = false;
604 this.hidden_views.append (view);
605 debug ("View removed successfully");
606@@ -209,8 +212,15 @@
607
608 // Detect the last focused Document throw a signal
609 private void on_document_changed (Scratch.Services.Document? document) {
610- if (document != null)
611- document_change (document);
612+ if (document != null) {
613+ document_changed (document);
614+ }
615+ }
616+
617+ private void on_document_opened (Scratch.Services.Document? document) {
618+ if (document != null) {
619+ document_opened (document);
620+ }
621 }
622
623 // Check the possibility to add or not a new view

Subscribers

People subscribed via source and target branches