1 // Copyright (C) 2008, 2014, 2015 Ben Asselstine 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Library General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16 // 02110-1301, USA. 17 18 #pragma once 19 #ifndef TIMED_MESSAGE_DIALOG_H 20 #define TIMED_MESSAGE_DIALOG_H 21 22 #include <sigc++/trackable.h> 23 #include <glibmm/main.h> 24 #include <gtkmm.h> 25 26 // used for displaying a timed dialog that goes away after a period of time 27 class TimedMessageDialog: public sigc::trackable 28 { 29 public: 30 TimedMessageDialog(Gtk::Window &parent, Glib::ustring message, int timeout, 31 int grace = 30); ~TimedMessageDialog()32 ~TimedMessageDialog() {delete window;}; 33 34 void add_cancel_button (); 35 36 void set_title(Glib::ustring title); 37 void set_image(Glib::RefPtr<Gdk::Pixbuf> picture); 38 void run_and_hide(); 39 get_response()40 int get_response () {return d_response;} 41 42 private: 43 Gtk::MessageDialog *window; 44 Glib::RefPtr<Glib::MainLoop> main_loop; 45 int d_timeout; 46 int d_timer_count; 47 int d_grace; 48 int d_response; 49 bool tick(); 50 void on_response(int response); 51 }; 52 53 #endif 54