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

Proposed by Artem Anufrij
Status: Merged
Approved by: Raphael Isemann
Approved revision: 1409
Merged at revision: 1420
Proposed branch: lp:~artem-anufrij/scratch/Bugfix-1085718
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 264 lines (+86/-23)
4 files modified
plugins/terminal/terminal.vala (+70/-18)
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
Raphael Isemann (community) functionality, code-style Approve
Danielle Foré ux Approve
Artem Anufrij (ux) Pending
Review via email: mp+242706@code.launchpad.net

This proposal supersedes a proposal from 2014-11-12.

Commit message

Allow to set the position of the terminal via context-menu.

Description of the change

Switching terminal location via context menu.

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

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 : Posted in a previous version of this proposal

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))
Revision history for this message
Artem Anufrij (artem-anufrij) wrote : Posted in a previous version of this proposal
Revision history for this message
Cody Garver (codygarver) wrote : Posted in a previous version of this proposal

The terminal starts too slim, no? http://i.imgur.com/ODxhith.png

Revision history for this message
Artem Anufrij (artem-anufrij) wrote : Posted in a previous version of this proposal

@Cody:
It's the currently width of the right bar.

Revision history for this message
Danielle Foré (danrabbit) wrote : Posted in a previous version of this proposal

Yeah that's way too thin. And again, I don't think it's acceptable to hardcode a px size. We need to be smart about what a sane minimum size is for the terminal and also about what space we have available. hardcoding a px size doesn't take into account other plugins or when settings have been changed by the user.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote : Posted in a previous version of this proposal

Dan, what do you think about a button in the toolbar for manual switching the terminal location?

Revision history for this message
Danielle Foré (danrabbit) wrote : Posted in a previous version of this proposal

If we can't do it automatically, perhaps a context menu on the Terminal would be a little more subtle.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote : Posted in a previous version of this proposal

Could you please review the branch...

1409. By artem-anufrij

Change Menu items: Terminal on Right | Terminal on Bottom

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

Saw screenshots on Slack. Looks solid :)

review: Approve (ux)
Revision history for this message
Raphael Isemann (teemperor) wrote :

Looks fine to me in terms of functionality and code-style.

review: Approve (functionality, code-style)

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

Subscribers

People subscribed via source and target branches