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
=== modified file 'plugins/terminal/terminal.vala'
--- plugins/terminal/terminal.vala 2014-11-10 18:09:21 +0000
+++ plugins/terminal/terminal.vala 2014-11-24 21:01:57 +0000
@@ -26,7 +26,13 @@
26public class Scratch.Plugins.Terminal : Peas.ExtensionBase, Peas.Activatable {26public class Scratch.Plugins.Terminal : Peas.ExtensionBase, Peas.Activatable {
2727
28 MainWindow window = null;28 MainWindow window = null;
29
29 Gtk.Notebook? bottombar = null;30 Gtk.Notebook? bottombar = null;
31 Gtk.Notebook? contextbar = null;
32
33 Gtk.RadioMenuItem location_bottom = null;
34 Gtk.RadioMenuItem location_right = null;
35
30 Vte.Terminal terminal;36 Vte.Terminal terminal;
31 Gtk.Grid grid;37 Gtk.Grid grid;
3238
@@ -37,12 +43,13 @@
37 }43 }
3844
39 public void activate () {45 public void activate () {
46
40 plugins = (Scratch.Services.Interface) object;47 plugins = (Scratch.Services.Interface) object;
4148
42 plugins.hook_window.connect ((w) => {49 plugins.hook_window.connect ((w) => {
43 if (window != null)50 if (window != null)
44 return;51 return;
45 52
46 window = w;53 window = w;
47 window.key_press_event.connect (switch_focus);54 window.key_press_event.connect (switch_focus);
48 });55 });
@@ -50,38 +57,66 @@
50 plugins.hook_notebook_bottom.connect ((n) => {57 plugins.hook_notebook_bottom.connect ((n) => {
51 if (bottombar == null) {58 if (bottombar == null) {
52 this.bottombar = n;59 this.bottombar = n;
53 on_hook (this.bottombar);60 }
54 }61 switch_terminal_location ();
55 });62 });
56 if (bottombar != null)63
57 on_hook (this.bottombar);64 plugins.hook_notebook_context.connect ((n) => {
65 if (contextbar == null) {
66 this.contextbar = n;
67 }
68 });
69
70 on_hook ();
58 }71 }
5972
60 public void deactivate () {73 public void deactivate () {
61 if (terminal != null)74 if (terminal != null)
62 grid.destroy ();75 grid.destroy ();
63 if (window != null)76
64 window.key_press_event.disconnect (switch_focus);77 window.key_press_event.disconnect (switch_focus);
78 }
79
80 void switch_terminal_location () {
81
82 if (bottombar.page_num (grid) == -1 && this.location_bottom.active) {
83
84 contextbar.remove_page (contextbar.page_num (grid));
85 bottombar.append_page (grid, new Gtk.Label (_("Terminal")));
86 debug ("Move Terminal: BOTTOMBAR.");
87
88 } else if (contextbar.page_num (grid) == -1 && this.location_right.active) {
89
90 bottombar.remove_page (bottombar.page_num (grid));
91 contextbar.append_page (grid, new Gtk.Label (_("Terminal")));
92 debug ("Move Terminal: CONTEXTBAR.");
93
94 }
65 }95 }
6696
67 bool switch_focus (Gdk.EventKey event) {97 bool switch_focus (Gdk.EventKey event) {
68 if (event.keyval == Gdk.Key.t98 if (event.keyval == Gdk.Key.t
69 && Gdk.ModifierType.MOD1_MASK in event.state99 && Gdk.ModifierType.MOD1_MASK in event.state
70 && Gdk.ModifierType.CONTROL_MASK in event.state) {100 && Gdk.ModifierType.CONTROL_MASK in event.state) {
101
71 if (terminal.has_focus && window.get_current_document () != null) {102 if (terminal.has_focus && window.get_current_document () != null) {
103
72 window.get_current_document ().focus ();104 window.get_current_document ().focus ();
73 debug ("Move focus: EDITOR.");105 debug ("Move focus: EDITOR.");
74 return true;106 return true;
107
75 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {108 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {
109
76 terminal.grab_focus ();110 terminal.grab_focus ();
77 debug ("Move focus: TERMINAL.");111 debug ("Move focus: TERMINAL.");
78 return true;112 return true;
113
79 }114 }
80 }115 }
81 return false;116 return false;
82 }117 }
83118
84 void on_hook (Gtk.Notebook notebook) {119 void on_hook () {
85 this.terminal = new Vte.Terminal ();120 this.terminal = new Vte.Terminal ();
86 this.terminal.scrollback_lines = -1;121 this.terminal.scrollback_lines = -1;
87122
@@ -147,19 +182,39 @@
147 // Popup menu182 // Popup menu
148 var menu = new Gtk.Menu ();183 var menu = new Gtk.Menu ();
149184
150 var copy = new Gtk.MenuItem.with_label (_("Copy"));185 // COPY
186 Gtk.MenuItem copy = new Gtk.MenuItem.with_label (_("Copy"));
151 copy.activate.connect (() => {187 copy.activate.connect (() => {
152 terminal.copy_clipboard ();188 terminal.copy_clipboard ();
153 });189 });
154 menu.append (copy);190 menu.append (copy);
155 copy.show ();
156191
157 var paste = new Gtk.MenuItem.with_label (_("Paste"));192 // PASTE
193 Gtk.MenuItem paste = new Gtk.MenuItem.with_label (_("Paste"));
158 paste.activate.connect (() => {194 paste.activate.connect (() => {
159 terminal.paste_clipboard ();195 terminal.paste_clipboard ();
160 });196 });
161 menu.append (paste);197 menu.append (paste);
162 paste.show ();198
199 // SEPARATOR
200 menu.append (new Gtk.SeparatorMenuItem ());
201
202 // ON RIGHT
203 location_right = new Gtk.RadioMenuItem.with_label (null, _("Terminal on Right"));
204 location_right.toggled.connect (() => {
205 switch_terminal_location ();
206 });
207 menu.append (location_right);
208
209 // ON BOTTOM
210 location_bottom = new Gtk.RadioMenuItem.with_label (location_right.get_group (), _("Terminal on Bottom"));
211 location_bottom.active = true;
212 location_bottom.toggled.connect (() => {
213 switch_terminal_location ();
214 });
215 menu.append (location_bottom);
216
217 menu.show_all ();
163218
164 this.terminal.button_press_event.connect ((event) => {219 this.terminal.button_press_event.connect ((event) => {
165 if (event.button == 3) {220 if (event.button == 3) {
@@ -168,7 +223,7 @@
168 }223 }
169 return false;224 return false;
170 });225 });
171 226
172 try {227 try {
173 this.terminal.fork_command_full (Vte.PtyFlags.DEFAULT, "~/", { Vte.get_user_shell () }, null, GLib.SpawnFlags.SEARCH_PATH, null, null);228 this.terminal.fork_command_full (Vte.PtyFlags.DEFAULT, "~/", { Vte.get_user_shell () }, null, GLib.SpawnFlags.SEARCH_PATH, null, null);
174 } catch (GLib.Error e) {229 } catch (GLib.Error e) {
@@ -184,10 +239,7 @@
184 terminal.vexpand = true;239 terminal.vexpand = true;
185 terminal.hexpand = true;240 terminal.hexpand = true;
186241
187 notebook.append_page (grid, new Gtk.Label (_("Terminal")));
188
189 grid.show_all ();242 grid.show_all ();
190
191 }243 }
192}244}
193245
@@ -196,4 +248,4 @@
196 var objmodule = module as Peas.ObjectModule;248 var objmodule = module as Peas.ObjectModule;
197 objmodule.register_extension_type (typeof (Peas.Activatable),249 objmodule.register_extension_type (typeof (Peas.Activatable),
198 typeof (Scratch.Plugins.Terminal));250 typeof (Scratch.Plugins.Terminal));
199}
200\ No newline at end of file251\ No newline at end of file
252}
201253
=== modified file 'src/MainWindow.vala'
--- src/MainWindow.vala 2014-11-23 10:44:26 +0000
+++ src/MainWindow.vala 2014-11-24 21:01:57 +0000
@@ -214,13 +214,21 @@
214214
215 this.contextbar = new Gtk.Notebook ();215 this.contextbar = new Gtk.Notebook ();
216 this.contextbar.no_show_all = true;216 this.contextbar.no_show_all = true;
217 this.contextbar.page_added.connect (() => { on_plugin_toggled (contextbar); });
218 this.contextbar.page_removed.connect (() => { on_plugin_toggled (contextbar); });217 this.contextbar.page_removed.connect (() => { on_plugin_toggled (contextbar); });
218 this.contextbar.page_added.connect (() => {
219 if (!this.split_view.is_empty ())
220 on_plugin_toggled (contextbar);
221 });
222
223
219224
220 this.bottombar = new Gtk.Notebook ();225 this.bottombar = new Gtk.Notebook ();
221 this.bottombar.no_show_all = true;226 this.bottombar.no_show_all = true;
222 this.bottombar.page_added.connect (() => { on_plugin_toggled (bottombar); });
223 this.bottombar.page_removed.connect (() => { on_plugin_toggled (bottombar); });227 this.bottombar.page_removed.connect (() => { on_plugin_toggled (bottombar); });
228 this.bottombar.page_added.connect (() => {
229 if (!this.split_view.is_empty ())
230 on_plugin_toggled (bottombar);
231 });
224232
225 hp1 = new Granite.Widgets.ThinPaned ();233 hp1 = new Granite.Widgets.ThinPaned ();
226 hp2 = new Granite.Widgets.ThinPaned ();234 hp2 = new Granite.Widgets.ThinPaned ();
@@ -287,7 +295,7 @@
287 set_widgets_sensitive (!split_view.is_empty ());295 set_widgets_sensitive (!split_view.is_empty ());
288 }296 }
289297
290 private void on_plugin_toggled (Gtk.Notebook notebook) {298 private void on_plugin_toggled (Gtk.Notebook notebook) {
291 var pages = notebook.get_n_pages ();299 var pages = notebook.get_n_pages ();
292 notebook.set_show_tabs (pages > 1);300 notebook.set_show_tabs (pages > 1);
293 notebook.no_show_all = (pages == 0);301 notebook.no_show_all = (pages == 0);
294302
=== modified file 'src/Widgets/SplitView.vala'
--- src/Widgets/SplitView.vala 2014-10-26 08:26:36 +0000
+++ src/Widgets/SplitView.vala 2014-11-24 21:01:57 +0000
@@ -35,6 +35,7 @@
35 public signal void welcome_shown ();35 public signal void welcome_shown ();
36 public signal void welcome_hidden ();36 public signal void welcome_hidden ();
37 public signal void document_change (Scratch.Services.Document document);37 public signal void document_change (Scratch.Services.Document document);
38 public signal void views_changed (uint count);
3839
39 private weak MainWindow window;40 private weak MainWindow window;
4041
@@ -126,7 +127,6 @@
126127
127 // Enbale/Disable useless GtkActions about views128 // Enbale/Disable useless GtkActions about views
128 check_actions ();129 check_actions ();
129
130 return view;130 return view;
131 }131 }
132132
@@ -199,6 +199,8 @@
199 private void check_actions () {199 private void check_actions () {
200 window.main_actions.get_action ("NewView").sensitive = (views.length () < 2);200 window.main_actions.get_action ("NewView").sensitive = (views.length () < 2);
201 window.main_actions.get_action ("RemoveView").sensitive = (views.length () > 1);201 window.main_actions.get_action ("RemoveView").sensitive = (views.length () > 1);
202
203 views_changed (views.length ());
202 }204 }
203 }205 }
204}206}
205\ No newline at end of file207\ No newline at end of file
206208
=== modified file 'src/Widgets/ToolBar.vala'
--- src/Widgets/ToolBar.vala 2014-10-28 18:20:18 +0000
+++ src/Widgets/ToolBar.vala 2014-11-24 21:01:57 +0000
@@ -91,6 +91,7 @@
91 pack_start (revert_button);91 pack_start (revert_button);
92 pack_start (new SeparatorToolItem ());92 pack_start (new SeparatorToolItem ());
93 pack_start (find_button);93 pack_start (find_button);
94 pack_start (find_button);
94 95
95 pack_end (share_app_menu);96 pack_end (share_app_menu);
96 pack_end (zoom_default);97 pack_end (zoom_default);
@@ -106,4 +107,4 @@
106107
107 }108 }
108 }109 }
109}
110\ No newline at end of file110\ No newline at end of file
111}

Subscribers

People subscribed via source and target branches