Merge lp:~mefrio-g/scratch/fix-1258260 into lp:~elementary-apps/scratch/scratch
- fix-1258260
- Merge into scratch
Status: | Merged |
---|---|
Approved by: | Niclas Lockner |
Approved revision: | 1281 |
Merged at revision: | 1292 |
Proposed branch: | lp:~mefrio-g/scratch/fix-1258260 |
Merge into: | lp:~elementary-apps/scratch/scratch |
Diff against target: |
204 lines (+45/-26) 3 files modified
plugins/outline/CtagsSymbolResolver.vala (+7/-0) plugins/outline/OutlinePlugin.vala (+29/-8) plugins/outline/ValaSymbolResolver.vala (+9/-18) |
To merge this branch: | bzr merge lp:~mefrio-g/scratch/fix-1258260 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Niclas Lockner (community) | Approve | ||
Review via email: mp+215567@code.launchpad.net |
Commit message
Don't show outline pane if there is nothing to outline. Fixes bug #1258260
Description of the change
Niclas Lockner (niclasl) wrote : | # |
And when I say that the pane is shown alongside the welcome screen, I mean that the buttons on the welcome screen are no longer centered and there's a large empty space to the right where the pane will be once a vala file is opened.
- 1278. By Mario Guerriero
-
fixed welcome screen and unsaved documents problems
Mario Guerriero (mefrio-g) wrote : | # |
It should work as expected now. I also fixed some compilation warnings.
Niclas Lockner (niclasl) wrote : | # |
It still doesn't work that well for me:
Open scratch (No tabs are open and the welcome screen is shown)
Open a Vala file
=> Outline pane has two Symbols tabs (the inactive tab isn't clickable)
Open a second Vala file
Switch between the tabs
=> The output pane no longer shows any content
=> For each switch, a new Symbols tab is added to the Outline pane
Close both tabs
=> failed assertion and SIGABRT when the last tab is closed
If I instead open Scratch, create a new document and then open a Vala document, it seems to work.
I can switch between the two tabs and the outline pane is shown or hidden accordingly. The outline pane also has the right content.
- 1279. By Mario Guerriero
-
do not add several useless symbols view to the left pane
Mario Guerriero (mefrio-g) wrote : | # |
Everything should work as expected now. Thanks for your patience.
Niclas Lockner (niclasl) wrote : | # |
Now it works much better, but there's still one bug:
If I open a vala file and a regular file (not a new document but an existing one) and then switch tab from the vala file to the non-vala file, the outline pane becomes empty but doesn't hide as it should.
If I instead open a vala file and a new empty document, it works as long as the new document isn't saved. Once saved, Scratch behaves as above.
Also, there's a conflict with trunk's ValaSymbolResol
Niclas Lockner (niclasl) wrote : | # |
And if the code style is to be strictly followed:
Newline before diff line 26
Remove spaces on diff lines 66, 97, 104, 137, 139
Add space after if on diff line 99
Make a cuddled else if on diff lines 92-93
- 1280. By Mario Guerriero
-
fixed switch between vala and non-vala files
Mario Guerriero (mefrio-g) wrote : | # |
It now works fine. I see the conflict project but to be honest I don't know how to fix it. Could you help me?
Niclas Lockner (niclasl) wrote : | # |
Yes, now it works as expected :) Just the code style issues and the conflict left then.
To resolve the conflict, first merge with trunk:
bzr merge lp:scratch
which should give you:
Text conflict in plugins/
1 conflicts encountered.
After that, open plugins/
After that, mark all conflicts as resolved:
bzr resolve
and commit the changes:
bzr commit -m "Merge changes from lp:scratch"
- 1281. By Mario Guerriero
-
Merge changes from lp:scratch
Mario Guerriero (mefrio-g) wrote : | # |
It should be everything fine now. Thanks.
Niclas Lockner (niclasl) : | # |
Preview Diff
1 | === modified file 'plugins/outline/CtagsSymbolResolver.vala' | |||
2 | --- plugins/outline/CtagsSymbolResolver.vala 2014-04-13 08:35:48 +0000 | |||
3 | +++ plugins/outline/CtagsSymbolResolver.vala 2014-04-25 14:53:01 +0000 | |||
4 | @@ -30,6 +30,8 @@ | |||
5 | 30 | Granite.Widgets.SourceList store; | 30 | Granite.Widgets.SourceList store; |
6 | 31 | Granite.Widgets.SourceList.ExpandableItem root; | 31 | Granite.Widgets.SourceList.ExpandableItem root; |
7 | 32 | 32 | ||
8 | 33 | public int n_symbols { get; protected set; } | ||
9 | 34 | |||
10 | 33 | public CtagsSymbolOutline (Scratch.Services.Document _doc) | 35 | public CtagsSymbolOutline (Scratch.Services.Document _doc) |
11 | 34 | { | 36 | { |
12 | 35 | doc = _doc; | 37 | doc = _doc; |
13 | @@ -37,6 +39,8 @@ | |||
14 | 37 | 39 | ||
15 | 38 | root = new Granite.Widgets.SourceList.ExpandableItem (_("Symbols")); | 40 | root = new Granite.Widgets.SourceList.ExpandableItem (_("Symbols")); |
16 | 39 | 41 | ||
17 | 42 | this.n_symbols = 0; | ||
18 | 43 | |||
19 | 40 | store = new Granite.Widgets.SourceList (); | 44 | store = new Granite.Widgets.SourceList (); |
20 | 41 | store.get_style_context ().add_class ("sidebar"); | 45 | store.get_style_context ().add_class ("sidebar"); |
21 | 42 | store.item_selected.connect ((selected) => { | 46 | store.item_selected.connect ((selected) => { |
22 | @@ -133,6 +137,7 @@ | |||
23 | 133 | } else | 137 | } else |
24 | 134 | parent_dependent.add (new CtagsSymbolIter (name, parent, line, icon)); | 138 | parent_dependent.add (new CtagsSymbolIter (name, parent, line, icon)); |
25 | 135 | } | 139 | } |
26 | 140 | this.n_symbols++; | ||
27 | 136 | 141 | ||
28 | 137 | var found_something = true; | 142 | var found_something = true; |
29 | 138 | while (found_something && parent_dependent.size > 0) { | 143 | while (found_something && parent_dependent.size > 0) { |
30 | @@ -173,6 +178,8 @@ | |||
31 | 173 | void parse_fields (string fields, out int line, out string parent) | 178 | void parse_fields (string fields, out int line, out string parent) |
32 | 174 | { | 179 | { |
33 | 175 | var index = -1; | 180 | var index = -1; |
34 | 181 | line = -1; | ||
35 | 182 | parent = null; | ||
36 | 176 | if ((index = fields.index_of ("line:")) > -1) { | 183 | if ((index = fields.index_of ("line:")) > -1) { |
37 | 177 | line = int.parse (fields.substring (index + 5, int.max (fields.index_of (" ", index + 6) - index, -1))); | 184 | line = int.parse (fields.substring (index + 5, int.max (fields.index_of (" ", index + 6) - index, -1))); |
38 | 178 | } | 185 | } |
39 | 179 | 186 | ||
40 | === modified file 'plugins/outline/OutlinePlugin.vala' | |||
41 | --- plugins/outline/OutlinePlugin.vala 2014-04-13 08:35:48 +0000 | |||
42 | +++ plugins/outline/OutlinePlugin.vala 2014-04-25 14:53:01 +0000 | |||
43 | @@ -25,6 +25,7 @@ | |||
44 | 25 | { | 25 | { |
45 | 26 | public abstract Scratch.Services.Document doc { get; protected set; } | 26 | public abstract Scratch.Services.Document doc { get; protected set; } |
46 | 27 | public abstract void parse_symbols (); | 27 | public abstract void parse_symbols (); |
47 | 28 | public abstract int n_symbols { get; protected set; } | ||
48 | 28 | public abstract Granite.Widgets.SourceList get_source_list (); | 29 | public abstract Granite.Widgets.SourceList get_source_list (); |
49 | 29 | public signal void closed (); | 30 | public signal void closed (); |
50 | 30 | public signal void goto (Scratch.Services.Document doc, int line); | 31 | public signal void goto (Scratch.Services.Document doc, int line); |
51 | @@ -37,6 +38,7 @@ | |||
52 | 37 | Scratch.Services.Interface scratch_interface; | 38 | Scratch.Services.Interface scratch_interface; |
53 | 38 | SymbolOutline? current_view = null; | 39 | SymbolOutline? current_view = null; |
54 | 39 | Gtk.EventBox? container = null; | 40 | Gtk.EventBox? container = null; |
55 | 41 | Gtk.Notebook? notebook = null; | ||
56 | 40 | 42 | ||
57 | 41 | uint refresh_timeout = 0; | 43 | uint refresh_timeout = 0; |
58 | 42 | 44 | ||
59 | @@ -60,11 +62,11 @@ | |||
60 | 60 | void on_hook_context (Gtk.Notebook notebook) { | 62 | void on_hook_context (Gtk.Notebook notebook) { |
61 | 61 | if (container != null) | 63 | if (container != null) |
62 | 62 | return; | 64 | return; |
64 | 63 | 65 | if (this.notebook == null) | |
65 | 66 | this.notebook = notebook; | ||
66 | 67 | |||
67 | 64 | container = new Gtk.EventBox (); | 68 | container = new Gtk.EventBox (); |
71 | 65 | container.visible = false; | 69 | container.visible = false; |
69 | 66 | notebook.append_page (container, new Gtk.Label (_("Symbols"))); | ||
70 | 67 | container.show_all (); | ||
72 | 68 | } | 70 | } |
73 | 69 | 71 | ||
74 | 70 | void on_hook_document (Scratch.Services.Document doc) { | 72 | void on_hook_document (Scratch.Services.Document doc) { |
75 | @@ -81,7 +83,7 @@ | |||
76 | 81 | break; | 83 | break; |
77 | 82 | } | 84 | } |
78 | 83 | } | 85 | } |
80 | 84 | if (view == null) { | 86 | if (view == null && doc.file != null) { |
81 | 85 | if (doc.get_mime_type () == "text/x-vala") { | 87 | if (doc.get_mime_type () == "text/x-vala") { |
82 | 86 | view = new ValaSymbolOutline (doc); | 88 | view = new ValaSymbolOutline (doc); |
83 | 87 | } else { | 89 | } else { |
84 | @@ -98,14 +100,33 @@ | |||
85 | 98 | container.add (view.get_source_list ()); | 100 | container.add (view.get_source_list ()); |
86 | 99 | container.show_all (); | 101 | container.show_all (); |
87 | 100 | current_view = view; | 102 | current_view = view; |
88 | 103 | |||
89 | 104 | if (view.n_symbols > 1) { | ||
90 | 105 | add_container (); | ||
91 | 106 | } | ||
92 | 107 | else if (doc.file == null || view.n_symbols <= 1) { | ||
93 | 108 | remove_container (); | ||
94 | 109 | } | ||
95 | 110 | } | ||
96 | 111 | |||
97 | 112 | void add_container () { | ||
98 | 113 | if(notebook.page_num (container) == -1) { | ||
99 | 114 | notebook.append_page (container, new Gtk.Label (_("Symbols"))); | ||
100 | 115 | container.show_all (); | ||
101 | 116 | } | ||
102 | 117 | } | ||
103 | 118 | |||
104 | 119 | void remove_container () { | ||
105 | 120 | if (notebook.page_num (container) != -1) | ||
106 | 121 | notebook.remove (container); | ||
107 | 101 | } | 122 | } |
108 | 102 | 123 | ||
109 | 103 | void on_hook_split_view (Scratch.Widgets.SplitView view) { | 124 | void on_hook_split_view (Scratch.Widgets.SplitView view) { |
110 | 104 | view.welcome_shown.connect (() => { | 125 | view.welcome_shown.connect (() => { |
112 | 105 | container.visible = false; | 126 | remove_container (); |
113 | 106 | }); | 127 | }); |
114 | 107 | view.welcome_hidden.connect (() => { | 128 | view.welcome_hidden.connect (() => { |
116 | 108 | container.visible = true; | 129 | add_container (); |
117 | 109 | }); | 130 | }); |
118 | 110 | } | 131 | } |
119 | 111 | 132 | ||
120 | @@ -144,4 +165,4 @@ | |||
121 | 144 | { | 165 | { |
122 | 145 | var objmodule = module as Peas.ObjectModule; | 166 | var objmodule = module as Peas.ObjectModule; |
123 | 146 | objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.OutlinePlugin)); | 167 | objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.OutlinePlugin)); |
125 | 147 | } | 168 | } |
126 | 148 | \ No newline at end of file | 169 | \ No newline at end of file |
127 | 149 | 170 | ||
128 | === modified file 'plugins/outline/ValaSymbolResolver.vala' | |||
129 | --- plugins/outline/ValaSymbolResolver.vala 2014-04-23 11:16:47 +0000 | |||
130 | +++ plugins/outline/ValaSymbolResolver.vala 2014-04-25 14:53:01 +0000 | |||
131 | @@ -40,7 +40,9 @@ | |||
132 | 40 | Vala.CodeContext context; | 40 | Vala.CodeContext context; |
133 | 41 | Vala.Parser parser; | 41 | Vala.Parser parser; |
134 | 42 | SymbolResolver resolver; | 42 | SymbolResolver resolver; |
136 | 43 | 43 | ||
137 | 44 | public int n_symbols { get; protected set; } | ||
138 | 45 | |||
139 | 44 | SymbolIter cache; | 46 | SymbolIter cache; |
140 | 45 | 47 | ||
141 | 46 | Gee.List<Vala.Field> field_blacklist; | 48 | Gee.List<Vala.Field> field_blacklist; |
142 | @@ -70,6 +72,8 @@ | |||
143 | 70 | field_blacklist.add (f); | 72 | field_blacklist.add (f); |
144 | 71 | }); | 73 | }); |
145 | 72 | 74 | ||
146 | 75 | this.n_symbols = 0; | ||
147 | 76 | |||
148 | 73 | init_context (); | 77 | init_context (); |
149 | 74 | } | 78 | } |
150 | 75 | 79 | ||
151 | @@ -117,7 +121,7 @@ | |||
152 | 117 | init_context (); | 121 | init_context (); |
153 | 118 | 122 | ||
154 | 119 | Thread<void*> thread = new Thread<void*>("parse-symbols", () => { | 123 | Thread<void*> thread = new Thread<void*>("parse-symbols", () => { |
156 | 120 | parse_symbols_async (); | 124 | parse_symbols_async.begin (); |
157 | 121 | return null; | 125 | return null; |
158 | 122 | }); | 126 | }); |
159 | 123 | 127 | ||
160 | @@ -126,8 +130,6 @@ | |||
161 | 126 | root.clear (); | 130 | root.clear (); |
162 | 127 | construct_tree (cache, root); | 131 | construct_tree (cache, root); |
163 | 128 | 132 | ||
164 | 129 | filter_generated_fields (root); | ||
165 | 130 | |||
166 | 131 | store.root.expand_all (); | 133 | store.root.expand_all (); |
167 | 132 | } | 134 | } |
168 | 133 | 135 | ||
169 | @@ -135,11 +137,14 @@ | |||
170 | 135 | Granite.Widgets.SourceList.ExpandableItem tree_parent) | 137 | Granite.Widgets.SourceList.ExpandableItem tree_parent) |
171 | 136 | { | 138 | { |
172 | 137 | foreach (var iter_child in iter_parent.children) { | 139 | foreach (var iter_child in iter_parent.children) { |
173 | 140 | if (iter_child == null) | ||
174 | 141 | continue; | ||
175 | 138 | var tree_child = new Symbol (doc, iter_child.symbol); | 142 | var tree_child = new Symbol (doc, iter_child.symbol); |
176 | 139 | tree_child.icon = iter_child.icon; | 143 | tree_child.icon = iter_child.icon; |
177 | 140 | tree_parent.add (tree_child); | 144 | tree_parent.add (tree_child); |
178 | 141 | 145 | ||
179 | 142 | construct_tree (iter_child, tree_child); | 146 | construct_tree (iter_child, tree_child); |
180 | 147 | this.n_symbols++; | ||
181 | 143 | } | 148 | } |
182 | 144 | } | 149 | } |
183 | 145 | 150 | ||
184 | @@ -159,20 +164,6 @@ | |||
185 | 159 | return match; | 164 | return match; |
186 | 160 | } | 165 | } |
187 | 161 | 166 | ||
188 | 162 | // vala generates for each property a field which we do not want to display | ||
189 | 163 | void filter_generated_fields (Granite.Widgets.SourceList.ExpandableItem parent) | ||
190 | 164 | { | ||
191 | 165 | var children = parent.children.to_array (); | ||
192 | 166 | foreach (var child in children) { | ||
193 | 167 | var child_symbol = child as Symbol; | ||
194 | 168 | if (field_blacklist.contains (child_symbol.symbol as Vala.Field)) { | ||
195 | 169 | parent.remove (child); | ||
196 | 170 | } else { | ||
197 | 171 | filter_generated_fields (child_symbol); | ||
198 | 172 | } | ||
199 | 173 | } | ||
200 | 174 | } | ||
201 | 175 | |||
202 | 176 | void add_symbol (Vala.Symbol symbol, string icon = "", Icon? real_icon = null) | 167 | void add_symbol (Vala.Symbol symbol, string icon = "", Icon? real_icon = null) |
203 | 177 | { | 168 | { |
204 | 178 | if (symbol.name == null) | 169 | if (symbol.name == null) |
The filter_ generated_ fields method in ValaSymbolResolver in unused now that the call at diff line 118 is removed. Should n't it be removed as well?
I noticed three situations where it doesn't work as expected:
When I start Scratch, the empty outline pane is shown alongside the welcome screen.
If the outline pane is shown when the last tab is closed (e.g. one single vala file opened and then closed), the outline pane is still shown alongside the welcome screen. If I instead let the last closed tab be a non-vala file, it works as expected.
If I open some new tabs with new or existing non-vala documents and then switch between them, the outline pane appears. It hides itself when I open yet another tab.