Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,25 @@ public class Terminal.Application : Gtk.Application {
return;
}

var process_string = _("Process completed");
var process_icon = new ThemedIcon ("process-completed-symbolic");
var notification_title = _("Process completed");
var notification_icon = new ThemedIcon ("process-completed-symbolic");
var tab_state = TerminalWidget.TabState.COMPLETED;
if (exit_status != 0) {
process_string = _("Process exited with errors");
process_icon = new ThemedIcon ("process-error-symbolic");
notification_title = _("Process exited with errors");
notification_icon = new ThemedIcon ("process-error-symbolic");
tab_state = ERROR;
}

if (terminal != terminal.main_window.current_terminal) {
terminal.tab.icon = process_icon;
terminal.tab_state = tab_state;
} else if (terminal.tab_state == WORKING) {
terminal.tab_state = NONE;
}

if (!(get_active_window ().is_active)) {
var notification = new Notification (process_string);
var notification = new Notification (notification_title);
notification.set_body (process);
notification.set_icon (process_icon);
notification.set_icon (notification_icon);
notification.set_default_action_and_target_value ("app.process-finished", new Variant.string (id));
send_notification ("process-finished-%s".printf (id), notification);

Expand All @@ -215,7 +219,7 @@ public class Terminal.Application : Gtk.Application {
return;
}

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

terminal.main_window.disconnect (tab_change_handler);
Expand Down
4 changes: 3 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ namespace Terminal {
return;
}

term.tab.icon = null; // Assume only process icons are set
if (term.tab_state != WORKING) {
term.tab_state = NONE;
}
});

notebook.tab_bar.bind_property ("tabs-revealed", new_tab_revealer, "reveal-child", SYNC_CREATE | INVERT_BOOLEAN);
Expand Down
17 changes: 17 additions & 0 deletions src/Widgets/TerminalView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,23 @@ public class Terminal.TerminalView : Granite.Bin {
terminal_widget.bind_property ("current-working-directory", tab, "tooltip");
terminal_widget.tab = tab;

terminal_widget.notify["tab-state"].connect (() => {
tab.loading = terminal_widget.tab_state == WORKING;

switch (terminal_widget.tab_state) {
case NONE:
case WORKING:
tab.icon = null;
break;
case COMPLETED:
tab.icon = new ThemedIcon ("process-completed-symbolic");
break;
case ERROR:
tab.icon = new ThemedIcon ("process-error-symbolic");
break;
}
});

//Set correct label now to avoid race when spawning shell

terminal_widget.set_font (term_font);
Expand Down
19 changes: 15 additions & 4 deletions src/Widgets/TerminalWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

namespace Terminal {
public class TerminalWidget : Vte.Terminal {
enum DropTargets {
URILIST,
STRING,
TEXT
public enum TabState {
NONE,
WORKING,
COMPLETED,
ERROR
}

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

GLib.Pid child_pid;
GLib.Pid fg_pid;
Expand Down Expand Up @@ -232,6 +234,7 @@ namespace Terminal {
notify["width-request"].connect (() => resized = true);
contents_changed.connect (on_contents_changed);
child_exited.connect (on_child_exited);
window_title_changed.connect (on_window_title_changed);
ulong once = 0;
once = realize.connect (() => {
clipboard = Gdk.Display.get_default ().get_clipboard ();
Expand Down Expand Up @@ -783,6 +786,14 @@ namespace Terminal {
fg_pid = -1;
}

private void on_window_title_changed () {
if (has_foreground_process ()) {
tab_state = WORKING;
}

// Application.dbus_register handles resetting the state
}

public void kill_fg () {
int fg_pid;
if (this.try_get_foreground_pid (out fg_pid)) {
Expand Down