intercepting WM destroy signal



In the GUI I'm developing I'd like to be able to save window information like size and placement when the 
user exits the application. I have connected the top level window to the destroy signal and placed the above 
mentioned functionality into the callback so it looks something like this:


void
destroy                                (gpointer         window)
{
   // Gracefully exit the program
   GET_WINDOW_SIZE(GTK_WIDGET(window), &WIDTH,
                                       &HEIGHT);
   GET_PANE_POSITIONS(&V_PANE_POS, &H_PANE_POS);

   if(TIMEOUT_ID != -1)
   {
      g_source_remove(TIMEOUT_ID);
   }
   SAVE_ARRAY_ENUMS();
   STORE_LOG_TO_FILE();
   SAVE_PROFILE();
   free(GLBL);
   free(dhandle);
   gtk_main_quit();
}

The problem is that when the user clicks the window manager's close button in the window decorations, by the 
time the GET_WINDOW_SIZE() and GET_PANE_POSITIONS() execute the window seems to have been removed and HEIGHT, 
WIDTH, V_PANE_POS and H_PANE_POS return values of 0. This seemed to work well under GTK 1.2.x but now that I 
have moved this to GTK 2.6 it stopped behaving as expected.

I've seen programs that seem to "ignore" the WM close button, is there a way to do that in GTK? Any examples?

Thanks.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]