1 #ifndef oxygensignal_h
2 #define oxygensignal_h
3 
4 /*
5 * this file is part of the oxygen gtk engine
6 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
7 *
8 * This  library is free  software; you can  redistribute it and/or
9 * modify it  under  the terms  of the  GNU Lesser  General  Public
10 * License  as published  by the Free  Software  Foundation; either
11 * version 2 of the License, or(at your option ) any later version.
12 *
13 * This library is distributed  in the hope that it will be useful,
14 * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License  along  with  this library;  if not,  write to  the Free
20 * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 */
23 
24 #include <gtk/gtk.h>
25 #include <cassert>
26 #include <string>
27 
28 namespace Oxygen
29 {
30     //! handles gtk signal connections
31     class Signal
32     {
33         public:
34 
35         //! constructor
Signal(void)36         Signal( void ):
37             _id(0),
38             _object(0L)
39         {}
40 
41         //! destructor
~Signal(void)42         virtual ~Signal( void )
43         {}
44 
45         //! true if connected
isConnected(void)46         bool isConnected( void ) const
47         { return _id > 0 && _object; }
48 
49         //! connect
50         bool connect( GObject*, const std::string&, GCallback, gpointer, bool after=false );
51 
52         //! disconnect
53         void disconnect( void );
54 
55         private:
56 
57         //! signal id
58         guint _id;
59 
60         //! connected object
61         GObject* _object;
62 
63     };
64 
65 }
66 #endif
67