diff --git a/configure.ac b/configure.ac index 0f4f323..c730b6d 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_CONFIG_SRCDIR([src]) AC_CONFIG_MACRO_DIR([m4]) PKG_CHECK_MODULES([Gnomato],[gtkmm-3.0 >= 3.0.0, sqlite3, libnotify >= 0.7.3, - python3 >= 3.5]) + python3 >= 3.5, gsound >= 1.0.0]) IT_PROG_INTLTOOL([0.35.0]) diff --git a/data/Makefile.am b/data/Makefile.am index 954b061..ee03b67 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -3,6 +3,7 @@ ui_DATA = \ tomato.png \ tomato-green.png \ tomato-gray.png \ + alert.ogg \ gnomato.ui gsettings_SCHEMAS = com.diegorubin.gnomato.gschema.xml diff --git a/data/alert.ogg b/data/alert.ogg new file mode 100644 index 0000000..04130ad Binary files /dev/null and b/data/alert.ogg differ diff --git a/src/Makefile.am b/src/Makefile.am index 1c443af..9f1143f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,6 +23,7 @@ gnomato_SOURCES = main.cc \ config.cc \ dbus_client.cc \ python_executor.cc \ + sound_player.cc \ utils.cc # [TODO] - Add boost in configure.ac diff --git a/src/dialog_preferences.cc b/src/dialog_preferences.cc index c8ff4e7..e92ae3d 100644 --- a/src/dialog_preferences.cc +++ b/src/dialog_preferences.cc @@ -1,40 +1,37 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ /*! -* dialog_preferences.cc -* Copyright (C) Diego Rubin 2011 -* -* Gnomato is free software: you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Gnomato is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License along -* with this program. If not, see . -* -* Author: Diego Rubin -* -*/ + * dialog_preferences.cc + * Copyright (C) Diego Rubin 2011 + * + * Gnomato is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gnomato is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Author: Diego Rubin + * + */ -#include #include "dialog_preferences.h" -DialogPreferences::DialogPreferences(BaseObjectType* cobject, - const Glib::RefPtr& refGlade) -: Gtk::Dialog(cobject), - m_refGlade(refGlade) -{ +DialogPreferences::DialogPreferences(BaseObjectType *cobject, + const Glib::RefPtr &refGlade) + : Gtk::Dialog(cobject), m_refGlade(refGlade) { configs.load(); // buttons m_refGlade->get_widget("btnOk", btnOk); m_refGlade->get_widget("btnCancel", btnCancel); - // page 1 - intervals + // page 1 - intervals m_refGlade->get_widget("spnWork", spnWork); m_refGlade->get_widget("spnShortBreak", spnShortBreak); m_refGlade->get_widget("spnLongBreak", spnLongBreak); @@ -47,35 +44,29 @@ DialogPreferences::DialogPreferences(BaseObjectType* cobject, // page 2 - colors m_refGlade->get_widget("clrTimer", clrTimer); Gdk::RGBA timer; - timer.set_rgba( - configs.colorTimerRed, - configs.colorTimerGreen, - configs.colorTimerBlue); + timer.set_rgba(configs.colorTimerRed, configs.colorTimerGreen, + configs.colorTimerBlue); clrTimer->set_rgba(timer); // connect signals - btnCancel->signal_clicked().connect(sigc::mem_fun(*this,&DialogPreferences::on_button_cancel_clicked)); - btnOk->signal_clicked().connect(sigc::mem_fun(*this,&DialogPreferences::on_button_ok_clicked)); + btnCancel->signal_clicked().connect( + sigc::mem_fun(*this, &DialogPreferences::on_button_cancel_clicked)); + btnOk->signal_clicked().connect( + sigc::mem_fun(*this, &DialogPreferences::on_button_ok_clicked)); show_all(); } -DialogPreferences::~DialogPreferences() -{ -} +DialogPreferences::~DialogPreferences() {} -void DialogPreferences::on_button_cancel_clicked() -{ - hide(); -} +void DialogPreferences::on_button_cancel_clicked() { hide(); } -void DialogPreferences::on_button_ok_clicked() -{ +void DialogPreferences::on_button_ok_clicked() { configs.work_interval = spnWork->get_text(); configs.break_interval = spnShortBreak->get_text(); configs.long_interval = spnLongBreak->get_text(); configs.inactive_interval = spnInactiveInterval->get_text(); - + Gdk::RGBA timer = clrTimer->get_rgba(); configs.colorTimerRed = timer.get_red(); configs.colorTimerGreen = timer.get_green(); @@ -84,4 +75,3 @@ void DialogPreferences::on_button_ok_clicked() configs.save(); hide(); } - diff --git a/src/dialog_preferences.h b/src/dialog_preferences.h index a926112..06dd365 100644 --- a/src/dialog_preferences.h +++ b/src/dialog_preferences.h @@ -1,42 +1,43 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ /*! -* dialog_preferences.h -* Copyright (C) Diego Rubin 2011 -* -* Gnomato is free software: you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Gnomato is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License along -* with this program. If not, see . -* -* Author: Diego Rubin -* -*/ + * dialog_preferences.h + * Copyright (C) Diego Rubin 2011 + * + * Gnomato is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gnomato is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Author: Diego Rubin + * + */ #ifndef _WIN_PREFERENCES_H_ #define _WIN_PREFERENCES_H_ +#include #include + #include "config.h" using namespace Gtk; -class DialogPreferences: public Gtk::Dialog -{ +class DialogPreferences : public Gtk::Dialog { public: - DialogPreferences(BaseObjectType* cobject, - const Glib::RefPtr& refGlade); + DialogPreferences(BaseObjectType *cobject, + const Glib::RefPtr &refGlade); - virtual ~DialogPreferences(); -protected: + virtual ~DialogPreferences(); +protected: private: // attributes Config configs; diff --git a/src/dialog_work_log_entries.cc b/src/dialog_work_log_entries.cc index 9381fb3..0a7f205 100644 --- a/src/dialog_work_log_entries.cc +++ b/src/dialog_work_log_entries.cc @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ /*! - * dialog_preferences.cc + * dialog_work_log_entries.cc * Copyright (C) Diego Rubin 2020 * * Gnomato is free software: you can redistribute it and/or modify it @@ -21,7 +21,6 @@ */ #include "dialog_work_log_entries.h" -#include DialogWorkLogEntries::DialogWorkLogEntries( BaseObjectType *cobject, const Glib::RefPtr &refGlade) diff --git a/src/dialog_work_log_entries.h b/src/dialog_work_log_entries.h index e331430..ea493de 100644 --- a/src/dialog_work_log_entries.h +++ b/src/dialog_work_log_entries.h @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ /*! - * dialog_preferences.h + * dialog_work_log_entries.h * Copyright (C) Diego Rubin 2020 * * Gnomato is free software: you can redistribute it and/or modify it diff --git a/src/main.cc b/src/main.cc index 1934211..a35df45 100644 --- a/src/main.cc +++ b/src/main.cc @@ -319,7 +319,6 @@ void migrate_database() { } int main(int argc, char **argv) { - sprintf(dbpath, "%s", dbfile().c_str()); bootstrap(); migrate_database(); diff --git a/src/sound_player.cc b/src/sound_player.cc new file mode 100644 index 0000000..4c2241d --- /dev/null +++ b/src/sound_player.cc @@ -0,0 +1,41 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ +/*! + * sound_player.cc + * Copyright (C) Diego Rubin 2020 + * + * Gnomato is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gnomato is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Author: Diego Rubin + * + */ + +#include "sound_player.h" + +SoundPlayer::SoundPlayer(string file) : file(file) { + gsound = gsound_context_new(NULL, NULL); +} + +SoundPlayer::SoundPlayer() : SoundPlayer(GNOMATO_DATADIR "/alert.ogg") {} + +SoundPlayer::~SoundPlayer() {} + +void SoundPlayer::play() { + if (!gsound) { + cout << _("Error on load gsound context") << endl; + return; + } + + gsound_context_play_simple(gsound, NULL, NULL, GSOUND_ATTR_MEDIA_FILENAME, + "phone-incoming-call", NULL); +} diff --git a/src/sound_player.h b/src/sound_player.h new file mode 100644 index 0000000..1df7a0e --- /dev/null +++ b/src/sound_player.h @@ -0,0 +1,49 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ +/*! + * sound_player.h + * Copyright (C) Diego Rubin 2020 + * + * Gnomato is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gnomato is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Author: Diego Rubin + * + */ + +#ifndef _SOUND_PLAYER_H_ +#define _SOUND_PLAYER_H_ + +#include +#include +#include +#include + +using namespace std; + +class SoundPlayer { +public: + SoundPlayer(string file); + SoundPlayer(); + + virtual ~SoundPlayer(); + + // methods + void play(); + +private: + // attributes + string file; + GSoundContext *gsound; +}; + +#endif // SOUND_PLAYER diff --git a/src/win_main.cc b/src/win_main.cc index b0cf7f1..523a858 100644 --- a/src/win_main.cc +++ b/src/win_main.cc @@ -345,6 +345,8 @@ void WinMain::notify(const char *message) { } void WinMain::notify(const char *icon, const char *message) { + SoundPlayer soundPlayer; + NotifyNotification *notMessage; GError *error = NULL; @@ -357,6 +359,7 @@ void WinMain::notify(const char *icon, const char *message) { notify_notification_set_urgency(notMessage, NOTIFY_URGENCY_NORMAL); + soundPlayer.play(); notify_notification_show(notMessage, &error); } diff --git a/src/win_main.h b/src/win_main.h index c285f8e..b289bbc 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -36,6 +36,7 @@ #include "dialog_task.h" #include "dialog_work_log_entries.h" #include "python_executor.h" +#include "sound_player.h" #include "task.h" #include "task_list.h" #include "utils.h"