Playing around with two windows in a program: problem






Hi All,

I was caught in a situation like this:

I have three windows, and a main window. The main window contains three
radio buttons 1)option1 2)option2 3)option3. On the coresponding option
being chosen, program then has to

a)close main window
b)open an another window(depending on the option chosen).

What I did was this:

**************************START CODE CHUNK**********************************
/*THIS IS IN THE CALL BACK FUNCTION OF A BUTTON WHICH IS IN MAIN WINDOW*/

/*if radiobutton1 was active, then redirect to utility suite window. Show
the window, that is*/
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(wdgt_radio_main_radiobutton2)))//Create and show window2.
        {

                //Create window2
                wdgt_window2 = create_ui_window2();
                gtk_widget_show (wdgt_window2);
                g_signal_connect ((gpointer) wdgt_window2, "destroy",
G_CALLBACK(func1),NULL);


                //Hide the main window
                GtkWidget * mainwindow = gtk_widget_get_toplevel(GTK_WIDGET(button));
                gtk_widget_hide(mainwindow);

        }
        else
        {
        g_print("Radiobutton2 not clicked !!"); //For now.:-)
        /* If control reaches here, the toggle button is up */
    }

        gtk_main ();

**************************END CODE CHUNK************************************

From this piece of code, things partly worked the way I wanted.

a) On clicking the corresponding button, radiobuttons were checked and
corresponding window opened, and the mainwindow got hidden.

b) PROBLEM: when I click the close button[at the top right in the new
window], gtk_main_quit() is not called. That is, the program doesnt end.

Then I thought the problem might be in calling this gtk main forever. So I
changed the last line of the code to gtk_main_iteration() [call it only
once].

Then my code works perfectly. When I click the close button in the new
window, the program ends.

My question:

0. Should I call gtk_main() after I show the new window and hide the main
window ?
1. Why did this trouble occur ? And how did gtk_main_iteration() solve the
problem ?
2. Am I likely to end up with problems with the way I have coded it now
[and it works ] ??

Pls help me soon buddies.



Vijayasarathy
Senior Research Associate
SETS

***************************************************************************
DISCLAIMER
This e-mail and any files transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. Any use, distribution, copying or disclosure by any other
person is strictly prohibited. If you have received this transmission
in error please notify SETS immediately either by replying to this e-mail
or
by telephone on +91-44-28205655 and then delete this e-mail.
The sender does not accept any responsibility for any damage which
you sustain as a result of software viruses or malicious programs.
You should therefore scan attachments (if any) prior to opening them.
**************************************************************************


*************************************************************************************
DISCLAIMER 
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may 
contain confidential and privileged information. 
Any use,distribution,copying or disclosure by any other person is strictly prohibited. If you have received 
this transmission in error please notify SETS immediately either by replying to this e-mail or by telephone 
+91-44-28205655 and then delete this e-mail. The sender does not accept any responsibility for any damage 
which you sustain as a result of software viruses or malicious programs. You should therefore scan 
attachments (if any) prior to opening them. 
************************************************************************************







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