Merge lp:~gero-bare/scratch/fix-1392031-again into lp:~elementary-apps/scratch/scratch

Proposed by Gero.Bare
Status: Work in progress
Proposed branch: lp:~gero-bare/scratch/fix-1392031-again
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 143 lines (+22/-26)
2 files modified
src/MainWindow.vala (+8/-15)
src/Widgets/SplitView.vala (+14/-11)
To merge this branch: bzr merge lp:~gero-bare/scratch/fix-1392031-again
Reviewer Review Type Date Requested Status
Danielle Foré Needs Fixing
Review via email: mp+318710@code.launchpad.net

Description of the change

Ok things to be tested.

> Open files using the file manager plugin.
> Open new SplitView, make sure that:
  * new tabs (Ctrl-n) are opened in the right split view.
  * files opened with the filemanager are opened in the right view.
  * switch focus between views and test the same conditions.

etc.

Additional notes. Sometimes a view is closed and when reopened it opens all the previously opened files but sometimes not. I don't know if intended or not, I wont fix.
I found that opening files with folder icon, can sometimes open the same file twice in the same splitview, I couldn't reproduce reliably plus I found it in the middle of the iteration so be warned, but I don't think that it's entirely my fault. But I won't fix.

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Please make sure this doesn't break the folder sidebar

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

With this change, opening files from the folder sidebar often does not work. It seems like it's maybe trying to open the file in the closed pane instead of the opened one.

Unmerged revisions

1831. By Gero.Bare

      * Fixed bug 1392031 again

      * Removed calls to split_view.get_focus_child (), use get_current_view () instead.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/MainWindow.vala'
--- src/MainWindow.vala 2017-01-06 17:11:40 +0000
+++ src/MainWindow.vala 2017-03-04 05:29:54 +0000
@@ -479,11 +479,7 @@
479 view.open_document (doc);479 view.open_document (doc);
480 } else {480 } else {
481 if (view == null) {481 if (view == null) {
482 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;482 view = this.split_view.get_current_view ();
483 }
484
485 if (view == null) {
486 view = this.split_view.current_view;
487 }483 }
488484
489 view.open_document (doc);485 view.open_document (doc);
@@ -497,10 +493,7 @@
497 view = split_view.add_view ();493 view = split_view.add_view ();
498 view.close_document (doc);494 view.close_document (doc);
499 } else {495 } else {
500 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;496 view = split_view.get_current_view ();
501 if (view == null) {
502 view = this.split_view.current_view;
503 }
504497
505 view.close_document (doc);498 view.close_document (doc);
506 }499 }
@@ -762,7 +755,7 @@
762 if (this.split_view.is_empty ()) {755 if (this.split_view.is_empty ()) {
763 view = split_view.add_view ();756 view = split_view.add_view ();
764 } else {757 } else {
765 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;758 view = split_view.get_current_view ();
766 }759 }
767760
768 view.new_document ();761 view.new_document ();
@@ -773,7 +766,7 @@
773 if (this.split_view.is_empty ()) {766 if (this.split_view.is_empty ()) {
774 view = split_view.add_view ();767 view = split_view.add_view ();
775 } else {768 } else {
776 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;769 view = split_view.get_current_view ();
777 }770 }
778771
779 string text_from_clipboard = clipboard.wait_for_text ();772 string text_from_clipboard = clipboard.wait_for_text ();
@@ -859,19 +852,19 @@
859852
860 private void action_next_tab () {853 private void action_next_tab () {
861 Scratch.Widgets.DocumentView? view = null;854 Scratch.Widgets.DocumentView? view = null;
862 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;855 view = split_view.get_current_view ();
863 view.next_document ();856 view.next_document ();
864 }857 }
865858
866 private void action_previous_tab () {859 private void action_previous_tab () {
867 Scratch.Widgets.DocumentView? view = null;860 Scratch.Widgets.DocumentView? view = null;
868 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;861 view = split_view.get_current_view ();
869 view.previous_document ();862 view.previous_document ();
870 }863 }
871864
872 private void action_to_lower_case () {865 private void action_to_lower_case () {
873 Scratch.Widgets.DocumentView? view = null;866 Scratch.Widgets.DocumentView? view = null;
874 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;867 view = split_view.get_current_view ();
875 var doc = view.get_current_document ();868 var doc = view.get_current_document ();
876 if (doc == null) {869 if (doc == null) {
877 return;870 return;
@@ -888,7 +881,7 @@
888881
889 private void action_to_upper_case () {882 private void action_to_upper_case () {
890 Scratch.Widgets.DocumentView? view = null;883 Scratch.Widgets.DocumentView? view = null;
891 view = split_view.get_focus_child () as Scratch.Widgets.DocumentView;884 view = split_view.get_current_view ();
892 var doc = view.get_current_document ();885 var doc = view.get_current_document ();
893 if (doc == null) {886 if (doc == null) {
894 return;887 return;
895888
=== modified file 'src/Widgets/SplitView.vala'
--- src/Widgets/SplitView.vala 2017-02-17 17:07:43 +0000
+++ src/Widgets/SplitView.vala 2017-03-04 05:29:54 +0000
@@ -24,7 +24,7 @@
2424
25 // Widgets25 // Widgets
26 public Granite.Widgets.Welcome welcome_screen;26 public Granite.Widgets.Welcome welcome_screen;
27 public Scratch.Widgets.DocumentView? current_view = null;27 private Scratch.Widgets.DocumentView? current_view = null;
2828
29 public GLib.List<Scratch.Widgets.DocumentView> views;29 public GLib.List<Scratch.Widgets.DocumentView> views;
30 private GLib.List<Scratch.Widgets.DocumentView> hidden_views;30 private GLib.List<Scratch.Widgets.DocumentView> hidden_views;
@@ -133,12 +133,14 @@
133 public void remove_view (Scratch.Widgets.DocumentView? view = null) {133 public void remove_view (Scratch.Widgets.DocumentView? view = null) {
134 // If no specific view is required to be removed, just remove the current one134 // If no specific view is required to be removed, just remove the current one
135 if (view == null)135 if (view == null)
136 view = get_focus_child () as Scratch.Widgets.DocumentView;136 view = current_view;
137 if (view == null) {137 if (view == null) {
138 warning ("There is no focused view to remove!");138 warning ("There is no focused view to remove!");
139 return;139 return;
140 }140 }
141141
142 view.save_opened_files ();
143
142 foreach (var doc in view.docs) {144 foreach (var doc in view.docs) {
143 if (!doc.close (true)) {145 if (!doc.close (true)) {
144 view.set_current_document (doc);146 view.set_current_document (doc);
@@ -155,9 +157,6 @@
155157
156 view.view_id = 2;158 view.view_id = 2;
157 right_view.view_id = 1;159 right_view.view_id = 1;
158
159 view.save_opened_files ();
160 right_view.save_opened_files ();
161 } else {160 } else {
162 remove (view);161 remove (view);
163 }162 }
@@ -177,16 +176,20 @@
177 }176 }
178177
179 // Show/Hide welcome screen178 // Show/Hide welcome screen
180 if (this.views.length () == 0)179 if (this.views.length () == 0) {
180 current_view = null;
181 show_welcome ();181 show_welcome ();
182 } else {
183 current_view = get_child1 () as Scratch.Widgets.DocumentView;
184 }
185
182 }186 }
183187
184 public Scratch.Widgets.DocumentView? get_current_view () {188 public Scratch.Widgets.DocumentView? get_current_view () {
185 views.foreach ((v) => {189 Scratch.Widgets.DocumentView _current_view = get_focus_child () as Scratch.Widgets.DocumentView;
186 if (v.has_focus) {190 if (_current_view != null) {
187 current_view = v;191 current_view = _current_view;
188 }192 }
189 });
190 return current_view;193 return current_view;
191 }194 }
192195

Subscribers

People subscribed via source and target branches