Skip to content

Commit 893c2cc

Browse files
committed
Cleanup handling of tab icons
1 parent 1d0f477 commit 893c2cc

4 files changed

Lines changed: 30 additions & 13 deletions

File tree

src/Application.vala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,23 @@ public class Terminal.Application : Gtk.Application {
174174
return;
175175
}
176176

177-
var process_string = _("Process completed");
178-
var process_icon = new ThemedIcon ("process-completed-symbolic");
177+
var notification_title = _("Process completed");
178+
var notification_icon = new ThemedIcon ("process-completed-symbolic");
179+
var tab_state = TerminalWidget.TabState.COMPLETED;
179180
if (exit_status != 0) {
180-
process_string = _("Process exited with errors");
181-
process_icon = new ThemedIcon ("process-error-symbolic");
181+
notification_title = _("Process exited with errors");
182+
notification_icon = new ThemedIcon ("process-error-symbolic");
183+
tab_state = ERROR;
182184
}
183185

184186
if (terminal != terminal.main_window.current_terminal) {
185-
terminal.tab.icon = process_icon;
187+
terminal.tab_state = tab_state;
186188
}
187189

188190
if (!(get_active_window ().is_active)) {
189-
var notification = new Notification (process_string);
191+
var notification = new Notification (notification_title);
190192
notification.set_body (process);
191-
notification.set_icon (process_icon);
193+
notification.set_icon (notification_icon);
192194
notification.set_default_action_and_target_value ("app.process-finished", new Variant.string (id));
193195
send_notification ("process-finished-%s".printf (id), notification);
194196

@@ -215,7 +217,7 @@ public class Terminal.Application : Gtk.Application {
215217
return;
216218
}
217219

218-
terminal.tab.icon = null;
220+
terminal.tab_state = NONE;
219221
withdraw_notification ("process-finished-%s".printf (id));
220222

221223
terminal.main_window.disconnect (tab_change_handler);

src/MainWindow.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ namespace Terminal {
303303
return;
304304
}
305305

306-
term.tab.icon = null; // Assume only process icons are set
306+
term.tab_state = NONE;
307307
});
308308

309309
notebook.tab_bar.bind_property ("tabs-revealed", new_tab_revealer, "reveal-child", SYNC_CREATE | INVERT_BOOLEAN);

src/Widgets/TerminalView.vala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ public class Terminal.TerminalView : Granite.Bin {
169169
terminal_widget.bind_property ("current-working-directory", tab, "tooltip");
170170
terminal_widget.tab = tab;
171171

172+
terminal_widget.notify["tab-state"].connect (() => {
173+
switch (terminal_widget.tab_state) {
174+
case NONE:
175+
tab.icon = null;
176+
break;
177+
case COMPLETED:
178+
tab.icon = new ThemedIcon ("process-completed-symbolic");
179+
break;
180+
case ERROR:
181+
tab.icon = new ThemedIcon ("process-error-symbolic");
182+
break;
183+
}
184+
});
185+
172186
//Set correct label now to avoid race when spawning shell
173187

174188
terminal_widget.set_font (term_font);

src/Widgets/TerminalWidget.vala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
namespace Terminal {
77
public class TerminalWidget : Vte.Terminal {
8-
enum DropTargets {
9-
URILIST,
10-
STRING,
11-
TEXT
8+
public enum TabState {
9+
NONE,
10+
COMPLETED,
11+
ERROR
1212
}
1313

1414
internal const string DEFAULT_LABEL = _("Terminal");
@@ -18,6 +18,7 @@ namespace Terminal {
1818
static int terminal_id_counter = 0;
1919
private bool init_complete;
2020
public bool resized {get; set;}
21+
public TabState tab_state { get; set; default = NONE; }
2122

2223
GLib.Pid child_pid;
2324
GLib.Pid fg_pid;

0 commit comments

Comments
 (0)