Merge lp:~artem-anufrij/scratch/hide-plugins-on-welcome-screen into lp:~elementary-apps/scratch/scratch

Proposed by Artem Anufrij
Status: Merged
Approved by: Robert Roth
Approved revision: 1407
Merged at revision: 1407
Proposed branch: lp:~artem-anufrij/scratch/hide-plugins-on-welcome-screen
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 218 lines (+60/-41)
3 files modified
plugins/browser-preview/browser-preview.vala (+26/-16)
plugins/terminal/terminal.vala (+20/-19)
src/MainWindow.vala (+14/-6)
To merge this branch: bzr merge lp:~artem-anufrij/scratch/hide-plugins-on-welcome-screen
Reviewer Review Type Date Requested Status
Robert Roth (community) Approve
Review via email: mp+241312@code.launchpad.net

Commit message

Hide the bottom and right side plugins on welcome screen (lp:1390895)

Description of the change

Hide the bottom and right side plugins on welcome screen.

To post a comment you must log in.
Revision history for this message
Robert Roth (evfool) wrote :

Branch works as expected, code style is fine, approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/browser-preview/browser-preview.vala'
--- plugins/browser-preview/browser-preview.vala 2014-11-09 16:08:42 +0000
+++ plugins/browser-preview/browser-preview.vala 2014-11-10 18:12:24 +0000
@@ -41,12 +41,12 @@
41 public void activate () {41 public void activate () {
42 plugins = (Scratch.Services.Interface) object;42 plugins = (Scratch.Services.Interface) object;
4343
44 plugins.hook_document.connect ((d) => {44 plugins.hook_window.connect ((w) => {
45 this.doc = d;45 set_current_document (w.get_current_document ());
46 this.doc.doc_saved.disconnect (show_preview);
47 this.doc.doc_saved.connect (show_preview);
48 });46 });
4947
48 plugins.hook_document.connect (set_current_document);
49
50 plugins.hook_split_view.connect (on_hook_split_view);50 plugins.hook_split_view.connect (on_hook_split_view);
5151
52 plugins.hook_notebook_context.connect (on_hook_context);52 plugins.hook_notebook_context.connect (on_hook_context);
@@ -60,23 +60,15 @@
6060
61 if (plugin_tab != null)61 if (plugin_tab != null)
62 plugin_tab.destroy ();62 plugin_tab.destroy ();
63
64 }63 }
6564
66 void on_hook_split_view (Scratch.Widgets.SplitView view) {65 void on_hook_split_view (Scratch.Widgets.SplitView view) {
67 this.tool_button.visible = ! view.is_empty ();66 this.tool_button.visible = ! view.is_empty ();
68 this.tool_button.no_show_all = view.is_empty ();
69 view.welcome_shown.connect (() => {67 view.welcome_shown.connect (() => {
70 this.tool_button.visible = false;68 this.tool_button.visible = false;
71 this.tool_button.no_show_all = true;
72 if (notebook.page_num (plugin_tab) != -1)
73 notebook.remove (plugin_tab);
74 });69 });
75 view.welcome_hidden.connect (() => {70 view.welcome_hidden.connect (() => {
76 this.tool_button.visible = true;71 this.tool_button.visible = true;
77 this.tool_button.no_show_all = false;
78 if (notebook.page_num (plugin_tab) == -1)
79 notebook.append_page (plugin_tab, new Gtk.Label (_("Web preview")));
80 });72 });
81 }73 }
8274
@@ -86,10 +78,8 @@
8678
87 var icon = new Gtk.Image.from_icon_name ("emblem-web", Gtk.IconSize.LARGE_TOOLBAR);79 var icon = new Gtk.Image.from_icon_name ("emblem-web", Gtk.IconSize.LARGE_TOOLBAR);
88 tool_button = new Gtk.ToolButton (icon, _("Get preview!"));80 tool_button = new Gtk.ToolButton (icon, _("Get preview!"));
89 tool_button.tooltip_text = _("Get preview!");81 tool_button.tooltip_text = _("Hide preview");
90 tool_button.clicked.connect (() => {82 tool_button.clicked.connect (toggle_plugin_visibility);
91 show_preview () ;
92 });
9383
94 icon.show ();84 icon.show ();
95 tool_button.show ();85 tool_button.show ();
@@ -104,6 +94,7 @@
104 this.notebook = notebook;94 this.notebook = notebook;
10595
106 plugin_tab = new Gtk.Paned (Gtk.Orientation.VERTICAL);96 plugin_tab = new Gtk.Paned (Gtk.Orientation.VERTICAL);
97
107 view = new BrowserPreview.BrowserView (plugin_tab);98 view = new BrowserPreview.BrowserView (plugin_tab);
10899
109 notebook.append_page (plugin_tab, new Gtk.Label (_("Web preview")));100 notebook.append_page (plugin_tab, new Gtk.Label (_("Web preview")));
@@ -111,6 +102,25 @@
111 plugin_tab.show_all ();102 plugin_tab.show_all ();
112 }103 }
113104
105 void toggle_plugin_visibility () {
106 if (notebook.page_num (plugin_tab) == -1) {
107 notebook.append_page (plugin_tab, new Gtk.Label (_("Web preview")));
108 tool_button.tooltip_text = _("Hide preview");
109 } else {
110 notebook.remove (plugin_tab);
111 tool_button.tooltip_text = _("Show preview");
112 }
113 }
114
115 void set_current_document (Scratch.Services.Document? d) {
116 if (d != null) {
117 this.doc = d;
118 this.doc.doc_saved.disconnect (show_preview);
119 this.doc.doc_saved.connect (show_preview);
120 show_preview ();
121 }
122 }
123
114 void show_preview () {124 void show_preview () {
115 // Get uri125 // Get uri
116 if (this.doc.file == null)126 if (this.doc.file == null)
117127
=== modified file 'plugins/terminal/terminal.vala'
--- plugins/terminal/terminal.vala 2014-11-08 20:46:59 +0000
+++ plugins/terminal/terminal.vala 2014-11-10 18:12:24 +0000
@@ -29,7 +29,6 @@
29 Gtk.Notebook? bottombar = null;29 Gtk.Notebook? bottombar = null;
30 Vte.Terminal terminal;30 Vte.Terminal terminal;
31 Gtk.Grid grid;31 Gtk.Grid grid;
32 ulong? connect_handler;
3332
34 Scratch.Services.Interface plugins;33 Scratch.Services.Interface plugins;
35 public Object object { owned get; construct; }34 public Object object { owned get; construct; }
@@ -45,22 +44,7 @@
45 return;44 return;
46 45
47 window = w;46 window = w;
48 connect_handler = window.key_press_event.connect ((event) => {47 window.key_press_event.connect (switch_focus);
49 if (event.keyval == Gdk.Key.t
50 && Gdk.ModifierType.MOD1_MASK in event.state
51 && Gdk.ModifierType.CONTROL_MASK in event.state) {
52 if (terminal.has_focus && window.get_current_document () != null) {
53 window.get_current_document ().focus ();
54 debug ("Move focus: EDITOR.");
55 return true;
56 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {
57 terminal.grab_focus ();
58 debug ("Move focus: TERMINAL.");
59 return true;
60 }
61 }
62 return false;
63 });
64 });48 });
6549
66 plugins.hook_notebook_bottom.connect ((n) => {50 plugins.hook_notebook_bottom.connect ((n) => {
@@ -76,8 +60,25 @@
76 public void deactivate () {60 public void deactivate () {
77 if (terminal != null)61 if (terminal != null)
78 grid.destroy ();62 grid.destroy ();
79 if (connect_handler != null)63 if (window != null)
80 window.disconnect ((ulong)connect_handler);64 window.key_press_event.disconnect (switch_focus);
65 }
66
67 bool switch_focus (Gdk.EventKey event) {
68 if (event.keyval == Gdk.Key.t
69 && Gdk.ModifierType.MOD1_MASK in event.state
70 && Gdk.ModifierType.CONTROL_MASK in event.state) {
71 if (terminal.has_focus && window.get_current_document () != null) {
72 window.get_current_document ().focus ();
73 debug ("Move focus: EDITOR.");
74 return true;
75 } else if (window.get_current_document () != null && window.get_current_document ().source_view.has_focus) {
76 terminal.grab_focus ();
77 debug ("Move focus: TERMINAL.");
78 return true;
79 }
80 }
81 return false;
81 }82 }
8283
83 void on_hook (Gtk.Notebook notebook) {84 void on_hook (Gtk.Notebook notebook) {
8485
=== modified file 'src/MainWindow.vala'
--- src/MainWindow.vala 2014-11-02 11:16:30 +0000
+++ src/MainWindow.vala 2014-11-10 18:12:24 +0000
@@ -175,7 +175,6 @@
175 // Signals175 // Signals
176 this.split_view.welcome_shown.connect (() => {176 this.split_view.welcome_shown.connect (() => {
177 set_widgets_sensitive (false);177 set_widgets_sensitive (false);
178
179 });178 });
180 this.split_view.welcome_hidden.connect (() => {179 this.split_view.welcome_hidden.connect (() => {
181 set_widgets_sensitive (true);180 set_widgets_sensitive (true);
@@ -278,15 +277,15 @@
278 plugins.hook_notebook_sidebar (this.sidebar);277 plugins.hook_notebook_sidebar (this.sidebar);
279 plugins.hook_notebook_context (this.contextbar);278 plugins.hook_notebook_context (this.contextbar);
280 plugins.hook_notebook_bottom (this.bottombar);279 plugins.hook_notebook_bottom (this.bottombar);
281 this.split_view.document_change.connect ((doc) => {280 this.split_view.document_change.connect ((doc) => { plugins.hook_document (doc); });
282 plugins.hook_document (doc);
283 });
284 plugins.hook_split_view (this.split_view);281 plugins.hook_split_view (this.split_view);
285 };282 };
286 plugins.extension_added.connect (() => {283 plugins.extension_added.connect (() => {
287 hook_func ();284 hook_func ();
288 });285 });
289 hook_func ();286 hook_func ();
287
288 set_widgets_sensitive (!split_view.is_empty ());
290 }289 }
291290
292 private void on_plugin_toggled (Gtk.Notebook notebook) {291 private void on_plugin_toggled (Gtk.Notebook notebook) {
@@ -317,6 +316,15 @@
317 main_actions.get_action ("Redo").sensitive = val;316 main_actions.get_action ("Redo").sensitive = val;
318 main_actions.get_action ("Revert").sensitive = val;317 main_actions.get_action ("Revert").sensitive = val;
319 this.toolbar.share_app_menu.sensitive = val;318 this.toolbar.share_app_menu.sensitive = val;
319
320 // PlugIns
321 if (val) {
322 on_plugin_toggled (this.contextbar);
323 on_plugin_toggled (this.bottombar);
324 } else {
325 this.contextbar.visible = val;
326 this.bottombar.visible = val;
327 }
320 }328 }
321329
322 // Get current view330 // Get current view
@@ -335,7 +343,7 @@
335 // Get current document343 // Get current document
336 public Scratch.Services.Document? get_current_document () {344 public Scratch.Services.Document? get_current_document () {
337 Scratch.Services.Document? doc = null;345 Scratch.Services.Document? doc = null;
338 346
339 var view = this.get_current_view ();347 var view = this.get_current_view ();
340 if (view != null)348 if (view != null)
341 doc = view.get_current_document ();349 doc = view.get_current_document ();
@@ -897,4 +905,4 @@
897 action_fullscreen }905 action_fullscreen }
898 };906 };
899 }907 }
900}
901\ No newline at end of file908\ No newline at end of file
909}

Subscribers

People subscribed via source and target branches