[Glade-users] Opening a dialog window with a button

Giovanni Corriga valkadesh@libero.it
Wed, 20 Sep 2000 15:26:19 +0200


Parrish M Myers wrote:
> 
> Hi all,
> 
> I am extremly green with gtk in general not to mention glade.  But, in
> my fooling around with creating an interface to the crontab I came up
> with a question that all of you might be able to answer...
> 
> I have created two dialog windows.  To keep it simple I put one button
> on the main dialog that is shown on execution of the program (dialog1).
>  The second dialog is made but the gtk_show_widget(dialog2) function
> has not been called yet.  (I took that line out of the main.c file as
> per the instructions in the comment above the function calls.)  Now all
> I want to do is open dialog2 when I click the button on dialog 1.  I
> found a way of doing it, but it required me to make GtkWidget *dialog2
> global.  The reason I say this is because if I rebuild the source in
> glade (after a modification) the modified source gets lost... except in
> main.c and callback.c.  Main seems to be the only function that knows
> about GtkWidget *dialog2, so rather than passing the widget into the
> create_dialog1 (which will get lost during an update using glade) I set
> the dialog2 wiget global and created a callback function:
> 
> open_dialog_2 () {
>    gtk_show_widget(dialog2);
> }

You can create dialog2 just before showing it:

open_dialog_2 ()
{
  GtkWidget* dialog2 = create_dialog2(); /* cut'n'paste this line from main.c */
  gtk_widget_show(dialog2);
}

Bye
	Giovanni