Re: gtk_main & gtk_main_quit



On Mon, 11 Sep 2000 22:01:30 +0200, "Vittorio" <trunks libero it> wrote:
This is a multi-part message in MIME format.

------=_NextPart_000_0018_01C01C3B.D73B2680
Content-Type: text/plain;
      charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi to everybody,
    this is my first letter.
I have this little problem: I need sometime to show a modal dialog =
before the main part of the program, but when I show that dialog=20
then the window does not respond, excepted for a little (on the fly) =
clock redrawn every second. I'll be more clear, I summarize the program =
sequence:
1. gtk_init()
2.if requested draw a modal dialog
3. gtk_main()
4. when the user click OK does a gtk_main_quit()

5. Draw a GtkWindow
6. Draw a GtkToolbar
7. gtk_main()
8. do events until user click exit
9. gtk_main_quit()

The trouble is when I did the points 2, 3 and 4 but if they was(?) =
skipped GtkWindow work correctly. I tried also to re-init Gtk.
I use Gtk 1.2

Thanks
Garbellotto Vittorio

This seems to work...

#include <gtk/gtk.h>

static gint close_dialog (GtkWidget *button, gpointer data)
{
        GtkWidget *dialog = GTK_WIDGET (data);

        gtk_widget_destroy (dialog);
        gtk_main_quit ();

        return FALSE;
}

static gint button_press_cb (GtkWidget *button, gpointer data)
{
        g_print ("still alive (in second gtk_main)\n");
        
        return FALSE;
}

int main (int argc, char *argv[])
{
        GtkWidget *dialog, *win, *button;

        gtk_init (&argc, &argv);

        dialog = gtk_dialog_new ();

        button = gtk_button_new_with_label ("close dialog");
        gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (close_dialog), dialog);
        gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button,
                        TRUE, TRUE, 0);
        gtk_widget_show_all (dialog);
        gtk_main ();

        /************************************************************/

        win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        
        button = gtk_button_new_with_label ("click me");
        gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (button_press_cb), NULL);
        gtk_container_add (GTK_CONTAINER (win), button);

        gtk_widget_show_all (win);      
        gtk_main ();
        return 0;
}





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