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: 252 lines (+73/-21)
4 files modified
plugins/terminal/terminal.vala (+57/-16)
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
Danielle Foré ux Pending
Artem Anufrij (ux) Pending
Review via email: mp+241621@code.launchpad.net

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

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

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 :
Revision history for this message
Cody Garver (codygarver) wrote :

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

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

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

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

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 :

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 :

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

1408. By artem-anufrij

Switching terminal location via context menu.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Could you please review the branch...

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
=== modified file 'plugins/terminal/terminal.vala'
--- plugins/terminal/terminal.vala 2014-11-10 18:09:21 +0000
+++ plugins/terminal/terminal.vala 2014-11-24 20:00:44 +0000
@@ -26,7 +26,12 @@
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.MenuItem location = null;
34
30 Vte.Terminal terminal;35 Vte.Terminal terminal;
31 Gtk.Grid grid;36 Gtk.Grid grid;
3237
@@ -37,12 +42,13 @@
37 }42 }
3843
39 public void activate () {44 public void activate () {
45
40 plugins = (Scratch.Services.Interface) object;46 plugins = (Scratch.Services.Interface) object;
4147
42 plugins.hook_window.connect ((w) => {48 plugins.hook_window.connect ((w) => {
43 if (window != null)49 if (window != null)
44 return;50 return;
45 51
46 window = w;52 window = w;
47 window.key_press_event.connect (switch_focus);53 window.key_press_event.connect (switch_focus);
48 });54 });
@@ -50,38 +56,68 @@
50 plugins.hook_notebook_bottom.connect ((n) => {56 plugins.hook_notebook_bottom.connect ((n) => {
51 if (bottombar == null) {57 if (bottombar == null) {
52 this.bottombar = n;58 this.bottombar = n;
53 on_hook (this.bottombar);59 }
54 }60 switch_terminal_location ();
55 });61 });
56 if (bottombar != null)62
57 on_hook (this.bottombar);63 plugins.hook_notebook_context.connect ((n) => {
64 if (contextbar == null) {
65 this.contextbar = n;
66 }
67 });
68
69 on_hook ();
58 }70 }
5971
60 public void deactivate () {72 public void deactivate () {
61 if (terminal != null)73 if (terminal != null)
62 grid.destroy ();74 grid.destroy ();
63 if (window != null)75
64 window.key_press_event.disconnect (switch_focus);76 window.key_press_event.disconnect (switch_focus);
77 }
78
79 void switch_terminal_location () {
80
81 if (bottombar.page_num (grid) == -1) {
82
83 contextbar.remove_page (contextbar.page_num (grid));
84 bottombar.append_page (grid, new Gtk.Label (_("Terminal")));
85 location.set_label (_("Move Terminal into contextbar"));
86 debug ("Move Terminal: BOTTOMBAR.");
87
88 } else if (contextbar.page_num (grid) == -1 ) {
89
90 bottombar.remove_page (bottombar.page_num (grid));
91 contextbar.append_page (grid, new Gtk.Label (_("Terminal")));
92 location.set_label (_("Move Terminal into bottombar"));
93 debug ("Move Terminal: CONTEXTBAR.");
94
95 }
65 }96 }
6697
67 bool switch_focus (Gdk.EventKey event) {98 bool switch_focus (Gdk.EventKey event) {
68 if (event.keyval == Gdk.Key.t99 if (event.keyval == Gdk.Key.t
69 && Gdk.ModifierType.MOD1_MASK in event.state100 && Gdk.ModifierType.MOD1_MASK in event.state
70 && Gdk.ModifierType.CONTROL_MASK in event.state) {101 && Gdk.ModifierType.CONTROL_MASK in event.state) {
102
71 if (terminal.has_focus && window.get_current_document () != null) {103 if (terminal.has_focus && window.get_current_document () != null) {
104
72 window.get_current_document ().focus ();105 window.get_current_document ().focus ();
73 debug ("Move focus: EDITOR.");106 debug ("Move focus: EDITOR.");
74 return true;107 return true;
108
75 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {109 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {
110
76 terminal.grab_focus ();111 terminal.grab_focus ();
77 debug ("Move focus: TERMINAL.");112 debug ("Move focus: TERMINAL.");
78 return true;113 return true;
114
79 }115 }
80 }116 }
81 return false;117 return false;
82 }118 }
83119
84 void on_hook (Gtk.Notebook notebook) {120 void on_hook () {
85 this.terminal = new Vte.Terminal ();121 this.terminal = new Vte.Terminal ();
86 this.terminal.scrollback_lines = -1;122 this.terminal.scrollback_lines = -1;
87123
@@ -147,20 +183,28 @@
147 // Popup menu183 // Popup menu
148 var menu = new Gtk.Menu ();184 var menu = new Gtk.Menu ();
149185
150 var copy = new Gtk.MenuItem.with_label (_("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 ();191 copy.show ();
156192
157 var paste = new Gtk.MenuItem.with_label (_("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 paste.show ();
163199
200 location = new Gtk.MenuItem.with_label ("");
201 location.activate.connect (() => {
202 switch_terminal_location ();
203 });
204
205 menu.append (location);
206 location.show ();
207
164 this.terminal.button_press_event.connect ((event) => {208 this.terminal.button_press_event.connect ((event) => {
165 if (event.button == 3) {209 if (event.button == 3) {
166 menu.select_first (false);210 menu.select_first (false);
@@ -168,7 +212,7 @@
168 }212 }
169 return false;213 return false;
170 });214 });
171 215
172 try {216 try {
173 this.terminal.fork_command_full (Vte.PtyFlags.DEFAULT, "~/", { Vte.get_user_shell () }, null, GLib.SpawnFlags.SEARCH_PATH, null, null);217 this.terminal.fork_command_full (Vte.PtyFlags.DEFAULT, "~/", { Vte.get_user_shell () }, null, GLib.SpawnFlags.SEARCH_PATH, null, null);
174 } catch (GLib.Error e) {218 } catch (GLib.Error e) {
@@ -184,10 +228,7 @@
184 terminal.vexpand = true;228 terminal.vexpand = true;
185 terminal.hexpand = true;229 terminal.hexpand = true;
186230
187 notebook.append_page (grid, new Gtk.Label (_("Terminal")));
188
189 grid.show_all ();231 grid.show_all ();
190
191 }232 }
192}233}
193234
@@ -196,4 +237,4 @@
196 var objmodule = module as Peas.ObjectModule;237 var objmodule = module as Peas.ObjectModule;
197 objmodule.register_extension_type (typeof (Peas.Activatable),238 objmodule.register_extension_type (typeof (Peas.Activatable),
198 typeof (Scratch.Plugins.Terminal));239 typeof (Scratch.Plugins.Terminal));
199}
200\ No newline at end of file240\ No newline at end of file
241}
201242
=== modified file 'src/MainWindow.vala'
--- src/MainWindow.vala 2014-11-23 10:44:26 +0000
+++ src/MainWindow.vala 2014-11-24 20:00:44 +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 20:00:44 +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 20:00:44 +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