Skip to content

Commit

Permalink
give a warning when notifications enabled but not available
Browse files Browse the repository at this point in the history
The "disable notifications" option in advanced preferences allows
the user to toggle desktop notifications on and off. However, if
the game was not compiled with support for these, the option won't
do anything.

In this revision, if disable_notifications is set to false, but
notifications are not available, a dialog is launched which
explains that this executable was not compiled with support for
notifications.

The preference *is* toggled however -- this is because all versions
of wesnoth use the same preference file (at least under linux), so
we would rather to allow the user to change the file at will --
a different wesnoth binary which they have may indeed support
notifications. So we only give a warning but allow them to toggle.
  • Loading branch information
cbeck88 committed Jul 14, 2014
1 parent 19a90b4 commit a39bfea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/game_preferences_display.cpp
Expand Up @@ -27,6 +27,7 @@
#include "gui/dialogs/transient_message.hpp"
#include "lobby_preferences.hpp"
#include "marked-up_text.hpp"
#include "notifications/notifications.hpp" //needed to check if notifications are not available
#include "preferences_display.hpp"
#include "wml_separators.hpp"
#include "widgets/combo.hpp"
Expand Down Expand Up @@ -1375,6 +1376,13 @@ void preferences_dialog::process_event()
if(pref["field"] == "color_cursors") {
set_color_cursors(advanced_button_.checked());
}

if (pref["field"] == "disable_notifications" && !advanced_button_check && !notifications::available()) {
gui::dialog(*display::get_singleton()
, _("Notifications Not Available")
, _("Support for notifications was not found. Please check with the packager for your platform, or if compiling yourself, check that you have the appropriate dependencies for your platform to support this feature.")
, gui::OK_ONLY).show();
}
}
}

Expand Down Expand Up @@ -1663,7 +1671,7 @@ void preferences_dialog::set_selection(int index)
advanced_option_label_.hide(hide_advanced_int && hide_advanced_combo);
}

}
} //end anonymous namespace

void show_preferences_dialog(display& disp, const config& game_cfg)
{
Expand Down Expand Up @@ -1788,4 +1796,4 @@ std::string show_wesnothd_server_search(display& disp)
}


}
} // end namespace preferences
7 changes: 7 additions & 0 deletions src/notifications/notifications.cpp
Expand Up @@ -40,11 +40,18 @@

namespace notifications
{

#if !(defined(HAVE_LIBDBUS) || defined(HAVE_GROWL) || defined(_WIN32))

bool available() { return false; }

void send_notification(const std::string& /*owner*/, const std::string& /*message*/, type /*t*/)
{}

#else

bool available() { return true; }

void send_notification(const std::string& owner, const std::string& message, type t)
{
if (preferences::get("disable_notifications", false)) { return; }
Expand Down
2 changes: 2 additions & 0 deletions src/notifications/notifications.hpp
Expand Up @@ -22,6 +22,8 @@ namespace notifications
enum type {CHAT, TURN_CHANGED, OTHER};

void send_notification(const std::string& owner, const std::string& message, type t);

bool available();
}

#endif

0 comments on commit a39bfea

Please sign in to comment.