[gtkmm] Help rounding up example



Hi,

 I just wrote the attached example becuase I had to spend some time
 hunting the docs for the right functions myself.  It's something silly:
 a dialog that pops up when the user tries to close the application.  My
 problem now is that I can't get rid of the minimize button on the
 confirmation dialog (and possibly the maximize button, too -- I don't
 know, my window manager doesn't have one).  Having a minimize button on
 a _modal_ dialog is a bad user interface design.  If you minimize the
 dialog, you can't do nothing with the application.  With some window
 managers this can be very confusing (because there isn't a direct
 visual feedback).  I know GTK+ can get rid of the minimize button
 without getting rid of the title bar because Galeon manages to do it
 (it could be a GNOME thing).

 Comments (and help!) appreciated,

 Marcelo
#include <gtkmm/button.h>
#include <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/window.h>

using namespace Gtk;

class MyWindow : public Window
{
    public:
        MyWindow();

        virtual void on_quit();
        virtual bool on_delete_event(GdkEventAny* event);
};

MyWindow::MyWindow()
{
    set_size_request(128, 64);
    Button* button = manage(new Button(StockID("gtk-quit")));
    button->signal_clicked().connect(slot(*this, &MyWindow::on_quit));
    add(*button);
    show_all();
}

void MyWindow::on_quit()
{
    MessageDialog* dialog = manage(
            new MessageDialog(
                "Do you want to quit?",
                MESSAGE_QUESTION, BUTTONS_YES_NO,
                true,
                true));
    dialog->set_default_response(RESPONSE_NO);
    dialog->set_resizable(false);
    dialog->set_title("Please confirm");

    if (dialog->run() == RESPONSE_YES)
        Main::quit();

    delete dialog;
}

bool MyWindow::on_delete_event(GdkEventAny* event)
{
    on_quit();
    return true;
}

int main(int argc, char* argv[])
{
    Main kit(&argc, &argv);
    manage(new class MyWindow());
    kit.run();
    return 0;
}


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