CoreGTK  3.10.0
CoreGTK is an Objective-C language binding for the GTK+ widget toolkit
 All Classes Functions Variables
CGTKSignalConnector.m
1 /*
2  * CGTKSignalConnector.m
3  * This file is part of CoreGTK
4  *
5  * Copyright (C) 2015 - Tyler Burton
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /*
23  * Modified by the CoreGTK Team, 2015. See the AUTHORS file for a
24  * list of people on the CoreGTK Team.
25  * See the ChangeLog files for a list of changes.
26  *
27  */
28 
29 /*
30  * Objective-C imports
31  */
32 #import "CGTKSignalConnector.h"
33 
37 void gsignal_forwarder(gpointer gtk, CGTKSignalData *data)
38 {
39  [[data target] performSelector:[data selector]];
40 }
41 
42 @implementation CGTKSignalConnector
43 
44 +(void)connectGpointer:(gpointer) object withSignal:(NSString *) name toTarget:(id) target withSelector:(SEL) selector andData:(gpointer) data
45 {
46  /*
47  * Don't release this or else we could seg fault! (Note that to avoid memory leaks in the case of a short-lived GUI, the application should
48  * maintain references to the CGTKSignalData elsewhere and release it there when it is no longer needed.)
49  */
50  CGTKSignalData *signalData = [[CGTKSignalData alloc] initWithTarget:(id) target selector:selector data:data];
51 
52  g_signal_connect(object, [name UTF8String], G_CALLBACK(gsignal_forwarder), signalData);
53 }
54 
55 @end