diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 5b167cb5e..9c0d5f3b5 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -419,6 +419,7 @@ const struct prefs vars[] = {"gui_lagometer", P_OFFINT (hex_gui_lagometer), TYPE_INT}, {"gui_lang", P_OFFINT (hex_gui_lang), TYPE_INT}, {"gui_mode_buttons", P_OFFINT (hex_gui_mode_buttons), TYPE_BOOL}, + {"gui_notification_timeout", P_OFFINT (hex_gui_notification_timeout), TYPE_INT}, {"gui_pane_divider_position", P_OFFINT (hex_gui_pane_divider_position), TYPE_INT}, {"gui_pane_left_size", P_OFFINT (hex_gui_pane_left_size), TYPE_INT}, {"gui_pane_right_size", P_OFFINT (hex_gui_pane_right_size), TYPE_INT}, @@ -826,6 +827,7 @@ load_default_config(void) prefs.hex_gui_dialog_width = 500; prefs.hex_gui_lagometer = 1; prefs.hex_gui_lang = get_default_language(); + prefs.hex_gui_notification_timeout = 0; prefs.hex_gui_pane_left_size = 128; /* with treeview icons we need a bit bigger space */ prefs.hex_gui_pane_right_size = 100; prefs.hex_gui_pane_right_size_min = 80; diff --git a/src/common/hexchat.h b/src/common/hexchat.h index 4c28db9ea..e2b846205 100644 --- a/src/common/hexchat.h +++ b/src/common/hexchat.h @@ -244,6 +244,7 @@ struct hexchatprefs int hex_gui_dialog_width; int hex_gui_lagometer; int hex_gui_lang; + int hex_gui_notification_timeout; int hex_gui_pane_divider_position; int hex_gui_pane_left_size; int hex_gui_pane_right_size; diff --git a/src/fe-gtk/notifications/notification-backend.h b/src/fe-gtk/notifications/notification-backend.h index 4bcaa7d89..1c1ffa995 100644 --- a/src/fe-gtk/notifications/notification-backend.h +++ b/src/fe-gtk/notifications/notification-backend.h @@ -20,7 +20,7 @@ #define HEXCHAT_PLUGIN_NOTIFICATION_BACKEND_H int notification_backend_supported (void); -void notification_backend_show (const char *title, const char *text); +void notification_backend_show (const char *title, const char *text, int notification_timeout); int notification_backend_init (const char **error); void notification_backend_deinit (void); diff --git a/src/fe-gtk/notifications/notification-dummy.c b/src/fe-gtk/notifications/notification-dummy.c index 9aa7d19c1..09c4f3a8c 100644 --- a/src/fe-gtk/notifications/notification-dummy.c +++ b/src/fe-gtk/notifications/notification-dummy.c @@ -17,7 +17,7 @@ */ void -notification_backend_show (const char *title, const char *text) +notification_backend_show (const char *title, const char *text, int notification_timeout) { } diff --git a/src/fe-gtk/notifications/notification-freedesktop.c b/src/fe-gtk/notifications/notification-freedesktop.c index a23284e57..c3b6edb95 100644 --- a/src/fe-gtk/notifications/notification-freedesktop.c +++ b/src/fe-gtk/notifications/notification-freedesktop.c @@ -44,7 +44,7 @@ on_notify_ready (GDBusProxy *proxy, GAsyncResult *res, gpointer user_data) } void -notification_backend_show (const char *title, const char *text) +notification_backend_show (const char *title, const char *text, int notification_timeout) { GVariantBuilder params; @@ -69,7 +69,9 @@ notification_backend_show (const char *title, const char *text) g_variant_builder_close (¶ms); g_variant_builder_close (¶ms); - g_variant_builder_add (¶ms, "i", -1); /* Expiration */ + /* Expiration */ + g_variant_builder_add (¶ms, "i", + notification_timeout > 0 ? notification_timeout : -1); g_dbus_proxy_call (fdo_notifications, "Notify", diff --git a/src/fe-gtk/notifications/notification-osx.m b/src/fe-gtk/notifications/notification-osx.m index 75aaf7773..66f1c6d0a 100644 --- a/src/fe-gtk/notifications/notification-osx.m +++ b/src/fe-gtk/notifications/notification-osx.m @@ -20,7 +20,7 @@ #include void -notification_backend_show (const char *title, const char *text) +notification_backend_show (const char *title, const char *text, int notification_timeout) { NSString *str_title = [[NSString alloc] initWithUTF8String:title]; NSString *str_text = [[NSString alloc] initWithUTF8String:text]; diff --git a/src/fe-gtk/notifications/notification-windows.c b/src/fe-gtk/notifications/notification-windows.c index 2fd896c5b..259a08dd3 100644 --- a/src/fe-gtk/notifications/notification-windows.c +++ b/src/fe-gtk/notifications/notification-windows.c @@ -28,7 +28,7 @@ void (*winrt_notification_backend_deinit) (void) = NULL; int (*winrt_notification_backend_supported) (void) = NULL; void -notification_backend_show (const char *title, const char *text) +notification_backend_show (const char *title, const char *text, int notification_timeout) { if (winrt_notification_backend_show == NULL) { diff --git a/src/fe-gtk/notifications/notification-winrt.cpp b/src/fe-gtk/notifications/notification-winrt.cpp index 3b966cf06..4be64081f 100644 --- a/src/fe-gtk/notifications/notification-winrt.cpp +++ b/src/fe-gtk/notifications/notification-winrt.cpp @@ -50,7 +50,7 @@ narrow(const std::wstring & to_narrow) extern "C" { __declspec (dllexport) void - notification_backend_show (const char *title, const char *text) + notification_backend_show (const char *title, const char *text, int notification_timeout) { try { diff --git a/src/fe-gtk/plugin-notification.c b/src/fe-gtk/plugin-notification.c index 7f8b7075b..1bf2bd2cf 100644 --- a/src/fe-gtk/plugin-notification.c +++ b/src/fe-gtk/plugin-notification.c @@ -82,12 +82,16 @@ static void show_notification (const char *title, const char *text) { char *stripped_title, *stripped_text; + int notification_timeout; /* Strip all colors */ stripped_title = hexchat_strip (ph, title, -1, 7); stripped_text = hexchat_strip (ph, text, -1, 7); - - notification_backend_show (stripped_title, stripped_text); + + if (hexchat_get_prefs (ph, "gui_notification_timeout", NULL, ¬ification_timeout) != 3) + notification_timeout = 0; + + notification_backend_show (stripped_title, stripped_text, notification_timeout); hexchat_free (ph, stripped_title); hexchat_free (ph, stripped_text); diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 60dfd2c0e..886924333 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -424,6 +424,10 @@ static const setting alert_settings[] = {ST_TOGGLE, N_("Close to tray"), P_OFFINTNL(hex_gui_tray_close), 0, 0, 0}, {ST_TOGGLE, N_("Automatically mark away/back"), P_OFFINTNL(hex_gui_tray_away), N_("Automatically change status when hiding to tray."), 0, 0}, {ST_TOGGLE, N_("Only show notifications when hidden or iconified"), P_OFFINTNL(hex_gui_tray_quiet), 0, 0, 0}, +#ifndef WIN32 // Based on meson.build:46 + {ST_NUMBER, N_("Notification timeout:"), P_OFFINTNL(hex_gui_notification_timeout), 0, + (const char **)N_("0 = backend default"), 1000}, +#endif {ST_HEADER, N_("Highlighted Messages"),0,0,0}, {ST_LABEL, N_("Highlighted messages are ones where your nickname is mentioned, but also:"), 0, 0, 0, 1},