Re: main form hide()



Does your main loop look like this?:

int main(int argc, char *argv[]) {
    Gtk::Main kit(argc, argv);
   
    MainForm mainform;
    Gtk::Main::run(mainform);

    return 0;
}

If it does, then your hide() call should close MainForm and terminate the loop. The call to exit(0) is not needed.

Jim

On 06/10/2010 4:36 PM, István Kelemen wrote:
Hello!

I want to write a program that first show a main form, then pops up a login form. Then, if the person click OK (and the login was successful), the login form closes and the main form remains, if the person click Cancel, the main form also closes. I tried something like that below (only mainform.cc):

#include "loginform.h"
#include "mainform.h"
#include <gtkmm/main.h>

MainForm::MainForm()
{
    set_border_width(10);
    set_size_request(800, 600);
    set_position(Gtk::WIN_POS_CENTER);
    ...
}

void MainForm::on_show()
{
    Gtk::Window::on_show();
    LoginForm loginform;
    if( ! loginform.run() )
    {
        hide();
        exit(0);
    }
}

MainForm::~MainForm()
{
}

It works, but I think, that calling exit(0) directly from the main loop is a bit rude. My problem is that hide() only closes the window, but does not exit the main loop. Gtk::Main::quit() is not good, because I started with Gtk::Main::run(mainform). Is there another way to do that?

Thanks for any help

Kelemen István

_______________________________________________ gtkmm-list mailing list gtkmm-list gnome org http://mail.gnome.org/mailman/listinfo/gtkmm-list


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