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
=== modified file 'plugins/terminal/terminal.vala'
--- plugins/terminal/terminal.vala 2014-11-10 18:09:21 +0000
+++ plugins/terminal/terminal.vala 2014-11-12 20:23:16 +0000
@@ -26,7 +26,9 @@
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 Scratch.Widgets.SplitView splitview = null;
29 Gtk.Notebook? bottombar = null;30 Gtk.Notebook? bottombar = null;
31 Gtk.Notebook? contextbar = null;
30 Vte.Terminal terminal;32 Vte.Terminal terminal;
31 Gtk.Grid grid;33 Gtk.Grid grid;
3234
@@ -37,51 +39,93 @@
37 }39 }
3840
39 public void activate () {41 public void activate () {
42
40 plugins = (Scratch.Services.Interface) object;43 plugins = (Scratch.Services.Interface) object;
4144
42 plugins.hook_window.connect ((w) => {45 plugins.hook_window.connect ((w) => {
43 if (window != null)46 if (window != null)
44 return;47 return;
45 48
46 window = w;49 window = w;
50 window.size_allocate.connect (set_terminal_location);
47 window.key_press_event.connect (switch_focus);51 window.key_press_event.connect (switch_focus);
48 });52 });
4953
50 plugins.hook_notebook_bottom.connect ((n) => {54 plugins.hook_notebook_bottom.connect ((n) => {
51 if (bottombar == null) {55 if (bottombar == null) {
52 this.bottombar = n;56 this.bottombar = n;
53 on_hook (this.bottombar);57 }
54 }58 });
55 });59
56 if (bottombar != null)60 plugins.hook_notebook_context.connect ((n) => {
57 on_hook (this.bottombar);61 if (contextbar == null) {
62 this.contextbar = n;
63 }
64 });
65
66 plugins.hook_split_view.connect ((s) => {
67 if (splitview != null)
68 return;
69
70 this.splitview = s;
71 splitview.views_changed.connect ((u) => { set_terminal_location (); });
72 });
73
74 on_hook ();
75 set_terminal_location ();
58 }76 }
5977
60 public void deactivate () {78 public void deactivate () {
61 if (terminal != null)79 if (terminal != null)
62 grid.destroy ();80 grid.destroy ();
63 if (window != null)81
64 window.key_press_event.disconnect (switch_focus);82 window.size_allocate.disconnect (set_terminal_location);
83 window.key_press_event.disconnect (switch_focus);
84 }
85
86 void set_terminal_location (Gtk.Allocation? alloc = null) {
87 if (alloc == null) {
88 window.get_allocation (out alloc);
89 }
90
91 if (alloc.width > 1366 && splitview.views.length () == 1 && contextbar.page_num (grid) == -1 ) {
92
93 bottombar.remove_page (bottombar.page_num (grid));
94 contextbar.append_page (grid, new Gtk.Label (_("Terminal")));
95 debug ("Move Terminal: CONTEXTBAR.");
96
97 } else if ((alloc.width <= 1366 || splitview.views.length () > 1) && bottombar.page_num (grid) == -1) {
98
99 contextbar.remove_page (contextbar.page_num (grid));
100 bottombar.append_page (grid, new Gtk.Label (_("Terminal")));
101 debug ("Move Terminal: BOTTOMBAR.");
102
103 }
65 }104 }
66105
67 bool switch_focus (Gdk.EventKey event) {106 bool switch_focus (Gdk.EventKey event) {
68 if (event.keyval == Gdk.Key.t107 if (event.keyval == Gdk.Key.t
69 && Gdk.ModifierType.MOD1_MASK in event.state108 && Gdk.ModifierType.MOD1_MASK in event.state
70 && Gdk.ModifierType.CONTROL_MASK in event.state) {109 && Gdk.ModifierType.CONTROL_MASK in event.state) {
110
71 if (terminal.has_focus && window.get_current_document () != null) {111 if (terminal.has_focus && window.get_current_document () != null) {
112
72 window.get_current_document ().focus ();113 window.get_current_document ().focus ();
73 debug ("Move focus: EDITOR.");114 debug ("Move focus: EDITOR.");
74 return true;115 return true;
116
75 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {117 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {
118
76 terminal.grab_focus ();119 terminal.grab_focus ();
77 debug ("Move focus: TERMINAL.");120 debug ("Move focus: TERMINAL.");
78 return true;121 return true;
122
79 }123 }
80 }124 }
81 return false;125 return false;
82 }126 }
83127
84 void on_hook (Gtk.Notebook notebook) {128 void on_hook () {
85 this.terminal = new Vte.Terminal ();129 this.terminal = new Vte.Terminal ();
86 this.terminal.scrollback_lines = -1;130 this.terminal.scrollback_lines = -1;
87131
@@ -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-10 18:09:21 +0000
+++ src/MainWindow.vala 2014-11-12 20:23:16 +0000
@@ -215,13 +215,21 @@
215215
216 this.contextbar = new Gtk.Notebook ();216 this.contextbar = new Gtk.Notebook ();
217 this.contextbar.no_show_all = true;217 this.contextbar.no_show_all = true;
218 this.contextbar.page_added.connect (() => { on_plugin_toggled (contextbar); });
219 this.contextbar.page_removed.connect (() => { on_plugin_toggled (contextbar); });218 this.contextbar.page_removed.connect (() => { on_plugin_toggled (contextbar); });
219 this.contextbar.page_added.connect (() => {
220 if (!this.split_view.is_empty ())
221 on_plugin_toggled (contextbar);
222 });
223
224
220225
221 this.bottombar = new Gtk.Notebook ();226 this.bottombar = new Gtk.Notebook ();
222 this.bottombar.no_show_all = true;227 this.bottombar.no_show_all = true;
223 this.bottombar.page_added.connect (() => { on_plugin_toggled (bottombar); });
224 this.bottombar.page_removed.connect (() => { on_plugin_toggled (bottombar); });228 this.bottombar.page_removed.connect (() => { on_plugin_toggled (bottombar); });
229 this.bottombar.page_added.connect (() => {
230 if (!this.split_view.is_empty ())
231 on_plugin_toggled (bottombar);
232 });
225233
226 hp1 = new Granite.Widgets.ThinPaned ();234 hp1 = new Granite.Widgets.ThinPaned ();
227 hp2 = new Granite.Widgets.ThinPaned ();235 hp2 = new Granite.Widgets.ThinPaned ();
@@ -288,7 +296,7 @@
288 set_widgets_sensitive (!split_view.is_empty ());296 set_widgets_sensitive (!split_view.is_empty ());
289 }297 }
290298
291 private void on_plugin_toggled (Gtk.Notebook notebook) {299 private void on_plugin_toggled (Gtk.Notebook notebook) {
292 var pages = notebook.get_n_pages ();300 var pages = notebook.get_n_pages ();
293 notebook.set_show_tabs (pages > 1);301 notebook.set_show_tabs (pages > 1);
294 notebook.no_show_all = (pages == 0);302 notebook.no_show_all = (pages == 0);
295303
=== modified file 'src/Widgets/SplitView.vala'
--- src/Widgets/SplitView.vala 2014-10-26 08:26:36 +0000
+++ src/Widgets/SplitView.vala 2014-11-12 20:23:16 +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-12 20:23:16 +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