Merge lp:~superscript18/scratch/fix-1013421 into lp:~elementary-apps/scratch/scratch

Proposed by SuperScript
Status: Merged
Approved by: Artem Anufrij
Approved revision: 1425
Merged at revision: 1423
Proposed branch: lp:~superscript18/scratch/fix-1013421
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 106 lines (+51/-8)
1 file modified
plugins/terminal/terminal.vala (+51/-8)
To merge this branch: bzr merge lp:~superscript18/scratch/fix-1013421
Reviewer Review Type Date Requested Status
Artem Anufrij (community) code & ux Approve
Review via email: mp+243059@code.launchpad.net

Commit message

Added Terminal plugin toggle button. Fixes bug 1013421

Description of the change

Added Terminal plugin toggle button. Fixes bug 1013421

To post a comment you must log in.
1419. By SuperScript

Fixed not removing icon with plugin. Also not showing is default now.

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

Please resolve the code conflicts.
(brz merge lp:scratch)

Caution: Terminal can be switched between the bottombar or contextbar (right).

https://bugs.launchpad.net/scratch/+bug/1085718

review: Needs Fixing (code)
1420. By SuperScript

Trying to fix with new sidebar stuff.

1421. By SuperScript

Merged in code for right-side switch. Now working again.

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

Tooltip should switch between "Show terminal" and "hide Terminal" like browser toggle button.

See line comments

review: Needs Fixing (code)
Revision history for this message
Artem Anufrij (artem-anufrij) wrote :
1422. By SuperScript

Made the tooltip toggle between show and hide.

1423. By SuperScript

Made the tooltip toggle between show and hide.

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

After "Show Terminal" Terminal should be showed in the foreground.

See my screencast:
https://bugs.launchpad.net/scratch/+bug/1013421/+attachment/4273655/+files/Screencast%202014-12-03%2020%3A41%3A01.mp4

review: Needs Fixing (ux)
1424. By SuperScript

Terminal goes to foreground now.

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

line comments

review: Needs Fixing (code style)
1425. By SuperScript

Fixed coding style, removed junk.

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

Works as expected. Code style was reviewed!

Great work! Thank you!

review: Approve (code & ux)

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-30 23:20:55 +0000
+++ plugins/terminal/terminal.vala 2014-12-03 20:42:43 +0000
@@ -29,7 +29,11 @@
2929
30 Gtk.Notebook? bottombar = null;30 Gtk.Notebook? bottombar = null;
31 Gtk.Notebook? contextbar = null;31 Gtk.Notebook? contextbar = null;
32 32 Scratch.Widgets.Toolbar? toolbar = null;
33 Gtk.ToggleToolButton? toolbutton = null;
34
35 bool on_bottom = true;
36
33 Gtk.RadioMenuItem location_bottom = null;37 Gtk.RadioMenuItem location_bottom = null;
34 Gtk.RadioMenuItem location_right = null;38 Gtk.RadioMenuItem location_right = null;
3539
@@ -58,7 +62,6 @@
58 if (bottombar == null) {62 if (bottombar == null) {
59 this.bottombar = n;63 this.bottombar = n;
60 }64 }
61 switch_terminal_location ();
62 });65 });
6366
64 plugins.hook_notebook_context.connect ((n) => {67 plugins.hook_notebook_context.connect ((n) => {
@@ -67,28 +70,39 @@
67 }70 }
68 });71 });
6972
70 on_hook ();73 plugins.hook_toolbar.connect ((n) => {
74 if (toolbar == null) {
75 this.toolbar = n;
76 on_hook_toolbar (this.toolbar);
77 }
78 });
79
80 on_hook_notebook ();
71 }81 }
7282
73 public void deactivate () {83 public void deactivate () {
74 if (terminal != null)84 if (terminal != null)
75 grid.destroy ();85 grid.destroy ();
86 if (toolbutton != null)
87 toolbutton.destroy ();
7688
77 window.key_press_event.disconnect (switch_focus);89 window.key_press_event.disconnect (switch_focus);
78 }90 }
7991
80 void switch_terminal_location () {92 void switch_terminal_location () {
81 93
82 if (bottombar.page_num (grid) == -1 && this.location_bottom.active) {94 if (bottombar.page_num (grid) == -1 && this.location_bottom.active) {
8395
84 contextbar.remove_page (contextbar.page_num (grid));96 contextbar.remove_page (contextbar.page_num (grid));
85 bottombar.append_page (grid, new Gtk.Label (_("Terminal")));97 bottombar.set_current_page (bottombar.append_page (grid, new Gtk.Label (_("Terminal"))));
98 on_bottom = true;
86 debug ("Move Terminal: BOTTOMBAR.");99 debug ("Move Terminal: BOTTOMBAR.");
87 100
88 } else if (contextbar.page_num (grid) == -1 && this.location_right.active) {101 } else if (contextbar.page_num (grid) == -1 && this.location_right.active) {
89102
90 bottombar.remove_page (bottombar.page_num (grid));103 bottombar.remove_page (bottombar.page_num (grid));
91 contextbar.append_page (grid, new Gtk.Label (_("Terminal")));104 contextbar.set_current_page (contextbar.append_page (grid, new Gtk.Label (_("Terminal"))));
105 on_bottom = false;
92 debug ("Move Terminal: CONTEXTBAR.");106 debug ("Move Terminal: CONTEXTBAR.");
93107
94 }108 }
@@ -116,7 +130,36 @@
116 return false;130 return false;
117 }131 }
118132
119 void on_hook () {133 void on_hook_toolbar (Scratch.Widgets.Toolbar toolbar) {
134 var icon = new Gtk.Image.from_icon_name ("utilities-terminal", Gtk.IconSize.LARGE_TOOLBAR);
135 toolbutton = new Gtk.ToggleToolButton ();
136 toolbutton.set_icon_widget (icon);
137 toolbutton.set_active (false);
138 toolbutton.tooltip_text = _("Show Terminal");
139 toolbutton.toggled.connect (() => {
140 if (this.toolbutton.active) {
141 toolbutton.tooltip_text = _("Hide Terminal");
142 if (on_bottom) {
143 bottombar.set_current_page (bottombar.append_page (grid, new Gtk.Label (_("Terminal"))));
144 } else {
145 contextbar.set_current_page (contextbar.append_page (grid, new Gtk.Label (_("Terminal"))));
146 }
147 } else {
148 toolbutton.tooltip_text = _("Show Terminal");
149 if (on_bottom) {
150 bottombar.remove_page (bottombar.page_num (grid));
151 } else {
152 contextbar.remove_page (contextbar.page_num (grid));
153 }
154 }
155 });
156
157 toolbutton.show_all ();
158
159 toolbar.pack_start (toolbutton);
160 }
161
162 void on_hook_notebook () {
120 this.terminal = new Vte.Terminal ();163 this.terminal = new Vte.Terminal ();
121 this.terminal.scrollback_lines = -1;164 this.terminal.scrollback_lines = -1;
122165

Subscribers

People subscribed via source and target branches