Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 669
Daniel Avatar asked Feb 03 '11 12:02

Daniel


1 Answers

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;

    gtk_window_set_geometry_hints(
        GTK_WINDOW(window),
        window,
        &hints,
        (GdkWindowHints)(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE));

    gtk_widget_show_all(window);
    gtk_main();
    return 0;
}

hope this helps, regards

like image 146
serge_gubenko Avatar answered Oct 04 '22 03:10

serge_gubenko