tags:

views:

27

answers:

2

I am creating a GTK Window which, for various reasons, I wish to make non-resizable by the user. But invoking the set_resizable method on the window causes it to display with a size of 1 pixel by 1 pixel. (jn the code below, the window displays the expected size if the set-resizable line is commented out. It makes no difference which order the resize and set-resizable are invoked.) the Is there anything else that needs to be done?

Here is the code...

#include <iostream>
#include "myarea.hpp"
#include <gtkmm/main.h>
#include <gtkmm/window.h>

int main(int argc, char** argv)
{
    Gtk::Main kit(argc, argv);
    Gtk::Window win;
    win.set_title("DrawingArea");
    win.resize (600, 600);
    //win.set_resizable (false);

    MyArea area;
    win.add(area);
    area.show();

    Gtk::Main::run(win);

    return 0;
}
+4  A: 

Use win.set_size_request(600, 600); instead of resize. I'm not 100% sure why your way doesn't work, but I think that set_resizable(false) undoes the effects of resize causing the window to revert to its default size request, which is as small as possible.

ptomato
Thank you, ptomato. That's done the trick. (It would have been quite a while before I found that out from the documentation.)
Brian Hooper
+1  A: 

Gtk::Window::set_default_size() may also be useful

jonner