GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Jul 29, 2014 10:42 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GTK+ Win32 Application Wont Close
PostPosted: Mon Aug 27, 2007 10:56 pm 
Offline
Familiar Face

Joined: Mon Aug 27, 2007 10:43 pm
Posts: 14
Ok after spending most of a day actually getting GTK to compile on my windows box I ran into a snafu. Basically when I run my application it looks and acts like normal, however when I close it, the window does close, but the program stays in memory. By this I mean I have the task manager open and run my program base.exe (from the OFFICIAL GTK+ tutorial) and when I close the window the base.exe stays in memory, indefinitely. Does anyone know what would cause this?

My environment is that of MinGW and MSYS with Tor Lillqvist GTK Win32 libs (sorry no link, first post). I proceed to compile the way the tutorial tells me to with the following makefile (i've tried hand coded too):
Code:
CC = /mingw/bin/gcc
PKGFLAGS = `pkg-config --cflags --libs gtk+-2.0`
WIN = -mwindows -mno-cygwin
CFLAGS = -Wall -O2 $(WIN)
SRC = base.c
LIBS =
EXE = base.exe

.PHONY : clean strip
all: $(EXE)

$(EXE) :
   $(CC)  -o $(EXE) $(SRC) $(CFLAGS) $(PKGFLAGS)

clean:
   rm -f $(SRC:.c=.o)

strip:
   strip $(EXE)

My Source is as follows:
Code:
#include <gtk/gtk.h>

int main( int argc, char **argv ) {
    GtkWidget *window;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show (window);

    gtk_main ();

    return 0;
}


So again, any help would be very much appriciated,
--Alex


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 5:54 am 
Offline
Familiar Face

Joined: Tue Feb 13, 2007 3:45 pm
Posts: 30
Location: Madrid, Spain
You have to link the 'destroy' signal that is emitted when you click on the close button with gtk_main_quit(), so the GTK+ main loop ends. Your code will look as follows:
Code:
#include <gtk/gtk.h>

int main( int argc, char **argv ) {
    GtkWidget *window;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL);
    gtk_widget_show (window);

    gtk_main ();

    return 0;
}

static void destroy (GtkWidget *window, gpointer data)
{
  gtk_main_quit ();
}

_________________
David Vilches


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 18, 2007 9:03 pm 
Offline
Familiar Face

Joined: Mon Aug 27, 2007 10:43 pm
Posts: 14
Thank you, I realized this after reading the next step, but i'm one of those people who don't like to move on without understanding and making a previous lesson work. Thank you very much it works perfectly now :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group