Commit 2d5d553e authored by daniel_e's avatar daniel_e
Browse files

New files containing various sigc++ related utilities. For now, there's

* src/signalutils.{cc,h}: New files containing various sigc++ related
utilities.  For now, there's only Util::QueuedSignal, which implements a
SigC::Signal0<void> that is emitted when the main loop is idle.

* src/Makefile.am (regexxer_SOURCES): Add signalutils.{cc,h}.
parent 63ac4fde
2002-11-25 Daniel Elstner <daniel.elstner@gmx.net>
* src/signalutils.{cc,h}: New files containing various sigc++
related utilities. For now, there's only Util::QueuedSignal,
which implements a SigC::Signal0<void> that is emitted when the
main loop is idle.
* src/Makefile.am (regexxer_SOURCES): Add signalutils.{cc,h}.
2002-11-25 Daniel Elstner <daniel.elstner@gmx.net>
* src/filebuffer.{cc,h} (trigger_preview_line_changed): Rename to
......
......@@ -44,6 +44,8 @@ regexxer_SOURCES = \
prefdialog.h \
sharedptr.cc \
sharedptr.h \
signalutils.cc \
signalutils.h \
statusline.cc \
statusline.h \
stringutils.cc \
......
/* $Id$
*
* Copyright (c) 2002 Daniel Elstner <daniel.elstner@gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License VERSION 2 as
* published by the Free Software Foundation. You are not allowed to
* use any other version of the license; unless you got the explicit
* permission from the author to do so.
*
* This program 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "signalutils.h"
namespace Util
{
QueuedSignal::QueuedSignal(int priority)
:
signal_ (),
priority_ (priority),
queued_ (false)
{}
QueuedSignal::~QueuedSignal()
{}
SigC::Connection QueuedSignal::connect(const SigC::Slot0<void>& slot)
{
return signal_.connect(slot);
}
void QueuedSignal::queue()
{
if(!queued_)
{
Glib::signal_idle().connect(SigC::slot(*this, &QueuedSignal::idle_handler), priority_);
queued_ = true;
}
}
bool QueuedSignal::idle_handler()
{
queued_ = false;
signal_(); // emit
return false; // disconnect idle handler
}
} // namespace Util
/* $Id$
*
* Copyright (c) 2002 Daniel Elstner <daniel.elstner@gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License VERSION 2 as
* published by the Free Software Foundation. You are not allowed to
* use any other version of the license; unless you got the explicit
* permission from the author to do so.
*
* This program 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef REGEXXER_SIGNALUTILS_H_INCLUDED
#define REGEXXER_SIGNALUTILS_H_INCLUDED
#include <glibmm.h>
namespace Util
{
class QueuedSignal : public SigC::Object
{
public:
explicit QueuedSignal(int priority = Glib::PRIORITY_HIGH_IDLE);
virtual ~QueuedSignal();
SigC::Connection connect(const SigC::Slot0<void>& slot);
void queue();
void operator()() { queue(); }
private:
SigC::Signal0<void> signal_;
int priority_;
bool queued_;
QueuedSignal(const QueuedSignal&);
QueuedSignal& operator=(const QueuedSignal&);
bool idle_handler();
};
} // namespace Util
#endif /* REGEXXER_SIGNALUTILS_H_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment