#define gtk	((GtkWindow *) gtk)
static gint focus_in_window (GtkWidget *win, GdkEvent *event, GTKWindow *self)
{
    [[NSNotificationCenter defaultCenter] postNotificationName:
	GTKWindowDidBecomeMainNotification object:self];
    return NO;
}
static gint focus_out_window (GtkWidget *win, GdkEvent *event, GTKWindow *self)
{
    [[NSNotificationCenter defaultCenter] postNotificationName:
	GTKWindowDidResignMainNotification object:self];
    return NO;
}
static void destroy_window (GtkWidget *win, GTKWindow *self)
{
    [[NSNotificationCenter defaultCenter] postNotificationName:
	GTKWindowWillCloseNotification object:self];
}
 - initWithGtk:(gpointer) _gtk
{
    [super initWithGtk:_gtk];
    [self ref];		// first reference is missing (due to floating flag)
 
    gtk_signal_connect(_gtk, "focus_in_event",
			(GtkSignalFunc) focus_in_window, self);
    gtk_signal_connect(_gtk, "focus_out_event",
			(GtkSignalFunc) focus_out_window, self);
    gtk_signal_connect(_gtk, "destroy", (GtkSignalFunc) destroy_window, self);
    [[NSNotificationCenter defaultCenter] postNotificationName:
	GTKWindowWillOpenNotification object:self];
 
    return self;
}
- (NSString *) title
{
    return String_to_NSString(gtk->title);
}
- (GTKWidget *) focusWidget
{
    return Gtk_to_Object(gtk->focus_widget, 0);
}
- (GTKWidget *) defaultWidget
{
    return Gtk_to_Object(gtk->default_widget, 0);
}
#undef gtk

%extern NSString *GTKWindowDidBecomeMainNotification;
NSString *GTKWindowDidBecomeMainNotification = @"GTKWindowDidBecomeMain";
%extern NSString *GTKWindowDidResignMainNotification;
NSString *GTKWindowDidResignMainNotification = @"GTKWindowDidResignMain";
%extern NSString *GTKWindowWillCloseNotification;
NSString *GTKWindowWillCloseNotification = @"GTKWindowWillClose";
%extern NSString *GTKWindowWillOpenNotification;
NSString *GTKWindowWillOpenNotification = @"GTKWindowWillOpen";
