From e833d88cae8585fdacd4f1b46d2630b6e3257848 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Fri, 27 Oct 2023 11:05:22 +0200 Subject: [PATCH] terminal-screen: show notifications when a foreground process terminates if the window isn't active --- .build.yml | 1 + configure.ac | 1 + src/terminal-screen.c | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/.build.yml b/.build.yml index 8ca7cf8..ddee49e 100644 --- a/.build.yml +++ b/.build.yml @@ -17,6 +17,7 @@ requires: - git - libdconf-dev - libglib2.0-dev + - libnotify-dev - libsm-dev - libtool - libx11-dev diff --git a/configure.ac b/configure.ac index 93d1444..ccf277d 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,7 @@ PKG_CHECK_MODULES([TERM], gio-2.0 >= $GIO_REQUIRED ctk+-3.0 >= $CTK_REQUIRED dconf >= $DCONF_REQUIRED + libnotify x11]) # ******** diff --git a/src/terminal-screen.c b/src/terminal-screen.c index 791718a..55b2993 100644 --- a/src/terminal-screen.c +++ b/src/terminal-screen.c @@ -32,6 +32,8 @@ #include #include +#include + #include "terminal-accels.h" #include "terminal-app.h" #include "terminal-debug.h" @@ -129,6 +131,8 @@ static void terminal_screen_window_title_changed (BteTerminal *bte_terminal TerminalScreen *screen); static void terminal_screen_icon_title_changed (BteTerminal *bte_terminal, TerminalScreen *screen); +static void terminal_screen_text_inserted (BteTerminal *bte_terminal, + TerminalScreen *screen); static void update_color_scheme (TerminalScreen *screen); @@ -380,6 +384,9 @@ terminal_screen_init (TerminalScreen *screen) g_signal_connect (screen, "icon-title-changed", G_CALLBACK (terminal_screen_icon_title_changed), screen); + g_signal_connect (screen, "text-inserted", + G_CALLBACK (terminal_screen_text_inserted), + screen); g_signal_connect (terminal_app_get (), "notify::system-font", G_CALLBACK (terminal_screen_system_font_notify_cb), screen); @@ -1928,6 +1935,26 @@ terminal_screen_icon_title_changed (BteTerminal *bte_terminal, FALSE); } +static void +terminal_screen_text_inserted (BteTerminal *bte_terminal, + TerminalScreen *screen) +{ + if ((ctk_window_is_active (CTK_WINDOW (terminal_screen_get_window (screen))) == FALSE) && + (terminal_screen_has_foreground_process (screen) == FALSE)) + { + notify_init ("cafe-terminal"); + NotifyNotification *notification; + + notification = notify_notification_new ("cafe-terminal", + _("Process completed"), + "utilities-terminal"); + + notify_notification_show (notification, NULL); + g_object_unref (G_OBJECT (notification)); + notify_uninit(); + } +} + static void terminal_screen_child_exited (BteTerminal *terminal, int status) {