From 56530d2bf19b5d4914404b134113e0cea5601870 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sun, 12 Oct 2014 02:15:59 -0400 Subject: [PATCH] grey out the notifications opts when they weren't compiled in In this case, we deactivate all of the notification checkboxes, and set all relevant preferences and checkboxes to false. We also put a tooltip on the header for this column, saying "This build of wesnoth doesn't support desktop notifications, contact your package manager." --- data/gui/default/window/lobby_sounds_options.cfg | 1 + src/gui/dialogs/lobby_sounds_options.cpp | 16 +++++++++++++++- src/mp_ui_sounds.cpp | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/data/gui/default/window/lobby_sounds_options.cfg b/data/gui/default/window/lobby_sounds_options.cfg index e7fc8a24fbf..ba47e699175 100644 --- a/data/gui/default/window/lobby_sounds_options.cfg +++ b/data/gui/default/window/lobby_sounds_options.cfg @@ -149,6 +149,7 @@ horizontal_alignment = "left" [label] + id = "notification_label" definition = "default" label = _ "Desktop Notification:" diff --git a/src/gui/dialogs/lobby_sounds_options.cpp b/src/gui/dialogs/lobby_sounds_options.cpp index bc9d6d8aff3..d3aee89b19e 100644 --- a/src/gui/dialogs/lobby_sounds_options.cpp +++ b/src/gui/dialogs/lobby_sounds_options.cpp @@ -87,7 +87,16 @@ static void setup_item(const std::string & item, twindow & window) setup_pref_toggle_button(item+"_sound", mp_ui_sounds::get_def_pref_sound(item), window); // Set up the notification checkbox - setup_pref_toggle_button(item+"_notification", mp_ui_sounds::get_def_pref_notif(item), window); + ttoggle_button * notif = setup_pref_toggle_button(item+"_notification", mp_ui_sounds::get_def_pref_notif(item), window); + + // Check if desktop notifications are available + if (!desktop::notifications::available()) { + notif->set_value(false); + notif->set_active(false); + preferences::set(item+"_notif", false); + } else { + notif->set_active(true); + } // Set up the in_lobby checkbox setup_pref_toggle_button(item+"_in_lobby", mp_ui_sounds::get_def_pref_lobby(item), window); @@ -121,6 +130,11 @@ void tlobby_sounds_options::pre_show(CVideo& /*video*/, twindow& window) setup_item(i, window); } + if (!desktop::notifications::available()) { + tlabel * nlabel = &find_widget(&window, "notification_label", false); + nlabel->set_tooltip(_("This build of wesnoth does not include support for desktop notifications, contact your package manager")); + } + ttoggle_button * in_lobby; in_lobby = &find_widget(&window,"ready_for_start_in_lobby", false); in_lobby->set_visible(twidget::tvisible::invisible); diff --git a/src/mp_ui_sounds.cpp b/src/mp_ui_sounds.cpp index 91d0cbc8cc6..27915bb2bca 100644 --- a/src/mp_ui_sounds.cpp +++ b/src/mp_ui_sounds.cpp @@ -168,7 +168,7 @@ bool get_def_pref_sound(const std::string & id) { } bool get_def_pref_notif(const std::string & id) { - return (id == "private_message" || id == "ready_for_start" || id == "game_has_begun"); + return (desktop::notifications::available() && (id == "private_message" || id == "ready_for_start" || id == "game_has_begun")); } bool get_def_pref_lobby(const std::string & id) {