Daniel Daniel - 4 years ago 130
C Question

Gtk: Forbid vertical resize of GtkWindow

I can't find how to do that :( there's gtk_window_set_resizable, but it disables resizing at all and i still want my window to resize horizontally.
Any ideas?

Answer Source

I believe you can try using gtk_window_set_geometry_hints function and specify max and min height for your window. In this case you would still allow width change whereas height will stay constant. Pls, check if an example below would work for you:

int main(int argc, char * argv[])
    gtk_init(&argc, &argv);
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    GdkGeometry hints;
    hints.min_width = 0;
    hints.max_width = gdk_screen_get_width(gtk_widget_get_screen(window));;
    hints.min_height = 300;
    hints.max_height = 300;

        (GdkWindowHints)(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE));

    return 0;

hope this helps, regards

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download