Re: [gtk-list] clean removal of dialog windows



Matthew <matthew@slux.corepub.com> writes:

> I am trying to learn gtk from the tutorial
> I have been able to make multiple windows, but I don't know how to remove
> them, could someone show an example kill_only_this_window function to do
> this? or explain why a simple function like that won't work.
> I tried to look through the gimp source, but I don't have enough knowledge
> of it to really figure out what is going on, I noticed that widget=NULL
> will remove it, but that doesn't look like a proper way to do it.

 void gtk_widget_destroy (GtkWidget *WIDGET)

is the prototype for the function you're looking for.

If you created a window like this:

  GtkWidget *window

  /* program ... */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL)

  /* more program logic etc.
   * requires killing our window */

 gtk_widget_destroy (GTKWIDGET (window))

  /* does the job */


Usually, though, killing a window -- or other widget -- is associated
with an event, like pressing a button...

    GtkWidget *button

    button = gtk_button_new_with_label ("kill window");
    gtk_container_add (GTK_CONTAINER (window), button);

    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                               GTK_SIGNAL_FUNC (gtk_widget_destroy),
                               GTK_OBJECT (window));



Is the relevant portion of code to add a button to an already created
GtkWidget *window then kill the window upon clicking it.  You can see
that gtk_widget_destroy is the "signal function" action called that
the object this function is called upon is the window GtkWidget.

Keep slugging through the tutorial.  I am and it's helping.  I'm
working on a project now, but I'm pretty much a novice too.  I'm
waiting for the details on GtkMenuFactory and accelerator tables ;)
for widgets and menus.  The Gimp code helps a little but I'm mostly
guesstimating my way through a lot of it.

-- 
---------------------------------------------------------------------
Omegaman <mailto:omegam@cmq.com>|"When they kick out your front door,
   PGP Key fingerprint =        | How are you gonna come? 
   6D 31 C3 00 77 8C D1 C2      | With your hands upon your head,   
   59 0A 01 E3 AF 81 94 63      | Or on the trigger of your gun?" 
Send email with "get key" as the| -- The Clash, "Guns of Brixton"
"Subject:" to get my public key |   _London_Calling_ , 1979
---------------------------------------------------------------------



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