Skip to content

Commit

Permalink
grey out the notifications opts when they weren't compiled in
Browse files Browse the repository at this point in the history
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."
  • Loading branch information
cbeck88 committed Oct 12, 2014
1 parent c7c6cb4 commit 56530d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/gui/default/window/lobby_sounds_options.cfg
Expand Up @@ -149,6 +149,7 @@
horizontal_alignment = "left"

[label]
id = "notification_label"
definition = "default"

label = _ "Desktop Notification:"
Expand Down
16 changes: 15 additions & 1 deletion src/gui/dialogs/lobby_sounds_options.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/mp_ui_sounds.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit 56530d2

Please sign in to comment.