Merge lp:~artem-anufrij/scratch/Bugfix-1085718 into lp:~elementary-apps/scratch/scratch

Proposed by Artem Anufrij
Status: Superseded
Proposed branch: lp:~artem-anufrij/scratch/Bugfix-1085718
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 229 lines (+71/-19)
4 files modified
plugins/terminal/terminal.vala (+55/-14)
src/MainWindow.vala (+11/-3)
src/Widgets/SplitView.vala (+3/-1)
src/Widgets/ToolBar.vala (+2/-1)
To merge this branch: bzr merge lp:~artem-anufrij/scratch/Bugfix-1085718
Reviewer Review Type Date Requested Status
Artem Anufrij (community) (ux) Needs Information
Danielle Foré ux Needs Fixing
Review via email: mp+240381@code.launchpad.net

This proposal has been superseded by a proposal from 2014-11-12.

Description of the change

Terminal switches automatically to the left side if width of the window is > 1366pix

To post a comment you must log in.
1404. By artem-anufrij

remove [tabulator] -> [4 x spase]

1405. By artem-anufrij

Disconnect size_allocate when PlugIn deactivate

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

I would prefer not to set a static px limit here. We should change based on the side of the Line Width Guide and also if there are other panes open like the Folder Browser.

review: Needs Fixing (ux)
Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Hey Dan,

I didn't get any feedback on slack.com about this behavior. I use since a week this branch on my system and it's very helpful, although it will be checked the window width in pix, and not line width.

I think we can merge this branch.

What do you think about?

review: Needs Information ((ux))
1406. By artem-anufrij

move terminal back to bottombar if open two code views

1407. By artem-anufrij

move terminal back to bottombar if open two code views

1408. By artem-anufrij

Switching terminal location via context menu.

1409. By artem-anufrij

Change Menu items: Terminal on Right | Terminal on Bottom

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/terminal/terminal.vala'
2--- plugins/terminal/terminal.vala 2014-11-10 18:09:21 +0000
3+++ plugins/terminal/terminal.vala 2014-11-12 20:23:16 +0000
4@@ -26,7 +26,9 @@
5 public class Scratch.Plugins.Terminal : Peas.ExtensionBase, Peas.Activatable {
6
7 MainWindow window = null;
8+ Scratch.Widgets.SplitView splitview = null;
9 Gtk.Notebook? bottombar = null;
10+ Gtk.Notebook? contextbar = null;
11 Vte.Terminal terminal;
12 Gtk.Grid grid;
13
14@@ -37,51 +39,93 @@
15 }
16
17 public void activate () {
18+
19 plugins = (Scratch.Services.Interface) object;
20
21 plugins.hook_window.connect ((w) => {
22 if (window != null)
23 return;
24-
25+
26 window = w;
27+ window.size_allocate.connect (set_terminal_location);
28 window.key_press_event.connect (switch_focus);
29 });
30
31 plugins.hook_notebook_bottom.connect ((n) => {
32 if (bottombar == null) {
33 this.bottombar = n;
34- on_hook (this.bottombar);
35- }
36- });
37- if (bottombar != null)
38- on_hook (this.bottombar);
39+ }
40+ });
41+
42+ plugins.hook_notebook_context.connect ((n) => {
43+ if (contextbar == null) {
44+ this.contextbar = n;
45+ }
46+ });
47+
48+ plugins.hook_split_view.connect ((s) => {
49+ if (splitview != null)
50+ return;
51+
52+ this.splitview = s;
53+ splitview.views_changed.connect ((u) => { set_terminal_location (); });
54+ });
55+
56+ on_hook ();
57+ set_terminal_location ();
58 }
59
60 public void deactivate () {
61 if (terminal != null)
62 grid.destroy ();
63- if (window != null)
64- window.key_press_event.disconnect (switch_focus);
65+
66+ window.size_allocate.disconnect (set_terminal_location);
67+ window.key_press_event.disconnect (switch_focus);
68+ }
69+
70+ void set_terminal_location (Gtk.Allocation? alloc = null) {
71+ if (alloc == null) {
72+ window.get_allocation (out alloc);
73+ }
74+
75+ if (alloc.width > 1366 && splitview.views.length () == 1 && contextbar.page_num (grid) == -1 ) {
76+
77+ bottombar.remove_page (bottombar.page_num (grid));
78+ contextbar.append_page (grid, new Gtk.Label (_("Terminal")));
79+ debug ("Move Terminal: CONTEXTBAR.");
80+
81+ } else if ((alloc.width <= 1366 || splitview.views.length () > 1) && bottombar.page_num (grid) == -1) {
82+
83+ contextbar.remove_page (contextbar.page_num (grid));
84+ bottombar.append_page (grid, new Gtk.Label (_("Terminal")));
85+ debug ("Move Terminal: BOTTOMBAR.");
86+
87+ }
88 }
89
90 bool switch_focus (Gdk.EventKey event) {
91 if (event.keyval == Gdk.Key.t
92 && Gdk.ModifierType.MOD1_MASK in event.state
93 && Gdk.ModifierType.CONTROL_MASK in event.state) {
94+
95 if (terminal.has_focus && window.get_current_document () != null) {
96+
97 window.get_current_document ().focus ();
98 debug ("Move focus: EDITOR.");
99 return true;
100+
101 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {
102+
103 terminal.grab_focus ();
104 debug ("Move focus: TERMINAL.");
105 return true;
106+
107 }
108 }
109 return false;
110 }
111
112- void on_hook (Gtk.Notebook notebook) {
113+ void on_hook () {
114 this.terminal = new Vte.Terminal ();
115 this.terminal.scrollback_lines = -1;
116
117@@ -168,7 +212,7 @@
118 }
119 return false;
120 });
121-
122+
123 try {
124 this.terminal.fork_command_full (Vte.PtyFlags.DEFAULT, "~/", { Vte.get_user_shell () }, null, GLib.SpawnFlags.SEARCH_PATH, null, null);
125 } catch (GLib.Error e) {
126@@ -184,10 +228,7 @@
127 terminal.vexpand = true;
128 terminal.hexpand = true;
129
130- notebook.append_page (grid, new Gtk.Label (_("Terminal")));
131-
132 grid.show_all ();
133-
134 }
135 }
136
137@@ -196,4 +237,4 @@
138 var objmodule = module as Peas.ObjectModule;
139 objmodule.register_extension_type (typeof (Peas.Activatable),
140 typeof (Scratch.Plugins.Terminal));
141-}
142\ No newline at end of file
143+}
144
145=== modified file 'src/MainWindow.vala'
146--- src/MainWindow.vala 2014-11-10 18:09:21 +0000
147+++ src/MainWindow.vala 2014-11-12 20:23:16 +0000
148@@ -215,13 +215,21 @@
149
150 this.contextbar = new Gtk.Notebook ();
151 this.contextbar.no_show_all = true;
152- this.contextbar.page_added.connect (() => { on_plugin_toggled (contextbar); });
153 this.contextbar.page_removed.connect (() => { on_plugin_toggled (contextbar); });
154+ this.contextbar.page_added.connect (() => {
155+ if (!this.split_view.is_empty ())
156+ on_plugin_toggled (contextbar);
157+ });
158+
159+
160
161 this.bottombar = new Gtk.Notebook ();
162 this.bottombar.no_show_all = true;
163- this.bottombar.page_added.connect (() => { on_plugin_toggled (bottombar); });
164 this.bottombar.page_removed.connect (() => { on_plugin_toggled (bottombar); });
165+ this.bottombar.page_added.connect (() => {
166+ if (!this.split_view.is_empty ())
167+ on_plugin_toggled (bottombar);
168+ });
169
170 hp1 = new Granite.Widgets.ThinPaned ();
171 hp2 = new Granite.Widgets.ThinPaned ();
172@@ -288,7 +296,7 @@
173 set_widgets_sensitive (!split_view.is_empty ());
174 }
175
176- private void on_plugin_toggled (Gtk.Notebook notebook) {
177+ private void on_plugin_toggled (Gtk.Notebook notebook) {
178 var pages = notebook.get_n_pages ();
179 notebook.set_show_tabs (pages > 1);
180 notebook.no_show_all = (pages == 0);
181
182=== modified file 'src/Widgets/SplitView.vala'
183--- src/Widgets/SplitView.vala 2014-10-26 08:26:36 +0000
184+++ src/Widgets/SplitView.vala 2014-11-12 20:23:16 +0000
185@@ -35,6 +35,7 @@
186 public signal void welcome_shown ();
187 public signal void welcome_hidden ();
188 public signal void document_change (Scratch.Services.Document document);
189+ public signal void views_changed (uint count);
190
191 private weak MainWindow window;
192
193@@ -126,7 +127,6 @@
194
195 // Enbale/Disable useless GtkActions about views
196 check_actions ();
197-
198 return view;
199 }
200
201@@ -199,6 +199,8 @@
202 private void check_actions () {
203 window.main_actions.get_action ("NewView").sensitive = (views.length () < 2);
204 window.main_actions.get_action ("RemoveView").sensitive = (views.length () > 1);
205+
206+ views_changed (views.length ());
207 }
208 }
209 }
210\ No newline at end of file
211
212=== modified file 'src/Widgets/ToolBar.vala'
213--- src/Widgets/ToolBar.vala 2014-10-28 18:20:18 +0000
214+++ src/Widgets/ToolBar.vala 2014-11-12 20:23:16 +0000
215@@ -91,6 +91,7 @@
216 pack_start (revert_button);
217 pack_start (new SeparatorToolItem ());
218 pack_start (find_button);
219+ pack_start (find_button);
220
221 pack_end (share_app_menu);
222 pack_end (zoom_default);
223@@ -106,4 +107,4 @@
224
225 }
226 }
227-}
228\ No newline at end of file
229+}

Subscribers

People subscribed via source and target branches