@@ -31,6 +31,35 @@ public class Terminal.Application : Gtk.Application {
31
31
Intl . bind_textdomain_codeset (Config . GETTEXT_PACKAGE , " UTF-8" );
32
32
Intl . textdomain (Config . GETTEXT_PACKAGE );
33
33
34
+ var act = new SimpleAction (" process-finished" , VariantType . STRING );
35
+ add_action (act);
36
+ act. activate. connect ((v) = > {
37
+ MainWindow window_to_present = (MainWindow )active_window;
38
+ size_t len;
39
+ var tid = v. get_string (out len);
40
+ foreach (var window in (List<MainWindow > ) get_windows ()) {
41
+ var terminal = window. get_terminal (tid);
42
+ if (terminal != null ) {
43
+ window. set_active_terminal_tab (terminal. tab);
44
+ window_to_present = window;
45
+ break ;
46
+ }
47
+ }
48
+
49
+ // This is a hack to avoid using Gdk-Xii dependency. Using present_with_time ()
50
+ // with the current event time does not work either on X11 or Wayland perhaps
51
+ // because the triggering event did not occur on the Terminal window?
52
+ // Using set_keep_above () at least works on X11 but not on Wayland
53
+ // TODO It may well be possible to use present () on Gtk4 so this needs revisiting
54
+ window_to_present. set_keep_above (true );
55
+ window_to_present. present ();
56
+ window_to_present. grab_focus ();
57
+ Idle . add (() = > {
58
+ window_to_present. set_keep_above (false );
59
+ return Source . REMOVE ;
60
+ });
61
+ });
62
+
34
63
add_main_option (" version" , ' v' , 0 , OptionArg . NONE , _(" Show version" ), null );
35
64
// -n flag forces a new window
36
65
add_main_option (" new-window" , ' n' , 0 , OptionArg . NONE , _(" Open a new terminal window" ), null );
@@ -171,7 +200,8 @@ public class Terminal.Application : Gtk.Application {
171
200
var notification = new Notification (process_string);
172
201
notification. set_body (process);
173
202
notification. set_icon (process_icon);
174
- send_notification (null , notification);
203
+ notification. set_default_action_and_target_value (" app.process-finished" , new Variant .string (id));
204
+ send_notification (" process-finished-%s " . printf (id), notification);
175
205
}
176
206
});
177
207
0 commit comments