Re: [gtkmm] Help rounding up example



Am 06.08.2002 18:22 schrieb(en) Marcelo E. Magallon:
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->property_allow_shrink()->set_value(false);
  dialog->property_allow_grow()->set_value(false);

  // I don't know whether this also makes the buttons disappear.
  // It's what I found scanning the ref docs.

    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;
}


Regards,

  Martin



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