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."
This commit is contained in:
Chris Beck 2014-10-12 02:15:59 -04:00
parent c7c6cb4de7
commit 56530d2bf1
3 changed files with 17 additions and 2 deletions

View File

@ -149,6 +149,7 @@
horizontal_alignment = "left"
[label]
id = "notification_label"
definition = "default"
label = _ "Desktop Notification:"

View File

@ -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<tlabel>(&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<ttoggle_button>(&window,"ready_for_start_in_lobby", false);
in_lobby->set_visible(twidget::tvisible::invisible);

View File

@ -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) {