Destroying file selection



Hi all,

	I've created a file selection window which I want destroyed when I
hit cancel.  However, I don't know what I'm doing wrong as I've tried
various combinations and, when I click it, I destroy everything but the
window -- I've destroyed the button, the vbox of the filesel window, and
even the whole program.  I can't seem to get the window.  I don't know is
it because of what I'm destroying, how I'm connecting the callback, or how
I've created the filesel window.  In a previous version, I cheated with a
global variable and that worked -- I was hoping to find the better
solution to this.

	My code is below, much of it taken from samples.  However, the
samples I've seen are usually small programs and clicking cancel to kill
the program is fine in those cases.  In comments are the various things
I've tried...  Any help would be appreciated; thank you! 

Ray

-----
static void fileBoxCancel (GtkWidget *w, gpointer data) {
  GtkWidget *parent;

  parent = w -> parent;
  /*  parent = w -> parent -> window;*/
  /*  parent = w -> parent -> parent;*/
  /*  parent = w -> parent -> parent -> parent;*/
  /*  parent = gtk_widget_get_ancestor (w, GTK_TYPE_DIALOG);*/

  /*  gtk_widget_destroy (GTK_WIDGET (parent));*/
  /*  gtk_widget_destroy (GTK_WIDGET (w));*/
  gtk_widget_destroy (GTK_WIDGET (data));
}


void createOpenFile () {
  GtkWidget *filebox;

  filebox = gtk_file_selection_new ("Open");

  gtk_signal_connect (GTK_OBJECT (filebox), "destroy", G_CALLBACK
(gtk_main_quit), NULL);

  gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filebox) ->
ok_button), "clicked", GTK_SIGNAL_FUNC (fileBoxOK), (gpointer) filebox);

  gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filebox) ->
cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) filebox);

  /*  gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filebox) ->
cancel_button), "clicked", GTK_SIGNAL_FUNC (fileBoxCancel), G_OBJECT
(filebox));*/

  gtk_widget_show (filebox);

  gtk_grab_add (filebox);

  /*  gtk_widget_destroy (filebox);*/
}





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