mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 23:08:14 +00:00
Added support for libnotify-based desktop notifications...
...(patch #1179 by method).
This commit is contained in:
parent
0140e8dd03
commit
fdd6ee4ca2
@ -25,6 +25,7 @@ Version 1.7.0+svn:
|
||||
* Removed the hidden option to disable the tips of the day
|
||||
* A click on a slider now properly sets the position
|
||||
* WML generated messages, labels and sounds are skiped during replay (bug #13519)
|
||||
* Added support for desktop notifications (GTK/libnotify only for now, patch #1179)
|
||||
* WML Engine:
|
||||
* Made new turn, turn X, side turn and turn refresh events synchronous.
|
||||
(bug #10603)
|
||||
|
33
configure.ac
33
configure.ac
@ -278,6 +278,18 @@ AC_ARG_ENABLE([internal-data],
|
||||
[internaldata=$enableval],
|
||||
[internaldata=no])
|
||||
|
||||
AC_ARG_ENABLE([notifications],
|
||||
AS_HELP_STRING([--disable-notifications],
|
||||
[disable OS-specific notifications]),
|
||||
[notifications=$enableval],
|
||||
[notifications=yes])
|
||||
|
||||
AC_ARG_ENABLE([gtkmm],
|
||||
AS_HELP_STRING([--disable-gtkmm],
|
||||
[disable gtkmm support for notifications]),
|
||||
[gtkmm=$enableval],
|
||||
[gtkmm=yes])
|
||||
|
||||
#if test "x$game" = "xno"
|
||||
#then
|
||||
# python=no
|
||||
@ -845,6 +857,27 @@ PKG_CHECK_MODULES(LUA, [lua >= 5.1], , [PKG_CHECK_MODULES(LUA, [lua5.1 >= 5.1],
|
||||
CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
|
||||
LIBS="$LIBS $LUA_LIBS"
|
||||
|
||||
#######################################################################
|
||||
# Check for different notifications systems #
|
||||
#######################################################################
|
||||
found_notifications=no
|
||||
if test "x$notifications" = "xyes"; then
|
||||
if test "x$gtkmm" = "xyes"; then
|
||||
PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.8.0], [
|
||||
PKG_CHECK_MODULES([LIBNOTIFY], [libnotifymm-1.0], [
|
||||
CPPFLAGS="$CPPFLAGS $GTKMM_CFLAGS $LIBNOTIFY_CFLAGS"
|
||||
LIBS="$LIBS $GTKMM_LIBS $LIBNOTIFY_LIBS"
|
||||
found_notifications=yes
|
||||
AC_DEFINE([HAVE_LIBNOTIFY],,[Define if you have Libnotify for GTK.])
|
||||
], [AC_MSG_RESULT([no])])
|
||||
], [AC_MSG_RESULT([no])])
|
||||
fi
|
||||
# tests for other notification systems
|
||||
fi
|
||||
AC_MSG_CHECKING([for notifications])
|
||||
AC_MSG_RESULT([$found_notifications])
|
||||
|
||||
|
||||
#######################################################################
|
||||
# Check for boost iostreams #
|
||||
#######################################################################
|
||||
|
@ -21,6 +21,10 @@
|
||||
|
||||
#include "game_display.hpp"
|
||||
|
||||
#ifdef HAVE_LIBNOTIFY
|
||||
#include <libnotifymm-1.0/libnotifymm.h>
|
||||
#endif
|
||||
|
||||
#include "actions.hpp"
|
||||
#include "foreach.hpp"
|
||||
#include "halo.hpp"
|
||||
@ -1025,6 +1029,32 @@ std::string game_display::current_team_name() const
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void game_display::send_notification(const std::string& owner, const std::string& message)
|
||||
{
|
||||
#ifdef HAVE_LIBNOTIFY
|
||||
|
||||
// SDL_APPACTIVE, SDL_APPINPUTFOCUS, SDL_APPMOUSEFOCUS
|
||||
Uint8 app_state = SDL_GetAppState();
|
||||
|
||||
// Only show notification if the window is not visible
|
||||
if((SDL_APPACTIVE & app_state) != 0)
|
||||
{
|
||||
// Or if window is in background
|
||||
if((SDL_APPMOUSEFOCUS & app_state) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Notify::init("Wesnoth");
|
||||
|
||||
// I tried to use the fancy Gtk::IconTheme stuff but it didn't seem worth it. -- method
|
||||
Glib::ustring wesnoth_icon_info = game_config::path + "images/wesnoth-icon-small.png";
|
||||
Notify::Notification notification(owner, message, wesnoth_icon_info);
|
||||
notification.show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void game_display::set_team(size_t teamindex, bool show_everything)
|
||||
{
|
||||
assert(teamindex < teams_.size());
|
||||
@ -1162,6 +1192,9 @@ void game_display::add_chat_message(const time_t& time, const std::string& speak
|
||||
rect.x + chat_message_x + font::get_floating_label_rect(speaker_handle).w,rect.y+ypos,
|
||||
0,0,-1,rect,font::LEFT_ALIGN,&chat_message_bg,chat_message_border);
|
||||
|
||||
// Send system notification if appropriate.
|
||||
send_notification(speaker, message);
|
||||
|
||||
chat_messages_.push_back(chat_message(speaker_handle,message_handle));
|
||||
|
||||
prune_chat_messages();
|
||||
|
@ -228,6 +228,8 @@ public:
|
||||
//void draw_terrain_palette(int x, int y, terrain_type::TERRAIN selected);
|
||||
t_translation::t_terrain get_terrain_on(int palx, int paly, int x, int y);
|
||||
|
||||
void send_notification(const std::string& owner, const std::string& message);
|
||||
|
||||
/**
|
||||
* Sets the team controlled by the player using the computer.
|
||||
*
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "savegame.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "upload_log.hpp"
|
||||
#include "formula_string_utils.hpp"
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define LOG_NG LOG_STREAM(info, log_engine)
|
||||
@ -142,6 +143,14 @@ void playmp_controller::play_side(const unsigned int team_index, bool save){
|
||||
}
|
||||
} while (player_type_changed_);
|
||||
//keep looping if the type of a team (human/ai/networked) has changed mid-turn
|
||||
|
||||
// Notify on turn change.
|
||||
utils::string_map player;
|
||||
player["name"] = current_team().current_player();
|
||||
std::string turn_notification_msg = _("$name has taken control");
|
||||
turn_notification_msg = utils::interpolate_variables_into_string(turn_notification_msg, &player);
|
||||
|
||||
gui_->send_notification(_("Turn changed"), turn_notification_msg);
|
||||
}
|
||||
|
||||
void playmp_controller::before_human_turn(bool save){
|
||||
|
Loading…
x
Reference in New Issue
Block a user