Skip to content

Commit 7ea86db

Browse files
authored
Merge branch 'master' into jeremypw/terminal/no-settings-schema
2 parents 031a537 + 0dde465 commit 7ea86db

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Widgets/Terminal.vala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ public class Code.Terminal : Gtk.Box {
116116
update_colors ();
117117

118118
terminal.child_exited.connect (() => {
119-
GLib.Application.get_default ().activate_action (Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_TOGGLE_TERMINAL, null);
119+
//Hide the exited terminal
120+
var win_group = get_action_group (Scratch.MainWindow.ACTION_GROUP);
121+
win_group.activate_action (Scratch.MainWindow.ACTION_TOGGLE_TERMINAL, null);
122+
//Get ready to resume at last saved location
123+
spawn_shell (Scratch.saved_state.get_string ("last-opened-path"));
124+
//Clear screen of new shell
125+
terminal.feed_child ("clear -x\n".data);
120126
});
121127

122128
var copy_action = new SimpleAction (ACTION_COPY, null);
@@ -161,16 +167,15 @@ public class Code.Terminal : Gtk.Box {
161167
copy_action.set_enabled (terminal.get_has_selection ());
162168
});
163169

164-
var settings = new Settings (Constants.PROJECT_NAME + ".saved-state");
165-
spawn_shell (settings.get_string ("last-opened-path"));
170+
spawn_shell (Scratch.saved_state.get_string ("last-opened-path"));
166171

167172
var scrolled_window = new Gtk.ScrolledWindow (null, terminal.get_vadjustment ());
168173
scrolled_window.add (terminal);
169174

170175
add (scrolled_window);
171176

172177
destroy.connect (() => {
173-
settings.set_string ("last-opened-path", get_shell_location ());
178+
Scratch.saved_state.set_string ("last-opened-path", get_shell_location ());
174179
});
175180

176181
show_all ();
@@ -197,6 +202,7 @@ public class Code.Terminal : Gtk.Box {
197202
Posix.kill (child_pid, Posix.Signal.TERM);
198203
terminal.reset (true, true);
199204
spawn_shell (dir);
205+
Scratch.saved_state.set_string ("last-opened-path", dir);
200206
}
201207

202208
private string get_shell_location () {

0 commit comments

Comments
 (0)