Merge lp:~voldyman/pantheon-terminal/fixed-917766 into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Akshay Shekher
Status: Merged
Merged at revision: 306
Proposed branch: lp:~voldyman/pantheon-terminal/fixed-917766
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 154 lines (+51/-7)
4 files modified
org.elementary.pantheon-terminal.gschema.xml (+5/-0)
src/PantheonTerminalWindow.vala (+34/-7)
src/Settings.vala (+1/-0)
src/TerminalWidget.vala (+11/-0)
To merge this branch: bzr merge lp:~voldyman/pantheon-terminal/fixed-917766
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Review via email: mp+119709@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Approve to make branch go away.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'org.elementary.pantheon-terminal.gschema.xml'
2--- org.elementary.pantheon-terminal.gschema.xml 2012-08-11 02:59:46 +0000
3+++ org.elementary.pantheon-terminal.gschema.xml 2012-08-15 13:23:20 +0000
4@@ -22,6 +22,11 @@
5 <summary>The saved state of the window.</summary>
6 <description>The saved state of the window.</description>
7 </key>
8+ <key name="tabs" type="s">
9+ <default>""</default>
10+ <summary>List of tabs which were active when the window was closed</summary>
11+ <description>List of tabs which were active when the window was closed</description>
12+ </key>
13 </schema>
14
15 <schema path="/org/pantheon/pantheon-terminal/settings/" id="org.elementary.PantheonTerminal.Settings" gettext-domain="pantheon-terminal">
16
17=== modified file 'src/PantheonTerminalWindow.vala'
18--- src/PantheonTerminalWindow.vala 2012-08-11 02:59:46 +0000
19+++ src/PantheonTerminalWindow.vala 2012-08-15 13:23:20 +0000
20@@ -112,7 +112,7 @@
21
22 term_font = FontDescription.from_string (get_term_font ());
23
24- new_tab ();
25+ open_tabs ();
26 }
27
28 private void setup_ui () {
29@@ -125,7 +125,7 @@
30 notebook.allow_new_window = true;
31
32 notebook.tab_added.connect ((tab) => {
33- new_tab (tab);
34+ new_tab ("", tab);
35 });
36
37 notebook.tab_removed.connect ((tab) => {
38@@ -240,6 +240,15 @@
39 PantheonTerminal.saved_state.window_width = width;
40 PantheonTerminal.saved_state.window_height = height;
41 }
42+
43+ saved_state.tabs = "";
44+ string tab_loc;
45+ foreach (var t in terminals) {
46+ t = (TerminalWidget) t;
47+ tab_loc = t.get_shell_location ();
48+ if (tab_loc != "")
49+ saved_state.tabs += tab_loc + ",";
50+ }
51 }
52
53 void on_switch_page (Granite.Widgets.Tab? old, Granite.Widgets.Tab new_tab) {
54@@ -249,7 +258,18 @@
55 new_tab.page.grab_focus ();
56 }
57
58- private void new_tab (owned Granite.Widgets.Tab? tab=null) {
59+ private void open_tabs () {
60+ if (saved_state.tabs == "")
61+ new_tab ();
62+ else {
63+ foreach (string loc in saved_state.tabs.split (",")) {
64+ if (loc != "")
65+ new_tab (loc);
66+ }
67+ }
68+ }
69+
70+ private void new_tab (string location="", owned Granite.Widgets.Tab? tab=null) {
71 /* Set up terminal */
72 var t = new TerminalWidget (main_actions, ui, this);
73 t.scrollback_lines = settings.scrollback_lines;
74@@ -264,7 +284,10 @@
75 t.hexpand = true;
76
77 /* Set up the virtual terminal */
78- t.active_shell ();
79+ if (location == "")
80+ t.active_shell ();
81+ else
82+ t.active_shell (location);
83
84 /* Set up actions releated to the terminal */
85 main_actions.get_action ("Copy").set_sensitive (t.get_has_selection ());
86@@ -349,14 +372,16 @@
87 protected override bool delete_event (Gdk.EventAny event) {
88 update_saved_state ();
89 action_quit ();
90+ string tabs = "";
91
92 foreach (var t in terminals) {
93- if (((TerminalWidget)t).has_foreground_process ()) {
94+ t = (TerminalWidget) t;
95+ tabs += t.get_shell_location () + ",";
96+ if (t.has_foreground_process ()) {
97 var d = new ForegroundProcessDialog.before_close ();
98 if (d.run () == 1) {
99- ((TerminalWidget) t).kill_ps_and_fg ();
100+ t.kill_ps_and_fg ();
101 d.destroy ();
102- return false;
103 } else {
104 d.destroy ();
105 return true;
106@@ -364,6 +389,7 @@
107 }
108 }
109
110+ saved_state.tabs = tabs;
111 return false;
112 }
113
114@@ -388,6 +414,7 @@
115
116 void action_close_tab () {
117 notebook.remove_tab (notebook.current);
118+ terminals.remove (current_terminal);
119 }
120
121 void action_new_window () {
122
123=== modified file 'src/Settings.vala'
124--- src/Settings.vala 2012-08-11 02:59:46 +0000
125+++ src/Settings.vala 2012-08-15 13:23:20 +0000
126@@ -34,6 +34,7 @@
127 public int window_width { get; set; }
128 public int window_height { get; set; }
129 public PantheonTerminalWindowState window_state { get; set; }
130+ public string tabs { get; set; }
131
132 public SavedState () {
133 base ("org.elementary.PantheonTerminal.SavedState");
134
135=== modified file 'src/TerminalWidget.vala'
136--- src/TerminalWidget.vala 2012-08-04 17:42:18 +0000
137+++ src/TerminalWidget.vala 2012-08-15 13:23:20 +0000
138@@ -191,5 +191,16 @@
139 return this.match_check(col, row, out tag);
140
141 }
142+
143+ public string get_shell_location () {
144+ int pid = (!) (this.child_pid);
145+
146+ try {
147+ return GLib.FileUtils.read_link ("/proc/%d/cwd".printf(pid));
148+ } catch(GLib.FileError error) {
149+ warning ("An error occured while fetching the current dir of shell");
150+ }
151+ return "";
152+ }
153 }
154 }

Subscribers

People subscribed via source and target branches